e9dd279de5
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gnome-settings-daemon?expand=0&rev=49
118 lines
4.4 KiB
Diff
118 lines
4.4 KiB
Diff
diff --git a/plugins/keyboard/gsd-keyboard-xkb.c b/plugins/keyboard/gsd-keyboard-xkb.c
|
|
index cb969e3..3a5ed6c 100644
|
|
--- a/plugins/keyboard/gsd-keyboard-xkb.c
|
|
+++ b/plugins/keyboard/gsd-keyboard-xkb.c
|
|
@@ -137,6 +137,103 @@ apply_desktop_settings (void)
|
|
gkbd_desktop_config_activate (¤t_config);
|
|
}
|
|
|
|
+#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)
|
|
{
|
|
@@ -274,6 +371,8 @@ apply_xkb_settings (void)
|
|
|
|
g_slist_foreach (free_layouts, (GFunc) g_free, NULL);
|
|
g_slist_free (free_layouts);
|
|
+
|
|
+ _maybe_add_layout_switcher (layouts, conf_client);
|
|
}
|
|
|
|
gconf_client_set_list (conf_client,
|