static GtkWidget * region_widget_new (const gchar *locale_id, gboolean is_extra) { gchar *locale_name; gchar *locale_current_name; gchar *locale_untranslated_name; GtkWidget *row, *box; GtkWidget *check; locale_name = gnome_get_country_from_locale (locale_id, locale_id); if (!locale_name) return NULL; locale_current_name = gnome_get_country_from_locale (locale_id, NULL); locale_untranslated_name = gnome_get_country_from_locale (locale_id, "C"); row = gtk_list_box_row_new (); box = padded_label_new (locale_name, is_extra); gtk_container_add (GTK_CONTAINER (row), box); /* We add a check on each side of the label to keep it centered. */ check = gtk_image_new (); gtk_image_set_from_icon_name (GTK_IMAGE (check), "object-select-symbolic", GTK_ICON_SIZE_MENU); gtk_widget_set_opacity (check, 0.0); g_object_set (check, "icon-size", GTK_ICON_SIZE_MENU, NULL); gtk_box_pack_start (GTK_BOX (box), check, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (box), check, 0); check = gtk_image_new (); gtk_image_set_from_icon_name (GTK_IMAGE (check), "object-select-symbolic", GTK_ICON_SIZE_MENU); gtk_widget_set_opacity (check, 0.0); g_object_set (check, "icon-size", GTK_ICON_SIZE_MENU, NULL); gtk_box_pack_start (GTK_BOX (box), check, FALSE, FALSE, 0); g_object_set_data (G_OBJECT (row), "check", check); g_object_set_data_full (G_OBJECT (row), "locale-id", g_strdup (locale_id), g_free); g_object_set_data_full (G_OBJECT (row), "locale-name", locale_name, g_free); g_object_set_data_full (G_OBJECT (row), "locale-current-name", locale_current_name, g_free); g_object_set_data_full (G_OBJECT (row), "locale-untranslated-name", locale_untranslated_name, g_free); g_object_set_data (G_OBJECT (row), "is-extra", GUINT_TO_POINTER (is_extra)); return row; }
int main (int argc, char **argv) { char **locales; guint i; setlocale (LC_ALL, ""); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); if (argc > 1) { guint i; for (i = 1; i < argc; i++) { char *lang, *country, *norm; norm = gnome_normalize_locale (argv[i]); lang = gnome_get_language_from_locale (norm, NULL); country = gnome_get_country_from_locale (norm, NULL); g_print ("%s (norm: %s) == %s -- %s\n", argv[i], norm, lang, country); g_free (norm); g_free (lang); g_free (country); } return 0; } locales = gnome_get_all_locales (); if (locales == NULL) { g_warning ("No locales found"); return 1; } for (i = 0; locales[i] != NULL; i++) { char *lang, *country; lang = gnome_get_language_from_locale (locales[i], NULL); country = gnome_get_country_from_locale (locales[i], NULL); g_print ("%s == %s -- %s\n", locales[i], lang, country); g_free (lang); g_free (country); } g_strfreev (locales); return 0; }