summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2015-01-15 19:57:20 +0100
committerCarlos Garnacho <carlosg@gnome.org>2015-01-15 21:23:51 +0100
commitde8363afe771a4e3de5a717bcff12f166f267c0b (patch)
tree7f723a8a1da55e120e55817b6517aefa81e0448e
parentd432d4e7ab0e18102f1ae78603e933547f63e6d4 (diff)
downloadgnome-settings-daemon-wip/settings-relocation.tar.gz
common: Migrate input settings to gsettings-desktop-schemas keyswip/settings-relocation
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
-rw-r--r--data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in176
-rw-r--r--plugins/common/Makefile.am2
-rw-r--r--plugins/common/gsd-settings-migrate.c67
-rw-r--r--plugins/common/gsd-settings-migrate.h43
-rw-r--r--plugins/keyboard/gsd-keyboard-manager.c18
-rw-r--r--plugins/mouse/gsd-mouse-manager.c70
6 files changed, 290 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 d2f70ed9..6a65f081 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 6f232c86..daa5193d 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/common/gsd-settings-migrate.c b/plugins/common/gsd-settings-migrate.c
new file mode 100644
index 00000000..a6d10df0
--- /dev/null
+++ b/plugins/common/gsd-settings-migrate.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2015 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Carlos Garnacho <carlosg@gnome.org>
+ */
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "gsd-settings-migrate.h"
+
+void
+gsd_settings_migrate_check (const gchar *origin_schema,
+ const gchar *origin_path,
+ const gchar *dest_schema,
+ const gchar *dest_path,
+ GsdSettingsMigrateEntry entries[],
+ guint n_entries)
+{
+ GSettings *origin_settings, *dest_settings;
+ GVariant *variant;
+ guint i;
+
+ origin_settings = g_settings_new_with_path (origin_schema, origin_path);
+ dest_settings = g_settings_new_with_path (dest_schema, dest_path);
+
+ for (i = 0; i < n_entries; i++) {
+ variant = g_settings_get_user_value (origin_settings, entries[i].origin_key);
+
+ if (!variant)
+ continue;
+
+ if (entries[i].dest_key) {
+ if (entries[i].func) {
+ GVariant *modified;
+
+ modified = entries[i].func (variant);
+ g_variant_unref (variant);
+ variant = g_variant_ref_sink (modified);
+ }
+
+ g_settings_set_value (dest_settings, entries[i].dest_key, variant);
+ }
+
+ g_settings_reset (origin_settings, entries[i].origin_key);
+ g_variant_unref (variant);
+ }
+
+ g_object_unref (origin_settings);
+ g_object_unref (dest_settings);
+}
diff --git a/plugins/common/gsd-settings-migrate.h b/plugins/common/gsd-settings-migrate.h
new file mode 100644
index 00000000..65e8598c
--- /dev/null
+++ b/plugins/common/gsd-settings-migrate.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2015 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Carlos Garnacho <carlosg@gnome.org>
+ */
+
+#ifndef __GSD_SETTINGS_MIGRATE_H__
+#define __GSD_SETTINGS_MIGRATE_H__
+
+typedef struct _GsdSettingsMigrateEntry GsdSettingsMigrateEntry;
+
+typedef GVariant * (* GsdSettingsMigrateFunc) (GVariant *variant);
+
+struct _GsdSettingsMigrateEntry
+{
+ const gchar *origin_key;
+ const gchar *dest_key;
+ GsdSettingsMigrateFunc func;
+};
+
+void gsd_settings_migrate_check (const gchar *origin_schema,
+ const gchar *origin_path,
+ const gchar *dest_schema,
+ const gchar *dest_path,
+ GsdSettingsMigrateEntry entries[],
+ guint n_entries);
+
+#endif /* __GSD_SETTINGS_MIGRATE_H__ */
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index 55ac2d0b..df496dcd 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 0d01cd8e..34eb4820 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);