chore: apply recommendations from clippy

This commit is contained in:
Cheong Lau 2025-10-04 10:51:18 +10:00 committed by GitHub
parent cec55dafd7
commit 8e0f1c4a09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 720 additions and 824 deletions

View file

@ -110,7 +110,7 @@ impl cosmic::Application for IcedWorkspacesApplet {
},
core,
workspaces: Vec::new(),
workspace_tx: Default::default(),
workspace_tx: Option::default(),
scroll: 0.0,
next_scroll: None,
last_scroll: Instant::now(),
@ -211,7 +211,7 @@ impl cosmic::Application for IcedWorkspacesApplet {
Task::none()
}
fn view(&self) -> Element<Message> {
fn view(&self) -> Element<'_, Message> {
if self.workspaces.is_empty() {
return row![].padding(8).into();
}
@ -224,7 +224,7 @@ impl cosmic::Application for IcedWorkspacesApplet {
let suggested_window_size = self.core.applet.suggested_window_size();
let popup_index = self.popup_index().unwrap_or(self.workspaces.len());
let buttons = self.workspaces[..popup_index].iter().filter_map(|w| {
let buttons = self.workspaces[..popup_index].iter().map(|w| {
let content = self.core.applet.text(&w.name).font(cosmic::font::bold());
let (width, height) = if self.core.applet.is_horizontal() {
@ -258,79 +258,73 @@ impl cosmic::Application for IcedWorkspacesApplet {
)
.padding(0);
Some(
btn.class(
if w.state.contains(ext_workspace_handle_v1::State::Active) {
cosmic::theme::iced::Button::Primary
} else if w.state.contains(ext_workspace_handle_v1::State::Urgent) {
let appearance = |theme: &Theme| {
let cosmic = theme.cosmic();
button::Style {
btn.class(
if w.state.contains(ext_workspace_handle_v1::State::Active) {
cosmic::theme::iced::Button::Primary
} else if w.state.contains(ext_workspace_handle_v1::State::Urgent) {
let appearance = |theme: &Theme| {
let cosmic = theme.cosmic();
button::Style {
background: Some(Background::Color(cosmic.palette.neutral_3.into())),
border: Border {
radius: cosmic.radius_xl().into(),
..Default::default()
},
border_radius: theme.cosmic().radius_xl().into(),
text_color: theme.cosmic().destructive_button.base.into(),
..button::Style::default()
}
};
cosmic::theme::iced::Button::Custom(Box::new(
move |theme, status| match status {
button::Status::Active => appearance(theme),
button::Status::Hovered => button::Style {
background: Some(Background::Color(
cosmic.palette.neutral_3.into(),
theme.current_container().component.hover.into(),
)),
border: Border {
radius: cosmic.radius_xl().into(),
radius: theme.cosmic().radius_xl().into(),
..Default::default()
},
border_radius: theme.cosmic().radius_xl().into(),
text_color: theme.cosmic().destructive_button.base.into(),
..button::Style::default()
}
};
cosmic::theme::iced::Button::Custom(Box::new(move |theme, status| {
match status {
button::Status::Active => appearance(theme),
button::Status::Hovered => button::Style {
background: Some(Background::Color(
theme.current_container().component.hover.into(),
)),
border: Border {
radius: theme.cosmic().radius_xl().into(),
..Default::default()
},
..appearance(theme)
},
button::Status::Pressed => appearance(theme),
button::Status::Disabled => appearance(theme),
}
}))
} else {
let appearance = |theme: &Theme| {
let cosmic = theme.cosmic();
button::Style {
background: None,
..appearance(theme)
},
button::Status::Pressed => appearance(theme),
button::Status::Disabled => appearance(theme),
},
))
} else {
let appearance = |theme: &Theme| {
let cosmic = theme.cosmic();
button::Style {
background: None,
border: Border {
radius: cosmic.radius_xl().into(),
..Default::default()
},
border_radius: cosmic.radius_xl().into(),
text_color: theme.current_container().component.on.into(),
..button::Style::default()
}
};
cosmic::theme::iced::Button::Custom(Box::new(
move |theme, status| match status {
button::Status::Active => appearance(theme),
button::Status::Hovered => button::Style {
background: Some(Background::Color(
theme.current_container().component.hover.into(),
)),
border: Border {
radius: cosmic.radius_xl().into(),
radius: theme.cosmic().radius_xl().into(),
..Default::default()
},
border_radius: cosmic.radius_xl().into(),
text_color: theme.current_container().component.on.into(),
..button::Style::default()
}
};
cosmic::theme::iced::Button::Custom(Box::new(move |theme, status| {
match status {
button::Status::Active => appearance(theme),
button::Status::Hovered => button::Style {
background: Some(Background::Color(
theme.current_container().component.hover.into(),
)),
border: Border {
radius: theme.cosmic().radius_xl().into(),
..Default::default()
},
..appearance(theme)
},
button::Status::Pressed | button::Status::Disabled => {
appearance(theme)
}
}
}))
},
)
.into(),
..appearance(theme)
},
button::Status::Pressed | button::Status::Disabled => appearance(theme),
},
))
},
)
.into()
});
// TODO if there is a popup_index, create a button with a popup for the remaining workspaces
// Should it appear on hover or on click?