From 900acaacde087a6d5ac0754dd6ffcd96611097b5 Mon Sep 17 00:00:00 2001 From: "Sergey V. Udaltsov" Date: Sat, 28 Aug 2004 00:02:42 +0000 Subject: [PATCH] fixing #137428 --- .../keyboard/gnome-keyboard-properties-xkb.h | 20 ++++++++ .../gnome-keyboard-properties-xkblt.c | 47 +++++++++++++++---- .../gnome-keyboard-properties-xkbot.c | 10 ---- 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/capplets/keyboard/gnome-keyboard-properties-xkb.h b/capplets/keyboard/gnome-keyboard-properties-xkb.h index 8f23fe421..c63be2e7a 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkb.h +++ b/capplets/keyboard/gnome-keyboard-properties-xkb.h @@ -62,5 +62,25 @@ extern void preview_toggled (GladeXML * dialog, GtkWidget * button); extern void choose_model (GladeXML * dialog); +#define get_selected_layouts_list() \ + gconf_client_get_list (gconf_client_get_default (), \ + GSWITCHIT_CONFIG_XKB_KEY_LAYOUTS, \ + GCONF_VALUE_STRING, NULL) + +#define set_selected_layouts_list(list) \ + gconf_client_set_list (gconf_client_get_default (), \ + GSWITCHIT_CONFIG_XKB_KEY_LAYOUTS, \ + GCONF_VALUE_STRING, (list), NULL) + +#define get_selected_options_list() \ + gconf_client_get_list (gconf_client_get_default (), \ + GSWITCHIT_CONFIG_XKB_KEY_OPTIONS, \ + GCONF_VALUE_STRING, NULL) + +#define set_selected_options_list(list) \ + gconf_client_set_list (gconf_client_get_default (), \ + GSWITCHIT_CONFIG_XKB_KEY_OPTIONS, \ + GCONF_VALUE_STRING, (list), NULL) + G_END_DECLS #endif /* __GNOME_KEYBOARD_PROPERTY_XKB_H */ diff --git a/capplets/keyboard/gnome-keyboard-properties-xkblt.c b/capplets/keyboard/gnome-keyboard-properties-xkblt.c index 4c18b260b..fc34b60c0 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkblt.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkblt.c @@ -39,6 +39,9 @@ #include "gnome-keyboard-properties-xkb.h" +#define GROUP_SWITCHERS_GROUP "grp" +#define DEFAULT_GROUP_SWITCH "grp:alt_shift_toggle" + static GtkTreeIter current1stLevelIter; static const char *current1stLevelId; static int idx2Select = -1; @@ -56,16 +59,6 @@ clear_xkb_elements_list (GSList * list) } } -#define get_selected_layouts_list() \ - gconf_client_get_list (gconf_client_get_default (), \ - GSWITCHIT_CONFIG_XKB_KEY_LAYOUTS, \ - GCONF_VALUE_STRING, NULL) - -#define set_selected_layouts_list(list) \ - gconf_client_set_list (gconf_client_get_default (), \ - GSWITCHIT_CONFIG_XKB_KEY_LAYOUTS, \ - GCONF_VALUE_STRING, (list), NULL) - static void add_variant_to_available_layouts_tree (const XklConfigItemPtr configItem, GladeXML * dialog) @@ -277,6 +270,40 @@ add_selected_layout (GtkWidget * button, GladeXML * dialog) gtk_tree_model_get (model, &selectedIter, 1, &id, -1); layoutsList = g_slist_append (layoutsList, id); set_selected_layouts_list (layoutsList); + // process default switcher + if (g_slist_length(layoutsList) >= 2) + { + GSList *optionsList = get_selected_options_list (); + gboolean anySwitcher = False; + GSList *option = optionsList; + while (option != NULL) + { + char *g, *o; + if (GSwitchItConfigSplitItems (option->data, &g, &o)) + { + if (!g_ascii_strcasecmp (g, GROUP_SWITCHERS_GROUP)) + { + anySwitcher = True; + break; + } + } + option = option->next; + } + if (!anySwitcher) + { + XklConfigItem ci; + g_snprintf( ci.name, XKL_MAX_CI_NAME_LENGTH, DEFAULT_GROUP_SWITCH ); + if (XklConfigFindOption( GROUP_SWITCHERS_GROUP, + &ci )) + + { + const gchar* id = GSwitchItConfigMergeItems (GROUP_SWITCHERS_GROUP, DEFAULT_GROUP_SWITCH); + optionsList = g_slist_append (optionsList, g_strdup (id)); + set_selected_options_list (optionsList); + } + } + clear_xkb_elements_list (optionsList); + } clear_xkb_elements_list (layoutsList); } } diff --git a/capplets/keyboard/gnome-keyboard-properties-xkbot.c b/capplets/keyboard/gnome-keyboard-properties-xkbot.c index 20632d8b3..e428e08a3 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkbot.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkbot.c @@ -42,16 +42,6 @@ static GtkTreeIter current1stLevelIter; static const char *current1stLevelId; -#define get_selected_options_list() \ - gconf_client_get_list (gconf_client_get_default (), \ - GSWITCHIT_CONFIG_XKB_KEY_OPTIONS, \ - GCONF_VALUE_STRING, NULL) - -#define set_selected_options_list(list) \ - gconf_client_set_list (gconf_client_get_default (), \ - GSWITCHIT_CONFIG_XKB_KEY_OPTIONS, \ - GCONF_VALUE_STRING, (list), NULL) - static gboolean can_add_option (GladeXML * dialog) {