gnome-settings-daemon/gnome-settings-daemon-add-layout-switcher.patch

67 lines
2.3 KiB
Diff

Index: plugins/keyboard/gsd-keyboard-xkb.c
===================================================================
--- plugins/keyboard/gsd-keyboard-xkb.c.orig
+++ plugins/keyboard/gsd-keyboard-xkb.c
@@ -317,6 +317,53 @@ show_hide_icon ()
}
}
+static void
+_maybe_add_layout_switcher (GSList *layouts,
+ GSettings *settings_keyboard)
+{
+ gchar **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
+ * plugins/region/gnome-region-panel-xkbltadd.c
+ * (gnome-control-center) */
+ g_settings_get_strv (settings_keyboard, GKBD_KEYBOARD_CONFIG_KEY_OPTIONS);
+
+ if (options == NULL) {
+ GPtrArray *options_array;
+ gchar *option;
+
+ /* nothing in gconf, get the current options from X */
+ GkbdKeyboardConfig kbd_config;
+
+ gkbd_keyboard_config_init (&kbd_config, xkl_engine);
+ gkbd_keyboard_config_load_from_x_initial (&kbd_config, NULL);
+
+ options_array = g_ptr_array_new ();
+ option = kbd_config.options;
+
+ while (option != NULL) {
+ g_ptr_array_add (options_array, g_strdup (option));
+ option++;
+ }
+ options = g_ptr_array_free (options_array, FALSE);
+
+ gkbd_keyboard_config_term (&kbd_config);
+ }
+
+ appended = FALSE;
+ options = gkbd_keyboard_config_add_default_switch_option_if_necessary (layouts, options, &appended);
+
+ if (appended) {
+ g_settings_set_strv (settings_keyboard,
+ GKBD_KEYBOARD_CONFIG_KEY_OPTIONS,
+ (const gchar *const*)(options));
+ }
+
+ g_strfreev (options);
+}
+
static gboolean
try_activating_xkb_config_if_new (GkbdKeyboardConfig *
current_sys_kbd_config)
@@ -486,6 +533,7 @@ apply_xkb_settings (void)
(gdm_layout));
}
+ _maybe_add_layout_switcher (layouts, settings_keyboard);
g_settings_set_strv (settings_keyboard,
GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
(const gchar *