diff --git a/examples/dock/dock_item/dock_item.ui b/examples/dock/dock_item/dock_item.ui index 230ac8c..7dfa41b 100644 --- a/examples/dock/dock_item/dock_item.ui +++ b/examples/dock/dock_item/dock_item.ui @@ -2,14 +2,20 @@ diff --git a/examples/dock/dock_item/imp.rs b/examples/dock/dock_item/imp.rs index 0b75264..1d6f1c3 100644 --- a/examples/dock/dock_item/imp.rs +++ b/examples/dock/dock_item/imp.rs @@ -12,6 +12,8 @@ use gtk::CompositeTemplate; pub struct DockItem { #[template_child] pub image: TemplateChild, + #[template_child] + pub dots: TemplateChild, pub drag_controller: OnceCell, } diff --git a/examples/dock/dock_item/mod.rs b/examples/dock/dock_item/mod.rs index 284d5f1..ff98ccb 100644 --- a/examples/dock/dock_item/mod.rs +++ b/examples/dock/dock_item/mod.rs @@ -1,3 +1,4 @@ +use crate::BoxedSearchResults; use gdk4::ContentProvider; use gdk4::Display; use gio::DesktopAppInfo; @@ -6,6 +7,7 @@ use gio::ListStore; use gtk4 as gtk; use gtk4::DragSource; use gtk4::IconTheme; +use gtk4::Label; mod imp; use gtk::glib; @@ -51,10 +53,10 @@ impl DockItem { // TODO current method seems very messy... // refactor to emit event for removing the item? pub fn set_app_info(&self, app_info: &DockObject, i: u32, saved_app_model: &ListStore) { + let self_ = imp::DockItem::from_instance(self); if let Ok(app_info_value) = app_info.property("appinfo") { if let Ok(Some(app_info)) = app_info_value.get::>() { println!("setting app info {}", &app_info.name()); - let self_ = imp::DockItem::from_instance(self); self_.image.set_tooltip_text(Some(&app_info.name())); let icon = app_info.icon().unwrap_or( @@ -117,5 +119,12 @@ impl DockItem { } else { println!("initializing dock item failed..."); } + if let Ok(active_value) = app_info.property("active") { + if let Ok(active) = active_value.get::() { + for _ in active.0 { + self_.dots.append(&Label::new(Some("ยท"))); + } + } + } } } diff --git a/examples/dock/main.rs b/examples/dock/main.rs index c32211c..18cadf0 100644 --- a/examples/dock/main.rs +++ b/examples/dock/main.rs @@ -167,7 +167,8 @@ fn main() { if let Some((i, s)) = stack_active.iter().enumerate().find(|(_i, s)| s.0[0].description == cur_app_info.name()) { println!("found active saved app {} at {}", s.0[0].name, i); let active = stack_active.remove(i); - dock_obj.set_property("active", active.to_value()).expect("failed to update dock active apps") + dock_obj.set_property("active", active.to_value()).expect("failed to update dock active apps"); + saved_app_model.items_changed(i.try_into().unwrap(), 0, 0); } }