From ac34c05d2ecb07fd871ed03ef6ee545dc2e6743d Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sat, 17 Jun 2023 16:43:38 +0100 Subject: [PATCH 1/2] fix(focused): empty icon rendered when `show_icon = false` Fixes #184 --- src/modules/focused.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/focused.rs b/src/modules/focused.rs index 3a4933a..4eb0342 100644 --- a/src/modules/focused.rs +++ b/src/modules/focused.rs @@ -97,7 +97,10 @@ impl Module for FocusedModule { let container = gtk::Box::new(info.bar_position.get_orientation(), 5); let icon = gtk::Image::new(); - add_class(&icon, "icon"); + if self.show_icon { + add_class(&icon, "icon"); + container.add(&icon); + } let label = Label::new(None); add_class(&label, "label"); @@ -106,7 +109,6 @@ impl Module for FocusedModule { truncate.truncate_label(&label); } - container.add(&icon); container.add(&label); { From de3aa5d7b10e0bf6d5ff3a39b009ff53a3316a5e Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sat, 17 Jun 2023 16:43:58 +0100 Subject: [PATCH 2/2] fix(focused): previous icon does not clear if new icon fails to load Fixes #169 --- src/modules/focused.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/focused.rs b/src/modules/focused.rs index 4eb0342..c46f3f6 100644 --- a/src/modules/focused.rs +++ b/src/modules/focused.rs @@ -115,8 +115,12 @@ impl Module for FocusedModule { let icon_theme = icon_theme.clone(); context.widget_rx.attach(None, move |(name, id)| { if self.show_icon { - ImageProvider::parse(&id, &icon_theme, self.icon_size) - .map(|image| image.load_into_image(icon.clone())); + match ImageProvider::parse(&id, &icon_theme, self.icon_size) + .map(|image| image.load_into_image(icon.clone())) + { + Some(Ok(_)) => icon.show(), + _ => icon.hide(), + } } if self.show_title {