static void add_available_languages (GtkListStore *store) { char **languages; int i; char *name; char *language; GtkTreeIter iter; gtk_list_store_clear (store); languages = gdm_get_all_language_names (); for (i = 0; languages[i] != NULL; i++) { if (!language_has_font (languages[i])) continue; name = gdm_normalize_language_name (languages[i]); language = gdm_get_language_from_name (name, NULL); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, LOCALE_COL, name, DISPLAY_LOCALE_COL, language, -1); g_free (name); g_free (language); } g_strfreev (languages); }
static void add_available_languages (GdmLanguageChooserWidget *widget) { char **language_names; int i; language_names = gdm_get_all_language_names (); for (i = 0; language_names[i] != NULL; i++) { if (!language_has_font (language_names[i])) { g_debug ("There is insufficient font coverage to display messages in the '%s' locale", language_names[i]); continue; } gdm_language_chooser_widget_add_language (widget, language_names[i]); } g_strfreev (language_names); }
void um_add_user_languages (GtkWidget *combo) { GHashTable *seen; GSList *users, *l; UmUser *user; const char *lang; char *name; char *language; GtkTreeIter iter; UmUserManager *manager; GtkTreeModel *model; GtkListStore *store; model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); store = GTK_LIST_STORE (model); gtk_list_store_clear (store); seen = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); manager = um_user_manager_ref_default (); users = um_user_manager_list_users (manager); g_object_unref (manager); for (l = users; l; l = l->next) { user = l->data; lang = um_user_get_language (user); if (!lang || !language_has_font (lang)) { continue; } name = gdm_normalize_language_name (lang); if (g_hash_table_lookup (seen, name)) { g_free (name); continue; } g_hash_table_insert (seen, name, GINT_TO_POINTER (TRUE)); language = gdm_get_language_from_name (name, NULL); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, LOCALE_COL, name, DISPLAY_LOCALE_COL, language, -1); g_free (language); } g_slist_free (users); /* Make sure the current locale is present */ lang = (const gchar *) setlocale (LC_MESSAGES, NULL); name = gdm_normalize_language_name (lang); if (!g_hash_table_lookup (seen, name)) { language = gdm_get_language_from_name (name, NULL); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, LOCALE_COL, name, DISPLAY_LOCALE_COL, language, -1); g_free (language); } g_free (name); g_hash_table_destroy (seen); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, LOCALE_COL, NULL, DISPLAY_LOCALE_COL, _("Other..."), -1); }