[gnome-settings-daemon] Use GSettings for smartcard and touchpad settings
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] Use GSettings for smartcard and touchpad settings
- Date: Thu, 7 Oct 2010 09:57:37 +0000 (UTC)
commit 5bc2b95f557ff5e47d13f7063adb2fa3e04ceb02
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Oct 6 18:41:16 2010 +0200
Use GSettings for smartcard and touchpad settings
configure.ac | 1 +
data/Makefile.am | 1 +
.../desktop_gnome_peripherals_smartcard.schemas.in | 17 ---
data/desktop_gnome_peripherals_touchpad.schemas.in | 65 -----------
data/gnome-settings-daemon.convert | 10 ++
...org.gnome.desktop.peripherals.gschema.xml.in.in | 40 +++++++
plugins/mouse/gsd-mouse-manager.c | 116 ++++++++++----------
plugins/smartcard/gsd-smartcard-plugin.c | 15 +--
8 files changed, 118 insertions(+), 147 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6d1dfb6..d3aa3a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -466,6 +466,7 @@ data/gnome-settings-daemon.pc
data/gnome-settings-daemon-uninstalled.pc
data/org.gnome.desktop.font-rendering.gschema.xml.in
data/org.gnome.desktop.keybindings.gschema.xml.in
+data/org.gnome.desktop.peripherals.gschema.xml.in
data/org.gnome.settings-daemon.plugins.housekeeping.gschema.xml.in
data/org.gnome.settings-daemon.plugins.xrandr.gschema.xml.in
po/Makefile.in
diff --git a/data/Makefile.am b/data/Makefile.am
index e4f364a..e2c6f73 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -3,6 +3,7 @@ NULL =
gsettings_SCHEMAS = \
org.gnome.desktop.font-rendering.gschema.xml \
org.gnome.desktop.keybindings.gschema.xml \
+ org.gnome.desktop.peripherals.gschema.xml \
org.gnome.settings-daemon.plugins.housekeeping.gschema.xml \
org.gnome.settings-daemon.plugins.xrandr.gschema.xml
diff --git a/data/gnome-settings-daemon.convert b/data/gnome-settings-daemon.convert
index 6b16841..e18a90e 100644
--- a/data/gnome-settings-daemon.convert
+++ b/data/gnome-settings-daemon.convert
@@ -26,6 +26,16 @@ volume-mute = /apps/gnome_settings_daemon/keybindings/volume_mute
volume-up = /apps/gnome_settings_daemon/keybindings/volume_up
www = /apps/gnome_settings_daemon/keybindings/www
+[org.gnome.desktop.peripherals.smartcard]
+removal-action = /desktop/gnome/peripherals/smartcard/removal_action
+
+[org.gnome.desktop.peripherals.touchpad]
+disable-while-typing = /desktop/gnome/peripherals/touchpad/disable_while_typing
+horiz-scroll-enabled = /desktop/gnome/peripherals/touchpad/horiz_scroll_enabled
+scroll-method = /desktop/gnome/peripherals/touchpad/scroll_method
+tap-to-click = /desktop/gnome/peripherals/touchpad/tap_to_click
+touchpad-enabled = /desktop/gnome/peripherals/touchpad/touchpad_enabled
+
[org.gnome.settings-daemon.plugins.housekeeping]
free-percent-notify = /apps/gnome_settings_daemon/plugins/housekeeping/free_percent_notify
free-percent-notify-again = /apps/gnome_settings_daemon/plugins/housekeeping/free_percent_notify_again
diff --git a/data/org.gnome.desktop.peripherals.gschema.xml.in.in b/data/org.gnome.desktop.peripherals.gschema.xml.in.in
new file mode 100644
index 0000000..fd4495c
--- /dev/null
+++ b/data/org.gnome.desktop.peripherals.gschema.xml.in.in
@@ -0,0 +1,40 @@
+<schemalist>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.desktop.peripherals" path="/desktop/gnome/peripherals">
+ <child name="smartcard" schema="org.gnome.desktop.peripherals.smartcard"/>
+ <child name="touchpad" schema="org.gnome.desktop.peripherals.touchpad"/>
+ </schema>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.desktop.peripherals.smartcard" path="/desktop/gnome/peripherals/smartcard">
+ <key name="removal-action" type="s">
+ <default>none</default>
+ <_summary>Smartcard removal action</_summary>
+ <_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.desktop.peripherals.touchpad" path="/desktop/gnome/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>false</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" type="i">
+ <default>1</default>
+ <_summary>Select the touchpad scroll method</_summary>
+ <_description>Select the touchpad scroll method. Supported values are: 0: disabled, 1: edge scrolling, and 2: 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>
+ </schema>
+</schemalist>
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index 740805f..a0853c6 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -33,6 +33,7 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
@@ -54,7 +55,7 @@
#define GCONF_MOUSE_DIR "/desktop/gnome/peripherals/mouse"
#define GCONF_MOUSE_A11Y_DIR "/desktop/gnome/accessibility/mouse"
-#define GCONF_TOUCHPAD_DIR "/desktop/gnome/peripherals/touchpad"
+#define SETTINGS_TOUCHPAD_DIR "org.gnome.desktop.peripherals.touchpad"
#define KEY_LEFT_HANDED GCONF_MOUSE_DIR "/left_handed"
#define KEY_MOTION_ACCELERATION GCONF_MOUSE_DIR "/motion_acceleration"
@@ -62,19 +63,19 @@
#define KEY_LOCATE_POINTER GCONF_MOUSE_DIR "/locate_pointer"
#define KEY_DWELL_ENABLE GCONF_MOUSE_A11Y_DIR "/dwell_enable"
#define KEY_DELAY_ENABLE GCONF_MOUSE_A11Y_DIR "/delay_enable"
-#define KEY_TOUCHPAD_DISABLE_W_TYPING GCONF_TOUCHPAD_DIR "/disable_while_typing"
+#define KEY_TOUCHPAD_DISABLE_W_TYPING "disable_while_typing"
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
-#define KEY_TAP_TO_CLICK GCONF_TOUCHPAD_DIR "/tap_to_click"
-#define KEY_SCROLL_METHOD GCONF_TOUCHPAD_DIR "/scroll_method"
-#define KEY_PAD_HORIZ_SCROLL GCONF_TOUCHPAD_DIR "/horiz_scroll_enabled"
-#define KEY_TOUCHPAD_ENABLED GCONF_TOUCHPAD_DIR "/touchpad_enabled"
+#define KEY_TAP_TO_CLICK "tap_to_click"
+#define KEY_SCROLL_METHOD "scroll_method"
+#define KEY_PAD_HORIZ_SCROLL "horiz_scroll_enabled"
+#define KEY_TOUCHPAD_ENABLED "touchpad_enabled"
#endif
struct GsdMouseManagerPrivate
{
+ GSettings *touchpad_settings;
guint notify;
guint notify_a11y;
- guint notify_touchpad;
gboolean mousetweaks_daemon_running;
gboolean syndaemon_spawned;
@@ -297,7 +298,7 @@ touchpad_has_single_button (XDevice *device)
static void
-set_xinput_devices_left_handed (gboolean left_handed)
+set_xinput_devices_left_handed (GsdMouseManager *manager, gboolean left_handed)
{
XDeviceInfo *device_info;
gint n_devices;
@@ -327,7 +328,7 @@ set_xinput_devices_left_handed (gboolean left_handed)
device = device_is_touchpad (device_info[i]);
if (device != NULL) {
GConfClient *client = gconf_client_get_default ();
- gboolean tap = gconf_client_get_bool (client, KEY_TAP_TO_CLICK, NULL);
+ gboolean tap = g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TAP_TO_CLICK);
gboolean single_button = touchpad_has_single_button (device);
if (tap && !single_button)
@@ -429,7 +430,7 @@ set_left_handed (GsdMouseManager *manager,
/* When XInput support is available, never set the
* button ordering on the core pointer as that would
* revert the changes we make on the devices themselves */
- set_xinput_devices_left_handed (left_handed);
+ set_xinput_devices_left_handed (manager, left_handed);
return;
}
#endif
@@ -572,7 +573,7 @@ set_disable_w_typing (GsdMouseManager *manager, gboolean state)
if (error) {
GConfClient *client;
client = gconf_client_get_default ();
- gconf_client_set_bool (client, KEY_TOUCHPAD_DISABLE_W_TYPING, FALSE, NULL);
+ g_settings_set_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_DISABLE_W_TYPING, FALSE);
g_object_unref (client);
g_error_free (error);
}
@@ -906,12 +907,12 @@ set_mouse_settings (GsdMouseManager *manager)
set_motion_acceleration (manager, gconf_client_get_float (client, KEY_MOTION_ACCELERATION , NULL));
set_motion_threshold (manager, gconf_client_get_int (client, KEY_MOTION_THRESHOLD, NULL));
- set_disable_w_typing (manager, gconf_client_get_bool (client, KEY_TOUCHPAD_DISABLE_W_TYPING, NULL));
+ set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_DISABLE_W_TYPING));
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
- set_tap_to_click (gconf_client_get_bool (client, KEY_TAP_TO_CLICK, NULL), left_handed);
- set_edge_scroll (gconf_client_get_int (client, KEY_SCROLL_METHOD, NULL));
- set_horiz_scroll (gconf_client_get_bool (client, KEY_PAD_HORIZ_SCROLL, NULL));
- set_touchpad_enabled (gconf_client_get_bool (client, KEY_TOUCHPAD_ENABLED, NULL));
+ set_tap_to_click (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TAP_TO_CLICK), left_handed);
+ set_edge_scroll (g_settings_get_int (manager->priv->touchpad_settings, KEY_SCROLL_METHOD));
+ set_horiz_scroll (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_PAD_HORIZ_SCROLL));
+ set_touchpad_enabled (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_ENABLED));
#endif
g_object_unref (client);
@@ -935,34 +936,10 @@ mouse_callback (GConfClient *client,
if (entry->value->type == GCONF_VALUE_INT) {
set_motion_threshold (manager, gconf_value_get_int (entry->value));
}
- } else if (! strcmp (entry->key, KEY_TOUCHPAD_DISABLE_W_TYPING)) {
- if (entry->value->type == GCONF_VALUE_BOOL)
- set_disable_w_typing (manager, gconf_value_get_bool (entry->value));
-#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
- } else if (! strcmp (entry->key, KEY_TAP_TO_CLICK)) {
- if (entry->value->type == GCONF_VALUE_BOOL) {
- set_tap_to_click (gconf_value_get_bool (entry->value),
- gconf_client_get_bool (client, KEY_LEFT_HANDED, NULL));
- }
- } else if (! strcmp (entry->key, KEY_SCROLL_METHOD)) {
- if (entry->value->type == GCONF_VALUE_INT) {
- set_edge_scroll (gconf_value_get_int (entry->value));
- set_horiz_scroll (gconf_client_get_bool (client, KEY_PAD_HORIZ_SCROLL, NULL));
- }
- } else if (! strcmp (entry->key, KEY_PAD_HORIZ_SCROLL)) {
- if (entry->value->type == GCONF_VALUE_BOOL)
- set_horiz_scroll (gconf_value_get_bool (entry->value));
-#endif
} else if (! strcmp (entry->key, KEY_LOCATE_POINTER)) {
if (entry->value->type == GCONF_VALUE_BOOL) {
set_locate_pointer (manager, gconf_value_get_bool (entry->value));
}
-#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
- } else if (! strcmp (entry->key, KEY_TOUCHPAD_ENABLED)) {
- if (entry->value->type == GCONF_VALUE_BOOL) {
- set_touchpad_enabled (gconf_value_get_bool (entry->value));
- }
-#endif
} else if (! strcmp (entry->key, KEY_DWELL_ENABLE)) {
if (entry->value->type == GCONF_VALUE_BOOL) {
set_mousetweaks_daemon (manager,
@@ -978,6 +955,33 @@ mouse_callback (GConfClient *client,
}
}
+static void
+touchpad_callback (GSettings *settings,
+ const gchar *key,
+ GsdMouseManager *manager)
+{
+ GConfClient *client = gconf_client_get_default ();
+
+ if (! strcmp (key, KEY_TOUCHPAD_DISABLE_W_TYPING)) {
+ set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->touchpad_settings, key));
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
+ } else if (! strcmp (key, KEY_TAP_TO_CLICK)) {
+ set_tap_to_click (g_settings_get_boolean (settings, key),
+ gconf_client_get_bool (client, KEY_LEFT_HANDED, NULL));
+ } else if (! strcmp (key, KEY_SCROLL_METHOD)) {
+ set_edge_scroll (g_settings_get_int (settings, key));
+ set_horiz_scroll (g_settings_get_boolean (settings, KEY_PAD_HORIZ_SCROLL));
+ } else if (! strcmp (key, KEY_PAD_HORIZ_SCROLL)) {
+ set_horiz_scroll (g_settings_get_boolean (settings, key));
+ } else if (! strcmp (key, KEY_TOUCHPAD_ENABLED)) {
+ set_touchpad_enabled (g_settings_get_boolean (settings, key));
+ }
+#endif
+
+ g_object_unref (client);
+
+}
+
static guint
register_config_callback (GsdMouseManager *manager,
GConfClient *client,
@@ -1013,11 +1017,11 @@ gsd_mouse_manager_idle_cb (GsdMouseManager *manager)
client,
GCONF_MOUSE_A11Y_DIR,
(GConfClientNotifyFunc) mouse_callback);
- manager->priv->notify_touchpad =
- register_config_callback (manager,
- client,
- GCONF_TOUCHPAD_DIR,
- (GConfClientNotifyFunc) mouse_callback);
+
+ manager->priv->touchpad_settings = g_settings_new (SETTINGS_TOUCHPAD_DIR);
+ g_signal_connect (manager->priv->touchpad_settings, "changed",
+ G_CALLBACK (touchpad_callback), manager);
+
manager->priv->syndaemon_spawned = FALSE;
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
@@ -1029,13 +1033,13 @@ gsd_mouse_manager_idle_cb (GsdMouseManager *manager)
gconf_client_get_bool (client, KEY_DWELL_ENABLE, NULL),
gconf_client_get_bool (client, KEY_DELAY_ENABLE, NULL));
- set_disable_w_typing (manager, gconf_client_get_bool (client, KEY_TOUCHPAD_DISABLE_W_TYPING, NULL));
+ set_disable_w_typing (manager, g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_DISABLE_W_TYPING));
#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
- set_tap_to_click (gconf_client_get_bool (client, KEY_TAP_TO_CLICK, NULL),
+ set_tap_to_click (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TAP_TO_CLICK),
gconf_client_get_bool (client, KEY_LEFT_HANDED, NULL));
- set_edge_scroll (gconf_client_get_int (client, KEY_SCROLL_METHOD, NULL));
- set_horiz_scroll (gconf_client_get_bool (client, KEY_PAD_HORIZ_SCROLL, NULL));
- set_touchpad_enabled (gconf_client_get_bool (client, KEY_TOUCHPAD_ENABLED, NULL));
+ set_edge_scroll (g_settings_get_int (manager->priv->touchpad_settings, KEY_SCROLL_METHOD));
+ set_horiz_scroll (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_PAD_HORIZ_SCROLL));
+ set_touchpad_enabled (g_settings_get_boolean (manager->priv->touchpad_settings, KEY_TOUCHPAD_ENABLED));
#endif
g_object_unref (client);
@@ -1080,13 +1084,8 @@ gsd_mouse_manager_stop (GsdMouseManager *manager)
p->notify_a11y = 0;
}
- if (p->notify_touchpad != 0) {
- gconf_client_remove_dir (client, GCONF_TOUCHPAD_DIR, NULL);
- gconf_client_notify_remove (client, p->notify_touchpad);
- p->notify_touchpad = 0;
- }
-
g_object_unref (client);
+ g_object_unref (manager->priv->touchpad_settings);
set_locate_pointer (manager, FALSE);
@@ -1107,6 +1106,11 @@ gsd_mouse_manager_finalize (GObject *object)
g_return_if_fail (mouse_manager->priv != NULL);
+ if (mouse_manager->priv->touchpad_settings != NULL)
+ g_object_unref (mouse_manager->priv->touchpad_settings);
+
+ g_free (mouse_manager->priv);
+
G_OBJECT_CLASS (gsd_mouse_manager_parent_class)->finalize (object);
}
diff --git a/plugins/smartcard/gsd-smartcard-plugin.c b/plugins/smartcard/gsd-smartcard-plugin.c
index 56136f0..1beda23 100644
--- a/plugins/smartcard/gsd-smartcard-plugin.c
+++ b/plugins/smartcard/gsd-smartcard-plugin.c
@@ -25,11 +25,10 @@
#include <glib.h>
#include <glib-object.h>
+#include <gio/gio.h>
#include <dbus/dbus-glib.h>
-#include <gconf/gconf-client.h>
-
#include "gnome-settings-plugin.h"
#include "gsd-smartcard-plugin.h"
#include "gsd-smartcard-manager.h"
@@ -57,8 +56,7 @@ typedef enum
#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
#define SM_LOGOUT_MODE_FORCE 2
-#define GSD_SMARTCARD_KEY "/desktop/gnome/peripherals/smartcard"
-#define KEY_REMOVE_ACTION GSD_SMARTCARD_KEY "/removal_action"
+#define KEY_REMOVE_ACTION "removal_action"
#define GSD_SMARTCARD_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_SMARTCARD_PLUGIN, GsdSmartcardPluginPrivate))
@@ -182,13 +180,12 @@ user_logged_in_with_smartcard (void)
static GsdSmartcardRemoveAction
get_configured_remove_action (GsdSmartcardPlugin *plugin)
{
- GConfClient *client;
+ GSettings *settings;
char *remove_action_string;
GsdSmartcardRemoveAction remove_action;
- client = gconf_client_get_default ();
- remove_action_string = gconf_client_get_string (client,
- KEY_REMOVE_ACTION, NULL);
+ settings = g_settings_new ("org.gnome.desktop.peripherals.smartcard");
+ remove_action_string = g_settings_get_string (settings, KEY_REMOVE_ACTION);
if (remove_action_string == NULL) {
g_warning ("GsdSmartcardPlugin unable to get smartcard remove action");
@@ -204,7 +201,7 @@ get_configured_remove_action (GsdSmartcardPlugin *plugin)
remove_action = GSD_SMARTCARD_REMOVE_ACTION_NONE;
}
- g_object_unref (client);
+ g_object_unref (settings);
return remove_action;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]