Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanabx committed Sep 2, 2024
1 parent aaf9aa9 commit 5cfcba8
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 43 deletions.
22 changes: 12 additions & 10 deletions src/app_tray/compositor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,9 @@ impl From<zwlr_foreign_toplevel_handle_v1::Event> for ToplevelHandleEvent {
zwlr_foreign_toplevel_handle_v1::Event::State { state } => {
let mut r_state = HashSet::new();
for value in state.chunks_exact(4) {
if let Some(state) = zwlr_foreign_toplevel_handle_v1::State::try_from(
if let Ok(state) = zwlr_foreign_toplevel_handle_v1::State::try_from(
u32::from_ne_bytes(value[0..4].try_into().unwrap()),
)
.ok()
{
) {
r_state.insert(ToplevelState::from(state));
}
}
Expand Down Expand Up @@ -300,11 +298,9 @@ impl From<zcosmic_toplevel_handle_v1::Event> for ToplevelHandleEvent {
zcosmic_toplevel_handle_v1::Event::State { state } => {
let mut r_state = HashSet::new();
for value in state.chunks_exact(4) {
if let Some(state) = zcosmic_toplevel_handle_v1::State::try_from(
if let Ok(state) = zcosmic_toplevel_handle_v1::State::try_from(
u32::from_ne_bytes(value[0..4].try_into().unwrap()),
)
.ok()
{
) {
r_state.insert(ToplevelState::from(state));
}
}
Expand Down Expand Up @@ -475,7 +471,7 @@ fn wayland_client_listener(tx: UnboundedSender<WaylandIncoming>, rx: Channel<Way

// Create an event queue for our event processing

let (globals, mut event_queue) = registry_queue_init(&conn).unwrap();
let (globals, event_queue) = registry_queue_init(&conn).unwrap();

let mut event_loop = EventLoop::<AppData>::try_new().unwrap();
let qh = event_queue.handle();
Expand Down Expand Up @@ -732,6 +728,12 @@ async fn start_listening(
}
}

impl Default for CompositorBackend {
fn default() -> Self {
Self::new()
}
}

impl CompositorBackend {
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -891,6 +893,6 @@ impl CompositorBackend {
}
}
}
focused_toplevels.first().map(|f| f.clone())
focused_toplevels.first().cloned()
}
}
17 changes: 5 additions & 12 deletions src/app_tray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ impl<'a> AppTray<'a> {
.map(|(app_id, group)| {
let entry = &self.de_cache.fuzzy_match(&app_id);

self.view_tray_item(
&app_id,
entry.as_ref(),
group,
active_window.as_ref().map(|f| f.clone()),
)
self.view_tray_item(&app_id, entry.as_ref(), group, active_window.clone())
})
.map(|x| {
Element::from(
Expand Down Expand Up @@ -135,7 +130,7 @@ impl<'a> AppTray<'a> {
let icon_name = desktop_entry.and_then(|entry| entry.icon());
let icon_path = icon_name
.and_then(|icon| freedesktop_icons::lookup(icon).with_cache().find())
.or_else(|| get_default_icon());
.or_else(get_default_icon);
iced::widget::mouse_area(
match icon_path {
Some(path) => iced::widget::button(column![
Expand Down Expand Up @@ -224,12 +219,10 @@ fn tray_button_style(
} else {
(0.21, 0.20)
}
} else if matches!(status, button::Status::Hovered | button::Status::Pressed) {
(0.11, 0.1)
} else {
if matches!(status, button::Status::Hovered | button::Status::Pressed) {
(0.11, 0.1)
} else {
(0.06, 0.05)
}
(0.06, 0.05)
};

button::Style {
Expand Down
10 changes: 1 addition & 9 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@ pub enum ConfigError {
Serde(#[from] serde_json::Error),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct PanelConfig {
pub app_tray: AppTrayConfig,
}

impl<'a> Default for PanelConfig {
fn default() -> Self {
Self {
app_tray: AppTrayConfig::default(),
}
}
}

impl PanelConfig {
pub fn from_file_or_default(path: &Path) -> Self {
File::open(path)
Expand Down
6 changes: 6 additions & 0 deletions src/desktop_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ use freedesktop_desktop_entry::{
#[derive(Clone, Debug)]
pub struct DesktopEntryCache<'a>(pub HashMap<String, DesktopEntry<'a>>);

impl<'a> Default for DesktopEntryCache<'a> {
fn default() -> Self {
Self::new()
}
}

impl<'a> DesktopEntryCache<'a> {
pub fn new() -> Self {
let locales = get_languages_from_env();
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ fn main() -> Result<(), PanelError> {
.map_err(PanelError::Iced);

res
}
}
14 changes: 6 additions & 8 deletions src/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,13 @@ impl<'a> Panel<'a> {
.width(Length::Fill)
.height(Length::Fill)
.into()
} else {
if let Some(popup_window) = &self.popup_window.as_ref() {
match &popup_window.1 {
PopupType::AppTrayContextMenu { app_id } => text!("Hey").into(),
PopupType::StartMenu => self.start_menu.view_popup().map(Message::StartMenu),
}
} else {
iced::widget::horizontal_space().into()
} else if let Some(popup_window) = &self.popup_window.as_ref() {
match &popup_window.1 {
PopupType::AppTrayContextMenu { app_id } => text!("Hey").into(),
PopupType::StartMenu => self.start_menu.view_popup().map(Message::StartMenu),
}
} else {
iced::widget::horizontal_space().into()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/settings_tray/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Clock {
let now = Local::now();
let formatted_time = now.format("%I:%M %p").to_string();
let formatted_date = now.format("%Y-%m-%d").to_string();
let _ = output
output
.send(ClockMessage::UpdateClock(formatted_time, formatted_date))
.await
.unwrap();
Expand Down
3 changes: 1 addition & 2 deletions src/start_menu/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::{path::Path, rc::Rc};

use freedesktop_desktop_entry::{get_languages_from_env, DesktopEntry, Locale};
use freedesktop_desktop_entry::{get_languages_from_env, DesktopEntry};
use iced::{
alignment::{Horizontal, Vertical},
border::Radius,
widget::{
button, row,
Expand Down

0 comments on commit 5cfcba8

Please sign in to comment.