mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 06:41: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 {
|
spawn(async move {
|
||||||
if let Err(error) = client.run().await {
|
if let Err(error) = client.run().await {
|
||||||
error!("{}", error);
|
error!("{}", error);
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Ok(client)
|
Ok(client)
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl Client {
|
||||||
Event::Toplevel(event) => toplevel_tx.send_expect(event),
|
Event::Toplevel(event) => toplevel_tx.send_expect(event),
|
||||||
#[cfg(feature = "clipboard")]
|
#[cfg(feature = "clipboard")]
|
||||||
Event::Clipboard(item) => clipboard_tx.send_expect(item),
|
Event::Clipboard(item) => clipboard_tx.send_expect(item),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,11 @@ pub struct LayoutConfig {
|
||||||
impl LayoutConfig {
|
impl LayoutConfig {
|
||||||
pub fn orientation(&self, info: &ModuleInfo) -> gtk::Orientation {
|
pub fn orientation(&self, info: &ModuleInfo) -> gtk::Orientation {
|
||||||
self.orientation
|
self.orientation
|
||||||
.map(ModuleOrientation::into)
|
.map_or(info.bar_position.orientation(), ModuleOrientation::into)
|
||||||
.unwrap_or(info.bar_position.orientation())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn angle(&self, info: &ModuleInfo) -> f64 {
|
pub fn angle(&self, info: &ModuleInfo) -> f64 {
|
||||||
self.orientation
|
self.orientation
|
||||||
.map(ModuleOrientation::to_angle)
|
.map_or(info.bar_position.angle(), ModuleOrientation::to_angle)
|
||||||
.unwrap_or(info.bar_position.angle())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,11 @@ pub fn handle_command(command: IronvarCommand) -> Response {
|
||||||
|
|
||||||
if key.contains('.') {
|
if key.contains('.') {
|
||||||
for part in key.split('.') {
|
for part in key.split('.') {
|
||||||
ns = match ns.get_namespace(part) {
|
ns = if let Some(ns) = ns.get_namespace(part) {
|
||||||
Some(ns) => ns.clone(),
|
ns.clone()
|
||||||
None => {
|
} else {
|
||||||
key = part.into();
|
key = part.into();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl Namespace for VariableManager {
|
||||||
let namespaces = read_lock!(self.namespaces);
|
let namespaces = read_lock!(self.namespaces);
|
||||||
let ns = namespaces.get(ns)?;
|
let ns = namespaces.get(ns)?;
|
||||||
|
|
||||||
ns.get(key).map(|v| v.to_owned())
|
ns.get(key).as_deref().map(ToOwned::to_owned)
|
||||||
} else {
|
} else {
|
||||||
read_lock!(self.variables).get(key).and_then(IronVar::get)
|
read_lock!(self.variables).get(key).and_then(IronVar::get)
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,11 +466,10 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
&container,
|
&container,
|
||||||
self.page_size,
|
self.page_size,
|
||||||
self.layout.orientation(info),
|
self.layout.orientation(info),
|
||||||
IconContext {
|
&IconContext {
|
||||||
icon_back: &self.icons.page_back,
|
back: &self.icons.page_back,
|
||||||
icon_fwd: &self.icons.page_forward,
|
fwd: &self.icons.page_forward,
|
||||||
icon_size: self.pagination_icon_size,
|
size: self.pagination_icon_size,
|
||||||
icon_theme: info.icon_theme,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -524,9 +523,9 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.reversed {
|
if self.reversed {
|
||||||
container.pack_end(button.button.deref(), false, false, 0);
|
container.pack_end(&*button.button, false, false, 0);
|
||||||
} else {
|
} else {
|
||||||
container.add(button.button.deref());
|
container.add(&*button.button);
|
||||||
}
|
}
|
||||||
|
|
||||||
if buttons.len() + 1 >= pagination.offset() + page_size {
|
if buttons.len() + 1 >= pagination.offset() + page_size {
|
||||||
|
@ -599,7 +598,7 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LauncherUpdate::Hover(_) => {}
|
LauncherUpdate::Hover(_) => {}
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
rx.recv_glib(handle_event);
|
rx.recv_glib(handle_event);
|
||||||
|
|
|
@ -14,10 +14,9 @@ pub struct Pagination {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct IconContext<'a> {
|
pub struct IconContext<'a> {
|
||||||
pub icon_back: &'a str,
|
pub back: &'a str,
|
||||||
pub icon_fwd: &'a str,
|
pub fwd: &'a str,
|
||||||
pub icon_size: i32,
|
pub size: i32,
|
||||||
pub icon_theme: &'a IconTheme,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pagination {
|
impl Pagination {
|
||||||
|
@ -86,8 +85,8 @@ impl Pagination {
|
||||||
if page_size < *offset {
|
if page_size < *offset {
|
||||||
*offset -= page_size;
|
*offset -= page_size;
|
||||||
} else {
|
} else {
|
||||||
*offset = 1
|
*offset = 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
Self::update_page(&container, *offset, page_size);
|
Self::update_page(&container, *offset, page_size);
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ impl Module<Overlay> for NotificationsModule {
|
||||||
match initial_state {
|
match initial_state {
|
||||||
Ok(ev) => tx.send_update(ev).await,
|
Ok(ev) => tx.send_update(ev).await,
|
||||||
Err(err) => error!("{err:?}"),
|
Err(err) => error!("{err:?}"),
|
||||||
};
|
}
|
||||||
|
|
||||||
while let Ok(ev) = rx.recv().await {
|
while let Ok(ev) = rx.recv().await {
|
||||||
tx.send_update(ev).await;
|
tx.send_update(ev).await;
|
||||||
|
|
|
@ -251,7 +251,7 @@ impl Module<gtk::Box> for SysInfoModule {
|
||||||
RefreshType::Disks => client.refresh_disks(),
|
RefreshType::Disks => client.refresh_disks(),
|
||||||
RefreshType::Network => client.refresh_network(),
|
RefreshType::Network => client.refresh_network(),
|
||||||
RefreshType::System => client.refresh_load_average(),
|
RefreshType::System => client.refresh_load_average(),
|
||||||
};
|
}
|
||||||
|
|
||||||
for (i, token_set) in format_tokens.iter().enumerate() {
|
for (i, token_set) in format_tokens.iter().enumerate() {
|
||||||
let is_affected = token_set
|
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)?;
|
formatting.align = Alignment::try_from(char)?;
|
||||||
}
|
}
|
||||||
(_, FormattingMode::WidthFillAlign) => formatting.fill = char,
|
(_, FormattingMode::WidthFillAlign) => formatting.fill = char,
|
||||||
};
|
}
|
||||||
|
|
||||||
next_char = chars.next();
|
next_char = chars.next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl Popup {
|
||||||
/// This includes setting up gtk-layer-shell
|
/// This includes setting up gtk-layer-shell
|
||||||
/// and an empty `gtk::Box` container.
|
/// and an empty `gtk::Box` container.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ironbar: Rc<Ironbar>,
|
ironbar: &Ironbar,
|
||||||
module_info: &ModuleInfo,
|
module_info: &ModuleInfo,
|
||||||
output_size: (i32, i32),
|
output_size: (i32, i32),
|
||||||
gap: i32,
|
gap: i32,
|
||||||
|
|
|
@ -217,7 +217,7 @@ impl Script {
|
||||||
}
|
}
|
||||||
Err(err) => error!("{err:?}"),
|
Err(err) => error!("{err:?}"),
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|
||||||
sleep(tokio::time::Duration::from_millis(self.interval)).await;
|
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("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.")
|
.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");
|
let screen = gdk::Screen::default().expect("Failed to get default GTK screen");
|
||||||
StyleContext::add_provider_for_screen(
|
StyleContext::add_provider_for_screen(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue