Skip to content

Commit 5140811

Browse files
committed
anyrun: Fixed hide_icons not doing anything
1 parent 8e2c9d5 commit 5140811

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

anyrun/src/plugin_box.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ use crate::Config;
1111
pub struct PluginMatch {
1212
pub content: Match,
1313
pub row: gtk::ListBoxRow,
14+
config: Rc<Config>,
1415
}
1516

1617
#[relm4::factory(pub)]
1718
impl FactoryComponent for PluginMatch {
18-
type Init = Match;
19+
type Init = (Match, Rc<Config>);
1920
type Input = ();
2021
type Output = ();
2122
type CommandOutput = ();
@@ -33,6 +34,7 @@ impl FactoryComponent for PluginMatch {
3334
#[name = "icon"]
3435
gtk::Image {
3536
set_pixel_size: 32,
37+
set_visible: false,
3638
set_css_classes: &["match"]
3739
},
3840

@@ -81,16 +83,16 @@ impl FactoryComponent for PluginMatch {
8183

8284
self.row = root;
8385

84-
match &self.content.icon {
85-
ROption::RSome(icon) => {
86+
if !self.config.hide_icons {
87+
if let ROption::RSome(icon) = &self.content.icon {
88+
widgets.icon.set_visible(true);
8689
let path = PathBuf::from(icon.to_string());
8790
if path.is_absolute() {
8891
widgets.icon.set_from_file(Some(path));
8992
} else {
9093
widgets.icon.set_icon_name(Some(icon));
9194
}
9295
}
93-
ROption::RNone => widgets.icon.set_visible(false),
9496
}
9597

9698
match &self.content.description {
@@ -101,10 +103,18 @@ impl FactoryComponent for PluginMatch {
101103
widgets
102104
}
103105

104-
fn init_model(content: Self::Init, _index: &Self::Index, _sender: FactorySender<Self>) -> Self {
106+
fn init_model(
107+
(content, config): Self::Init,
108+
_index: &Self::Index,
109+
_sender: FactorySender<Self>,
110+
) -> Self {
105111
let row = gtk::ListBoxRow::default();
106112

107-
Self { row, content }
113+
Self {
114+
row,
115+
content,
116+
config,
117+
}
108118
}
109119
}
110120

@@ -158,6 +168,7 @@ impl FactoryComponent for PluginBox {
158168
gtk::Image {
159169
set_css_classes: &["plugin", "info"],
160170
set_icon_name: Some(&plugin_info.icon),
171+
set_visible: !self.config.hide_icons,
161172
set_halign: gtk::Align::Start,
162173
set_valign: gtk::Align::Start,
163174
set_pixel_size: 32,
@@ -270,7 +281,7 @@ impl FactoryComponent for PluginBox {
270281
guard.clear();
271282

272283
for _match in matches {
273-
guard.push_back(_match);
284+
guard.push_back((_match, self.config.clone()));
274285
}
275286
}
276287

0 commit comments

Comments
 (0)