refactor: config improvements
This commit is contained in:
parent
3eed30f723
commit
efe4ce2f5b
7 changed files with 69 additions and 86 deletions
|
|
@ -214,27 +214,37 @@ impl Core {
|
|||
self.system_theme_mode
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus-config")]
|
||||
pub fn watch_config<T: CosmicConfigEntry + Send + Sync + Default + 'static + Clone>(
|
||||
pub fn watch_config<
|
||||
T: CosmicConfigEntry + Send + Sync + Default + 'static + Clone + PartialEq,
|
||||
>(
|
||||
&self,
|
||||
config_id: &'static str,
|
||||
) -> iced::Subscription<cosmic_config::dbus::Update<T>> {
|
||||
) -> iced::Subscription<cosmic_config::Update<T>> {
|
||||
#[cfg(feature = "dbus-config")]
|
||||
if let Some(settings_daemon) = self.settings_daemon.clone() {
|
||||
cosmic_config::dbus::watcher_subscription(settings_daemon, config_id, false)
|
||||
} else {
|
||||
iced::Subscription::none()
|
||||
return cosmic_config::dbus::watcher_subscription(settings_daemon, config_id, false);
|
||||
}
|
||||
cosmic_config::config_subscription(
|
||||
std::any::TypeId::of::<T>(),
|
||||
std::borrow::Cow::Borrowed(config_id),
|
||||
T::VERSION,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus-config")]
|
||||
pub fn watch_state<T: CosmicConfigEntry + Send + Sync + Default + 'static + Clone>(
|
||||
pub fn watch_state<
|
||||
T: CosmicConfigEntry + Send + Sync + Default + 'static + Clone + PartialEq,
|
||||
>(
|
||||
&self,
|
||||
state_id: &'static str,
|
||||
) -> iced::Subscription<cosmic_config::dbus::Update<T>> {
|
||||
) -> iced::Subscription<cosmic_config::Update<T>> {
|
||||
#[cfg(feature = "dbus-config")]
|
||||
if let Some(settings_daemon) = self.settings_daemon.clone() {
|
||||
cosmic_config::dbus::watcher_subscription(settings_daemon, state_id, true)
|
||||
} else {
|
||||
iced::Subscription::none()
|
||||
return cosmic_config::dbus::watcher_subscription(settings_daemon, state_id, true);
|
||||
}
|
||||
cosmic_config::config_subscription(
|
||||
std::any::TypeId::of::<T>(),
|
||||
std::borrow::Cow::Borrowed(state_id),
|
||||
T::VERSION,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue