gpointing-device-settings r172 - in trunk: modules/gnome-settings-daemon-plugins src



Author: hiikezoe
Date: Sun Mar  8 01:04:22 2009
New Revision: 172
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=172&view=rev

Log:
now gnome-settings-daemon plugin works fine.

Added:
   trunk/src/gpds-gconf.c
      - copied, changed from r171, /trunk/src/gpds-gconf.h
Modified:
   trunk/modules/gnome-settings-daemon-plugins/gsd-mouse-extension-manager.c
   trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.c
   trunk/modules/gnome-settings-daemon-plugins/gsd-touchpad-manager.c
   trunk/src/Makefile.am
   trunk/src/gpds-gconf.h
   trunk/src/gpointing-device-settings.h

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	Sun Mar  8 01:04:22 2009
@@ -26,6 +26,7 @@
 #include <gconf/gconf-client.h>
 #include <gpds-xinput.h>
 #include <gpds-xinput-utils.h>
+#include <gpds-gconf.h>
 
 #include "gpds-mouse-definitions.h"
 #include "gpds-mouse-xinput.h"
@@ -72,7 +73,7 @@
     xinput = gpds_xinput_new(device_name);
 
     value = gconf_entry_get_value(entry);
-    key = gconf_entry_get_key(entry);
+    key = gpds_gconf_get_key_from_path(gconf_entry_get_key(entry));
 
     switch (value->type) {
     case GCONF_VALUE_BOOL:

Modified: trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.c
==============================================================================
--- trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.c	(original)
+++ trunk/modules/gnome-settings-daemon-plugins/gsd-pointing-device-manager.c	Sun Mar  8 01:04:22 2009
@@ -78,17 +78,41 @@
     gobject_class->set_property = set_property;
     gobject_class->get_property = get_property;
 
+    g_object_class_install_property
+        (gobject_class,
+         PROP_DEVICE_NAME,
+         g_param_spec_string("device-name",
+                             "Device Name",
+                             "The device name",
+                             NULL,
+                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
     g_type_class_add_private(gobject_class, sizeof(GsdPointingDeviceManagerPrivate));
 }
 
-static void
-dispose (GObject *object)
+static gchar *
+build_gconf_dir (const gchar *device_name)
 {
-    GsdPointingDeviceManagerPrivate *priv = GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(object);
+    gchar *escaped_device_name;
+    gchar *gconf_dir;
 
-    g_free(priv->device_name);
+    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
+dispose_gconf (GsdPointingDeviceManagerPrivate *priv)
+{
     if (priv->notify_id) {
+        gchar *gconf_dir;
+        gconf_dir = build_gconf_dir(priv->device_name);
+        gconf_client_remove_dir(priv->gconf, gconf_dir, NULL);
+        gconf_client_notify_remove(priv->gconf, priv->notify_id);
+        g_free(gconf_dir);
         priv->notify_id = 0;
     }
 
@@ -96,6 +120,15 @@
         g_object_unref(priv->gconf);
         priv->gconf = NULL;
     }
+}
+
+static void
+dispose (GObject *object)
+{
+    GsdPointingDeviceManagerPrivate *priv = GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(object);
+
+    g_free(priv->device_name);
+    dispose_gconf(priv);
 
     if (G_OBJECT_CLASS(gsd_pointing_device_manager_parent_class)->dispose)
         G_OBJECT_CLASS(gsd_pointing_device_manager_parent_class)->dispose(object);
@@ -143,29 +176,17 @@
 {
     if (!strcmp(device_type, "mouse")) {
         return g_object_new(GSD_TYPE_MOUSE_EXTENSION_MANAGER,
-                            "device-name", device_name);
+                            "device-name", device_name,
+                            NULL);
     } else if (!strcmp(device_type, "touchpad")) {
         return g_object_new(GSD_TYPE_TOUCHPAD_MANAGER,
-                            "device-name", device_name);
+                            "device-name", device_name,
+                            NULL);
     }
 
     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,
@@ -192,6 +213,7 @@
     priv->gconf = gconf_client_get_default();
 
     gconf_dir = build_gconf_dir(priv->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,
@@ -206,19 +228,7 @@
 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;
-    }
+    dispose_gconf(GSD_POINTING_DEVICE_MANAGER_GET_PRIVATE(manager));
 }
 
 const gchar *

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	Sun Mar  8 01:04:22 2009
@@ -26,6 +26,7 @@
 #include <gconf/gconf-client.h>
 #include <gpds-xinput.h>
 #include <gpds-xinput-utils.h>
+#include <gpds-gconf.h>
 
 #include "gpds-touchpad-definitions.h"
 #include "gpds-touchpad-xinput.h"
@@ -72,7 +73,7 @@
     xinput = gpds_xinput_new(device_name);
 
     value = gconf_entry_get_value(entry);
-    key = gconf_entry_get_key(entry);
+    key = gpds_gconf_get_key_from_path(gconf_entry_get_key(entry));
 
     switch (value->type) {
     case GCONF_VALUE_BOOL:

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sun Mar  8 01:04:22 2009
@@ -15,6 +15,7 @@
 	gpds-module.c			\
 	gpds-module.h			\
 	gpds-ui.c			\
+	gpds-gconf.c			\
 	gpds-utils.c			\
 	gpds-xinput.c			\
 	gpds-xinput-pointer-info.c	\

Copied: trunk/src/gpds-gconf.c (from r171, /trunk/src/gpds-gconf.h)
==============================================================================
--- /trunk/src/gpds-gconf.h	(original)
+++ trunk/src/gpds-gconf.c	Sun Mar  8 01:04:22 2009
@@ -17,19 +17,23 @@
  *
  */
 
-#ifndef __GPDS_GCONF_H__
-#define __GPDS_GCONF_H__
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gpds-gconf.h"
+#include <string.h>
+
+const gchar *
+gpds_gconf_get_key_from_path (const gchar *path)
+{
+    const gchar *segment;
 
-#include <glib.h>
+    segment = strrchr(path, '/');
 
-G_BEGIN_DECLS
+    return segment ? segment + 1 : NULL;
+}
 
-#define GPDS_GCONF_DIR             "/desktop/gnome/peripherals"
-#define GPDS_GCONF_DEVICE_TYPE_KEY "device_type"
-
-G_END_DECLS
-
-#endif /* __GPDS_GCONF_H__ */
 /*
 vi:ts=4:nowrap:ai:expandtab:sw=4
 */

Modified: trunk/src/gpds-gconf.h
==============================================================================
--- trunk/src/gpds-gconf.h	(original)
+++ trunk/src/gpds-gconf.h	Sun Mar  8 01:04:22 2009
@@ -27,6 +27,8 @@
 #define GPDS_GCONF_DIR             "/desktop/gnome/peripherals"
 #define GPDS_GCONF_DEVICE_TYPE_KEY "device_type"
 
+const gchar *gpds_gconf_get_key_from_path (const gchar *path);
+
 G_END_DECLS
 
 #endif /* __GPDS_GCONF_H__ */

Modified: trunk/src/gpointing-device-settings.h
==============================================================================
--- trunk/src/gpointing-device-settings.h	(original)
+++ trunk/src/gpointing-device-settings.h	Sun Mar  8 01:04:22 2009
@@ -24,6 +24,7 @@
 #include <gpds-module-impl.h>
 #include <gpds-gconf.h>
 #include <gpds-utils.h>
+#include <gpds-gconf.h>
 
 #endif /* __GPOINTING_DEVICE_SETTINGS_H__ */
 /*



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