[gnome-settings-daemon/wip/xsettings-manager: 16/16] xsettings: always call xsettings_setting_set()



commit d45ef4abad2f6190e1da8fbf7114f9b602782002
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Mar 8 00:29:04 2012 -0500

    xsettings: always call xsettings_setting_set()
    
    Let it work out if the last_change_sequence needs to be updated or not.

 plugins/xsettings/xsettings-common.c  |   34 +++++++++++++++++++++++---------
 plugins/xsettings/xsettings-common.h  |    5 +--
 plugins/xsettings/xsettings-manager.c |   10 +--------
 3 files changed, 27 insertions(+), 22 deletions(-)
---
diff --git a/plugins/xsettings/xsettings-common.c b/plugins/xsettings/xsettings-common.c
index 647f1df..3a3c474 100644
--- a/plugins/xsettings/xsettings-common.c
+++ b/plugins/xsettings/xsettings-common.c
@@ -44,21 +44,35 @@ xsettings_setting_new (const gchar *name)
   return result;
 }
 
-void
-xsettings_setting_set (XSettingsSetting *setting,
-                       GVariant         *value)
+static gboolean
+xsettings_variant_equal0 (GVariant *a,
+                          GVariant *b)
 {
-  if (setting->value)
-    g_variant_unref (setting->value);
+  if (a == b)
+    return TRUE;
+
+  if (!a || !b)
+    return FALSE;
 
-  setting->value = value ? g_variant_ref (value) : NULL;
+  return g_variant_equal (a, b);
 }
 
-gboolean
-xsettings_setting_equal (XSettingsSetting *setting,
-                         GVariant         *value)
+void
+xsettings_setting_set (XSettingsSetting *setting,
+                       GVariant         *value,
+                       guint32           serial)
 {
-  return setting->value && g_variant_equal (setting->value, value);
+  GVariant *old_value;
+
+  old_value = setting->value;
+
+  setting->value = value ? g_variant_ref_sink (value) : NULL;
+
+  if (!xsettings_variant_equal0 (old_value, setting->value))
+    setting->last_change_serial = serial;
+
+  if (old_value)
+    g_variant_unref (old_value);
 }
 
 void
diff --git a/plugins/xsettings/xsettings-common.h b/plugins/xsettings/xsettings-common.h
index 4f03d9e..0385bb9 100644
--- a/plugins/xsettings/xsettings-common.h
+++ b/plugins/xsettings/xsettings-common.h
@@ -52,10 +52,9 @@ struct _XSettingsSetting
 
 XSettingsSetting *xsettings_setting_new   (const gchar      *name);
 void              xsettings_setting_set   (XSettingsSetting *setting,
-                                           GVariant         *value);
+                                           GVariant         *value,
+                                           guint32           serial);
 void              xsettings_setting_free  (XSettingsSetting *setting);
-gboolean          xsettings_setting_equal (XSettingsSetting *setting,
-                                           GVariant         *value);
 
 char xsettings_byte_order (void);
 
diff --git a/plugins/xsettings/xsettings-manager.c b/plugins/xsettings/xsettings-manager.c
index 401f28d..75e672d 100644
--- a/plugins/xsettings/xsettings-manager.c
+++ b/plugins/xsettings/xsettings-manager.c
@@ -207,8 +207,6 @@ xsettings_manager_set_setting (XSettingsManager *manager,
 {
   XSettingsSetting *setting;
 
-  g_variant_ref_sink (value);
-
   setting = g_hash_table_lookup (manager->settings, name);
 
   if (setting == NULL)
@@ -218,13 +216,7 @@ xsettings_manager_set_setting (XSettingsManager *manager,
       g_hash_table_insert (manager->settings, setting->name, setting);
     }
 
-  if (xsettings_setting_equal (setting, value))
-    {
-      xsettings_setting_set (setting, value);
-      setting->last_change_serial = manager->serial;
-    }
-
-  g_variant_unref (value);
+  xsettings_setting_set (setting, value, manager->serial);
 }
 
 void



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