display active indicators for each open window of an app on the dock
This commit is contained in:
parent
b3ce9ada8c
commit
a3349e673f
4 changed files with 28 additions and 10 deletions
|
|
@ -2,14 +2,20 @@
|
|||
<interface>
|
||||
<template class="DockItem" parent="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">4</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="margin-bottom">4</property>
|
||||
<property name="pixel-size">48</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="pixel-size">48</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="dots">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="spacing">4</property>
|
||||
<property name="hexpand">true</property>
|
||||
<property name="halign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ use gtk::CompositeTemplate;
|
|||
pub struct DockItem {
|
||||
#[template_child]
|
||||
pub image: TemplateChild<gtk::Image>,
|
||||
#[template_child]
|
||||
pub dots: TemplateChild<gtk::Box>,
|
||||
pub drag_controller: OnceCell<DragSource>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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::<Option<DesktopAppInfo>>() {
|
||||
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::<BoxedSearchResults>() {
|
||||
for _ in active.0 {
|
||||
self_.dots.append(&Label::new(Some("·")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue