chore: apply recommendations from clippy
This commit is contained in:
parent
cec55dafd7
commit
8e0f1c4a09
56 changed files with 720 additions and 824 deletions
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -43,6 +43,6 @@ pub fn localize() {
|
|||
let requested_languages = i18n_embed::DesktopLanguageRequester::requested_languages();
|
||||
|
||||
if let Err(error) = localizer.select(&requested_languages) {
|
||||
eprintln!("Error while loading language for App List {}", error);
|
||||
eprintln!("Error while loading language for App List {error}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ pub fn spawn_workspaces(tx: mpsc::Sender<Vec<Workspace>>) -> SyncSender<Workspac
|
|||
};
|
||||
let loop_handle = event_loop.handle();
|
||||
loop_handle
|
||||
.insert_source(workspaces_rx, |e, _, state| match e {
|
||||
.insert_source(workspaces_rx, |e, (), state| match e {
|
||||
Event::Msg(WorkspaceEvent::Activate(handle)) => {
|
||||
handle.activate();
|
||||
state
|
||||
|
|
|
|||
|
|
@ -79,6 +79,6 @@ impl WorkspacesWatcher {
|
|||
pub fn new() -> anyhow::Result<Self> {
|
||||
let (tx, rx) = mpsc::channel(20);
|
||||
let tx = wayland::spawn_workspaces(tx);
|
||||
Ok(Self { tx, rx })
|
||||
Ok(Self { rx, tx })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue