Call RegisterStatusNotifierHost

This commit is contained in:
Ian Douglas Scott 2021-09-24 11:30:44 -07:00
parent 397c671da0
commit 845ca1e396

View file

@ -1,8 +1,3 @@
// TODO
// - Implement StatusNotifierWatcher if one is not running
// - Register with StatusNotiferWatcher
// - Handle signals for registered/unreigisted items
use cascade::cascade;
use gtk4::{
gio,
@ -52,6 +47,10 @@ impl ObjectImpl for StatusAreaInner {
}
};
if let Err(err) = watcher.register_host().await {
eprintln!("Failed to register status notifier host: {}", err);
}
for name in watcher.registered_items().await {
glib::MainContext::default().spawn_local(clone!(@strong obj => async move {
obj.item_registered(&name).await;
@ -160,4 +159,17 @@ impl StatusNotifierWatcher {
})
.unwrap()
}
async fn register_host(&self) -> Result<(), glib::Error> {
let service = self.0.connection().unique_name().unwrap();
self.0
.call_future(
"RegisterStatusNotifierHost",
Some(&(service.as_str(),).to_variant()),
gio::DBusCallFlags::NONE,
1000,
)
.await?;
Ok(())
}
}