app-list: Fix clippy lints
This commit is contained in:
parent
d1dcbd4915
commit
ba832143fc
2 changed files with 52 additions and 37 deletions
|
|
@ -218,7 +218,7 @@ impl Application for CosmicAppList {
|
||||||
let new_id = window::Id::new(self.surface_id_ctr);
|
let new_id = window::Id::new(self.surface_id_ctr);
|
||||||
self.popup.replace(new_id);
|
self.popup.replace(new_id);
|
||||||
toplevel_group.popup.replace(new_id);
|
toplevel_group.popup.replace(new_id);
|
||||||
|
|
||||||
let mut popup_settings = self.applet_helper.get_popup_settings(
|
let mut popup_settings = self.applet_helper.get_popup_settings(
|
||||||
window::Id::new(0),
|
window::Id::new(0),
|
||||||
new_id,
|
new_id,
|
||||||
|
|
@ -271,11 +271,11 @@ impl Application for CosmicAppList {
|
||||||
Message::Toplevel(event) => {
|
Message::Toplevel(event) => {
|
||||||
match event {
|
match event {
|
||||||
ToplevelUpdate::AddToplevel(handle, info) => {
|
ToplevelUpdate::AddToplevel(handle, info) => {
|
||||||
if info.app_id == "" {
|
if info.app_id.is_empty() {
|
||||||
return Command::none();
|
return Command::none();
|
||||||
}
|
}
|
||||||
if let Some(i) = self.toplevel_list.iter().position(
|
if let Some(i) = self.toplevel_list.iter().position(
|
||||||
|Toplevel { desktop_info, .. }| &desktop_info.id == &info.app_id,
|
|Toplevel { desktop_info, .. }| desktop_info.id == info.app_id,
|
||||||
) {
|
) {
|
||||||
self.toplevel_list[i].toplevels.push((handle, info));
|
self.toplevel_list[i].toplevels.push((handle, info));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -309,7 +309,7 @@ impl Application for CosmicAppList {
|
||||||
desktop_info,
|
desktop_info,
|
||||||
..
|
..
|
||||||
}| {
|
}| {
|
||||||
if let Some(ret) = toplevels.iter().position(|t| &t.0 == &handle) {
|
if let Some(ret) = toplevels.iter().position(|t| t.0 == handle) {
|
||||||
toplevels.remove(ret);
|
toplevels.remove(ret);
|
||||||
toplevels.is_empty()
|
toplevels.is_empty()
|
||||||
&& !self.config.favorites.contains(&desktop_info.id)
|
&& !self.config.favorites.contains(&desktop_info.id)
|
||||||
|
|
@ -326,7 +326,7 @@ impl Application for CosmicAppList {
|
||||||
}
|
}
|
||||||
ToplevelUpdate::UpdateToplevel(handle, info) => {
|
ToplevelUpdate::UpdateToplevel(handle, info) => {
|
||||||
// TODO probably want to make sure it is removed
|
// TODO probably want to make sure it is removed
|
||||||
if info.app_id == "" {
|
if info.app_id.is_empty() {
|
||||||
return Command::none();
|
return Command::none();
|
||||||
}
|
}
|
||||||
'toplevel_loop: for toplevel_list in &mut self.toplevel_list {
|
'toplevel_loop: for toplevel_list in &mut self.toplevel_list {
|
||||||
|
|
@ -351,12 +351,12 @@ impl Application for CosmicAppList {
|
||||||
Message::Exec(exec_str) => {
|
Message::Exec(exec_str) => {
|
||||||
let mut exec = shlex::Shlex::new(&exec_str);
|
let mut exec = shlex::Shlex::new(&exec_str);
|
||||||
let mut cmd = match exec.next() {
|
let mut cmd = match exec.next() {
|
||||||
Some(cmd) if !cmd.contains("=") => tokio::process::Command::new(cmd),
|
Some(cmd) if !cmd.contains('=') => tokio::process::Command::new(cmd),
|
||||||
_ => return Command::none(),
|
_ => return Command::none(),
|
||||||
};
|
};
|
||||||
for arg in exec {
|
for arg in exec {
|
||||||
// TODO handle "%" args here if necessary?
|
// TODO handle "%" args here if necessary?
|
||||||
if !arg.starts_with("%") {
|
if !arg.starts_with('%') {
|
||||||
cmd.arg(arg);
|
cmd.arg(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -398,7 +398,10 @@ impl Application for CosmicAppList {
|
||||||
desktop_info,
|
desktop_info,
|
||||||
..
|
..
|
||||||
}| {
|
}| {
|
||||||
let cosmic_icon = cosmic::widget::icon(Path::new(&desktop_info.icon), self.applet_helper.suggested_size().0);
|
let cosmic_icon = cosmic::widget::icon(
|
||||||
|
Path::new(&desktop_info.icon),
|
||||||
|
self.applet_helper.suggested_size().0,
|
||||||
|
);
|
||||||
// let icon = if desktop_info.icon.extension() == Some(&OsStr::new("svg")) {
|
// let icon = if desktop_info.icon.extension() == Some(&OsStr::new("svg")) {
|
||||||
// svg::Handle::from_path(&desktop_info.icon);
|
// svg::Handle::from_path(&desktop_info.icon);
|
||||||
// svg::Svg::new(handle)
|
// svg::Svg::new(handle)
|
||||||
|
|
@ -433,22 +436,30 @@ impl Application for CosmicAppList {
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
dots.push(vertical_space(Length::Units(4)).into());
|
dots.push(vertical_space(Length::Units(4)).into());
|
||||||
let icon_wrapper = match &self.applet_helper.anchor {
|
let icon_wrapper = match &self.applet_helper.anchor {
|
||||||
PanelAnchor::Left => row(vec![column(dots).spacing(4).into(), cosmic_icon.into()])
|
PanelAnchor::Left => {
|
||||||
.align_items(iced::Alignment::Center)
|
row(vec![column(dots).spacing(4).into(), cosmic_icon.into()])
|
||||||
.spacing(4)
|
.align_items(iced::Alignment::Center)
|
||||||
.into(),
|
.spacing(4)
|
||||||
PanelAnchor::Right => row(vec![cosmic_icon.into(), column(dots).spacing(4).into()])
|
.into()
|
||||||
.align_items(iced::Alignment::Center)
|
}
|
||||||
.spacing(4)
|
PanelAnchor::Right => {
|
||||||
.into(),
|
row(vec![cosmic_icon.into(), column(dots).spacing(4).into()])
|
||||||
PanelAnchor::Top => column(vec![row(dots).spacing(4).into(), cosmic_icon.into()])
|
.align_items(iced::Alignment::Center)
|
||||||
.align_items(iced::Alignment::Center)
|
.spacing(4)
|
||||||
.spacing(4)
|
.into()
|
||||||
.into(),
|
}
|
||||||
PanelAnchor::Bottom => column(vec![cosmic_icon.into(), row(dots).spacing(4).into()])
|
PanelAnchor::Top => {
|
||||||
.align_items(iced::Alignment::Center)
|
column(vec![row(dots).spacing(4).into(), cosmic_icon.into()])
|
||||||
.spacing(4)
|
.align_items(iced::Alignment::Center)
|
||||||
.into(),
|
.spacing(4)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
PanelAnchor::Bottom => {
|
||||||
|
column(vec![cosmic_icon.into(), row(dots).spacing(4).into()])
|
||||||
|
.align_items(iced::Alignment::Center)
|
||||||
|
.spacing(4)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let mut icon_button = cosmic::widget::button(Button::Text)
|
let mut icon_button = cosmic::widget::button(Button::Text)
|
||||||
.custom(vec![icon_wrapper])
|
.custom(vec![icon_wrapper])
|
||||||
|
|
@ -463,8 +474,10 @@ impl Application for CosmicAppList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO tooltip on hover
|
// TODO tooltip on hover
|
||||||
let icon_button = mouse_listener(icon_button.width(Length::Shrink).height(Length::Shrink))
|
let icon_button = mouse_listener(
|
||||||
.on_right_release(Message::Popup(desktop_info.id.clone()));
|
icon_button.width(Length::Shrink).height(Length::Shrink),
|
||||||
|
)
|
||||||
|
.on_right_release(Message::Popup(desktop_info.id.clone()));
|
||||||
let icon_button = if let Some(tracker) = self.rectangle_tracker.as_ref() {
|
let icon_button = if let Some(tracker) = self.rectangle_tracker.as_ref() {
|
||||||
tracker.container(*id, icon_button).into()
|
tracker.container(*id, icon_button).into()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -495,7 +508,9 @@ impl Application for CosmicAppList {
|
||||||
.align_items(Alignment::Center)
|
.align_items(Alignment::Center)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.width(Length::Fill),
|
.width(Length::Fill),
|
||||||
).height(Length::Fill).width(Length::Fill),
|
)
|
||||||
|
.height(Length::Fill)
|
||||||
|
.width(Length::Fill),
|
||||||
};
|
};
|
||||||
if self.popup.is_some() {
|
if self.popup.is_some() {
|
||||||
mouse_listener(content)
|
mouse_listener(content)
|
||||||
|
|
@ -554,19 +569,19 @@ impl Application for CosmicAppList {
|
||||||
.on_press(Message::Favorite(desktop_info.id.clone()))
|
.on_press(Message::Favorite(desktop_info.id.clone()))
|
||||||
});
|
});
|
||||||
|
|
||||||
if toplevels.len() == 1 {
|
content = match toplevels.len() {
|
||||||
content = content.push(
|
0 => content,
|
||||||
|
1 => content.push(
|
||||||
cosmic::widget::button(Button::Text)
|
cosmic::widget::button(Button::Text)
|
||||||
.custom(vec![iced::widget::text(fl!("quit")).into()])
|
.custom(vec![iced::widget::text(fl!("quit")).into()])
|
||||||
.on_press(Message::Quit(desktop_info.id.clone())),
|
.on_press(Message::Quit(desktop_info.id.clone())),
|
||||||
)
|
),
|
||||||
} else if toplevels.len() > 1 {
|
_ => content.push(
|
||||||
content = content.push(
|
|
||||||
cosmic::widget::button(Button::Text)
|
cosmic::widget::button(Button::Text)
|
||||||
.custom(vec![iced::widget::text(&fl!("quit-all")).into()])
|
.custom(vec![iced::widget::text(&fl!("quit-all")).into()])
|
||||||
.on_press(Message::Quit(desktop_info.id.clone())),
|
.on_press(Message::Quit(desktop_info.id.clone())),
|
||||||
)
|
),
|
||||||
}
|
};
|
||||||
// return Container::new(Container::new(content.width(Length::Shrink).height(Length::Shrink)).style(
|
// return Container::new(Container::new(content.width(Length::Shrink).height(Length::Shrink)).style(
|
||||||
// cosmic::Container::Custom(|theme| container::Appearance {
|
// cosmic::Container::Custom(|theme| container::Appearance {
|
||||||
// text_color: Some(theme.cosmic().on_bg_color().into()),
|
// text_color: Some(theme.cosmic().on_bg_color().into()),
|
||||||
|
|
@ -578,7 +593,7 @@ impl Application for CosmicAppList {
|
||||||
// )).into();
|
// )).into();
|
||||||
return self.applet_helper.popup_container(content).into();
|
return self.applet_helper.popup_container(content).into();
|
||||||
}
|
}
|
||||||
return horizontal_space(Length::Units(1)).into();
|
horizontal_space(Length::Units(1)).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ async fn start_listening<I: Copy>(id: I, state: State) -> (Option<(I, ToplevelUp
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
toplevel_handler(toplevel_tx, calloop_rx);
|
toplevel_handler(toplevel_tx, calloop_rx);
|
||||||
});
|
});
|
||||||
return (
|
(
|
||||||
Some((id, ToplevelUpdate::Init(calloop_tx.clone()))),
|
Some((id, ToplevelUpdate::Init(calloop_tx.clone()))),
|
||||||
State::Waiting(toplevel_rx, calloop_tx),
|
State::Waiting(toplevel_rx, calloop_tx),
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
State::Waiting(mut rx, tx) => match rx.next().await {
|
State::Waiting(mut rx, tx) => match rx.next().await {
|
||||||
Some(u) => (Some((id, u)), State::Waiting(rx, tx)),
|
Some(u) => (Some((id, u)), State::Waiting(rx, tx)),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue