Skip to content

Commit

Permalink
all-compact: Use connect_items_changed for backwards compatibility
Browse files Browse the repository at this point in the history
Fixes #30, issue with gio < 2.76
  • Loading branch information
nik012003 committed Aug 25, 2023
1 parent eaa9380 commit 139fba2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/compact_view.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::ARGS;
use glib::Object;
use glib_macros::clone;
use gtk::gio::ListStore;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
Expand Down Expand Up @@ -65,10 +66,14 @@ impl CompactLabel {
obj.set_label(label);

obj.append(&obj.label());

obj.model()
.bind_property("n-items", &obj.label(), "label")
.transform_to(|_, item_count: u32| Some(format!("{} elements", item_count)))
.build();
.connect_items_changed(clone!(@weak obj => @default-return (),
move |_,_,_,_| {
obj.label().set_text(&create_string(obj.model().n_items()));
obj.label().set_tooltip_text(Some(&format!("Drag {}", create_string(obj.model().n_items()))));
}));

obj
}
}
Expand Down

0 comments on commit 139fba2

Please sign in to comment.