Index: plugins/keyboard/gsd-keyboard-xkb.c =================================================================== --- plugins/keyboard/gsd-keyboard-xkb.c.orig +++ plugins/keyboard/gsd-keyboard-xkb.c @@ -361,6 +361,57 @@ show_hide_icon () } } +static void +_maybe_add_layout_switcher (GSList *layouts, + GConfClient *conf_client) +{ + GSList *options; + gboolean appended; + + /* 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, + NULL); + + if (options == NULL) { + GSList *option; + + /* 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); + } + + appended = FALSE; + options = gkbd_keyboard_config_add_default_switch_option_if_necessary (layouts, options, &appended); + + if (appended) { + gconf_client_set_list (conf_client, + GKBD_KEYBOARD_CONFIG_KEY_OPTIONS, + GCONF_VALUE_STRING, options, + NULL); + } + + g_slist_foreach (options, (GFunc) g_free, NULL); + g_slist_free (options); +} + static gboolean try_activating_xkb_config_if_new (GkbdKeyboardConfig * current_sys_kbd_config) @@ -542,6 +593,7 @@ apply_xkb_settings (void) g_slist_free (free_layouts); } + _maybe_add_layout_switcher (layouts, conf_client); gconf_client_set_list (conf_client, GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, GCONF_VALUE_STRING, layouts,