gnome-settings-daemon/gnome-settings-daemon-add-layout-switcher.patch
Vincent Untz a2f8ef80f8 Accepting request 35881 from home:sreeves1:branches:GNOME:Factory
Copy from home:sreeves1:branches:GNOME:Factory/gnome-settings-daemon via accept of submit request 35881 revision 2.
Request was accepted with message:
thanks

OBS-URL: https://build.opensuse.org/request/show/35881
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gnome-settings-daemon?expand=0&rev=58
2010-03-29 11:23:31 +00:00

117 lines
4.4 KiB
Diff

Index: plugins/keyboard/gsd-keyboard-xkb.c
===================================================================
--- plugins/keyboard/gsd-keyboard-xkb.c.orig
+++ plugins/keyboard/gsd-keyboard-xkb.c
@@ -461,6 +461,103 @@ show_hide_icon ()
}
}
+#define GROUP_SWITCHERS_GROUP "grp"
+#define DEFAULT_GROUP_SWITCH "grp:shifts_toggle"
+
+static void
+_maybe_add_layout_switcher (GSList *layouts,
+ GConfClient *conf_client)
+{
+ GSList *options;
+ GSList *option;
+ gboolean any_switcher;
+
+ /* do we have more than one layout? */
+ if (g_slist_length (layouts) > 1)
+ return;
+
+ /* 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) {
+ /* 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);
+ }
+
+ 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);
+ }
+
+ g_object_unref (G_OBJECT (ci));
+ }
+
+ 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)
@@ -623,6 +720,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,