Skip to content

Commit

Permalink
refactor: rename single-instance feature
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Nov 18, 2023
1 parent ef5b6fb commit c38dc6d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ xdg-portal = ["ashpd"]
# XXX Use "a11y"; which is causing a panic currently
applet = ["wayland", "tokio", "cosmic-panel-config", "ron"]
applet-token = []
zbus = ["dep:zbus", "serde", "ron"]
single-instance = ["dep:zbus", "serde", "ron"]

[dependencies]
apply = "0.3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/app/cosmic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ where
})
.map(super::Message::Cosmic),
window_events.map(super::Message::Cosmic),
#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
self.app
.core()
.single_instance
Expand Down
24 changes: 12 additions & 12 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use iced::Subscription;
use iced::{window, Application as IcedApplication};
pub use message::Message;
use url::Url;
#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
use {
iced_futures::futures::channel::mpsc::{Receiver, Sender},
iced_futures::futures::SinkExt,
Expand Down Expand Up @@ -122,7 +122,7 @@ pub fn run<App: Application>(settings: Settings, flags: App::Flags) -> iced::Res

cosmic::Cosmic::<App>::run(iced)
}
#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
#[derive(Debug, Clone)]
pub struct DbusActivationMessage<Action = String, Args = Vec<String>> {
pub activation_token: Option<String>,
Expand All @@ -142,10 +142,10 @@ pub enum DbusActivationDetails<Action = String, Args = Vec<String>> {
args: Args,
},
}
#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
#[derive(Debug, Default)]
pub struct DbusActivation(Option<Sender<DbusActivationMessage>>);
#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
impl DbusActivation {
#[must_use]
pub fn new() -> Self {
Expand All @@ -159,7 +159,7 @@ impl DbusActivation {
}
}

#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
#[dbus_proxy(interface = "org.freedesktop.DbusActivation")]
pub trait DbusActivationInterface {
/// Activate the application.
Expand All @@ -181,7 +181,7 @@ pub trait DbusActivationInterface {
) -> zbus::Result<()>;
}

#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
#[dbus_interface(interface = "org.freedesktop.DbusActivation")]
impl DbusActivation {
async fn activate(&mut self, platform_data: HashMap<&str, Value<'_>>) {
Expand Down Expand Up @@ -258,7 +258,7 @@ impl DbusActivation {
}
}

#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]

/// Launch a COSMIC application with the given [`Settings`].
/// If the application is already running, the arguments will be passed to the
Expand Down Expand Up @@ -349,15 +349,15 @@ where
/// Default async executor to use with the app.
type Executor: iced_futures::Executor;

#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
/// Argument received [`Application::new`].
type Flags: Clone + CosmicFlags;

#[cfg(not(feature = "zbus"))]
#[cfg(not(feature = "single-instance"))]
/// Argument received [`Application::new`].
type Flags: Clone;

#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
/// Message type specific to our app.
type Message: Clone
+ From<
Expand All @@ -369,7 +369,7 @@ where
+ Send
+ 'static;

#[cfg(not(feature = "zbus"))]
#[cfg(not(feature = "single-instance"))]
/// Message type specific to our app.
type Message: Clone + std::fmt::Debug + Send + 'static;

Expand Down Expand Up @@ -626,7 +626,7 @@ impl<App: Application> ApplicationExt for App {
}
}

#[cfg(feature = "zbus")]
#[cfg(feature = "single-instance")]
fn single_instance_subscription<App: ApplicationExt>() -> Subscription<Message<App::Message>> {
use iced_futures::futures::StreamExt;

Expand Down

0 comments on commit c38dc6d

Please sign in to comment.