[gnome-settings-daemon/wip/xsettings-manager] xsettings: introduce 'tiers' of XSettings



commit 3d888b12a334786fb441a15989fd1b859f9c281b
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Mar 8 10:09:14 2012 -0500

    xsettings: introduce 'tiers' of XSettings
    
    For now, there is only 1.

 plugins/xsettings/xsettings-common.c  |   26 +++++++++++++++++---------
 plugins/xsettings/xsettings-common.h  |    5 ++++-
 plugins/xsettings/xsettings-manager.c |   11 ++++++-----
 3 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/plugins/xsettings/xsettings-common.c b/plugins/xsettings/xsettings-common.c
index 593358a..e5f9fcc 100644
--- a/plugins/xsettings/xsettings-common.c
+++ b/plugins/xsettings/xsettings-common.c
@@ -36,10 +36,8 @@ xsettings_setting_new (const gchar *name)
 {
   XSettingsSetting *result;
 
-  result = g_slice_new (XSettingsSetting);
+  result = g_slice_new0 (XSettingsSetting);
   result->name = g_strdup (name);
-  result->value = NULL;
-  result->last_change_serial = 0;
 
   return result;
 }
@@ -60,11 +58,18 @@ xsettings_variant_equal0 (GVariant *a,
 GVariant *
 xsettings_setting_get (XSettingsSetting *setting)
 {
-  return setting->value;
+  gint i;
+
+  for (i = G_N_ELEMENTS (setting->value) - 1; 0 <= i; i--)
+    if (setting->value[i])
+      return setting->value[i];
+
+  return NULL;
 }
 
 void
 xsettings_setting_set (XSettingsSetting *setting,
+                       gint              tier,
                        GVariant         *value,
                        guint32           serial)
 {
@@ -74,9 +79,9 @@ xsettings_setting_set (XSettingsSetting *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 (setting->value[tier])
+    g_variant_unref (setting->value[tier]);
+  setting->value[tier] = value ? g_variant_ref_sink (value) : NULL;
 
   if (!xsettings_variant_equal0 (old_value, xsettings_setting_get (setting)))
     setting->last_change_serial = serial;
@@ -88,8 +93,11 @@ xsettings_setting_set (XSettingsSetting *setting,
 void
 xsettings_setting_free (XSettingsSetting *setting)
 {
-  if (setting->value)
-    g_variant_unref (setting->value);
+  gint i;
+
+  for (i = 0; i < G_N_ELEMENTS (setting->value); i++)
+    if (setting->value[i])
+      g_variant_unref (setting->value[i]);
 
   g_free (setting->name);
 
diff --git a/plugins/xsettings/xsettings-common.h b/plugins/xsettings/xsettings-common.h
index 536fa2f..0a0d840 100644
--- a/plugins/xsettings/xsettings-common.h
+++ b/plugins/xsettings/xsettings-common.h
@@ -25,6 +25,8 @@
 
 #include <glib.h>
 
+#define XSETTINGS_N_TIERS 1
+
 typedef struct _XSettingsColor   XSettingsColor;
 typedef struct _XSettingsSetting XSettingsSetting;
 
@@ -46,13 +48,14 @@ struct _XSettingsColor
 struct _XSettingsSetting
 {
   char *name;
-  GVariant *value;
+  GVariant *value[XSETTINGS_N_TIERS];
   unsigned long last_change_serial;
 };
 
 XSettingsSetting *xsettings_setting_new   (const gchar      *name);
 GVariant *        xsettings_setting_get   (XSettingsSetting *setting);
 void              xsettings_setting_set   (XSettingsSetting *setting,
+                                           gint              tier,
                                            GVariant         *value,
                                            guint32           serial);
 void              xsettings_setting_free  (XSettingsSetting *setting);
diff --git a/plugins/xsettings/xsettings-manager.c b/plugins/xsettings/xsettings-manager.c
index ae53919..d5afbff 100644
--- a/plugins/xsettings/xsettings-manager.c
+++ b/plugins/xsettings/xsettings-manager.c
@@ -196,6 +196,7 @@ xsettings_manager_destroy (XSettingsManager *manager)
 static void
 xsettings_manager_set_setting (XSettingsManager *manager,
                                const gchar      *name,
+                               gint              tier,
                                GVariant         *value)
 {
   XSettingsSetting *setting;
@@ -209,7 +210,7 @@ xsettings_manager_set_setting (XSettingsManager *manager,
       g_hash_table_insert (manager->settings, setting->name, setting);
     }
 
-  xsettings_setting_set (setting, value, manager->serial);
+  xsettings_setting_set (setting, tier, value, manager->serial);
 
   if (xsettings_setting_get (setting) == NULL)
     g_hash_table_remove (manager->settings, name);
@@ -220,7 +221,7 @@ xsettings_manager_set_int (XSettingsManager *manager,
 			   const char       *name,
 			   int               value)
 {
-  xsettings_manager_set_setting (manager, name, g_variant_new_int32 (value));
+  xsettings_manager_set_setting (manager, name, 0, g_variant_new_int32 (value));
 }
 
 void
@@ -228,7 +229,7 @@ xsettings_manager_set_string (XSettingsManager *manager,
 			      const char       *name,
 			      const char       *value)
 {
-  xsettings_manager_set_setting (manager, name, g_variant_new_string (value));
+  xsettings_manager_set_setting (manager, name, 0, g_variant_new_string (value));
 }
 
 void
@@ -239,14 +240,14 @@ xsettings_manager_set_color (XSettingsManager *manager,
   GVariant *tmp;
 
   tmp = g_variant_new ("(qqqq)", value->red, value->green, value->blue, value->alpha);
-  xsettings_manager_set_setting (manager, name, tmp);
+  xsettings_manager_set_setting (manager, name, 0, tmp);
 }
 
 void
 xsettings_manager_delete_setting (XSettingsManager *manager,
                                   const char       *name)
 {
-  xsettings_manager_set_setting (manager, name, NULL);
+  xsettings_manager_set_setting (manager, name, 0, NULL);
 }
 
 static gchar



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