refactor: general tidy up

fix clippy warnings from latest stable rust
This commit is contained in:
Jake Stanger 2023-02-25 14:24:21 +00:00
parent ca4fe422f2
commit d84139a914
No known key found for this signature in database
GPG Key ID: C51FC8F9CB0BEA61
5 changed files with 18 additions and 24 deletions

View File

@ -394,8 +394,6 @@ fn setup_module_common_options(container: EventBox, common: CommonConfig) {
let scroll_down_script = common.on_scroll_down.map(Script::new_polling);
container.connect_scroll_event(move |_, event| {
println!("{:?}", event.direction());
let script = match event.direction() {
ScrollDirection::Up => scroll_up_script.as_ref(),
ScrollDirection::Down => scroll_down_script.as_ref(),

View File

@ -74,7 +74,7 @@ impl Default for BarPosition {
}
}
#[derive(Debug, Deserialize, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Default, Deserialize, Copy, Clone, PartialEq, Eq)]
pub struct MarginConfig {
#[serde(default)]
pub bottom: i32,
@ -86,17 +86,6 @@ pub struct MarginConfig {
pub top: i32,
}
impl Default for MarginConfig {
fn default() -> Self {
MarginConfig {
bottom: 0,
left: 0,
right: 0,
top: 0,
}
}
}
#[derive(Debug, Deserialize, Clone)]
pub struct Config {
#[serde(default)]

View File

@ -132,16 +132,16 @@ impl<'a> ImageProvider<'a> {
});
}
} else {
self.load_into_image_sync(image)?;
self.load_into_image_sync(&image)?;
};
#[cfg(not(feature = "http"))]
self.load_into_image_sync(image)?;
self.load_into_image_sync(&image)?;
Ok(())
}
fn load_into_image_sync(&self, image: gtk::Image) -> Result<()> {
fn load_into_image_sync(&self, image: &gtk::Image) -> Result<()> {
let pixbuf = match &self.location {
ImageLocation::Icon { name, theme } => self.get_from_icon(name, theme),
ImageLocation::Local(path) => self.get_from_file(path),

View File

@ -110,9 +110,9 @@ impl Module<gtk::Box> for LauncherModule {
let wl = wayland::get_client().await;
let open_windows = read_lock!(wl.toplevels);
let mut items = lock!(items);
for (_, (window, _)) in open_windows.clone() {
let open_windows = open_windows.clone();
for (_, (window, _)) in open_windows {
let mut items = lock!(items);
let item = items.get_mut(&window.app_id);
match item {
Some(item) => {
@ -124,6 +124,7 @@ impl Module<gtk::Box> for LauncherModule {
}
}
let items = lock!(items);
let items = items.iter();
for (_, item) in items {
tx.try_send(ModuleUpdateEvent::Update(LauncherUpdate::AddItem(
@ -281,7 +282,7 @@ impl Module<gtk::Box> for LauncherModule {
ItemEvent::FocusItem(app_id) => items
.get(&app_id)
.and_then(|item| item.windows.first().map(|(_, win)| win.id)),
ItemEvent::FocusWindow(id) => Some(id),
ItemEvent::FocusWindow(id) => Some(id), // FIXME: Broken on wlroots-git
ItemEvent::OpenItem(_) => unreachable!(),
};
@ -292,6 +293,9 @@ impl Module<gtk::Box> for LauncherModule {
handle.activate(seat);
};
}
// roundtrip to immediately send activate event
wl.roundtrip();
}
}
});

View File

@ -361,16 +361,19 @@ fn refresh_system_tokens(format_info: &mut HashMap<String, String>, sys: &System
// no refresh required for these tokens
let load_average = sys.load_average();
format_info.insert(String::from("load_average:1"), load_average.one.to_string());
format_info.insert(
String::from("load_average:1"),
format!("{:.2}", load_average.one),
);
format_info.insert(
String::from("load_average:5"),
load_average.five.to_string(),
format!("{:.2}", load_average.five),
);
format_info.insert(
String::from("load_average:15"),
load_average.fifteen.to_string(),
format!("{:.2}", load_average.fifteen),
);
let uptime = Duration::from_secs(sys.uptime()).as_secs();