2010-01-18 14:20:07 +01:00
|
|
|
Index: plugins/keyboard/gsd-keyboard-xkb.c
|
|
|
|
===================================================================
|
2010-04-01 03:30:18 +02:00
|
|
|
--- plugins/keyboard/gsd-keyboard-xkb.c.orig
|
|
|
|
+++ plugins/keyboard/gsd-keyboard-xkb.c
|
2010-08-09 22:51:52 +02:00
|
|
|
@@ -461,6 +461,103 @@ show_hide_icon ()
|
2010-01-18 14:20:07 +01:00
|
|
|
}
|
2009-07-31 19:33:52 +02:00
|
|
|
}
|
|
|
|
|
2010-08-09 22:51:52 +02:00
|
|
|
+#define GROUP_SWITCHERS_GROUP "grp"
|
|
|
|
+#define DEFAULT_GROUP_SWITCH "grp:shifts_toggle"
|
|
|
|
+
|
2009-07-31 19:33:52 +02:00
|
|
|
+static void
|
|
|
|
+_maybe_add_layout_switcher (GSList *layouts,
|
|
|
|
+ GConfClient *conf_client)
|
|
|
|
+{
|
|
|
|
+ GSList *options;
|
2010-08-09 22:51:52 +02:00
|
|
|
+ GSList *option;
|
|
|
|
+ gboolean any_switcher;
|
|
|
|
+
|
|
|
|
+ /* do we have more than one layout? */
|
|
|
|
+ if (g_slist_length (layouts) > 1)
|
|
|
|
+ return;
|
2009-07-31 19:33:52 +02:00
|
|
|
+
|
|
|
|
+ /* If yes, we need to make sure there's a way to change the layout
|
|
|
|
+ * Based on xkl_layout_chooser_add_default_switcher_if_necessary() in
|
|
|
|
+ * capplets/keyboard/gnome-keyboard-properties-xkbltadd.c
|
|
|
|
+ * (gnome-control-center) */
|
|
|
|
+ options = gconf_client_get_list (conf_client,
|
|
|
|
+ GKBD_KEYBOARD_CONFIG_KEY_OPTIONS,
|
|
|
|
+ GCONF_VALUE_STRING,
|
2009-12-04 23:48:24 +01:00
|
|
|
+ NULL);
|
2009-07-31 19:33:52 +02:00
|
|
|
+
|
|
|
|
+ if (options == NULL) {
|
|
|
|
+ /* nothing in gconf, get the current options from X */
|
|
|
|
+ GkbdKeyboardConfig kbd_config;
|
|
|
|
+
|
|
|
|
+ gkbd_keyboard_config_init (&kbd_config,
|
|
|
|
+ conf_client,
|
|
|
|
+ xkl_engine);
|
|
|
|
+ gkbd_keyboard_config_load_from_x_initial (&kbd_config, NULL);
|
|
|
|
+
|
|
|
|
+ for (option = kbd_config.options; option != NULL; option = option->next) {
|
|
|
|
+ options = g_slist_prepend (options,
|
|
|
|
+ g_strdup (option->data));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ options = g_slist_reverse (options);
|
|
|
|
+
|
|
|
|
+ gkbd_keyboard_config_term (&kbd_config);
|
|
|
|
+ }
|
|
|
|
+
|
2010-08-09 22:51:52 +02:00
|
|
|
+ any_switcher = FALSE;
|
|
|
|
+
|
|
|
|
+ while (option != NULL) {
|
|
|
|
+ char *g, *o;
|
|
|
|
+
|
|
|
|
+ if (gkbd_keyboard_config_split_items (option->data, &g, &o)) {
|
|
|
|
+ if (!g_ascii_strcasecmp (g, GROUP_SWITCHERS_GROUP)) {
|
|
|
|
+ any_switcher = TRUE;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ option = option->next;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* no option to switch between layouts, let's add one */
|
|
|
|
+ if (!any_switcher) {
|
|
|
|
+ XklConfigItem *ci = xkl_config_item_new ();
|
|
|
|
+
|
|
|
|
+ g_snprintf (ci->name, XKL_MAX_CI_NAME_LENGTH,
|
|
|
|
+ DEFAULT_GROUP_SWITCH);
|
|
|
|
+
|
|
|
|
+ /* we make sure the option we want to add is known */
|
|
|
|
+ if (!xkl_registry) {
|
|
|
|
+ xkl_registry = xkl_config_registry_get_instance (xkl_engine);
|
|
|
|
+ if (!xkl_config_registry_load (xkl_registry, TRUE)) {
|
|
|
|
+ g_object_unref (xkl_registry);
|
|
|
|
+ xkl_registry = NULL;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (xkl_registry &&
|
|
|
|
+ xkl_config_registry_find_option (xkl_registry,
|
|
|
|
+ GROUP_SWITCHERS_GROUP,
|
|
|
|
+ ci)) {
|
|
|
|
+ const char *id;
|
|
|
|
+
|
|
|
|
+ id = gkbd_keyboard_config_merge_items
|
|
|
|
+ (GROUP_SWITCHERS_GROUP,
|
|
|
|
+ DEFAULT_GROUP_SWITCH);
|
|
|
|
+
|
|
|
|
+ options = g_slist_append (options, g_strdup (id));
|
|
|
|
+ gconf_client_set_list (conf_client,
|
|
|
|
+ GKBD_KEYBOARD_CONFIG_KEY_OPTIONS,
|
|
|
|
+ GCONF_VALUE_STRING, options,
|
|
|
|
+ NULL);
|
|
|
|
+ }
|
2009-07-31 19:33:52 +02:00
|
|
|
+
|
2010-08-09 22:51:52 +02:00
|
|
|
+ g_object_unref (G_OBJECT (ci));
|
2009-07-31 19:33:52 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ g_slist_foreach (options, (GFunc) g_free, NULL);
|
|
|
|
+ g_slist_free (options);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static gboolean
|
2010-01-18 14:20:07 +01:00
|
|
|
try_activating_xkb_config_if_new (GkbdKeyboardConfig *
|
|
|
|
current_sys_kbd_config)
|
2010-08-09 22:51:52 +02:00
|
|
|
@@ -623,6 +720,7 @@ apply_xkb_settings (void)
|
2009-12-04 23:48:24 +01:00
|
|
|
g_slist_free (free_layouts);
|
|
|
|
}
|
|
|
|
|
2010-04-01 03:30:18 +02:00
|
|
|
+ _maybe_add_layout_switcher (layouts, conf_client);
|
2009-06-12 18:05:33 +02:00
|
|
|
gconf_client_set_list (conf_client,
|
2010-04-01 03:30:18 +02:00
|
|
|
GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
|
|
|
|
GCONF_VALUE_STRING, layouts,
|