Call RegisterStatusNotifierHost
This commit is contained in:
parent
397c671da0
commit
845ca1e396
1 changed files with 17 additions and 5 deletions
|
|
@ -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 cascade::cascade;
|
||||||
use gtk4::{
|
use gtk4::{
|
||||||
gio,
|
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 {
|
for name in watcher.registered_items().await {
|
||||||
glib::MainContext::default().spawn_local(clone!(@strong obj => async move {
|
glib::MainContext::default().spawn_local(clone!(@strong obj => async move {
|
||||||
obj.item_registered(&name).await;
|
obj.item_registered(&name).await;
|
||||||
|
|
@ -160,4 +159,17 @@ impl StatusNotifierWatcher {
|
||||||
})
|
})
|
||||||
.unwrap()
|
.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(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue