gnome-settings-daemon r291 - in trunk: . plugins/keyboard
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r291 - in trunk: . plugins/keyboard
- Date: Thu, 10 Apr 2008 22:26:05 +0100 (BST)
Author: jensg
Date: Thu Apr 10 22:26:05 2008
New Revision: 291
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=291&view=rev
Log:
2008-04-10 Jens Granseuer <jensgr gmx net>
Make keyboard plugin deactivation work
* plugins/keyboard/gsd-keyboard-manager.c:
(register_config_callback), (gsd_keyboard_manager_start),
(gsd_keyboard_manager_stop):
* plugins/keyboard/gsd-keyboard-xkb.c: (register_config_callback),
(gsd_keyboard_xkb_init), (gsd_keyboard_xkb_shutdown):
* plugins/keyboard/gsd-keyboard-xkb.h: clean up properly on stop
* plugins/keyboard/gsd-keyboard-plugin.c: (impl_deactivate): stop
manager on deactivation
Modified:
trunk/ChangeLog
trunk/plugins/keyboard/gsd-keyboard-manager.c
trunk/plugins/keyboard/gsd-keyboard-plugin.c
trunk/plugins/keyboard/gsd-keyboard-xkb.c
trunk/plugins/keyboard/gsd-keyboard-xkb.h
Modified: trunk/plugins/keyboard/gsd-keyboard-manager.c
==============================================================================
--- trunk/plugins/keyboard/gsd-keyboard-manager.c (original)
+++ trunk/plugins/keyboard/gsd-keyboard-manager.c Thu Apr 10 22:26:05 2008
@@ -73,7 +73,8 @@
struct GsdKeyboardManagerPrivate
{
gboolean have_xkb;
- int xkb_event_base;
+ gint xkb_event_base;
+ guint notify;
};
static void gsd_keyboard_manager_class_init (GsdKeyboardManagerClass *klass);
@@ -373,19 +374,14 @@
gdk_error_trap_pop ();
}
-static void
+static guint
register_config_callback (GsdKeyboardManager *manager,
+ GConfClient *client,
const char *path,
GConfClientNotifyFunc func)
{
- GConfClient *client;
-
- client = gconf_client_get_default ();
-
gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
- gconf_client_notify_add (client, path, func, manager, NULL, NULL);
-
- g_object_unref (client);
+ return gconf_client_notify_add (client, path, func, manager, NULL, NULL);
}
gboolean
@@ -397,6 +393,8 @@
gnome_settings_profile_start (NULL);
g_debug ("Starting keyboard manager");
+
+ manager->priv->have_xkb = 0;
client = gconf_client_get_default ();
/* Essential - xkb initialization should happen before */
@@ -407,12 +405,14 @@
numlock_xkb_init (manager);
#endif /* HAVE_X11_EXTENSIONS_XKB_H */
- register_config_callback (manager,
- GSD_KEYBOARD_KEY,
- (GConfClientNotifyFunc) apply_settings);
-
/* apply current settings before we install the callback */
apply_settings (client, 0, NULL, manager);
+
+ manager->priv->notify = register_config_callback (manager,
+ client,
+ GSD_KEYBOARD_KEY,
+ (GConfClientNotifyFunc) apply_settings);
+
g_object_unref (client);
#ifdef HAVE_X11_EXTENSIONS_XKB_H
@@ -427,7 +427,27 @@
void
gsd_keyboard_manager_stop (GsdKeyboardManager *manager)
{
+ GsdKeyboardManagerPrivate *p = manager->priv;
+
g_debug ("Stopping keyboard manager");
+
+ if (p->notify != 0) {
+ GConfClient *client = gconf_client_get_default ();
+ gconf_client_remove_dir (client, GSD_KEYBOARD_KEY, NULL);
+ gconf_client_notify_remove (client, p->notify);
+ g_object_unref (client);
+ p->notify = 0;
+ }
+
+#if HAVE_X11_EXTENSIONS_XKB_H
+ if (p->have_xkb) {
+ gdk_window_remove_filter (NULL,
+ numlock_xkb_callback,
+ GINT_TO_POINTER (p->xkb_event_base));
+ }
+#endif /* HAVE_X11_EXTENSIONS_XKB_H */
+
+ gsd_keyboard_xkb_shutdown ();
}
static void
Modified: trunk/plugins/keyboard/gsd-keyboard-plugin.c
==============================================================================
--- trunk/plugins/keyboard/gsd-keyboard-plugin.c (original)
+++ trunk/plugins/keyboard/gsd-keyboard-plugin.c Thu Apr 10 22:26:05 2008
@@ -86,6 +86,7 @@
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating keyboard plugin");
+ gsd_keyboard_manager_stop (GSD_KEYBOARD_PLUGIN (plugin)->priv->manager);
}
static void
Modified: trunk/plugins/keyboard/gsd-keyboard-xkb.c
==============================================================================
--- trunk/plugins/keyboard/gsd-keyboard-xkb.c (original)
+++ trunk/plugins/keyboard/gsd-keyboard-xkb.c Thu Apr 10 22:26:05 2008
@@ -48,6 +48,9 @@
static gboolean inited_ok = FALSE;
+static guint notify_desktop = 0;
+static guint notify_keyboard = 0;
+
static PostActivationCallback pa_callback = NULL;
static void *pa_callback_user_data = NULL;
@@ -283,22 +286,17 @@
return GDK_FILTER_CONTINUE;
}
-static void
-register_config_callback (const char *path,
- GConfClientNotifyFunc func)
+static guint
+register_config_callback (GConfClient *client,
+ const char *path,
+ GConfClientNotifyFunc func)
{
- GConfClient *client;
-
- client = gconf_client_get_default ();
-
gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
- gconf_client_notify_add (client, path, func, NULL, NULL, NULL);
-
- g_object_unref (client);
+ return gconf_client_notify_add (client, path, func, NULL, NULL, NULL);
}
void
-gsd_keyboard_xkb_init (GConfClient * client)
+gsd_keyboard_xkb_init (GConfClient *client)
{
#ifdef GSDKX
xkl_set_debug_level (200);
@@ -319,11 +317,15 @@
gsd_keyboard_xkb_analyze_sysconfig ();
gsd_keyboard_xkb_chk_lcl_xmm ();
- register_config_callback (GKBD_DESKTOP_CONFIG_DIR,
- (GConfClientNotifyFunc)apply_settings);
-
- register_config_callback (GKBD_KEYBOARD_CONFIG_DIR,
- (GConfClientNotifyFunc)apply_xkb_settings);
+ notify_desktop =
+ register_config_callback (client,
+ GKBD_DESKTOP_CONFIG_DIR,
+ (GConfClientNotifyFunc) apply_settings);
+
+ notify_keyboard =
+ register_config_callback (client,
+ GKBD_KEYBOARD_CONFIG_DIR,
+ (GConfClientNotifyFunc) apply_xkb_settings);
gdk_window_add_filter (NULL, (GdkFilterFunc)
gsd_keyboard_xkb_evt_filter,
@@ -336,3 +338,40 @@
apply_xkb_settings ();
}
}
+
+void
+gsd_keyboard_xkb_shutdown (void)
+{
+ GConfClient *client;
+
+ if (!inited_ok)
+ return;
+
+ xkl_engine_stop_listen (xkl_engine);
+
+ gdk_window_remove_filter (NULL,
+ (GdkFilterFunc) gsd_keyboard_xkb_evt_filter,
+ NULL);
+
+ client = gconf_client_get_default ();
+
+ if (notify_desktop != 0) {
+ gconf_client_remove_dir (client, GKBD_DESKTOP_CONFIG_DIR, NULL);
+ gconf_client_notify_remove (client, notify_desktop);
+ notify_desktop = 0;
+ }
+
+ if (notify_keyboard != 0) {
+ gconf_client_remove_dir (client, GKBD_KEYBOARD_CONFIG_DIR, NULL);
+ gconf_client_notify_remove (client, notify_keyboard);
+ notify_keyboard = 0;
+ }
+
+ g_object_unref (client);
+ g_object_unref (xkl_engine);
+
+ pa_callback = NULL;
+ pa_callback_user_data = NULL;
+ xkl_engine = NULL;
+ inited_ok = FALSE;
+}
Modified: trunk/plugins/keyboard/gsd-keyboard-xkb.h
==============================================================================
--- trunk/plugins/keyboard/gsd-keyboard-xkb.h (original)
+++ trunk/plugins/keyboard/gsd-keyboard-xkb.h Thu Apr 10 22:26:05 2008
@@ -29,7 +29,8 @@
#include <libxklavier/xklavier.h>
-void gsd_keyboard_xkb_init (GConfClient * client);
+void gsd_keyboard_xkb_init (GConfClient *client);
+void gsd_keyboard_xkb_shutdown (void);
typedef void (*PostActivationCallback) (void *userData);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]