Skip to content

Commit 8846b22

Browse files
committed
chore: apply clippy suggestions
Also some slight refactors for readability/minor performance.
1 parent 91ae469 commit 8846b22

File tree

28 files changed

+331
-363
lines changed

28 files changed

+331
-363
lines changed

cosmic-app-list/src/app.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,10 +1360,10 @@ impl cosmic::Application for CosmicAppList {
13601360
+ 4.0 * (popup_applet_count - 1.);
13611361
let (max_width, max_height) = match self.core.applet.anchor {
13621362
PanelAnchor::Top | PanelAnchor::Bottom => {
1363-
(popup_applet_size, applet_suggested_size as f32)
1363+
(popup_applet_size, applet_suggested_size.into())
13641364
}
13651365
PanelAnchor::Left | PanelAnchor::Right => {
1366-
(applet_suggested_size as f32, popup_applet_size)
1366+
(applet_suggested_size.into(), popup_applet_size)
13671367
}
13681368
};
13691369
popup_settings.positioner.size_limits = Limits::NONE
@@ -1714,14 +1714,14 @@ impl cosmic::Application for CosmicAppList {
17141714

17151715
let mut content = match &self.core.applet.anchor {
17161716
PanelAnchor::Left | PanelAnchor::Right => container(
1717-
Column::with_children(content_list)
1717+
Column::from_vec(content_list)
17181718
.spacing(4.0)
17191719
.align_x(Alignment::Center)
17201720
.height(h)
17211721
.width(w),
17221722
),
17231723
PanelAnchor::Top | PanelAnchor::Bottom => container(
1724-
Row::with_children(content_list)
1724+
Row::from_vec(content_list)
17251725
.spacing(4.0)
17261726
.align_y(Alignment::Center)
17271727
.height(h)
@@ -2032,14 +2032,14 @@ impl cosmic::Application for CosmicAppList {
20322032
.collect();
20332033
let content = match &self.core.applet.anchor {
20342034
PanelAnchor::Left | PanelAnchor::Right => container(
2035-
Column::with_children(active)
2035+
Column::from_vec(active)
20362036
.spacing(4.0)
20372037
.align_x(Alignment::Center)
20382038
.width(Length::Shrink)
20392039
.height(Length::Shrink),
20402040
),
20412041
PanelAnchor::Top | PanelAnchor::Bottom => container(
2042-
Row::with_children(active)
2042+
Row::from_vec(active)
20432043
.spacing(4.0)
20442044
.align_y(Alignment::Center)
20452045
.width(Length::Shrink)
@@ -2135,14 +2135,14 @@ impl cosmic::Application for CosmicAppList {
21352135
.collect();
21362136
let content = match &self.core.applet.anchor {
21372137
PanelAnchor::Left | PanelAnchor::Right => container(
2138-
Column::with_children(favorites)
2138+
Column::from_vec(favorites)
21392139
.spacing(4.0)
21402140
.align_x(Alignment::Center)
21412141
.width(Length::Shrink)
21422142
.height(Length::Shrink),
21432143
),
21442144
PanelAnchor::Top | PanelAnchor::Bottom => container(
2145-
Row::with_children(favorites)
2145+
Row::from_vec(favorites)
21462146
.spacing(4.0)
21472147
.align_y(Alignment::Center)
21482148
.width(Length::Shrink)
@@ -2240,7 +2240,7 @@ impl CosmicAppList {
22402240
}) else {
22412241
return (None, active_index);
22422242
};
2243-
// tracing::error!("{} {}", max_major_axis_len, self.pinned_list.len());
2243+
// tracing::error!("{max_major_axis_len} {}", self.pinned_list.len());
22442244
// subtract the divider width
22452245
max_major_axis_len -= 1;
22462246
let applet_icon = AppletIconData::new(&self.core.applet);
@@ -2279,7 +2279,7 @@ impl CosmicAppList {
22792279
} else {
22802280
favorite_index = (btn_count as usize).min(self.pinned_list.len());
22812281
}
2282-
// tracing::error!("{} {} {:?}", btn_count, favorite_index, active_index);
2282+
// tracing::error!("{btn_count} {favorite_index} {active_index:?}");
22832283
(Some(favorite_index), active_index)
22842284
}
22852285

@@ -2335,7 +2335,11 @@ impl CosmicAppList {
23352335
// in addition, try to match WINE entries who have its
23362336
// appid = the full name of the executable (incl. .exe)
23372337
let is_proton_game = info.app_id == "steam_app_default";
2338-
if is_proton_game || info.app_id.ends_with(".exe") {
2338+
if is_proton_game
2339+
|| PathBuf::from(info.app_id.clone())
2340+
.extension()
2341+
.is_some_and(|ext| ext.eq_ignore_ascii_case("exe"))
2342+
{
23392343
for entry in &self.desktop_entries {
23402344
let localised_name = entry.name(&self.locales).unwrap_or_default();
23412345

cosmic-app-list/src/wayland_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl CaptureData {
404404
// XXX
405405
if !formats.shm_formats.contains(&wl_shm::Format::Abgr8888) {
406406
tracing::error!("No suitable buffer format found");
407-
tracing::warn!("Available formats: {:#?}", formats);
407+
tracing::warn!("Available formats: {formats:#?}");
408408
return None;
409409
}
410410

cosmic-applet-a11y/src/app.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,21 @@ impl cosmic::Application for CosmicA11yApplet {
147147
Message::TogglePopup => {
148148
if let Some(p) = self.popup.take() {
149149
return destroy_popup(p);
150-
} else {
151-
self.timeline = Timeline::new();
150+
}
151+
self.timeline = Timeline::new();
152152

153-
let new_id = window::Id::unique();
154-
self.popup.replace(new_id);
153+
let new_id = window::Id::unique();
154+
self.popup.replace(new_id);
155155

156-
let popup_settings = self.core.applet.get_popup_settings(
157-
self.core.main_window_id().unwrap(),
158-
new_id,
159-
Some((1, 1)),
160-
None,
161-
None,
162-
);
156+
let popup_settings = self.core.applet.get_popup_settings(
157+
self.core.main_window_id().unwrap(),
158+
new_id,
159+
Some((1, 1)),
160+
None,
161+
None,
162+
);
163163

164-
return get_popup(popup_settings);
165-
}
164+
return get_popup(popup_settings);
166165
}
167166
Message::CloseRequested(id) => {
168167
if Some(id) == self.popup {

cosmic-applet-a11y/src/backend/wayland/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
// SPDX-License-Identifier: GPL-3.0-only
33

44
use anyhow;
5-
use cctk::sctk::reexports::calloop::{self, channel::SyncSender};
5+
use cctk::sctk::reexports::calloop;
66
use cosmic::iced::{
77
self, Subscription,
8-
futures::{self, SinkExt, StreamExt, channel::mpsc},
8+
futures::{self, SinkExt},
99
stream,
1010
};
11-
use cosmic_protocols::a11y::v1::client::cosmic_a11y_manager_v1::Filter;
1211
use cosmic_settings_subscriptions::cosmic_a11y_manager::{
1312
self as thread, AccessibilityEvent, AccessibilityRequest,
1413
};

cosmic-applet-audio/src/lib.rs

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,16 @@ impl Audio {
203203
.icon_button(GO_NEXT)
204204
.on_press(Message::MprisRequest(MprisRequest::Next))
205205
.into(),
206-
)
206+
);
207207
}
208208

209209
Some(match self.core.applet.anchor {
210-
PanelAnchor::Left | PanelAnchor::Right => Column::with_children(elements)
211-
.align_x(Alignment::Center)
212-
.into(),
213-
PanelAnchor::Top | PanelAnchor::Bottom => Row::with_children(elements)
214-
.align_y(Alignment::Center)
215-
.into(),
210+
PanelAnchor::Left | PanelAnchor::Right => {
211+
Column::from_vec(elements).align_x(Alignment::Center).into()
212+
}
213+
PanelAnchor::Top | PanelAnchor::Bottom => {
214+
Row::from_vec(elements).align_y(Alignment::Center).into()
215+
}
216216
})
217217
} else {
218218
None
@@ -315,34 +315,34 @@ impl cosmic::Application for Audio {
315315
Message::TogglePopup => {
316316
if let Some(p) = self.popup.take() {
317317
return destroy_popup(p);
318-
} else {
319-
if let Some(conn) = self.pulse_state.connection() {
320-
conn.send(pulse::Message::UpdateConnection);
321-
}
322-
let new_id = window::Id::unique();
323-
self.popup.replace(new_id);
324-
self.timeline = Timeline::new();
325-
326-
self.output_amplification = amplification_sink();
327-
self.input_amplification = amplification_source();
328-
329-
let popup_settings = self.core.applet.get_popup_settings(
330-
self.core.main_window_id().unwrap(),
331-
new_id,
332-
None,
333-
None,
334-
None,
335-
);
318+
}
336319

337-
if let Some(conn) = self.pulse_state.connection() {
338-
conn.send(pulse::Message::GetDefaultSink);
339-
conn.send(pulse::Message::GetDefaultSource);
340-
conn.send(pulse::Message::GetSinks);
341-
conn.send(pulse::Message::GetSources);
342-
}
320+
if let Some(conn) = self.pulse_state.connection() {
321+
conn.send(pulse::Message::UpdateConnection);
322+
}
323+
let new_id = window::Id::unique();
324+
self.popup.replace(new_id);
325+
self.timeline = Timeline::new();
326+
327+
self.output_amplification = amplification_sink();
328+
self.input_amplification = amplification_source();
329+
330+
let popup_settings = self.core.applet.get_popup_settings(
331+
self.core.main_window_id().unwrap(),
332+
new_id,
333+
None,
334+
None,
335+
None,
336+
);
343337

344-
return get_popup(popup_settings);
338+
if let Some(conn) = self.pulse_state.connection() {
339+
conn.send(pulse::Message::GetDefaultSink);
340+
conn.send(pulse::Message::GetDefaultSource);
341+
conn.send(pulse::Message::GetSinks);
342+
conn.send(pulse::Message::GetSources);
345343
}
344+
345+
return get_popup(popup_settings);
346346
}
347347
Message::SetOutputVolume(vol) => {
348348
if self.output_volume == vol {
@@ -400,7 +400,7 @@ impl cosmic::Application for Audio {
400400
if let PulseState::Connected(connection) = &mut self.pulse_state {
401401
if let Some(device) = &self.current_input {
402402
if let Some(name) = &device.name {
403-
tracing::info!("increasing volume of {}", name);
403+
tracing::info!("increasing volume of {name}");
404404
connection.send(pulse::Message::SetSourceVolumeByName(
405405
name.clone(),
406406
device.volume,
@@ -432,7 +432,7 @@ impl cosmic::Application for Audio {
432432
connection.send(pulse::Message::SetSourceMuteByName(
433433
name.clone(),
434434
device.mute,
435-
))
435+
));
436436
}
437437
}
438438
}
@@ -506,7 +506,7 @@ impl cosmic::Application for Audio {
506506
panic!("Subscription error handling is bad. This should never happen.")
507507
}
508508
_ => {
509-
tracing::trace!("Received misc message")
509+
tracing::trace!("Received misc message");
510510
}
511511
}
512512
}
@@ -559,35 +559,35 @@ impl cosmic::Application for Audio {
559559
MprisRequest::Play => tokio::spawn(async move {
560560
let res = player.play().await;
561561
if let Err(err) = res {
562-
tracing::error!("Error playing: {}", err);
562+
tracing::error!("Error playing: {err}");
563563
}
564564
}),
565565
MprisRequest::Pause => tokio::spawn(async move {
566566
let res = player.pause().await;
567567
if let Err(err) = res {
568-
tracing::error!("Error pausing: {}", err);
568+
tracing::error!("Error pausing: {err}");
569569
}
570570
}),
571571
MprisRequest::Next => tokio::spawn(async move {
572572
let res = player.next().await;
573573
if let Err(err) = res {
574-
tracing::error!("Error playing next: {}", err);
574+
tracing::error!("Error playing next: {err}");
575575
}
576576
}),
577577
MprisRequest::Previous => tokio::spawn(async move {
578578
let res = player.previous().await;
579579
if let Err(err) = res {
580-
tracing::error!("Error playing previous: {}", err);
580+
tracing::error!("Error playing previous: {err}");
581581
}
582582
}),
583583
MprisRequest::Raise => tokio::spawn(async move {
584584
let res = player.media_player().await;
585585
if let Err(err) = res {
586-
tracing::error!("Error fetching MediaPlayer: {}", err);
586+
tracing::error!("Error fetching MediaPlayer: {err}");
587587
} else {
588588
let res = res.unwrap().raise().await;
589589
if let Err(err) = res {
590-
tracing::error!("Error raising client: {}", err);
590+
tracing::error!("Error raising client: {err}");
591591
}
592592
}
593593
}),
@@ -626,10 +626,10 @@ impl cosmic::Application for Audio {
626626
self.current_output.as_mut().map(|output| {
627627
output
628628
.volume
629-
.set(output.volume.len(), percent_to_volume(value as f64))
629+
.set(output.volume.len(), percent_to_volume(value.into()))
630630
});
631631

632-
self.output_volume = value as f64;
632+
self.output_volume = value.into();
633633
self.output_volume_text = format!("{}%", self.output_volume.round());
634634
}
635635
sub_pulse::Event::SinkMute(value) => {
@@ -641,10 +641,10 @@ impl cosmic::Application for Audio {
641641
self.current_input.as_mut().map(|input| {
642642
input
643643
.volume
644-
.set(input.volume.len(), percent_to_volume(value as f64))
644+
.set(input.volume.len(), percent_to_volume(value.into()))
645645
});
646646

647-
self.input_volume = value as f64;
647+
self.input_volume = value.into();
648648
self.input_volume_text = format!("{}%", self.input_volume.round());
649649
}
650650
sub_pulse::Event::SourceMute(value) => {
@@ -909,7 +909,7 @@ impl cosmic::Application for Audio {
909909
}
910910
let control_cnt = control_elements.len() as u16;
911911
elements.push(
912-
Row::with_children(control_elements)
912+
Row::from_vec(control_elements)
913913
.align_y(Alignment::Center)
914914
.width(Length::FillPortion(control_cnt.saturating_add(1)))
915915
.spacing(8)
@@ -920,7 +920,7 @@ impl cosmic::Application for Audio {
920920
.push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]));
921921
audio_content = audio_content.push(
922922
menu_button(
923-
Row::with_children(elements)
923+
Row::from_vec(elements)
924924
.align_y(Alignment::Center)
925925
.spacing(8),
926926
)

cosmic-applet-audio/src/mpris_subscription.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl State {
164164
players.push(player);
165165
}
166166
Err(err) => {
167-
tracing::error!("Failed to add player: {}", err);
167+
tracing::error!("Failed to add player: {err}");
168168
}
169169
}
170170
}
@@ -190,7 +190,7 @@ impl State {
190190
let player = match MprisPlayer::new(&self.conn, name).await {
191191
Ok(player) => player,
192192
Err(err) => {
193-
tracing::error!("Failed to add player: {}", err);
193+
tracing::error!("Failed to add player: {err}");
194194
return;
195195
}
196196
};
@@ -243,7 +243,7 @@ async fn run(output: &mut futures::channel::mpsc::Sender<MprisUpdate>) {
243243
let mut state = match State::new().await {
244244
Ok(state) => state,
245245
Err(err) => {
246-
tracing::error!("Failed to monitor for mpris clients: {}", err);
246+
tracing::error!("Failed to monitor for mpris clients: {err}");
247247
return;
248248
}
249249
};
@@ -273,7 +273,7 @@ async fn run(output: &mut futures::channel::mpsc::Sender<MprisUpdate>) {
273273
Some(Ok(enumerator::Event::Add(name))) => state.add_player(name).await,
274274
Some(Ok(enumerator::Event::Remove(name))) => state.remove_player(name).await,
275275
Some(Err(err)) => {
276-
tracing::error!("Error listening for mpris clients: {:?}", err);
276+
tracing::error!("Error listening for mpris clients: {err:?}");
277277
return;
278278
}
279279
None => {}

0 commit comments

Comments
 (0)