[gnome-settings-daemon] Using GkbdStatus for the automatic notification icon



commit b9f5c3e225e85a3e0a900a814c2a3e9254b94305
Author: Sergey V. Udaltsov <svu gnome org>
Date:   Fri Dec 25 02:20:34 2009 +0000

    Using GkbdStatus for the automatic notification icon
    
    Once number of layouts is >1, the indicator icon automatically appears.
    This requires new version of libgnomekbd. Currently, it is only
    indicator - the popup menu is to be added

 configure.ac                        |    6 +++---
 plugins/keyboard/Makefile.am        |    4 ++--
 plugins/keyboard/gsd-keyboard-xkb.c |   23 ++++++++++++++++++++++-
 3 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index df1e5cc..429877f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -220,9 +220,9 @@ AC_CHECK_X_LIB(Xxf86misc, XF86MiscQueryExtension, [
 AC_SUBST(XF86MISC_LIBS)
 AC_CHECK_X_HEADERS([X11/extensions/XKB.h])
 
-PKG_CHECK_MODULES(LIBGNOMEKBD, [libgnomekbd >= 2.21.4 libxklavier >= 4.0])
-AC_SUBST(LIBGNOMEKBD_CFLAGS)
-AC_SUBST(LIBGNOMEKBD_LIBS)
+PKG_CHECK_MODULES(LIBGNOMEKBDUI, [libgnomekbdui >= 2.29.5 libgnomekbd >= 2.29.5 libxklavier >= 4.0])
+AC_SUBST(LIBGNOMEKBDUI_CFLAGS)
+AC_SUBST(LIBGNOMEKBDUI_LIBS)
 
 dnl ---------------------------------------------------------------------------
 dnl - Housekeeping plugin stuff
diff --git a/plugins/keyboard/Makefile.am b/plugins/keyboard/Makefile.am
index 3d6f395..f3e1a22 100644
--- a/plugins/keyboard/Makefile.am
+++ b/plugins/keyboard/Makefile.am
@@ -28,7 +28,7 @@ libkeyboard_la_CPPFLAGS = \
 
 libkeyboard_la_CFLAGS = \
 	$(SETTINGS_PLUGIN_CFLAGS)	\
-	$(LIBGNOMEKBD_CFLAGS)		\
+	$(LIBGNOMEKBDUI_CFLAGS)		\
 	$(AM_CFLAGS)
 
 libkeyboard_la_LDFLAGS = 	\
@@ -38,7 +38,7 @@ libkeyboard_la_LDFLAGS = 	\
 libkeyboard_la_LIBADD  = 	\
 	$(SETTINGS_PLUGIN_LIBS)	\
 	$(XF86MISC_LIBS)	\
-	$(LIBGNOMEKBD_LIBS)	\
+	$(LIBGNOMEKBDUI_LIBS)	\
 	$(NULL)
 
 plugin_in_files = 		\
diff --git a/plugins/keyboard/gsd-keyboard-xkb.c b/plugins/keyboard/gsd-keyboard-xkb.c
index e7d6644..987456c 100644
--- a/plugins/keyboard/gsd-keyboard-xkb.c
+++ b/plugins/keyboard/gsd-keyboard-xkb.c
@@ -31,6 +31,7 @@
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
 
+#include <libgnomekbd/gkbd-status.h>
 #include <libgnomekbd/gkbd-desktop-config.h>
 #include <libgnomekbd/gkbd-keyboard-config.h>
 
@@ -61,6 +62,8 @@ static const char KNOWN_FILES_KEY[] =
 
 static const char *gdm_keyboard_layout = NULL;
 
+static GkbdStatus *icon = NULL;
+
 #define noGSDKX
 
 #ifdef GSDKX
@@ -137,6 +140,23 @@ apply_desktop_settings (void)
 	gkbd_desktop_config_activate (&current_config);
 }
 
+static void
+show_hide_icon ()
+{
+	if (g_slist_length(current_kbd_config.layouts_variants) > 1) {
+		if (icon == NULL) {
+			xkl_debug (150, "Creating new icon\n");
+			icon = gkbd_status_new();
+		}
+	} else {
+		if (icon != NULL) {
+			xkl_debug (150, "Destroying icon\n");
+			g_object_unref(icon);
+			icon = NULL;
+		}
+	}
+}
+
 static gboolean
 try_activating_xkb_config_if_new (GkbdKeyboardConfig *current_sys_kbd_config)
 {
@@ -144,6 +164,7 @@ try_activating_xkb_config_if_new (GkbdKeyboardConfig *current_sys_kbd_config)
 	if (!gkbd_keyboard_config_equals
 	    (&current_kbd_config, current_sys_kbd_config)) {
 		if (gkbd_keyboard_config_activate (&current_kbd_config)) {
+			show_hide_icon ();
 			if (pa_callback != NULL) {
 				(*pa_callback) (pa_callback_user_data);
 				return TRUE;
@@ -258,7 +279,7 @@ apply_xkb_settings (void)
 		 * prevents the list from becoming full if the user has a habit
 		 * of selecting many different keyboard layouts in GDM. */
 
-		found_node = g_slist_find_custom (layouts, gdm_layout, g_strcmp0);
+		found_node = g_slist_find_custom (layouts, gdm_layout, (GCompareFunc)g_strcmp0);
 
 		if (!found_node) {
 			/* Insert at the last valid place, or at the end of



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