[gnome-settings-daemon/wip/xsettings-manager: 21/21] xsettings: wire overrides into GSettings



commit 23f8ace015298cc025cbbe68c9d4af12f2ea413b
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Mar 8 10:29:04 2012 -0500

    xsettings: wire overrides into GSettings
    
    There is now a new GSettings 'override' key which can override the value
    of arbitrary XSETTINGS.

 ...ings-daemon.plugins.xsettings.gschema.xml.in.in |    5 ++++
 plugins/xsettings/gsd-xsettings-manager.c          |   21 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.plugins.xsettings.gschema.xml.in.in b/data/org.gnome.settings-daemon.plugins.xsettings.gschema.xml.in.in
index 8cece8e..781bd33 100644
--- a/data/org.gnome.settings-daemon.plugins.xsettings.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.xsettings.gschema.xml.in.in
@@ -35,5 +35,10 @@
       <_summary>List of explicitly enabled GTK+ modules</_summary>
       <_description>A list of strings representing the GTK+ modules that will be loaded, usually in addition to conditional and forcibly disabled ones.</_description>
     </key>
+    <key type="a{sv}" name="overrides">
+      <default>{}</default>
+      <_summary>A dictionary of XSETTINGS to override</_summary>
+      <_description>This dictionary maps XSETTINGS names to overrides values. The values must be either strings, signed int32s or (in the case of colors), 4-tuples of uint16 (red, green, blue, alpha; 65535 is fully opaque).</_description>
+    </key>
   </schema>
 </schemalist>
diff --git a/plugins/xsettings/gsd-xsettings-manager.c b/plugins/xsettings/gsd-xsettings-manager.c
index 868a864..f46910f 100644
--- a/plugins/xsettings/gsd-xsettings-manager.c
+++ b/plugins/xsettings/gsd-xsettings-manager.c
@@ -52,6 +52,7 @@
 #define SOUND_SETTINGS_SCHEMA     "org.gnome.desktop.sound"
 
 #define XSETTINGS_PLUGIN_SCHEMA "org.gnome.settings-daemon.plugins.xsettings"
+#define XSETTINGS_OVERRIDE_KEY  "overrides"
 
 #define GTK_MODULES_DISABLED_KEY "disabled-gtk-modules"
 #define GTK_MODULES_ENABLED_KEY  "enabled-gtk-modules"
@@ -575,6 +576,24 @@ xft_callback (GSettings             *settings,
 }
 
 static void
+override_callback (GSettings             *settings,
+                   const gchar           *key,
+                   GnomeXSettingsManager *manager)
+{
+        GVariant *value;
+        int i;
+
+        value = g_settings_get_value (settings, XSETTINGS_OVERRIDE_KEY);
+
+        for (i = 0; manager->priv->managers[i]; i++) {
+                xsettings_manager_set_overrides (manager->priv->managers[i], value);
+                xsettings_manager_notify (manager->priv->managers [i]);
+        }
+
+        g_variant_unref (value);
+}
+
+static void
 plugin_callback (GSettings             *settings,
                  const char            *key,
                  GnomeXSettingsManager *manager)
@@ -582,6 +601,8 @@ plugin_callback (GSettings             *settings,
         if (g_str_equal (key, GTK_MODULES_DISABLED_KEY) ||
             g_str_equal (key, GTK_MODULES_ENABLED_KEY)) {
                 /* Do nothing, as GsdXsettingsGtk will handle it */
+        } else if (g_str_equal (key, XSETTINGS_OVERRIDE_KEY)) {
+                override_callback (settings, key, manager);
         } else {
                 xft_callback (settings, key, manager);
         }



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