/* Update selected option counters for a group-bound expander */ static void xkb_options_update_option_counters (XklConfigRegistry * config_registry, XklConfigItem * config_item) { gchar *full_option_name = g_strdup (gkbd_keyboard_config_merge_items (current1st_level_id, config_item->name)); gboolean current_state = xkb_options_is_selected (full_option_name); g_free (full_option_name); xkb_options_expander_selcounter_add (current_state); }
/* Add a check_button or radio_button to control a particular option This function makes particular use of the current... variables at the top of this file. */ static void xkb_options_add_option (XklConfigRegistry * config_registry, XklConfigItem * config_item, GtkBuilder * dialog) { GtkWidget *option_check; gchar *utf_option_name = xci_desc_to_utf8 (config_item); /* Copy this out because we'll load it into the widget with set_data */ gchar *full_option_name = g_strdup (gkbd_keyboard_config_merge_items (current1st_level_id, config_item->name)); gboolean initial_state; if (current_multi_select) option_check = gtk_check_button_new_with_label (utf_option_name); else { if (current_radio_group == NULL) { /* The first radio in a group is to be "Default", meaning none of the below options are to be included in the selected list. This is a HIG-compliant alternative to allowing no selection in the group. */ option_check = gtk_radio_button_new_with_label (current_radio_group, _("Default")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (option_check), TRUE); /* Make option name underscore - to enforce its first position in the list */ g_object_set_data_full (G_OBJECT (option_check), "utfOptionName", g_strdup (" "), g_free); option_checks_list = g_slist_append (option_checks_list, option_check); current_radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (option_check)); current_none_radio = option_check; g_signal_connect (option_check, "focus-in-event", G_CALLBACK (option_focused_cb), WID ("options_scroll")); } option_check = gtk_radio_button_new_with_label (current_radio_group, utf_option_name); current_radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (option_check)); g_object_set_data (G_OBJECT (option_check), "NoneRadio", current_none_radio); } initial_state = xkb_options_is_selected (full_option_name); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (option_check), initial_state); g_object_set_data_full (G_OBJECT (option_check), OPTION_ID_PROP, full_option_name, g_free); g_object_set_data_full (G_OBJECT (option_check), "utfOptionName", utf_option_name, g_free); g_signal_connect (option_check, "toggled", G_CALLBACK (option_toggled_cb), NULL); option_checks_list = g_slist_append (option_checks_list, option_check); g_signal_connect (option_check, "focus-in-event", G_CALLBACK (option_focused_cb), WID ("options_scroll")); xkb_options_expander_selcounter_add (initial_state); g_object_set_data (G_OBJECT (option_check), GCONFSTATE_PROP, GINT_TO_POINTER (initial_state)); }
static void xkl_layout_add_to_list (XklConfigRegistry * config, const XklConfigItem * item, const XklConfigItem * subitem, GtkBuilder * chooser_dialog) { GtkListStore *list_store = GTK_LIST_STORE (gtk_builder_get_object (chooser_dialog, "layout_list_model")); GtkTreeIter iter; gchar *utf_variant_name = subitem ? xkb_layout_description_utf8 (gkbd_keyboard_config_merge_items (item->name, subitem->name)) : xci_desc_to_utf8 (item); const gchar *xkb_id = subitem ? gkbd_keyboard_config_merge_items (item->name, subitem->name) : item->name; gchar *country_desc = xkl_create_description_from_list (item, subitem, XCI_PROP_COUNTRY_LIST, xkl_get_country_name); gchar *language_desc = xkl_create_description_from_list (item, subitem, XCI_PROP_LANGUAGE_LIST, xkl_get_language_name); gchar *tmp = utf_variant_name; utf_variant_name = g_regex_replace_literal (left_bracket_regex, tmp, -1, 0, "<", 0, NULL); g_free (tmp); if (subitem && g_object_get_data (G_OBJECT (subitem), XCI_PROP_EXTRA_ITEM)) { gchar *buf = g_strdup_printf ("<i>%s</i>", utf_variant_name); gtk_list_store_insert_with_values (list_store, &iter, -1, COMBO_BOX_MODEL_COL_SORT, utf_variant_name, COMBO_BOX_MODEL_COL_VISIBLE, buf, COMBO_BOX_MODEL_COL_XKB_ID, xkb_id, COMBO_BOX_MODEL_COL_COUNTRY_DESC, country_desc, COMBO_BOX_MODEL_COL_LANGUAGE_DESC, language_desc, -1); g_free (buf); } else gtk_list_store_insert_with_values (list_store, &iter, -1, COMBO_BOX_MODEL_COL_SORT, utf_variant_name, COMBO_BOX_MODEL_COL_VISIBLE, utf_variant_name, COMBO_BOX_MODEL_COL_XKB_ID, xkb_id, COMBO_BOX_MODEL_COL_COUNTRY_DESC, country_desc, COMBO_BOX_MODEL_COL_LANGUAGE_DESC, language_desc, -1); g_free (utf_variant_name); g_free (country_desc); g_free (language_desc); }