Update to zbus 5.x
This commit is contained in:
parent
b61e0bc94d
commit
417f43a0f5
14 changed files with 756 additions and 514 deletions
|
|
@ -6,6 +6,7 @@ use cosmic::{
|
|||
widget::icon,
|
||||
};
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use std::collections::HashMap;
|
||||
use zbus::zvariant::{self, OwnedValue};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -122,7 +123,7 @@ async fn get_layout(menu_proxy: DBusMenuProxy<'static>) -> Result<Layout, String
|
|||
}
|
||||
|
||||
#[zbus::proxy(interface = "org.kde.StatusNotifierItem")]
|
||||
trait StatusNotifierItem {
|
||||
pub trait StatusNotifierItem {
|
||||
#[zbus(property)]
|
||||
fn icon_name(&self) -> zbus::Result<String>;
|
||||
|
||||
|
|
@ -143,15 +144,14 @@ pub struct Layout(i32, LayoutProps, Vec<Layout>);
|
|||
impl<'a> serde::Deserialize<'a> for Layout {
|
||||
fn deserialize<D: serde::Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error> {
|
||||
let (id, props, children) =
|
||||
<(i32, LayoutProps, Vec<(zvariant::Signature<'_>, Self)>)>::deserialize(deserializer)?;
|
||||
<(i32, LayoutProps, Vec<(zvariant::Signature, Self)>)>::deserialize(deserializer)?;
|
||||
Ok(Self(id, props, children.into_iter().map(|x| x.1).collect()))
|
||||
}
|
||||
}
|
||||
|
||||
impl zvariant::Type for Layout {
|
||||
fn signature() -> zvariant::Signature<'static> {
|
||||
zvariant::Signature::try_from("(ia{sv}av)").unwrap()
|
||||
}
|
||||
const SIGNATURE: &'static zvariant::Signature =
|
||||
<(i32, HashMap<String, zvariant::Value>, Vec<zvariant::Value>)>::SIGNATURE;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, zvariant::DeserializeDict)]
|
||||
|
|
@ -181,9 +181,7 @@ pub struct LayoutProps {
|
|||
}
|
||||
|
||||
impl zvariant::Type for LayoutProps {
|
||||
fn signature() -> zvariant::Signature<'static> {
|
||||
zvariant::Signature::try_from("a{sv}").unwrap()
|
||||
}
|
||||
const SIGNATURE: &'static zvariant::Signature = <HashMap<String, zvariant::Value>>::SIGNATURE;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -242,7 +240,7 @@ impl Layout {
|
|||
}
|
||||
|
||||
#[zbus::proxy(interface = "com.canonical.dbusmenu")]
|
||||
trait DBusMenu {
|
||||
pub trait DBusMenu {
|
||||
fn get_layout(
|
||||
&self,
|
||||
parent_id: i32,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@
|
|||
use futures::prelude::*;
|
||||
use zbus::{
|
||||
fdo::{DBusProxy, RequestNameFlags, RequestNameReply},
|
||||
message::Header,
|
||||
names::{BusName, UniqueName, WellKnownName},
|
||||
MessageHeader, Result, SignalContext,
|
||||
object_server::SignalEmitter,
|
||||
Result,
|
||||
};
|
||||
|
||||
const NAME: WellKnownName =
|
||||
|
|
@ -26,8 +28,8 @@ impl StatusNotifierWatcher {
|
|||
async fn register_status_notifier_item(
|
||||
&mut self,
|
||||
service: &str,
|
||||
#[zbus(header)] hdr: MessageHeader<'_>,
|
||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||
#[zbus(header)] hdr: Header<'_>,
|
||||
#[zbus(signal_emitter)] ctxt: SignalEmitter<'_>,
|
||||
) {
|
||||
let sender = hdr.sender().unwrap();
|
||||
let service = if service.starts_with('/') {
|
||||
|
|
@ -62,20 +64,20 @@ impl StatusNotifierWatcher {
|
|||
}
|
||||
|
||||
#[zbus(signal)]
|
||||
async fn status_notifier_item_registered(ctxt: &SignalContext<'_>, service: &str)
|
||||
async fn status_notifier_item_registered(ctxt: &SignalEmitter<'_>, service: &str)
|
||||
-> Result<()>;
|
||||
|
||||
#[zbus(signal)]
|
||||
async fn status_notifier_item_unregistered(
|
||||
ctxt: &SignalContext<'_>,
|
||||
ctxt: &SignalEmitter<'_>,
|
||||
service: &str,
|
||||
) -> Result<()>;
|
||||
|
||||
#[zbus(signal)]
|
||||
async fn status_notifier_host_registered(ctxt: &SignalContext<'_>) -> Result<()>;
|
||||
async fn status_notifier_host_registered(ctxt: &SignalEmitter<'_>) -> Result<()>;
|
||||
|
||||
#[zbus(signal)]
|
||||
async fn status_notifier_host_unregistered(ctxt: &SignalContext<'_>) -> Result<()>;
|
||||
async fn status_notifier_host_unregistered(ctxt: &SignalEmitter<'_>) -> Result<()>;
|
||||
}
|
||||
|
||||
pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
|
||||
|
|
@ -122,7 +124,7 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
|
|||
.iter()
|
||||
.position(|(unique_name, _)| unique_name == name)
|
||||
{
|
||||
let ctxt = zbus::SignalContext::new(&connection, OBJECT_PATH).unwrap();
|
||||
let ctxt = SignalEmitter::new(&connection, OBJECT_PATH).unwrap();
|
||||
let service = interface.items.remove(idx).1;
|
||||
StatusNotifierWatcher::status_notifier_item_unregistered(&ctxt, &service)
|
||||
.await
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue