mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 14:21:03 +02:00
refactor: fix some strict clippy warnings
This commit is contained in:
parent
bd9b3af5bc
commit
ca524f19f6
13 changed files with 28 additions and 33 deletions
|
@ -140,7 +140,7 @@ pub async fn create_client() -> Result<Arc<Client>> {
|
|||
spawn(async move {
|
||||
if let Err(error) = client.run().await {
|
||||
error!("{}", error);
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
Ok(client)
|
||||
|
|
|
@ -157,7 +157,7 @@ impl Client {
|
|||
Event::Toplevel(event) => toplevel_tx.send_expect(event),
|
||||
#[cfg(feature = "clipboard")]
|
||||
Event::Clipboard(item) => clipboard_tx.send_expect(item),
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,13 +25,11 @@ pub struct LayoutConfig {
|
|||
impl LayoutConfig {
|
||||
pub fn orientation(&self, info: &ModuleInfo) -> gtk::Orientation {
|
||||
self.orientation
|
||||
.map(ModuleOrientation::into)
|
||||
.unwrap_or(info.bar_position.orientation())
|
||||
.map_or(info.bar_position.orientation(), ModuleOrientation::into)
|
||||
}
|
||||
|
||||
pub fn angle(&self, info: &ModuleInfo) -> f64 {
|
||||
self.orientation
|
||||
.map(ModuleOrientation::to_angle)
|
||||
.unwrap_or(info.bar_position.angle())
|
||||
.map_or(info.bar_position.angle(), ModuleOrientation::to_angle)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,11 @@ pub fn handle_command(command: IronvarCommand) -> Response {
|
|||
|
||||
if key.contains('.') {
|
||||
for part in key.split('.') {
|
||||
ns = match ns.get_namespace(part) {
|
||||
Some(ns) => ns.clone(),
|
||||
None => {
|
||||
key = part.into();
|
||||
break;
|
||||
}
|
||||
ns = if let Some(ns) = ns.get_namespace(part) {
|
||||
ns.clone()
|
||||
} else {
|
||||
key = part.into();
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ impl Namespace for VariableManager {
|
|||
let namespaces = read_lock!(self.namespaces);
|
||||
let ns = namespaces.get(ns)?;
|
||||
|
||||
ns.get(key).map(|v| v.to_owned())
|
||||
ns.get(key).as_deref().map(ToOwned::to_owned)
|
||||
} else {
|
||||
read_lock!(self.variables).get(key).and_then(IronVar::get)
|
||||
}
|
||||
|
|
|
@ -466,11 +466,10 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
&container,
|
||||
self.page_size,
|
||||
self.layout.orientation(info),
|
||||
IconContext {
|
||||
icon_back: &self.icons.page_back,
|
||||
icon_fwd: &self.icons.page_forward,
|
||||
icon_size: self.pagination_icon_size,
|
||||
icon_theme: info.icon_theme,
|
||||
&IconContext {
|
||||
back: &self.icons.page_back,
|
||||
fwd: &self.icons.page_forward,
|
||||
size: self.pagination_icon_size,
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -524,9 +523,9 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
);
|
||||
|
||||
if self.reversed {
|
||||
container.pack_end(button.button.deref(), false, false, 0);
|
||||
container.pack_end(&*button.button, false, false, 0);
|
||||
} else {
|
||||
container.add(button.button.deref());
|
||||
container.add(&*button.button);
|
||||
}
|
||||
|
||||
if buttons.len() + 1 >= pagination.offset() + page_size {
|
||||
|
@ -599,7 +598,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
}
|
||||
}
|
||||
LauncherUpdate::Hover(_) => {}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
rx.recv_glib(handle_event);
|
||||
|
|
|
@ -14,10 +14,9 @@ pub struct Pagination {
|
|||
}
|
||||
|
||||
pub struct IconContext<'a> {
|
||||
pub icon_back: &'a str,
|
||||
pub icon_fwd: &'a str,
|
||||
pub icon_size: i32,
|
||||
pub icon_theme: &'a IconTheme,
|
||||
pub back: &'a str,
|
||||
pub fwd: &'a str,
|
||||
pub size: i32,
|
||||
}
|
||||
|
||||
impl Pagination {
|
||||
|
@ -86,8 +85,8 @@ impl Pagination {
|
|||
if page_size < *offset {
|
||||
*offset -= page_size;
|
||||
} else {
|
||||
*offset = 1
|
||||
};
|
||||
*offset = 1;
|
||||
}
|
||||
|
||||
Self::update_page(&container, *offset, page_size);
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ impl Module<Overlay> for NotificationsModule {
|
|||
match initial_state {
|
||||
Ok(ev) => tx.send_update(ev).await,
|
||||
Err(err) => error!("{err:?}"),
|
||||
};
|
||||
}
|
||||
|
||||
while let Ok(ev) = rx.recv().await {
|
||||
tx.send_update(ev).await;
|
||||
|
|
|
@ -251,7 +251,7 @@ impl Module<gtk::Box> for SysInfoModule {
|
|||
RefreshType::Disks => client.refresh_disks(),
|
||||
RefreshType::Network => client.refresh_network(),
|
||||
RefreshType::System => client.refresh_load_average(),
|
||||
};
|
||||
}
|
||||
|
||||
for (i, token_set) in format_tokens.iter().enumerate() {
|
||||
let is_affected = token_set
|
||||
|
|
|
@ -237,7 +237,7 @@ fn parse_formatting(chars: &mut Peekable<Chars>, mut formatting: Formatting) ->
|
|||
formatting.align = Alignment::try_from(char)?;
|
||||
}
|
||||
(_, FormattingMode::WidthFillAlign) => formatting.fill = char,
|
||||
};
|
||||
}
|
||||
|
||||
next_char = chars.next();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ impl Popup {
|
|||
/// This includes setting up gtk-layer-shell
|
||||
/// and an empty `gtk::Box` container.
|
||||
pub fn new(
|
||||
ironbar: Rc<Ironbar>,
|
||||
ironbar: &Ironbar,
|
||||
module_info: &ModuleInfo,
|
||||
output_size: (i32, i32),
|
||||
gap: i32,
|
||||
|
|
|
@ -217,7 +217,7 @@ impl Script {
|
|||
}
|
||||
Err(err) => error!("{err:?}"),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
sleep(tokio::time::Duration::from_millis(self.interval)).await;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ pub fn load_css(style_path: PathBuf, application: Application) {
|
|||
.suggestion("Check the CSS file for errors")
|
||||
.suggestion("GTK CSS uses a subset of the full CSS spec and many properties are not available. Ensure you are not using any unsupported property.")
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
let screen = gdk::Screen::default().expect("Failed to get default GTK screen");
|
||||
StyleContext::add_provider_for_screen(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue