[gnome-settings-daemon/wip/settings-relocation: 12/12] common: Migrate input settings to gsettings-desktop-schemas keys



commit 576ea0c93e89576439a67dafe4611176459195fa
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jan 15 19:57:20 2015 +0100

    common: Migrate input settings to gsettings-desktop-schemas keys
    
    The deprecated keys are kept in isolated ".deprecated" suffixed schemas.
    On plugin startup, the settings-daemon paths are opened with these legacy
    schemas, and all user-modified keys are dumped to the new location and
    reset.
    
    This ensures the transition just happens once per-key, and ensures the
    dconf database is left clean.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742593

 ...e.settings-daemon.peripherals.gschema.xml.in.in |  176 ++++++++++----------
 plugins/common/Makefile.am                         |    2 +
 plugins/keyboard/gsd-keyboard-manager.c            |   18 ++
 plugins/mouse/gsd-mouse-manager.c                  |   70 ++++++++
 4 files changed, 180 insertions(+), 86 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in 
b/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in
index d2f70ed..6a65f08 100644
--- a/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in
@@ -1,10 +1,8 @@
 <schemalist>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals" 
path="/org/gnome/settings-daemon/peripherals/">
     <child name="smartcard" schema="org.gnome.settings-daemon.peripherals.smartcard"/>
-    <child name="touchpad" schema="org.gnome.settings-daemon.peripherals.touchpad"/>
     <child name="keyboard" schema="org.gnome.settings-daemon.peripherals.keyboard"/>
     <child name="mouse" schema="org.gnome.settings-daemon.peripherals.mouse"/>
-    <child name="trackball" schema="org.gnome.settings-daemon.peripherals.trackball"/>
     <child name="touchscreen" schema="org.gnome.settings-daemon.peripherals.touchscreen"/>
     <child name="input-devices" schema="org.gnome.settings-daemon.peripherals.input-devices"/>
   </schema>
@@ -15,70 +13,10 @@
       <_description>Set this to one of "none", "lock-screen", or "force-logout". The action will get 
performed when the smartcard used for log in is removed.</_description>
     </key>
   </schema>
-  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.touchpad" 
path="/org/gnome/settings-daemon/peripherals/touchpad/">
-    <key name="disable-while-typing" type="b">
-      <default>false</default>
-      <_summary>Disable touchpad while typing</_summary>
-      <_description>Set this to TRUE if you have problems with accidentally hitting the touchpad while 
typing.</_description>
-    </key>
-    <key name="horiz-scroll-enabled" type="b">
-      <default>true</default>
-      <_summary>Enable horizontal scrolling</_summary>
-      <_description>Set this to TRUE to allow horizontal scrolling by the same method selected with the 
scroll_method key.</_description>
-    </key>
-    <key name="scroll-method" enum="org.gnome.settings-daemon.GsdTouchpadScrollMethod">
-      <default>'two-finger-scrolling'</default>
-      <_summary>Select the touchpad scroll method</_summary>
-      <_description>Select the touchpad scroll method. Supported values are: "disabled", "edge-scrolling", 
"two-finger-scrolling".</_description>
-    </key>
-    <key name="tap-to-click" type="b">
-      <default>false</default>
-      <_summary>Enable mouse clicks with touchpad</_summary>
-      <_description>Set this to TRUE to be able to send mouse clicks by tapping on the 
touchpad.</_description>
-    </key>
-    <key name="touchpad-enabled" type="b">
-      <default>true</default>
-      <_summary>Enable touchpad</_summary>
-      <_description>Set this to TRUE to enable all touchpads.</_description>
-    </key>
-    <key name="left-handed" enum="org.gnome.settings-daemon.GsdTouchpadHandedness">
-      <default>'mouse'</default>
-      <summary>Touchpad button orientation</summary>
-      <description>Swap left and right mouse buttons for left-handed mice with 'left', 'right' for 
right-handed, 'mouse' to follow the mouse setting.</description>
-    </key>
-    <key name="motion-acceleration" type="d">
-      <default>-1</default>
-      <summary>Single Click</summary>
-      <description>Acceleration multiplier for mouse motion. A value of -1 is the system 
default.</description>
-    </key>
-    <key name="motion-threshold" type="i">
-      <default>-1</default>
-      <summary>Motion Threshold</summary>
-      <description>Distance in pixels the pointer must move before accelerated mouse motion is activated. A 
value of -1 is the system default.</description>
-    </key>
-    <key name="natural-scroll" type="b">
-      <default>false</default>
-      <summary>Natural scrolling</summary>
-      <description>Set this to TRUE to enable natural (reverse) scrolling for touchpads.</description>
-    </key>
-  </schema>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.keyboard" 
path="/org/gnome/settings-daemon/peripherals/keyboard/">
-    <key name="repeat" type="b">
-      <default>true</default>
-    </key>
     <key name="click" type="b">
       <default>true</default>
     </key>
-    <key name="repeat-interval" type="u">
-      <default>30</default>
-      <summary>Key Repeat Interval</summary>
-      <description>Delay between repeats in milliseconds.</description>
-    </key>
-    <key name="delay" type="u">
-      <default>500</default>
-      <summary>Initial Key Repeat Delay</summary>
-      <description>Initial key repeat delay in milliseconds.</description>
-    </key>
     <key name="click-volume" type="i">
       <default>0</default>
     </key>
@@ -113,6 +51,33 @@
       <default>false</default>
       <_summary>Highlights the current location of the pointer when the Control key is pressed and 
released.</_summary>
     </key>
+    <key name="double-click" type="i">
+      <default>400</default>
+      <_summary>Double click time</_summary>
+      <_description> Length of a double click in milliseconds.</_description>
+    </key>
+    <key name="drag-threshold" type="i">
+      <default>8</default>
+      <_summary>Drag threshold</_summary>
+      <_description>Distance before a drag is started.</_description>
+    </key>
+  </schema>
+  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.touchscreen" 
path="/org/gnome/settings-daemon/peripherals/touchscreen/">
+    <key name="orientation-lock" type="b">
+      <default>false</default>
+      <_summary>Whether the tablet's orientation is locked, or rotated automatically.</_summary>
+    </key>
+  </schema>
+  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.input-devices" 
path="/org/gnome/settings-daemon/peripherals/input-devices/">
+    <key name="hotplug-command" type="s">
+      <default>''</default>
+      <_summary>Device hotplug custom command</_summary>
+      <_description>Command to be run when a device is added or removed. An exit value of 1 means that the 
device will not be handled further by gnome-settings-daemon.</_description>
+    </key>
+  </schema>
+
+  <!-- Deprecated schemas/keys -->
+  <schema id="org.gnome.settings-daemon.peripherals.mouse.deprecated">
     <key name="left-handed" type="b">
       <default>false</default>
       <summary>Mouse button orientation</summary>
@@ -128,40 +93,79 @@
       <summary>Motion Threshold</summary>
       <description>Distance in pixels the pointer must move before accelerated mouse motion is activated. A 
value of -1 is the system default.</description>
     </key>
-    <key name="double-click" type="i">
-      <default>400</default>
-      <_summary>Double click time</_summary>
-      <_description> Length of a double click in milliseconds.</_description>
-    </key>
-    <key name="drag-threshold" type="i">
-      <default>8</default>
-      <_summary>Drag threshold</_summary>
-      <_description>Distance before a drag is started.</_description>
-    </key>
     <key name="middle-button-enabled" type="b">
       <default>false</default>
-      <_summary>Middle button emulation</_summary>
-      <_description>Enables middle mouse button emulation through simultaneous left and right button 
click.</_description>
+      <summary>Middle button emulation</summary>
+      <description>Enables middle mouse button emulation through simultaneous left and right button 
click.</description>
     </key>
   </schema>
-  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.touchscreen" 
path="/org/gnome/settings-daemon/peripherals/touchscreen/">
-    <key name="orientation-lock" type="b">
+  <schema id="org.gnome.settings-daemon.peripherals.keyboard.deprecated">
+    <key name="repeat" type="b">
+      <default>true</default>
+    </key>
+    <key name="repeat-interval" type="u">
+      <default>30</default>
+      <summary>Key Repeat Interval</summary>
+      <description>Delay between repeats in milliseconds.</description>
+    </key>
+    <key name="delay" type="u">
+      <default>500</default>
+      <summary>Initial Key Repeat Delay</summary>
+      <description>Initial key repeat delay in milliseconds.</description>
+    </key>
+  </schema>
+  <schema id="org.gnome.settings-daemon.peripherals.touchpad.deprecated">
+    <key name="disable-while-typing" type="b">
       <default>false</default>
-      <_summary>Whether the tablet's orientation is locked, or rotated automatically.</_summary>
+      <summary>Disable touchpad while typing</summary>
+      <description>Set this to TRUE if you have problems with accidentally hitting the touchpad while 
typing.</description>
+    </key>
+    <key name="horiz-scroll-enabled" type="b">
+      <default>true</default>
+      <summary>Enable horizontal scrolling</summary>
+      <description>Set this to TRUE to allow horizontal scrolling by the same method selected with the 
scroll_method key.</description>
+    </key>
+    <key name="scroll-method" enum="org.gnome.settings-daemon.GsdTouchpadScrollMethod">
+      <default>'two-finger-scrolling'</default>
+      <summary>Select the touchpad scroll method</summary>
+      <description>Select the touchpad scroll method. Supported values are: "disabled", "edge-scrolling", 
"two-finger-scrolling".</description>
+    </key>
+    <key name="tap-to-click" type="b">
+      <default>false</default>
+      <summary>Enable mouse clicks with touchpad</summary>
+      <description>Set this to TRUE to be able to send mouse clicks by tapping on the touchpad.</description>
+    </key>
+    <key name="touchpad-enabled" type="b">
+      <default>true</default>
+      <summary>Enable touchpad</summary>
+      <description>Set this to TRUE to enable all touchpads.</description>
+    </key>
+    <key name="left-handed" enum="org.gnome.settings-daemon.GsdTouchpadHandedness">
+      <default>'mouse'</default>
+      <summary>Touchpad button orientation</summary>
+      <description>Swap left and right mouse buttons for left-handed mice with 'left', 'right' for 
right-handed, 'mouse' to follow the mouse setting.</description>
+    </key>
+    <key name="motion-acceleration" type="d">
+      <default>-1</default>
+      <summary>Single Click</summary>
+      <description>Acceleration multiplier for mouse motion. A value of -1 is the system 
default.</description>
+    </key>
+    <key name="motion-threshold" type="i">
+      <default>-1</default>
+      <summary>Motion Threshold</summary>
+      <description>Distance in pixels the pointer must move before accelerated mouse motion is activated. A 
value of -1 is the system default.</description>
+    </key>
+    <key name="natural-scroll" type="b">
+      <default>false</default>
+      <summary>Natural scrolling</summary>
+      <description>Set this to TRUE to enable natural (reverse) scrolling for touchpads.</description>
     </key>
   </schema>
-  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.trackball" 
path="/org/gnome/settings-daemon/peripherals/trackball/">
+  <schema id="org.gnome.settings-daemon.peripherals.trackball.deprecated">
     <key name="scroll-wheel-emulation-button" type="i">
       <default>0</default>
       <range min="0" max="24"/>
-      <_summary>Mouse wheel emulation button. 0 to disable the feature.</_summary>
-    </key>
-  </schema>
-  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.input-devices" 
path="/org/gnome/settings-daemon/peripherals/input-devices/">
-    <key name="hotplug-command" type="s">
-      <default>''</default>
-      <_summary>Device hotplug custom command</_summary>
-      <_description>Command to be run when a device is added or removed. An exit value of 1 means that the 
device will not be handled further by gnome-settings-daemon.</_description>
+      <summary>Mouse wheel emulation button. 0 to disable the feature.</summary>
     </key>
   </schema>
 </schemalist>
diff --git a/plugins/common/Makefile.am b/plugins/common/Makefile.am
index 6f232c8..daa5193 100644
--- a/plugins/common/Makefile.am
+++ b/plugins/common/Makefile.am
@@ -36,6 +36,8 @@ libcommon_la_SOURCES = \
        gsd-keygrab.h           \
        gsd-input-helper.c      \
        gsd-input-helper.h      \
+       gsd-settings-migrate.c  \
+       gsd-settings-migrate.h  \
        gsd-shell-helper.c      \
        gsd-shell-helper.h
 
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index 55ac2d0..df496dc 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -45,6 +45,7 @@
 #include "gsd-keyboard-manager.h"
 #include "gsd-input-helper.h"
 #include "gsd-enums.h"
+#include "gsd-settings-migrate.h"
 
 #define GSD_KEYBOARD_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_KEYBOARD_MANAGER, 
GsdKeyboardManagerPrivate))
 
@@ -833,12 +834,29 @@ gsd_keyboard_manager_finalize (GObject *object)
         G_OBJECT_CLASS (gsd_keyboard_manager_parent_class)->finalize (object);
 }
 
+static void
+migrate_keyboard_settings (void)
+{
+        GsdSettingsMigrateEntry entries[] = {
+                { "repeat",          "repeat",          NULL },
+                { "repeat-interval", "repeat-interval", NULL },
+                { "delay",           "delay",           NULL }
+        };
+
+        gsd_settings_migrate_check ("org.gnome.settings-daemon.peripherals.keyboard.deprecated",
+                                    "/org/gnome/settings-daemon/peripherals/keyboard/",
+                                    "org.gnome.desktop.peripherals.keyboard",
+                                    "/org/gnome/desktop/peripherals/keyboard/",
+                                    entries, G_N_ELEMENTS (entries));
+}
+
 GsdKeyboardManager *
 gsd_keyboard_manager_new (void)
 {
         if (manager_object != NULL) {
                 g_object_ref (manager_object);
         } else {
+                migrate_keyboard_settings ();
                 manager_object = g_object_new (GSD_TYPE_KEYBOARD_MANAGER, NULL);
                 g_object_add_weak_pointer (manager_object,
                                            (gpointer *) &manager_object);
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index 0d01cd8..34eb482 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -53,6 +53,7 @@
 #include "gsd-mouse-manager.h"
 #include "gsd-input-helper.h"
 #include "gsd-enums.h"
+#include "gsd-settings-migrate.h"
 
 #define GSD_MOUSE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_MOUSE_MANAGER, 
GsdMouseManagerPrivate))
 
@@ -1488,12 +1489,81 @@ gsd_mouse_manager_finalize (GObject *object)
         G_OBJECT_CLASS (gsd_mouse_manager_parent_class)->finalize (object);
 }
 
+static GVariant *
+map_speed (GVariant *variant)
+{
+        gdouble value;
+
+        value = g_variant_get_double (variant);
+
+        /* Remap from [0..10] to [-1..1] */
+        value = (value / 5) - 1;
+
+        return g_variant_new_double (value);
+}
+
+static GVariant *
+map_send_events (GVariant *variant)
+{
+        gboolean enabled;
+
+        enabled = g_variant_get_boolean (variant);
+
+        if (enabled) {
+                return g_variant_new_string ("enabled");
+        } else {
+                return g_variant_new_string ("disabled");
+        }
+}
+
+static void
+migrate_mouse_settings (void)
+{
+        GsdSettingsMigrateEntry trackball_entries[] = {
+                { "scroll-wheel-emulation-button", "scroll-wheel-emulation-button", NULL }
+        };
+        GsdSettingsMigrateEntry mouse_entries[] = {
+                { "left-handed",           "left-handed", NULL },
+                { "motion-acceleration",   "speed",       map_speed },
+                { "motion-threshold",      NULL,          NULL },
+                { "middle-button-enabled", NULL,          NULL },
+        };
+        GsdSettingsMigrateEntry touchpad_entries[] = {
+                { "disable-while-typing", NULL,             NULL },
+                { "horiz-scroll-enabled", NULL,             NULL },
+                { "scroll-method",        "scroll-method",  NULL },
+                { "tap-to-click",         "tap-to-click",   NULL },
+                { "touchpad-enabled",     "send-events",    map_send_events },
+                { "left-handed",          "left-handed",    NULL },
+                { "motion-acceleration",  "speed",          map_speed },
+                { "motion-threshold",     NULL,             NULL },
+                { "natural-scroll",       "natural-scroll", NULL }
+        };
+
+        gsd_settings_migrate_check ("org.gnome.settings-daemon.peripherals.trackball.deprecated",
+                                    "/org/gnome/settings-daemon/peripherals/trackball/",
+                                    "org.gnome.desktop.peripherals.trackball",
+                                    "/org/gnome/desktop/peripherals/trackball/",
+                                    trackball_entries, G_N_ELEMENTS (trackball_entries));
+        gsd_settings_migrate_check ("org.gnome.settings-daemon.peripherals.mouse.deprecated",
+                                    "/org/gnome/settings-daemon/peripherals/mouse/",
+                                    "org.gnome.desktop.peripherals.mouse",
+                                    "/org/gnome/desktop/peripherals/mouse/",
+                                    mouse_entries, G_N_ELEMENTS (mouse_entries));
+        gsd_settings_migrate_check ("org.gnome.settings-daemon.peripherals.touchpad.deprecated",
+                                    "/org/gnome/settings-daemon/peripherals/touchpad/",
+                                    "org.gnome.desktop.peripherals.touchpad",
+                                    "/org/gnome/desktop/peripherals/touchpad/",
+                                    touchpad_entries, G_N_ELEMENTS (touchpad_entries));
+}
+
 GsdMouseManager *
 gsd_mouse_manager_new (void)
 {
         if (manager_object != NULL) {
                 g_object_ref (manager_object);
         } else {
+                migrate_mouse_settings ();
                 manager_object = g_object_new (GSD_TYPE_MOUSE_MANAGER, NULL);
                 g_object_add_weak_pointer (manager_object,
                                            (gpointer *) &manager_object);


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