chore: apply recommendations from clippy
This commit is contained in:
parent
cec55dafd7
commit
8e0f1c4a09
56 changed files with 720 additions and 824 deletions
|
|
@ -65,15 +65,13 @@ impl App {
|
|||
}
|
||||
|
||||
fn overflow_index(&self) -> Option<usize> {
|
||||
let Some(max_major_axis_len) = self.core.applet.suggested_bounds.as_ref().map(|c| {
|
||||
let max_major_axis_len = self.core.applet.suggested_bounds.as_ref().map(|c| {
|
||||
// if we have a configure for width and height, we're in a overflow popup
|
||||
match self.core.applet.anchor {
|
||||
PanelAnchor::Top | PanelAnchor::Bottom => c.width as u32,
|
||||
PanelAnchor::Left | PanelAnchor::Right => c.height as u32,
|
||||
}
|
||||
}) else {
|
||||
return None;
|
||||
};
|
||||
})?;
|
||||
|
||||
let button_total_size =
|
||||
self.core.applet.suggested_size(true).0 + self.core.applet.suggested_padding(true) * 2;
|
||||
|
|
@ -111,7 +109,7 @@ impl App {
|
|||
});
|
||||
let theme = self.core.system_theme();
|
||||
let cosmic = theme.cosmic();
|
||||
let corners = cosmic.corner_radii.clone();
|
||||
let corners = cosmic.corner_radii;
|
||||
let pad = corners.radius_m[0];
|
||||
|
||||
self.core
|
||||
|
|
@ -211,12 +209,12 @@ impl cosmic::Application for App {
|
|||
self.resize_window()
|
||||
}
|
||||
status_notifier_watcher::Event::Error(err) => {
|
||||
eprintln!("Status notifier error: {}", err);
|
||||
eprintln!("Status notifier error: {err}");
|
||||
Task::none()
|
||||
}
|
||||
},
|
||||
Msg::TogglePopup(id) => {
|
||||
self.open_menu = if self.open_menu != Some(id) {
|
||||
self.open_menu = if self.open_menu.is_none() {
|
||||
Some(id)
|
||||
} else {
|
||||
None
|
||||
|
|
@ -232,15 +230,14 @@ impl cosmic::Application for App {
|
|||
let i = self.menus.keys().position(|&i| i == id).unwrap();
|
||||
let (i, parent) = self
|
||||
.overflow_index()
|
||||
.clone()
|
||||
.and_then(|overflow_i| {
|
||||
if overflow_i <= i {
|
||||
Some(i - overflow_i).zip(self.overflow_popup.clone())
|
||||
Some(i - overflow_i).zip(self.overflow_popup)
|
||||
} else {
|
||||
Some((i, self.core.main_window_id().unwrap()))
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| (0, self.core.main_window_id().unwrap()));
|
||||
.unwrap_or((0, self.core.main_window_id().unwrap()));
|
||||
|
||||
let mut popup_settings = self
|
||||
.core
|
||||
|
|
@ -315,15 +312,14 @@ impl cosmic::Application for App {
|
|||
|
||||
let (i, parent) = self
|
||||
.overflow_index()
|
||||
.clone()
|
||||
.and_then(|overflow_i| {
|
||||
if overflow_i <= i {
|
||||
Some(i - overflow_i).zip(self.overflow_popup.clone())
|
||||
Some(i - overflow_i).zip(self.overflow_popup)
|
||||
} else {
|
||||
Some((i, self.core.main_window_id().unwrap()))
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| (0, self.core.main_window_id().unwrap()));
|
||||
.unwrap_or((0, self.core.main_window_id().unwrap()));
|
||||
|
||||
let mut popup_settings = self
|
||||
.core
|
||||
|
|
@ -384,8 +380,7 @@ impl cosmic::Application for App {
|
|||
}
|
||||
|
||||
self.overflow_popup = Some(popup_id);
|
||||
let mut cmds = Vec::new();
|
||||
cmds.push(get_popup(popup_settings));
|
||||
let cmds = vec![get_popup(popup_settings)];
|
||||
return Task::batch(cmds);
|
||||
} else {
|
||||
return Task::none();
|
||||
|
|
@ -442,7 +437,7 @@ impl cosmic::Application for App {
|
|||
|
||||
subscriptions.push(status_notifier_watcher::subscription().map(Msg::StatusNotifier));
|
||||
|
||||
for (id, menu) in self.menus.iter() {
|
||||
for (id, menu) in &self.menus {
|
||||
subscriptions.push(menu.subscription().with(*id).map(Msg::StatusMenu));
|
||||
}
|
||||
subscriptions.push(activation_token_subscription(0).map(Msg::Token));
|
||||
|
|
@ -513,7 +508,7 @@ impl cosmic::Application for App {
|
|||
|
||||
let theme = self.core.system_theme();
|
||||
let cosmic = theme.cosmic();
|
||||
let corners = cosmic.corner_radii.clone();
|
||||
let corners = cosmic.corner_radii;
|
||||
let pad = corners.radius_m[0];
|
||||
match self.open_menu {
|
||||
Some(id) => match self.menus.get(&id) {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ impl State {
|
|||
Ok(layout) => {
|
||||
self.layout = Some(layout);
|
||||
}
|
||||
Err(err) => eprintln!("Error getting layout from icon: {}", err),
|
||||
Err(err) => eprintln!("Error getting layout from icon: {err}"),
|
||||
}
|
||||
iced::Task::none()
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ impl State {
|
|||
let _ = menu_proxy.event(id, "clicked", &0.into(), 0).await;
|
||||
});
|
||||
if is_submenu {
|
||||
self.expanded = if self.expanded != Some(id) {
|
||||
self.expanded = if self.expanded.is_none() {
|
||||
Some(id)
|
||||
} else {
|
||||
None
|
||||
|
|
@ -134,7 +134,7 @@ impl State {
|
|||
self.icon_pixmap.as_ref()
|
||||
}
|
||||
|
||||
pub fn popup_view(&self) -> cosmic::Element<Msg> {
|
||||
pub fn popup_view(&self) -> cosmic::Element<'_, Msg> {
|
||||
if let Some(layout) = self.layout.as_ref() {
|
||||
layout_view(layout, self.expanded)
|
||||
} else {
|
||||
|
|
@ -165,7 +165,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
fn layout_view(layout: &Layout, expanded: Option<i32>) -> cosmic::Element<Msg> {
|
||||
fn layout_view(layout: &Layout, expanded: Option<i32>) -> cosmic::Element<'_, Msg> {
|
||||
iced::widget::column(layout.children().iter().filter_map(|i| {
|
||||
if !i.visible() {
|
||||
None
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ impl StatusNotifierItem {
|
|||
}
|
||||
|
||||
pub fn icon_subscription(&self) -> iced::Subscription<IconUpdate> {
|
||||
fn icon_events<'a>(
|
||||
fn icon_events(
|
||||
item_proxy: StatusNotifierItemProxy<'static>,
|
||||
) -> impl futures::Stream<Item = IconUpdate> + 'static {
|
||||
async move {
|
||||
|
|
@ -99,7 +99,7 @@ impl StatusNotifierItem {
|
|||
format!("status-notifier-item-icon-{}", &self.name),
|
||||
async move {
|
||||
let new_icon_stream = item_proxy.receive_new_icon().await.unwrap();
|
||||
futures::stream::once(async { () })
|
||||
futures::stream::once(async {})
|
||||
.chain(new_icon_stream.map(|_| ()))
|
||||
.flat_map(move |()| icon_events(item_proxy.clone()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ pub async fn watch(connection: &zbus::Connection) -> zbus::Result<EventStream> {
|
|||
|
||||
let name = connection.unique_name().unwrap().as_str();
|
||||
if let Err(err) = watcher.register_status_notifier_host(name).await {
|
||||
eprintln!("Failed to register status notifier host: {}", err);
|
||||
eprintln!("Failed to register status notifier host: {err}");
|
||||
}
|
||||
|
||||
let connection_clone = connection.clone();
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ pub fn subscription() -> iced::Subscription<Event> {
|
|||
}
|
||||
Err(err) => Some((Event::Error(err.to_string()), State::Failed)),
|
||||
},
|
||||
State::Connected(mut stream) => match stream.next().await {
|
||||
Some(event) => Some((event, State::Connected(stream))),
|
||||
None => None,
|
||||
},
|
||||
State::Connected(mut stream) => stream
|
||||
.next()
|
||||
.await
|
||||
.map(|event| (event, State::Connected(stream))),
|
||||
State::Failed => None,
|
||||
}
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ impl StatusNotifierWatcher {
|
|||
) {
|
||||
let sender = hdr.sender().unwrap();
|
||||
let service = if service.starts_with('/') {
|
||||
format!("{}{}", sender, service)
|
||||
format!("{sender}{service}")
|
||||
} else {
|
||||
service.to_string()
|
||||
};
|
||||
|
|
@ -95,7 +95,7 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
|
|||
|
||||
let flags = RequestNameFlags::AllowReplacement.into();
|
||||
if dbus_proxy.request_name(NAME.as_ref(), flags).await? == RequestNameReply::InQueue {
|
||||
eprintln!("Bus name '{}' already owned", NAME);
|
||||
eprintln!("Bus name '{NAME}' already owned");
|
||||
}
|
||||
|
||||
let connection = connection.clone();
|
||||
|
|
@ -103,18 +103,15 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
|
|||
let mut have_bus_name = false;
|
||||
let unique_name = connection.unique_name().map(|x| x.as_ref());
|
||||
while let Some(evt) = name_owner_changed_stream.next().await {
|
||||
let args = match evt.args() {
|
||||
Ok(args) => args,
|
||||
Err(_) => {
|
||||
continue;
|
||||
}
|
||||
let Ok(args) = evt.args() else {
|
||||
continue;
|
||||
};
|
||||
if args.name.as_ref() == NAME {
|
||||
if args.new_owner.as_ref() == unique_name.as_ref() {
|
||||
eprintln!("Acquired bus name: {}", NAME);
|
||||
eprintln!("Acquired bus name: {NAME}");
|
||||
have_bus_name = true;
|
||||
} else if have_bus_name {
|
||||
eprintln!("Lost bus name: {}", NAME);
|
||||
eprintln!("Lost bus name: {NAME}");
|
||||
have_bus_name = false;
|
||||
}
|
||||
} else if let BusName::Unique(name) = &args.name {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue