mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01:04 +02:00
refactor: move label truncate function to ext trait
Conflicts: src/gtk_helpers.rs src/modules/music/mod.rs
This commit is contained in:
parent
cc6f21ed68
commit
8b05ed526d
8 changed files with 44 additions and 35 deletions
|
@ -1,6 +1,7 @@
|
|||
use crate::clients::clipboard::{self, ClipboardEvent};
|
||||
use crate::clients::wayland::{ClipboardItem, ClipboardValue};
|
||||
use crate::config::{CommonConfig, TruncateMode};
|
||||
use crate::gtk_helpers::IronbarLabelExt;
|
||||
use crate::image::new_icon_button;
|
||||
use crate::modules::{
|
||||
Module, ModuleInfo, ModuleParts, ModulePopup, ModuleUpdateEvent, PopupButton, WidgetContext,
|
||||
|
@ -195,7 +196,7 @@ impl Module<Button> for ClipboardModule {
|
|||
button.add(&label);
|
||||
|
||||
if let Some(truncate) = self.truncate {
|
||||
truncate.truncate_label(&label);
|
||||
label.truncate(truncate);
|
||||
}
|
||||
|
||||
button.style_context().add_class("text");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::clients::wayland::{self, ToplevelEvent};
|
||||
use crate::config::{CommonConfig, TruncateMode};
|
||||
use crate::gtk_helpers::IronbarGtkExt;
|
||||
use crate::gtk_helpers::IronbarLabelExt;
|
||||
use crate::image::ImageProvider;
|
||||
use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext};
|
||||
use crate::{glib_recv, module_impl, send_async, spawn, try_send};
|
||||
|
@ -145,7 +146,7 @@ impl Module<gtk::Box> for FocusedModule {
|
|||
label.add_class("label");
|
||||
|
||||
if let Some(truncate) = self.truncate {
|
||||
truncate.truncate_label(&label);
|
||||
label.truncate(truncate);
|
||||
}
|
||||
|
||||
container.add(&label);
|
||||
|
|
|
@ -196,7 +196,7 @@ impl Module<Button> for MusicModule {
|
|||
.build();
|
||||
|
||||
if let Some(truncate) = self.truncate {
|
||||
truncate.truncate_label(&label);
|
||||
label.truncate(truncate);
|
||||
}
|
||||
|
||||
button_contents.add(&icon_pause);
|
||||
|
|
|
@ -66,7 +66,7 @@ impl Module<GtkBox> for NetworkManagerModule {
|
|||
|
||||
let initial_icon_name = "content-loading-symbolic";
|
||||
ImageProvider::parse(initial_icon_name, &icon_theme, false, self.icon_size)
|
||||
.map(|provider| provider.load_into_image(icon.clone()));
|
||||
.map(|provider| provider.load_into_image(&icon));
|
||||
|
||||
let widget_receiver = context.subscribe();
|
||||
glib_recv!(widget_receiver, state => {
|
||||
|
@ -80,7 +80,7 @@ impl Module<GtkBox> for NetworkManagerModule {
|
|||
ClientState::Unknown => "dialog-question-symbolic",
|
||||
};
|
||||
ImageProvider::parse(icon_name, &icon_theme, false, self.icon_size)
|
||||
.map(|provider| provider.load_into_image(icon.clone()));
|
||||
.map(|provider| provider.load_into_image(&icon));
|
||||
});
|
||||
|
||||
Ok(ModuleParts::new(container, None))
|
||||
|
|
|
@ -66,7 +66,7 @@ impl Module<Label> for SwayModeModule {
|
|||
let label = label.clone();
|
||||
|
||||
if let Some(truncate) = self.truncate {
|
||||
truncate.truncate_label(&label);
|
||||
label.truncate(truncate);
|
||||
}
|
||||
|
||||
let on_mode = move |mode: ModeEvent| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue