Skip to content

Commit

Permalink
backend/settings: Add changed signal
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Aug 10, 2024
1 parent 7c868af commit 4fe2d69
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/backend/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ use futures_channel::{
use futures_util::{SinkExt, StreamExt};
use tokio::sync::Mutex;

use crate::{backend::Backend, desktop::settings::Namespace, zvariant::OwnedValue};
use crate::{backend::Backend, desktop::settings::Namespace, zbus::SignalContext, zvariant::{OwnedValue, Value}};

#[async_trait]
pub trait SettingsImpl {
async fn read_all(&self, namespaces: Vec<String>) -> HashMap<String, Namespace>;

async fn read(&self, namespace: &str, key: &str) -> OwnedValue;

async fn changed(signal_ctxt: &SignalContext<'_>, namespace: &str, key: &str, value: Value<'_>) -> zbus::Result<()> {
SettingsInterface::setting_changed(signal_ctxt, namespace, key, value)
.await
}
}

pub struct Settings<T: SettingsImpl> {
Expand Down Expand Up @@ -119,4 +124,7 @@ impl SettingsInterface {
tracing::debug!("Settings::Read returned {:#?}", response);
response
}

#[zbus(signal)]
async fn setting_changed(signal_ctxt: &SignalContext<'_>, namespace: &str, key: &str, value: Value<'_>) -> zbus::Result<()>;
}

0 comments on commit 4fe2d69

Please sign in to comment.