feat: add dbus_connection() method to app::Application trait
This commit is contained in:
parent
38dde24f96
commit
b8eaad2a7e
4 changed files with 21 additions and 0 deletions
|
|
@ -22,6 +22,8 @@ pub enum Action {
|
|||
Close,
|
||||
/// Closes or shows the context drawer.
|
||||
ContextDrawer(bool),
|
||||
#[cfg(feature = "single-instance")]
|
||||
DbusConnection(zbus::Connection),
|
||||
/// Requests to drag the window.
|
||||
Drag,
|
||||
/// Window focus changed
|
||||
|
|
|
|||
|
|
@ -761,6 +761,11 @@ impl<T: Application> Cosmic<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "single-instance")]
|
||||
Action::DbusConnection(conn) => {
|
||||
return self.app.dbus_connection(conn);
|
||||
}
|
||||
|
||||
#[cfg(feature = "xdg-portal")]
|
||||
Action::DesktopSettings(crate::theme::portal::Desktop::ColorScheme(s)) => {
|
||||
use ashpd::desktop::settings::ColorScheme;
|
||||
|
|
|
|||
|
|
@ -437,6 +437,14 @@ where
|
|||
fn dbus_activation(&mut self, msg: crate::dbus_activation::Message) -> Task<Self::Message> {
|
||||
Task::none()
|
||||
}
|
||||
|
||||
/// Invoked on connect to dbus session socket used for dbus activation
|
||||
///
|
||||
/// Can be used to expose custom interfaces on the same owned name.
|
||||
#[cfg(feature = "single-instance")]
|
||||
fn dbus_connection(&mut self, conn: zbus::Connection) -> Task<Self::Message> {
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Methods automatically derived for all types implementing [`Application`].
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ pub fn subscription<App: ApplicationExt>() -> Subscription<crate::Action<App::Me
|
|||
std::process::exit(1);
|
||||
}
|
||||
|
||||
output
|
||||
.send(crate::Action::Cosmic(crate::app::Action::DbusConnection(
|
||||
conn.clone(),
|
||||
)))
|
||||
.await;
|
||||
|
||||
#[cfg(feature = "smol")]
|
||||
let handle = {
|
||||
std::thread::spawn(move || {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue