From a2e5af0e8444074f0d9d1ad5a17090ff7a4d1985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Sat, 9 Dec 2023 21:36:13 +0100 Subject: [PATCH] system-settings: Port to glib::Properties macro --- src/system_settings.rs | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/system_settings.rs b/src/system_settings.rs index 9522edfc..47a90137 100644 --- a/src/system_settings.rs +++ b/src/system_settings.rs @@ -12,13 +12,13 @@ const GNOME_DESKTOP_NAMESPACE: &str = "org.gnome.desktop.interface"; mod imp { use std::cell::Cell; - use once_cell::sync::Lazy; - use super::*; - #[derive(Debug)] + #[derive(Debug, glib::Properties)] + #[properties(wrapper_type = super::SystemSettings)] pub struct SystemSettings { /// The clock format setting. + #[property(get, builder(ClockFormat::default()))] pub clock_format: Cell, } @@ -49,26 +49,8 @@ mod imp { type Type = super::SystemSettings; } + #[glib::derived_properties] impl ObjectImpl for SystemSettings { - fn properties() -> &'static [glib::ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![glib::ParamSpecEnum::builder::("clock-format") - .read_only() - .build()] - }); - - PROPERTIES.as_ref() - } - - fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { - let obj = self.obj(); - - match pspec.name() { - "clock-format" => obj.clock_format().to_value(), - _ => unimplemented!(), - } - } - fn constructed(&self) { self.parent_constructed(); let obj = self.obj(); @@ -156,11 +138,6 @@ impl SystemSettings { }).await; } - /// The clock format setting. - pub fn clock_format(&self) -> ClockFormat { - self.imp().clock_format.get() - } - /// Set the clock format setting. fn set_clock_format(&self, clock_format: ClockFormat) { if self.clock_format() == clock_format {