[gnome-settings-daemon] xsettings: add xsettings_setting_get() accessor



commit 4c8628bb9d1672c9a9f5bfab2ae78c4baffc3058
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Mar 8 09:43:55 2012 -0500

    xsettings: add xsettings_setting_get() accessor
    
    It will soon be non-trivial.

 plugins/xsettings/xsettings-common.c  |   14 ++++++++++++--
 plugins/xsettings/xsettings-common.h  |    1 +
 plugins/xsettings/xsettings-manager.c |    2 +-
 3 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/plugins/xsettings/xsettings-common.c b/plugins/xsettings/xsettings-common.c
index 3a3c474..593358a 100644
--- a/plugins/xsettings/xsettings-common.c
+++ b/plugins/xsettings/xsettings-common.c
@@ -57,6 +57,12 @@ xsettings_variant_equal0 (GVariant *a,
   return g_variant_equal (a, b);
 }
 
+GVariant *
+xsettings_setting_get (XSettingsSetting *setting)
+{
+  return setting->value;
+}
+
 void
 xsettings_setting_set (XSettingsSetting *setting,
                        GVariant         *value,
@@ -64,11 +70,15 @@ xsettings_setting_set (XSettingsSetting *setting,
 {
   GVariant *old_value;
 
-  old_value = setting->value;
+  old_value = xsettings_setting_get (setting);
+  if (old_value)
+    g_variant_ref (old_value);
 
+  if (setting->value)
+    g_variant_unref (setting->value);
   setting->value = value ? g_variant_ref_sink (value) : NULL;
 
-  if (!xsettings_variant_equal0 (old_value, setting->value))
+  if (!xsettings_variant_equal0 (old_value, xsettings_setting_get (setting)))
     setting->last_change_serial = serial;
 
   if (old_value)
diff --git a/plugins/xsettings/xsettings-common.h b/plugins/xsettings/xsettings-common.h
index 0385bb9..536fa2f 100644
--- a/plugins/xsettings/xsettings-common.h
+++ b/plugins/xsettings/xsettings-common.h
@@ -51,6 +51,7 @@ struct _XSettingsSetting
 };
 
 XSettingsSetting *xsettings_setting_new   (const gchar      *name);
+GVariant *        xsettings_setting_get   (XSettingsSetting *setting);
 void              xsettings_setting_set   (XSettingsSetting *setting,
                                            GVariant         *value,
                                            guint32           serial);
diff --git a/plugins/xsettings/xsettings-manager.c b/plugins/xsettings/xsettings-manager.c
index 75e672d..43d0354 100644
--- a/plugins/xsettings/xsettings-manager.c
+++ b/plugins/xsettings/xsettings-manager.c
@@ -270,7 +270,7 @@ setting_store (XSettingsSetting *setting,
   GVariant *value;
   guint16 len16;
 
-  value = setting->value;
+  value = xsettings_setting_get (setting);
 
   type = xsettings_get_typecode (value);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]