1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 02:31:04 +02:00

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); let scroll_down_script = common.on_scroll_down.map(Script::new_polling);
container.connect_scroll_event(move |_, event| { container.connect_scroll_event(move |_, event| {
println!("{:?}", event.direction());
let script = match event.direction() { let script = match event.direction() {
ScrollDirection::Up => scroll_up_script.as_ref(), ScrollDirection::Up => scroll_up_script.as_ref(),
ScrollDirection::Down => scroll_down_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 { pub struct MarginConfig {
#[serde(default)] #[serde(default)]
pub bottom: i32, pub bottom: i32,
@ -86,17 +86,6 @@ pub struct MarginConfig {
pub top: i32, pub top: i32,
} }
impl Default for MarginConfig {
fn default() -> Self {
MarginConfig {
bottom: 0,
left: 0,
right: 0,
top: 0,
}
}
}
#[derive(Debug, Deserialize, Clone)] #[derive(Debug, Deserialize, Clone)]
pub struct Config { pub struct Config {
#[serde(default)] #[serde(default)]

View file

@ -132,16 +132,16 @@ impl<'a> ImageProvider<'a> {
}); });
} }
} else { } else {
self.load_into_image_sync(image)?; self.load_into_image_sync(&image)?;
}; };
#[cfg(not(feature = "http"))] #[cfg(not(feature = "http"))]
self.load_into_image_sync(image)?; self.load_into_image_sync(&image)?;
Ok(()) 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 { let pixbuf = match &self.location {
ImageLocation::Icon { name, theme } => self.get_from_icon(name, theme), ImageLocation::Icon { name, theme } => self.get_from_icon(name, theme),
ImageLocation::Local(path) => self.get_from_file(path), 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 wl = wayland::get_client().await;
let open_windows = read_lock!(wl.toplevels); let open_windows = read_lock!(wl.toplevels);
let open_windows = open_windows.clone();
for (_, (window, _)) in open_windows {
let mut items = lock!(items); let mut items = lock!(items);
for (_, (window, _)) in open_windows.clone() {
let item = items.get_mut(&window.app_id); let item = items.get_mut(&window.app_id);
match item { match item {
Some(item) => { Some(item) => {
@ -124,6 +124,7 @@ impl Module<gtk::Box> for LauncherModule {
} }
} }
let items = lock!(items);
let items = items.iter(); let items = items.iter();
for (_, item) in items { for (_, item) in items {
tx.try_send(ModuleUpdateEvent::Update(LauncherUpdate::AddItem( tx.try_send(ModuleUpdateEvent::Update(LauncherUpdate::AddItem(
@ -281,7 +282,7 @@ impl Module<gtk::Box> for LauncherModule {
ItemEvent::FocusItem(app_id) => items ItemEvent::FocusItem(app_id) => items
.get(&app_id) .get(&app_id)
.and_then(|item| item.windows.first().map(|(_, win)| win.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!(), ItemEvent::OpenItem(_) => unreachable!(),
}; };
@ -292,6 +293,9 @@ impl Module<gtk::Box> for LauncherModule {
handle.activate(seat); 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 // no refresh required for these tokens
let load_average = sys.load_average(); 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( format_info.insert(
String::from("load_average:5"), String::from("load_average:5"),
load_average.five.to_string(), format!("{:.2}", load_average.five),
); );
format_info.insert( format_info.insert(
String::from("load_average:15"), String::from("load_average:15"),
load_average.fifteen.to_string(), format!("{:.2}", load_average.fifteen),
); );
let uptime = Duration::from_secs(sys.uptime()).as_secs(); let uptime = Duration::from_secs(sys.uptime()).as_secs();