gpointing-device-settings r146 - in trunk: . modules modules/common modules/gnome-settings-daemon-plugins src



Author: hiikezoe
Date: Sat Mar  7 05:52:55 2009
New Revision: 146
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=146&view=rev

Log:
Unify mouse-extension and touchpad plugins for gnome-setteings-daemon.

Added:
   trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.c
   trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.h
   trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-plugin.c
      - copied, changed from r145, /trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-plugin.c
   trunk/modules/gnome-settings-daemon-plugins/pointing-device.gnome-settings-plugin.in
Removed:
   trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-plugin.c
   trunk/modules/gnome-settings-daemon-plugins/mouse-extension.gnome-settings-plugin.in
   trunk/modules/gnome-settings-daemon-plugins/touchpad.gnome-settings-plugin.in
Modified:
   trunk/.gitignore
   trunk/TODO
   trunk/modules/common/gpds-touchpad-definitions.h
   trunk/modules/gnome-settings-daemon-plugins/Makefile.am
   trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.c
   trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.h
   trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.c
   trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.h
   trunk/modules/gpds-mouse-ui.c
   trunk/modules/gpds-touchpad-ui.c
   trunk/src/gpds-gconf.h

Modified: trunk/.gitignore
==============================================================================
--- trunk/.gitignore	(original)
+++ trunk/.gitignore	Sat Mar  7 05:52:55 2009
@@ -33,5 +33,4 @@
 po/stamp-it
 po/.intltool-merge-cache
 src/gpointing-device-settings
-modules/gnome-settings-daemon-plugins/touchpad.gnome-settings-plugin
-modules/gnome-settings-daemon-plugins/mouse-extension.gnome-settings-plugin
+modules/gnome-settings-daemon-plugins/pointing-device.gnome-settings-plugin

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	(original)
+++ trunk/TODO	Sat Mar  7 05:52:55 2009
@@ -1,2 +1 @@
-* trackpoint should be "mouse".
 * more touchpad settings.

Modified: trunk/modules/common/gpds-touchpad-definitions.h
==============================================================================
--- trunk/modules/common/gpds-touchpad-definitions.h	(original)
+++ trunk/modules/common/gpds-touchpad-definitions.h	Sat Mar  7 05:52:55 2009
@@ -20,20 +20,18 @@
 #ifndef __GPDS_TOUCHPAD_GCONF_H__
 #define __GPDS_TOUCHPAD_GCONF_H__
 
-#define GPDS_TOUCHPAD_GCONF_DIR                   "/desktop/gnome/peripherals/touchpad"
-
-#define GPDS_TOUCHPAD_EDGES_KEY                         GPDS_TOUCHPAD_GCONF_DIR "/edges"
-#define GPDS_TOUCHPAD_FINGER_KEY                        GPDS_TOUCHPAD_GCONF_DIR "/finger"
-#define GPDS_TOUCHPAD_OFF_KEY                           GPDS_TOUCHPAD_GCONF_DIR "/off"
-#define GPDS_TOUCHPAD_TAP_TIME_KEY                      GPDS_TOUCHPAD_GCONF_DIR "/tap_time"
-#define GPDS_TOUCHPAD_TAP_FAST_TAP_KEY                  GPDS_TOUCHPAD_GCONF_DIR "/tap_fast_tap"
-#define GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_DISTANCE_KEY GPDS_TOUCHPAD_GCONF_DIR "/horizontal_scrolling_distance"
-#define GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_KEY          GPDS_TOUCHPAD_GCONF_DIR "/horizontal_scrolling"
-#define GPDS_TOUCHPAD_VERTICAL_SCROLLING_DISTANCE_KEY   GPDS_TOUCHPAD_GCONF_DIR "/vertical_scrolling_distance"
-#define GPDS_TOUCHPAD_VERTICAL_SCROLLING_KEY            GPDS_TOUCHPAD_GCONF_DIR "/vertical_scrolling"
-#define GPDS_TOUCHPAD_CIRCULAR_SCROLLING_KEY            GPDS_TOUCHPAD_GCONF_DIR "/circular_scrolling"
-#define GPDS_TOUCHPAD_CIRCULAR_SCROLLING_DISTANCE_KEY   GPDS_TOUCHPAD_GCONF_DIR "/circular_scrolling_distance"
-#define GPDS_TOUCHPAD_CIRCULAR_SCROLLING_TRIGGER_KEY    GPDS_TOUCHPAD_GCONF_DIR "/circular_scrolling_trigger"
+#define GPDS_TOUCHPAD_EDGES_KEY                         "edges"
+#define GPDS_TOUCHPAD_FINGER_KEY                        "finger"
+#define GPDS_TOUCHPAD_OFF_KEY                           "off"
+#define GPDS_TOUCHPAD_TAP_TIME_KEY                      "tap_time"
+#define GPDS_TOUCHPAD_TAP_FAST_TAP_KEY                  "tap_fast_tap"
+#define GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_DISTANCE_KEY "horizontal_scrolling_distance"
+#define GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_KEY          "horizontal_scrolling"
+#define GPDS_TOUCHPAD_VERTICAL_SCROLLING_DISTANCE_KEY   "vertical_scrolling_distance"
+#define GPDS_TOUCHPAD_VERTICAL_SCROLLING_KEY            "vertical_scrolling"
+#define GPDS_TOUCHPAD_CIRCULAR_SCROLLING_KEY            "circular_scrolling"
+#define GPDS_TOUCHPAD_CIRCULAR_SCROLLING_DISTANCE_KEY   "circular_scrolling_distance"
+#define GPDS_TOUCHPAD_CIRCULAR_SCROLLING_TRIGGER_KEY    "circular_scrolling_trigger"
 
 #endif /* __GPDS_TOUCHPAD_GCONF_H__ */
 /*

Modified: trunk/modules/gnome-settings-daemon-plugins/Makefile.am
==============================================================================
--- trunk/modules/gnome-settings-daemon-plugins/Makefile.am	(original)
+++ trunk/modules/gnome-settings-daemon-plugins/Makefile.am	Sat Mar  7 05:52:55 2009
@@ -23,33 +23,27 @@
 	$(GNOME_SETTINGS_DAEMON_LIBS)
 
 gsd_plugin_LTLIBRARIES =	        \
-	libmouse-extension.la           \
-	libtouchpad.la
+	libpointing-device.la
 
 gsd_plugin_CFLAGS =					\
 	$(AM_CFLAGS)					\
 	$(GNOME_SETTINGS_DAEMON_CFLAGS)			\
 	-DGNOME_SETTINGS_LOCALEDIR=\""$(localedir)"\"
 
-libmouse_extension_la_CFLAGS = $(gsd_plugin_CFLAGS)
-libmouse_extension_la_SOURCES = 		\
-	gsd-mouse-extension-plugin.c	\
+libpointing_device_la_CFLAGS = $(gsd_plugin_CFLAGS)
+libpointing_device_la_SOURCES = 	\
+	gsd-pointing-device-plugin.c	\
+	gsd-pointing-device-manager.h	\
+	gsd-pointing-device-manager.c   \
 	gsd-mouse-extension-manager.h	\
 	gsd-mouse-extension-manager.c
 
-libmouse_extension_la_LIBADD = $(top_builddir)/modules/common/libmouse_common.la
-
-libtouchpad_la_CFLAGS = $(gsd_plugin_CFLAGS)
-libtouchpad_la_SOURCES = 		\
-	gsd-touchpad-plugin.c		\
-	gsd-touchpad-manager.h		\
-	gsd-touchpad-manager.c
-
-libtouchpad_la_LIBADD = $(top_builddir)/modules/common/libtouchpad_common.la
+libpointing_device_la_LIBADD =					\
+        $(top_builddir)/modules/common/libmouse_common.la	\
+        $(top_builddir)/modules/common/libtouchpad_common.la
 
 gsd_plugin_in_files =	 			        \
-	mouse-extension.gnome-settings-plugin.in	\
-	touchpad.gnome-settings-plugin.in
+	pointing-device.gnome-settings-plugin.in
 
 gsd_plugin_DATA = $(gsd_plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
 

Modified: trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.c
==============================================================================
--- trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.c	(original)
+++ trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.c	Sat Mar  7 05:52:55 2009
@@ -30,56 +30,31 @@
 #include "gpds-mouse-definitions.h"
 #include "gpds-mouse-xinput.h"
 
-#define GSD_MOUSE_EXTENSION_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSD_TYPE_MOUSE_EXTENSION_MANAGER, GsdMouseExtensionManagerPrivate))
+G_DEFINE_TYPE (GsdMouseExtensionManager, gsd_mouse_extension_manager, GSD_TYPE_POINTING_DEVICE_MANAGER)
 
-typedef struct _GsdMouseExtensionManagerPrivate  GsdMouseExtensionManagerPrivate;
-struct _GsdMouseExtensionManagerPrivate
-{
-    GConfClient *gconf;
-    guint notify_id;
-};
-
-G_DEFINE_TYPE (GsdMouseExtensionManager, gsd_mouse_extension_manager, G_TYPE_OBJECT)
-
-static gpointer manager_object = NULL;
+static void _gconf_client_notify (GsdPointingDeviceManager *manager,
+                                  GConfClient *client,
+                                  guint cnxn_id,
+                                  GConfEntry *entry);
 
 static void
 gsd_mouse_extension_manager_init (GsdMouseExtensionManager *manager)
 {
-    GsdMouseExtensionManagerPrivate *priv;
-
-    priv = GSD_MOUSE_EXTENSION_MANAGER_GET_PRIVATE(manager);
-
-    priv->gconf = NULL;
-    priv->notify_id = 0;
 }
 
 static void
 gsd_mouse_extension_manager_class_init (GsdMouseExtensionManagerClass *klass)
 {
-    GObjectClass   *gobject_class = G_OBJECT_CLASS(klass);
+    GsdPointingDeviceManagerClass *manager_class = GSD_POINTING_DEVICE_MANAGER_CLASS(klass);
 
-    g_type_class_add_private(gobject_class, sizeof(GsdMouseExtensionManagerPrivate));
-}
-
-GsdMouseExtensionManager *
-gsd_mouse_extension_manager_new (void)
-{
-    if (manager_object != NULL) {
-        g_object_ref(manager_object);
-    } else {
-        manager_object = g_object_new(GSD_TYPE_MOUSE_EXTENSION_MANAGER, NULL);
-        g_object_add_weak_pointer(manager_object, (gpointer *)&manager_object);
-    }
-
-    return GSD_MOUSE_EXTENSION_MANAGER(manager_object);
+    manager_class->gconf_client_notify = _gconf_client_notify;
 }
 
 static void
-cb_gconf_client_notify (GConfClient *client,
-                        guint cnxn_id,
-                        GConfEntry *entry,
-                        gpointer user_data)
+_gconf_client_notify (GsdPointingDeviceManager *manager,
+                      GConfClient *client,
+                      guint cnxn_id,
+                      GConfEntry *entry)
 {
     GConfValue *value;
     const gchar *key;
@@ -87,7 +62,7 @@
     gint properties[4];
     const gchar *device_name;
 
-    device_name = gpds_mouse_xinput_find_device_name();
+    device_name = gsd_pointing_device_manager_get_device_name(manager);
     if (!device_name)
         return;
 
@@ -181,79 +156,6 @@
     g_object_unref(xinput);
 }
 
-static gchar *
-build_gconf_dir (const gchar *device_name)
-{
-    gchar *escaped_device_name;
-    gchar *gconf_dir;
-
-    escaped_device_name = gconf_escape_key(device_name, -1);
-    gconf_dir = g_strdup_printf("%s/%s",
-                                GPDS_MOUSE_GCONF_DIR,
-                                escaped_device_name);
-    g_free(escaped_device_name);
-    return gconf_dir;
-}
-
-gboolean
-gsd_mouse_extension_manager_start (GsdMouseExtensionManager *manager,
-                                   GError              **error)
-{
-    GsdMouseExtensionManagerPrivate *priv;
-    gchar *gconf_dir;
-    const gchar *device_name;
-
-    device_name = gpds_mouse_xinput_find_device_name();
-    if (!device_name)
-        return FALSE;
-
-    priv = GSD_MOUSE_EXTENSION_MANAGER_GET_PRIVATE(manager);
-    priv->gconf = gconf_client_get_default();
-
-    gconf_dir = build_gconf_dir(device_name);
-    gconf_client_add_dir(priv->gconf,
-                         gconf_dir,
-                         GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-    priv->notify_id = gconf_client_notify_add(priv->gconf,
-                                              gconf_dir,
-                                              cb_gconf_client_notify,
-                                              manager,
-                                              NULL,
-                                              NULL);
-    g_free(gconf_dir);
-
-    return TRUE;
-}
-
-void
-gsd_mouse_extension_manager_stop (GsdMouseExtensionManager *manager)
-{
-    GsdMouseExtensionManagerPrivate *priv;
-
-    priv = GSD_MOUSE_EXTENSION_MANAGER_GET_PRIVATE(manager);
-
-    if (priv->notify_id) {
-        const gchar *device_name;
-
-        device_name = gpds_mouse_xinput_find_device_name();
-        if (device_name) {
-            gchar *gconf_dir;
-            gconf_dir = build_gconf_dir(device_name);
-            gconf_client_remove_dir(priv->gconf,
-                                    GPDS_MOUSE_GCONF_DIR,
-                                    NULL);
-            g_free(gconf_dir);
-        }
-        gconf_client_notify_remove(priv->gconf, priv->notify_id);
-        priv->notify_id = 0;
-    }
-
-    if (priv->gconf) {
-        g_object_unref(priv->gconf);
-        priv->gconf = NULL;
-    }
-}
-
 /*
 vi:ts=4:nowrap:ai:expandtab:sw=4
 */

Modified: trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.h
==============================================================================
--- trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.h	(original)
+++ trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.h	Sat Mar  7 05:52:55 2009
@@ -20,7 +20,7 @@
 #ifndef __GSD_MOUSE_EXTENSION_MANAGER_H__
 #define __GSD_MOUSE_EXTENSION_MANAGER_H__
 
-#include <glib-object.h>
+#include "gsd-pointing-device-manager.h"
 
 G_BEGIN_DECLS
 
@@ -36,21 +36,16 @@
 
 struct _GsdMouseExtensionManager
 {
-    GObject parent;
+    GsdPointingDeviceManager parent;
 };
 
 struct _GsdMouseExtensionManagerClass
 {
-    GObjectClass parent_class;
+    GsdPointingDeviceManagerClass parent_class;
 }; 
 
 GType gsd_mouse_extension_manager_get_type (void) G_GNUC_CONST;
 
-GsdMouseExtensionManager *gsd_mouse_extension_manager_new   (void);
-gboolean                  gsd_mouse_extension_manager_start (GsdMouseExtensionManager *manager,
-                                                             GError                  **error);
-void                      gsd_mouse_extension_manager_stop  (GsdMouseExtensionManager *manager);
-
 G_END_DECLS
 
 #endif /* __GSD_MOUSE_EXTENSION_MANAGER_H__ */

Added: trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.c
==============================================================================
--- (empty file)
+++ trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.c	Sat Mar  7 05:52:55 2009
@@ -0,0 +1,232 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *  Copyright (C) 2009 Hiroyuki Ikezoe  <poincare ikezoe net>
+ *
+ *  This library is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This library 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 Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gsd-pointing-device-manager.h"
+#include <glib/gi18n.h>
+#include <gpds-xinput.h>
+#include <gpds-xinput-utils.h>
+
+#include "gsd-mouse-extension-manager.h"
+#include "gsd-touchpad-manager.h"
+#include "gpds-gconf.h"
+
+enum
+{
+    PROP_0,
+    PROP_DEVICE_NAME
+};
+
+#define GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSD_TYPE_POINTING_DEVICE_MANAGER, GsdPointingDeviceManagerPrivate))
+
+typedef struct _GsdPointingDeviceManagerPrivate  GsdPointingDeviceManagerPrivate;
+struct _GsdPointingDeviceManagerPrivate
+{
+    gchar *device_name;
+    GConfClient *gconf;
+    guint notify_id;
+};
+
+G_DEFINE_ABSTRACT_TYPE (GsdPointingDeviceManager, gsd_pointing_device_manager, G_TYPE_OBJECT)
+
+static void dispose      (GObject      *object);
+static void set_property (GObject      *object,
+                          guint         prop_id,
+                          const GValue *value,
+                          GParamSpec   *pspec);
+static void get_property (GObject      *object,
+                          guint         prop_id,
+                          GValue       *value,
+                          GParamSpec   *pspec);
+static void
+gsd_pointing_device_manager_init (GsdPointingDeviceManager *manager)
+{
+    GsdPointingDeviceManagerPrivate *priv;
+
+    priv = GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(manager);
+
+    priv->device_name = NULL;
+    priv->gconf = NULL;
+    priv->notify_id = 0;
+}
+
+static void
+gsd_pointing_device_manager_class_init (GsdPointingDeviceManagerClass *klass)
+{
+    GObjectClass   *gobject_class = G_OBJECT_CLASS(klass);
+
+    gobject_class->dispose = dispose;
+    gobject_class->set_property = set_property;
+    gobject_class->get_property = get_property;
+
+    g_type_class_add_private(gobject_class, sizeof(GsdPointingDeviceManagerPrivate));
+}
+
+static void
+dispose (GObject *object)
+{
+    GsdPointingDeviceManagerPrivate *priv = GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(object);
+
+    g_free(priv->device_name);
+
+    if (priv->notify_id) {
+        priv->notify_id = 0;
+    }
+
+    if (priv->gconf) {
+        g_object_unref(priv->gconf);
+        priv->gconf = NULL;
+    }
+
+    if (G_OBJECT_CLASS(gsd_pointing_device_manager_parent_class)->dispose)
+        G_OBJECT_CLASS(gsd_pointing_device_manager_parent_class)->dispose(object);
+}
+
+static void
+set_property (GObject      *object,
+              guint         prop_id,
+              const GValue *value,
+              GParamSpec   *pspec)
+{
+    GsdPointingDeviceManagerPrivate *priv = GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(object);
+
+    switch (prop_id) {
+    case PROP_DEVICE_NAME:
+        g_free(priv->device_name);
+        priv->device_name = g_value_dup_string(value);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+get_property (GObject    *object,
+              guint       prop_id,
+              GValue     *value,
+              GParamSpec *pspec)
+{
+    GsdPointingDeviceManagerPrivate *priv = GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(object);
+
+    switch (prop_id) {
+    case PROP_DEVICE_NAME:
+        g_value_set_string(value, priv->device_name);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+GsdPointingDeviceManager *
+gsd_pointing_device_manager_new (const gchar *device_type, const gchar *device_name)
+{
+    if (!strcmp(device_type, "mouse")) {
+        return g_object_new(GSD_TYPE_MOUSE_EXTENSION_MANAGER,
+                            "device-name", device_name);
+    } else if (!strcmp(device_type, "touchpad")) {
+        return g_object_new(GSD_TYPE_TOUCHPAD_MANAGER,
+                            "device-name", device_name);
+    }
+
+    return NULL;
+}
+
+static gchar *
+build_gconf_dir (const gchar *device_name)
+{
+    gchar *escaped_device_name;
+    gchar *gconf_dir;
+
+    escaped_device_name = gconf_escape_key(device_name, -1);
+    gconf_dir = g_strdup_printf("%s/%s",
+                                GPDS_GCONF_DIR,
+                                escaped_device_name);
+    g_free(escaped_device_name);
+    return gconf_dir;
+}
+
+static void
+cb_gconf_client_notify (GConfClient *client,
+                        guint cnxn_id,
+                        GConfEntry *entry,
+                        gpointer user_data)
+{
+    GsdPointingDeviceManager *manager = user_data;
+    GsdPointingDeviceManagerClass *klass;
+
+    klass = GSD_POINTING_DEVICE_MANAGER_GET_CLASS(manager);
+
+    if (klass->gconf_client_notify)
+        klass->gconf_client_notify(manager, client, cnxn_id, entry);
+}
+
+gboolean
+gsd_pointing_device_manager_start (GsdPointingDeviceManager *manager,
+                                   GError              **error)
+{
+    GsdPointingDeviceManagerPrivate *priv;
+    gchar *gconf_dir;
+
+    priv = GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(manager);
+    priv->gconf = gconf_client_get_default();
+
+    gconf_dir = build_gconf_dir(priv->device_name);
+    priv->notify_id = gconf_client_notify_add(priv->gconf,
+                                              gconf_dir,
+                                              cb_gconf_client_notify,
+                                              manager,
+                                              NULL,
+                                              NULL);
+    g_free(gconf_dir);
+
+    return TRUE;
+}
+
+void
+gsd_pointing_device_manager_stop (GsdPointingDeviceManager *manager)
+{
+    GsdPointingDeviceManagerPrivate *priv;
+
+    priv = GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(manager);
+
+    if (priv->notify_id) {
+        gconf_client_notify_remove(priv->gconf, priv->notify_id);
+        priv->notify_id = 0;
+    }
+
+    if (priv->gconf) {
+        g_object_unref(priv->gconf);
+        priv->gconf = NULL;
+    }
+}
+
+const gchar *
+gsd_pointing_device_manager_get_device_name (GsdPointingDeviceManager *manager)
+{
+    return GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(manager)->device_name;
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/

Added: trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.h
==============================================================================
--- (empty file)
+++ trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.h	Sat Mar  7 05:52:55 2009
@@ -0,0 +1,68 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *  Copyright (C) 2009 Hiroyuki Ikezoe  <poincare ikezoe net>
+ *
+ *  This library is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This library 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 Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __GSD_POINTING_DEVICE_MANAGER_H__
+#define __GSD_POINTING_DEVICE_MANAGER_H__
+
+#include <glib-object.h>
+#include <gconf/gconf-client.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_POINTING_DEVICE_MANAGER            (gsd_pointing_device_manager_get_type ())
+#define GSD_POINTING_DEVICE_MANAGER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_POINTING_DEVICE_MANAGER, GsdPointingDeviceManager))
+#define GSD_POINTING_DEVICE_MANAGER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_POINTING_DEVICE_MANAGER, GsdPointingDeviceManagerClass))
+#define GSD_IS_POINTING_DEVICE_MANAGER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSD_TYPE_POINTING_DEVICE_MANAGER))
+#define GSD_IS_POINTING_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSD_TYPE_POINTING_DEVICE_MANAGER))
+#define GSD_POINTING_DEVICE_MANAGER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GSD_TYPE_POINTING_DEVICE_MANAGER, GsdPointingDeviceManagerClass))
+
+typedef struct _GsdPointingDeviceManager GsdPointingDeviceManager;
+typedef struct _GsdPointingDeviceManagerClass GsdPointingDeviceManagerClass;
+
+struct _GsdPointingDeviceManager
+{
+    GObject parent;
+};
+
+struct _GsdPointingDeviceManagerClass
+{
+    GObjectClass parent_class;
+
+    void (*gconf_client_notify) (GsdPointingDeviceManager *manager,
+                                 GConfClient              *client,
+                                 guint                     cnxn_id,
+                                 GConfEntry               *entry);
+}; 
+
+GType gsd_pointing_device_manager_get_type (void) G_GNUC_CONST;
+
+GsdPointingDeviceManager *gsd_pointing_device_manager_new   (const gchar              *device_type,
+                                                             const gchar              *device_name);
+const gchar              *gsd_pointing_device_manager_get_device_name
+                                                            (GsdPointingDeviceManager *manager);
+gboolean                  gsd_pointing_device_manager_start (GsdPointingDeviceManager *manager,
+                                                             GError                  **error);
+void                      gsd_pointing_device_manager_stop  (GsdPointingDeviceManager *manager);
+
+G_END_DECLS
+
+#endif /* __GSD_POINTING_DEVICE_MANAGER_H__ */
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/

Copied: trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-plugin.c (from r145, /trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-plugin.c)
==============================================================================
--- /trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-plugin.c	(original)
+++ trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-plugin.c	Sat Mar  7 05:52:55 2009
@@ -24,8 +24,11 @@
 /* #include <gnome-settings-daemon/gnome-settings-plugin.h> */
 #include "gnome-settings-plugin.h"
 #include <glib/gi18n.h>
+#include <gconf/gconf-client.h>
 
-#include "gsd-mouse-extension-manager.h"
+#include "gsd-pointing-device-manager.h"
+#include "gpds-gconf.h"
+#include "gpds-xinput-pointer-info.h"
 
 #define GSD_TYPE_MOUSE_EXTENSION_PLUGIN            (gsd_mouse_extension_plugin_get_type ())
 #define GSD_MOUSE_EXTENSION_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_MOUSE_EXTENSION_PLUGIN, GsdMouseExtensionPlugin))
@@ -40,7 +43,7 @@
 struct _GsdMouseExtensionPlugin
 {
     GnomeSettingsPlugin parent;
-    GsdMouseExtensionManager *manager;
+    GList *managers;
 };
 
 struct _GsdMouseExtensionPluginClass
@@ -56,30 +59,91 @@
 static void
 gsd_mouse_extension_plugin_init (GsdMouseExtensionPlugin *plugin)
 {
-    plugin->manager = NULL;
+    plugin->managers = NULL;
+}
+
+static GList *
+collect_pointer_device_infos_from_gconf (void)
+{
+    GConfClient *gconf;
+    GSList *dirs, *node;
+    GList *infos = NULL;
+
+    gconf = gconf_client_get_default();
+    dirs = gconf_client_all_dirs(gconf, GPDS_GCONF_DIR, NULL);
+
+    for (node = dirs; node; node = g_slist_next(node)) {
+        const gchar *dir = node->data;
+        gchar *device_type;
+        gchar *device_type_key;
+
+        device_type_key = gconf_concat_dir_and_key(dir, GPDS_GCONF_DEVICE_TYPE_KEY);
+        device_type = gconf_client_get_string(gconf, device_type_key, NULL);
+        if (device_type && !strcmp(device_type, "mouse")) {
+            GpdsXInputPointerInfo *info;
+            gchar *device_name;
+
+            device_name = g_path_get_basename(dir);
+            info = gpds_xinput_pointer_info_new(device_name, device_type);
+            infos = g_list_prepend(infos, info);
+            g_free(device_name);
+        }
+
+        g_free(device_type_key);
+        g_free(device_type);
+    }
+
+    g_slist_foreach(dirs, (GFunc)g_free, NULL);
+    g_slist_free(dirs);
+
+    return infos;
 }
 
 static void
 activate (GnomeSettingsPlugin *plugin)
 {
     GsdMouseExtensionPlugin *mouse_extension_plugin;
+    GList *pointer_device_infos, *node;
 
     mouse_extension_plugin = GSD_MOUSE_EXTENSION_PLUGIN(plugin); 
-    mouse_extension_plugin->manager = gsd_mouse_extension_manager_new();
-    gsd_mouse_extension_manager_start(mouse_extension_plugin->manager, NULL);
+
+    pointer_device_infos = collect_pointer_device_infos_from_gconf();
+    for (node = pointer_device_infos; node; node = g_list_next(node)) {
+        GsdPointingDeviceManager *manager;
+        GpdsXInputPointerInfo *info = node->data;
+
+        manager = gsd_pointing_device_manager_new(gpds_xinput_pointer_info_get_type_name(info),
+                                                  gpds_xinput_pointer_info_get_name(info));
+        if (!manager)
+            continue;
+
+        gsd_pointing_device_manager_start(manager, NULL);
+        mouse_extension_plugin->managers =
+            g_list_prepend(mouse_extension_plugin->managers, manager);
+    }
+
 }
 
 static void
-deactivate (GnomeSettingsPlugin *plugin)
+stop_all_managers (GsdMouseExtensionPlugin *plugin)
 {
-    GsdMouseExtensionPlugin *mouse_extension_plugin;
+    GList *node;
 
-    mouse_extension_plugin = GSD_MOUSE_EXTENSION_PLUGIN(plugin); 
-    if (mouse_extension_plugin->manager) {
-        gsd_mouse_extension_manager_stop(mouse_extension_plugin->manager);
-        g_object_unref(mouse_extension_plugin->manager);
-        mouse_extension_plugin->manager = NULL;
+    for (node = plugin->managers; node; node = g_list_next(node)) {
+        GsdPointingDeviceManager *manager = node->data;
+
+        gsd_pointing_device_manager_stop(manager);
+        g_object_unref(manager);
     }
+
+    g_list_free(plugin->managers);
+    plugin->managers = NULL;
+}
+
+static void
+deactivate (GnomeSettingsPlugin *plugin)
+{
+    stop_all_managers(GSD_MOUSE_EXTENSION_PLUGIN(plugin));
 }
 
 static void

Modified: trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.c
==============================================================================
--- trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.c	(original)
+++ trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.c	Sat Mar  7 05:52:55 2009
@@ -30,56 +30,32 @@
 #include "gpds-touchpad-definitions.h"
 #include "gpds-touchpad-xinput.h"
 
-#define GSD_TOUCHPAD_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSD_TYPE_TOUCHPAD_MANAGER, GsdTouchpadManagerPrivate))
+G_DEFINE_TYPE (GsdTouchpadManager, gsd_touchpad_manager, GSD_TYPE_POINTING_DEVICE_MANAGER)
 
-typedef struct _GsdTouchpadManagerPrivate  GsdTouchpadManagerPrivate;
-struct _GsdTouchpadManagerPrivate
-{
-    GConfClient *gconf;
-    guint notify_id;
-};
-
-G_DEFINE_TYPE (GsdTouchpadManager, gsd_touchpad_manager, G_TYPE_OBJECT)
-
-static gpointer manager_object = NULL;
+static void _gconf_client_notify (GsdPointingDeviceManager *manager,
+                                  GConfClient *client,
+                                  guint cnxn_id,
+                                  GConfEntry *entry);
 
 static void
 gsd_touchpad_manager_init (GsdTouchpadManager *manager)
 {
-    GsdTouchpadManagerPrivate *priv;
-
-    priv = GSD_TOUCHPAD_MANAGER_GET_PRIVATE(manager);
-
-    priv->gconf = NULL;
-    priv->notify_id = 0;
 }
 
 static void
 gsd_touchpad_manager_class_init (GsdTouchpadManagerClass *klass)
 {
-    GObjectClass   *gobject_class = G_OBJECT_CLASS(klass);
+    GsdPointingDeviceManagerClass *manager_class = GSD_POINTING_DEVICE_MANAGER_CLASS(klass);
 
-    g_type_class_add_private(gobject_class, sizeof(GsdTouchpadManagerPrivate));
-}
-
-GsdTouchpadManager *
-gsd_touchpad_manager_new (void)
-{
-    if (manager_object != NULL) {
-        g_object_ref(manager_object);
-    } else {
-        manager_object = g_object_new(GSD_TYPE_TOUCHPAD_MANAGER, NULL);
-        g_object_add_weak_pointer(manager_object, (gpointer *)&manager_object);
-    }
-
-    return GSD_TOUCHPAD_MANAGER(manager_object);
+    manager_class->gconf_client_notify = _gconf_client_notify;
 }
 
 static void
-cb_gconf_client_notify (GConfClient *client,
-                        guint cnxn_id,
-                        GConfEntry *entry,
-                        gpointer user_data)
+_gconf_client_notify (GsdPointingDeviceManager *manager,
+                      GConfClient *client,
+                      guint cnxn_id,
+                      GConfEntry *entry)
+{
 {
     GConfValue *value;
     const gchar *key;
@@ -87,7 +63,7 @@
     gint properties[4];
     const gchar *device_name;
 
-    device_name = gpds_touchpad_xinput_find_device_name();
+    device_name = gsd_pointing_device_manager_get_device_name(manager);
     if (!device_name)
         return;
 
@@ -179,49 +155,6 @@
     g_object_unref(xinput);
 }
 
-gboolean
-gsd_touchpad_manager_start (GsdTouchpadManager *manager,
-                            GError              **error)
-{
-    GsdTouchpadManagerPrivate *priv;
-
-    priv = GSD_TOUCHPAD_MANAGER_GET_PRIVATE(manager);
-    priv->gconf = gconf_client_get_default();
-
-    gconf_client_add_dir(priv->gconf,
-                         GPDS_TOUCHPAD_GCONF_DIR,
-                         GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-    priv->notify_id = gconf_client_notify_add(priv->gconf,
-                                              GPDS_TOUCHPAD_GCONF_DIR,
-                                              cb_gconf_client_notify,
-                                              manager,
-                                              NULL,
-                                              NULL);
-
-    return TRUE;
-}
-
-void
-gsd_touchpad_manager_stop (GsdTouchpadManager *manager)
-{
-    GsdTouchpadManagerPrivate *priv;
-
-    priv = GSD_TOUCHPAD_MANAGER_GET_PRIVATE(manager);
-
-    if (priv->notify_id) {
-        gconf_client_remove_dir(priv->gconf,
-                                GPDS_TOUCHPAD_GCONF_DIR,
-                                NULL);
-        gconf_client_notify_remove(priv->gconf, priv->notify_id);
-        priv->notify_id = 0;
-    }
-
-    if (priv->gconf) {
-        g_object_unref(priv->gconf);
-        priv->gconf = NULL;
-    }
-}
-
 /*
 vi:ts=4:nowrap:ai:expandtab:sw=4
 */

Modified: trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.h
==============================================================================
--- trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.h	(original)
+++ trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.h	Sat Mar  7 05:52:55 2009
@@ -20,7 +20,7 @@
 #ifndef __GSD_TOUCHPAD_MANAGER_H__
 #define __GSD_TOUCHPAD_MANAGER_H__
 
-#include <glib-object.h>
+#include "gsd-pointing-device-manager.h"
 
 G_BEGIN_DECLS
 
@@ -36,21 +36,16 @@
 
 struct _GsdTouchpadManager
 {
-    GObject parent;
+    GsdPointingDeviceManager parent;
 };
 
 struct _GsdTouchpadManagerClass
 {
-    GObjectClass parent_class;
+    GsdPointingDeviceManagerClass parent_class;
 }; 
 
 GType gsd_touchpad_manager_get_type (void) G_GNUC_CONST;
 
-GsdTouchpadManager *gsd_touchpad_manager_new   (void);
-gboolean            gsd_touchpad_manager_start (GsdTouchpadManager *manager,
-                                                GError            **error);
-void                gsd_touchpad_manager_stop  (GsdTouchpadManager *manager);
-
 G_END_DECLS
 
 #endif /* __GSD_TOUCHPAD_MANAGER_H__ */

Added: trunk/modules/gnome-settings-daemon-plugins/pointing-device.gnome-settings-plugin.in
==============================================================================
--- (empty file)
+++ trunk/modules/gnome-settings-daemon-plugins/pointing-device.gnome-settings-plugin.in	Sat Mar  7 05:52:55 2009
@@ -0,0 +1,8 @@
+[GNOME Settings Plugin]
+Module=pointing-device
+IAge=0
+_Name=PointingDevice
+_Description=PointingDevice plugin
+Authors=
+Copyright=Copyright  2009
+Website=

Modified: trunk/modules/gpds-mouse-ui.c
==============================================================================
--- trunk/modules/gpds-mouse-ui.c	(original)
+++ trunk/modules/gpds-mouse-ui.c	Sat Mar  7 05:52:55 2009
@@ -540,6 +540,7 @@
         return FALSE;
     }
 
+    gpds_ui_set_gconf_string(ui, GPDS_GCONF_DEVICE_TYPE_KEY, "mouse");
     GPDS_MOUSE_UI(ui)->xinput = gpds_xinput_new(gpds_ui_get_device_name(ui));
 
     setup_current_values(ui, builder);

Modified: trunk/modules/gpds-touchpad-ui.c
==============================================================================
--- trunk/modules/gpds-touchpad-ui.c	(original)
+++ trunk/modules/gpds-touchpad-ui.c	Sat Mar  7 05:52:55 2009
@@ -45,8 +45,6 @@
     GpdsUI parent;
     GpdsXInput *xinput;
     gchar *ui_file_path;
-    gchar *device_name;
-    GConfClient *gconf;
 };
 
 struct _GpdsTouchpadUIClass
@@ -95,11 +93,9 @@
 static void
 gpds_touchpad_ui_init (GpdsTouchpadUI *ui)
 {
-    ui->device_name = NULL;
     ui->xinput = NULL;
     ui->ui_file_path = 
         g_build_filename(get_ui_file_directory(), "touchpad.ui", NULL);
-    ui->gconf = gconf_client_get_default();
 }
 
 G_MODULE_EXPORT void
@@ -129,12 +125,6 @@
         ui->xinput = NULL;
     }
 
-    if (ui->gconf) {
-        g_object_unref(ui->gconf);
-        ui->gconf = NULL;
-    }
-
-    g_free(ui->device_name);
     g_free(ui->ui_file_path);
 
     if (G_OBJECT_CLASS(gpds_touchpad_ui_parent_class)->dispose)
@@ -288,7 +278,7 @@
     set_range_property(ui->xinput, range, GPDS_TOUCHPAD_TAP_TIME);
 
     time = gtk_range_get_value(range);
-    gconf_client_set_int(ui->gconf, GPDS_TOUCHPAD_TAP_TIME_KEY, (gint)time, NULL);
+    gpds_ui_set_gconf_int(GPDS_UI(ui), GPDS_TOUCHPAD_TAP_TIME_KEY, (gint)time);
 }
 
 static void
@@ -299,7 +289,7 @@
 
     set_toggle_property(ui->xinput, button, GPDS_TOUCHPAD_TAP_FAST_TAP);
     check = gtk_toggle_button_get_active(button);
-    gconf_client_set_bool(ui->gconf, GPDS_TOUCHPAD_TAP_FAST_TAP_KEY, check, NULL);
+    gpds_ui_set_gconf_bool(GPDS_UI(ui), GPDS_TOUCHPAD_TAP_FAST_TAP_KEY, check);
 }
 
 static void
@@ -315,7 +305,7 @@
 
     check = gtk_toggle_button_get_active(button);
     set_widget_sensitivity(builder, "circular_scrolling_box", check);
-    gconf_client_set_bool(ui->gconf, GPDS_TOUCHPAD_CIRCULAR_SCROLLING_KEY, check, NULL);
+    gpds_ui_set_gconf_bool(GPDS_UI(ui), GPDS_TOUCHPAD_CIRCULAR_SCROLLING_KEY, check);
 }
 
 static void
@@ -330,7 +320,7 @@
     set_edge_scroll_toggle_property(ui->xinput, builder);
 
     check = gtk_toggle_button_get_active(button);
-    gconf_client_set_bool(ui->gconf, GPDS_TOUCHPAD_VERTICAL_SCROLLING_KEY, check, NULL);
+    gpds_ui_set_gconf_bool(GPDS_UI(ui), GPDS_TOUCHPAD_VERTICAL_SCROLLING_KEY, check);
 }
 
 static void
@@ -345,7 +335,7 @@
     set_edge_scroll_toggle_property(ui->xinput, builder);
 
     check = gtk_toggle_button_get_active(button);
-    gconf_client_set_bool(ui->gconf, GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_KEY, check, NULL);
+    gpds_ui_set_gconf_bool(GPDS_UI(ui), GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_KEY, check);
 }
 
 static void
@@ -360,7 +350,7 @@
     set_scrolling_distance_range_property(ui->xinput, builder);
 
     distance = gtk_range_get_value(range);
-    gconf_client_set_int(ui->gconf, GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_DISTANCE_KEY, (gint)distance, NULL);
+    gpds_ui_set_gconf_int(GPDS_UI(ui), GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_DISTANCE_KEY, (gint)distance);
 }
 
 static void
@@ -375,7 +365,7 @@
     set_scrolling_distance_range_property(ui->xinput, builder);
 
     distance = gtk_range_get_value(range);
-    gconf_client_set_int(ui->gconf, GPDS_TOUCHPAD_VERTICAL_SCROLLING_DISTANCE_KEY, (gint)distance, NULL);
+    gpds_ui_set_gconf_int(GPDS_UI(ui), GPDS_TOUCHPAD_VERTICAL_SCROLLING_DISTANCE_KEY, (gint)distance);
 }
 
 static void
@@ -515,7 +505,7 @@
             g_error_free(error);
         }
     }
-    gconf_client_set_bool(ui->gconf, GPDS_TOUCHPAD_OFF_KEY, properties[0], NULL);
+    gpds_ui_set_gconf_bool(GPDS_UI(ui), GPDS_TOUCHPAD_OFF_KEY, properties[0]);
     set_sensitivity_depends_on_use_type(ui, properties[0]);
 }
 
@@ -585,17 +575,13 @@
     gint *values;
     gulong n_values;
     gint value;
-    gboolean dir_exists;
 
     if (!get_integer_properties(ui->xinput, property,
                                 &values, &n_values)) {
         return;
     }
 
-    dir_exists = gconf_client_dir_exists(ui->gconf, GPDS_TOUCHPAD_GCONF_DIR, NULL);
-    if (dir_exists)
-        value = gconf_client_get_int(ui->gconf, gconf_key_name, NULL);
-    else
+    if (!gpds_ui_get_gconf_int(GPDS_UI(ui), gconf_key_name, &value))
         value = values[0];
     object = gtk_builder_get_object(builder, object_name);
     gtk_range_set_value(GTK_RANGE(object), value);
@@ -612,17 +598,14 @@
     GObject *object;
     gint *values;
     gulong n_values;
-    gboolean enable, dir_exists;
+    gboolean enable;
 
     if (!get_integer_properties(ui->xinput, property,
                                 &values, &n_values)) {
         return FALSE;
     }
 
-    dir_exists = gconf_client_dir_exists(ui->gconf, GPDS_TOUCHPAD_GCONF_DIR, NULL);
-    if (dir_exists)
-        enable = gconf_client_get_bool(ui->gconf, gconf_key_name, NULL);
-    else
+    if (!gpds_ui_get_gconf_bool(GPDS_UI(ui), gconf_key_name, &enable))
         enable = (values[0] == 1);
     object = gtk_builder_get_object(builder, object_name);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object), enable);
@@ -638,7 +621,7 @@
     GObject *object;
     gint *values;
     gulong n_values;
-    gboolean enable, dir_exists;
+    gboolean enable;
 
     if (!get_integer_properties(ui->xinput, GPDS_TOUCHPAD_EDGE_SCROLLING,
                                 &values, &n_values)) {
@@ -650,18 +633,13 @@
         return;
     }
 
-    dir_exists = gconf_client_dir_exists(ui->gconf, GPDS_TOUCHPAD_GCONF_DIR, NULL);
-    if (dir_exists)
-        enable = gconf_client_get_bool(ui->gconf, GPDS_TOUCHPAD_VERTICAL_SCROLLING_KEY, NULL);
-    else
+    if (!gpds_ui_get_gconf_bool(GPDS_UI(ui), GPDS_TOUCHPAD_VERTICAL_SCROLLING_KEY, &enable))
         enable = (values[0] == 1);
     object = gtk_builder_get_object(builder, "vertical_scrolling");
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object), enable);
     set_widget_sensitivity(builder, "vertical_scrolling_box", enable);
 
-    if (dir_exists)
-        enable = gconf_client_get_bool(ui->gconf, GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_KEY, NULL);
-    else
+    if (!gpds_ui_get_gconf_bool(GPDS_UI(ui), GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_KEY, &enable))
         enable = (values[0] == 1);
     object = gtk_builder_get_object(builder, "horizontal_scrolling");
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object), enable);
@@ -675,7 +653,6 @@
                                               GtkBuilder *builder)
 {
     GObject *object;
-    GError *error = NULL;
     gint *values;
     gulong n_values;
     gint distance;
@@ -691,21 +668,15 @@
         return;
     }
 
-    distance = gconf_client_get_int(ui->gconf,
-                                    GPDS_TOUCHPAD_VERTICAL_SCROLLING_DISTANCE_KEY,
-                                    &error);
+    if (!gpds_ui_get_gconf_int(GPDS_UI(ui), GPDS_TOUCHPAD_VERTICAL_SCROLLING_DISTANCE_KEY, &distance))
+        distance = values[0];
     object = gtk_builder_get_object(builder, "vertical_scrolling_scale");
-    gtk_range_set_value(GTK_RANGE(object), error ? values[0] : distance);
-    if (error)
-        g_clear_error(&error);
-
-    distance = gconf_client_get_int(ui->gconf,
-                                    GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_DISTANCE_KEY,
-                                    &error);
+    gtk_range_set_value(GTK_RANGE(object), distance);
+
+    if (!gpds_ui_get_gconf_int(GPDS_UI(ui), GPDS_TOUCHPAD_HORIZONTAL_SCROLLING_DISTANCE_KEY, &distance))
+        distance = values[1];
     object = gtk_builder_get_object(builder, "horizontal_scrolling_scale");
-    gtk_range_set_value(GTK_RANGE(object), error ? values[1] : distance);
-    if (error)
-        g_clear_error(&error);
+    gtk_range_set_value(GTK_RANGE(object), distance);
 
     g_free(values);
 }
@@ -729,7 +700,6 @@
 set_circular_scrolling_trigger_property_from_preference (GpdsTouchpadUI *ui,
                                                          GtkBuilder *builder)
 {
-    GError *error = NULL;
     gint *values;
     gulong n_values;
     GpdsTouchpadCircularScrollingTrigger trigger;
@@ -740,12 +710,9 @@
         return;
     }
 
-    trigger = gconf_client_get_int(ui->gconf,
-                                   GPDS_TOUCHPAD_CIRCULAR_SCROLLING_TRIGGER_KEY,
-                                   &error);
-    set_circular_scrolling_trigger_button_state(ui, error ? values[0] : trigger);
-    if (error)
-        g_clear_error(&error);
+    if (!gpds_ui_get_gconf_int(GPDS_UI(ui), GPDS_TOUCHPAD_CIRCULAR_SCROLLING_TRIGGER_KEY, (gint*)&trigger))
+        trigger = values[0];
+    set_circular_scrolling_trigger_button_state(ui, trigger);
 
     g_free(values);
 }
@@ -754,7 +721,6 @@
 set_touchpad_use_type_property_from_preference (GpdsTouchpadUI *ui,
                                                 GtkBuilder *builder)
 {
-    GError *error = NULL;
     gint *values;
     gulong n_values;
     GpdsTouchpadUseType type;
@@ -765,12 +731,9 @@
         return;
     }
 
-    type = gconf_client_get_int(ui->gconf,
-                                GPDS_TOUCHPAD_OFF_KEY,
-                                &error);
-    set_touchpad_use_type_combo_state(ui, error ? values[0] : type);
-    if (error)
-        g_clear_error(&error);
+    if (!gpds_ui_get_gconf_int(GPDS_UI(ui), GPDS_TOUCHPAD_OFF_KEY, (gint*)&type))
+        type = values[0];
+    set_touchpad_use_type_combo_state(ui, type);
 
     g_free(values);
 }
@@ -801,17 +764,6 @@
 static gboolean
 is_available (GpdsUI *ui, GError **error)
 {
-    const gchar *device_name;
-    device_name = gpds_touchpad_xinput_find_device_name();
-
-    if (!device_name) {
-        g_set_error(error,
-                    GPDS_XINPUT_ERROR,
-                    GPDS_XINPUT_ERROR_NO_DEVICE,
-                    _("No Touchpad device found."));
-        return FALSE;
-    }
-
     if (!g_file_test(GPDS_TOUCHPAD_UI(ui)->ui_file_path, G_FILE_TEST_EXISTS)) {
         g_set_error(error,
                     GPDS_UI_ERROR,
@@ -821,8 +773,6 @@
         return FALSE;
     }
 
-    GPDS_TOUCHPAD_UI(ui)->device_name = g_strdup(device_name);
-
     return TRUE;
 }
 
@@ -839,7 +789,8 @@
         return FALSE;
     }
 
-    GPDS_TOUCHPAD_UI(ui)->xinput = gpds_xinput_new(GPDS_TOUCHPAD_UI(ui)->device_name);
+    gpds_ui_set_gconf_string(ui, GPDS_GCONF_DEVICE_TYPE_KEY, "touchpad");
+    GPDS_TOUCHPAD_UI(ui)->xinput = gpds_xinput_new(gpds_ui_get_device_name(ui));
 
     setup_current_values(ui, builder);
     setup_signals(ui, builder);

Modified: trunk/src/gpds-gconf.h
==============================================================================
--- trunk/src/gpds-gconf.h	(original)
+++ trunk/src/gpds-gconf.h	Sat Mar  7 05:52:55 2009
@@ -24,7 +24,8 @@
 
 G_BEGIN_DECLS
 
-#define GPDS_GCONF_DIR "/desktop/gnome/peripherals"
+#define GPDS_GCONF_DIR             "/desktop/gnome/peripherals"
+#define GPDS_GCONF_DEVICE_TYPE_KEY "device_type"
 
 G_END_DECLS
 



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