static void set_model_text (GtkWidget * picker, gchar * value) { XklConfigItem *ci = xkl_config_item_new (); char *model = NULL; if (value != NULL && value[0] != '\0') { model = g_strdup(value); } if (model == NULL) { model = g_strdup(initial_config.model); if (model == NULL) model = g_strdup(""); } g_snprintf (ci->name, sizeof (ci->name), "%s", model); if (xkl_config_registry_find_model (config_registry, ci)) { char *d; d = xci_desc_to_utf8 (ci); gtk_button_set_label (GTK_BUTTON (picker), d); g_free (d); } else { gtk_button_set_label (GTK_BUTTON (picker), _("Unknown")); } g_object_unref (G_OBJECT (ci)); g_free (model); }
static void set_model_text (GtkWidget * picker, MateConfValue * value) { XklConfigItem *ci = xkl_config_item_new (); const char *model = NULL; if (value != NULL && value->type == MATECONF_VALUE_STRING) { model = mateconf_value_get_string (value); if (model != NULL && model[0] == '\0') model = NULL; } if (model == NULL) { model = initial_config.model; if (model == NULL) model = ""; } g_snprintf (ci->name, sizeof (ci->name), "%s", model); if (xkl_config_registry_find_model (config_registry, ci)) { char *d; d = xci_desc_to_utf8 (ci); gtk_button_set_label (GTK_BUTTON (picker), d); g_free (d); } else { gtk_button_set_label (GTK_BUTTON (picker), _("Unknown")); } g_object_unref (G_OBJECT (ci)); }
static void xkb_layout_chooser_add_variant_to_available_country_variants (XklConfigRegistry * config_registry, XklConfigItem * parent_config_item, XklConfigItem * config_item, AddVariantData * data) { gchar *utf_variant_name = config_item ? xkb_layout_description_utf8 (matekbd_keyboard_config_merge_items (parent_config_item->name, config_item->name)) : xci_desc_to_utf8 (parent_config_item); GtkTreeIter iter; const gchar *xkb_id = config_item ? matekbd_keyboard_config_merge_items (parent_config_item->name, config_item->name) : parent_config_item->name; if (config_item && g_object_get_data (G_OBJECT (config_item), XCI_PROP_EXTRA_ITEM)) { gchar *buf = g_strdup_printf ("<i>%s</i>", utf_variant_name); gtk_list_store_insert_with_values (data->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, -1); g_free (buf); } else gtk_list_store_insert_with_values (data->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, -1); g_free (utf_variant_name); }
/* Add a group of options: create title and layout widgets and then add widgets for all the options in the group. */ static void xkb_options_add_group (XklConfigRegistry * config_registry, XklConfigItem * config_item, GtkBuilder * dialog) { GtkWidget *align, *vbox, *option_check; gboolean allow_multiple_selection = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (config_item), XCI_PROP_ALLOW_MULTIPLE_SELECTION)); GSList *expanders_list = g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP); gchar *utf_group_name = xci_desc_to_utf8 (config_item); gchar *titlemarkup = g_strconcat ("<span>", utf_group_name, "</span>", NULL); current_expander = gtk_expander_new (titlemarkup); gtk_expander_set_use_markup (GTK_EXPANDER (current_expander), TRUE); g_object_set_data_full (G_OBJECT (current_expander), "utfGroupName", utf_group_name, g_free); g_object_set_data_full (G_OBJECT (current_expander), "groupId", g_strdup (config_item->name), g_free); g_free (titlemarkup); align = gtk_alignment_new (0, 0, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 12, 12, 0); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (align), vbox); gtk_container_add (GTK_CONTAINER (current_expander), align); current_multi_select = (gboolean) allow_multiple_selection; current_radio_group = NULL; current1st_level_id = config_item->name; option_checks_list = NULL; xkl_config_registry_foreach_option (config_registry, config_item->name, (ConfigItemProcessFunc) xkb_options_add_option, dialog); /* sort it */ option_checks_list = g_slist_sort (option_checks_list, (GCompareFunc) xkb_option_checks_compare); while (option_checks_list) { option_check = GTK_WIDGET (option_checks_list->data); gtk_box_pack_start (GTK_BOX (vbox), option_check, TRUE, TRUE, 0); option_checks_list = option_checks_list->next; } /* free it */ g_slist_free (option_checks_list); option_checks_list = NULL; xkb_options_expander_highlight (); expanders_list = g_slist_append (expanders_list, current_expander); g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP, expanders_list); g_signal_connect (current_expander, "focus-in-event", G_CALLBACK (option_focused_cb), WID ("options_scroll")); }
/* 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 (matekbd_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); }
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); }