[gnome-control-center/wip/install-languages: 66/70] common: Show all supported languages in language chooser
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/install-languages: 66/70] common: Show all supported languages in language chooser
- Date: Thu, 22 Dec 2011 15:44:08 +0000 (UTC)
commit 3778e113ccf29959a660c3d552ea2fdcae941dd4
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Dec 21 10:46:15 2011 +0100
common: Show all supported languages in language chooser
panels/common/cc-common-language.c | 35 +++++++++++++++++++++++++++++++++++
panels/common/cc-common-language.h | 3 +++
panels/common/cc-language-chooser.c | 2 +-
panels/common/gdm-languages.c | 10 ++++++----
4 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/panels/common/cc-common-language.c b/panels/common/cc-common-language.c
index 0518f3a..2b6e862 100644
--- a/panels/common/cc-common-language.c
+++ b/panels/common/cc-common-language.c
@@ -236,6 +236,10 @@ add_one_language (gpointer d)
}
name = gdm_normalize_language_name (data->languages[data->position]);
+ if (!name) {
+ goto next;
+ }
+
if (g_hash_table_lookup (data->user_langs, name) != NULL) {
g_free (name);
goto next;
@@ -302,6 +306,37 @@ cc_common_language_add_available_languages (GtkListStore *store,
return gdk_threads_add_idle (add_one_language, data);
}
+guint
+cc_common_language_add_all_languages (GtkListStore *store,
+ gboolean regions,
+ GHashTable *user_langs)
+{
+ AsyncLangData *data;
+ gchar *file_contents;
+ gsize length;
+
+ data = g_new0 (AsyncLangData, 1);
+
+ data->store = g_object_ref (store);
+ data->user_langs = g_hash_table_ref (user_langs);
+ data->regions = regions;
+ data->position = 0;
+
+ /* Load /usr/share/i18n/SUPPORTED file to get all existing locales */
+ if (g_file_get_contents ("/usr/share/i18n/SUPPORTED", &file_contents, &length, NULL)) {
+ gchar **lines;
+ gint i = 0;
+
+ lines = g_strsplit (file_contents, "\n", 0);
+ if (lines)
+ data->languages = lines;
+
+ g_free (file_contents);
+ }
+
+ return gdk_threads_add_idle (add_one_language, data);
+}
+
gchar *
cc_common_language_get_current_language (void)
{
diff --git a/panels/common/cc-common-language.h b/panels/common/cc-common-language.h
index 169eee4..3ee95ae 100644
--- a/panels/common/cc-common-language.h
+++ b/panels/common/cc-common-language.h
@@ -43,6 +43,9 @@ gboolean cc_common_language_get_iter_for_region (GtkTreeModel *model,
guint cc_common_language_add_available_languages (GtkListStore *store,
gboolean regions,
GHashTable *user_langs);
+guint cc_common_language_add_all_languages (GtkListStore *store,
+ gboolean regions,
+ GHashTable *user_langs);
gboolean cc_common_language_has_font (const gchar *locale);
gchar *cc_common_language_get_current_language (void);
diff --git a/panels/common/cc-language-chooser.c b/panels/common/cc-language-chooser.c
index 6f8e9ff..00ddf39 100644
--- a/panels/common/cc-language-chooser.c
+++ b/panels/common/cc-language-chooser.c
@@ -170,7 +170,7 @@ finish_language_chooser (gpointer user_data)
model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
user_langs = g_object_get_data (G_OBJECT (chooser), "user-langs");
- async_id = cc_common_language_add_available_languages (GTK_LIST_STORE (model), regions, user_langs);
+ async_id = cc_common_language_add_all_languages (GTK_LIST_STORE (model), regions, user_langs);
g_object_set_data_full (G_OBJECT (chooser), "language-async", GUINT_TO_POINTER (async_id), remove_async);
parent = gtk_window_get_transient_for (GTK_WINDOW (chooser));
diff --git a/panels/common/gdm-languages.c b/panels/common/gdm-languages.c
index 2dfc436..930678f 100644
--- a/panels/common/gdm-languages.c
+++ b/panels/common/gdm-languages.c
@@ -256,10 +256,12 @@ gdm_normalize_language_name (const char *name)
return NULL;
}
- gdm_parse_language_name (name,
- &language_code,
- &territory_code,
- &codeset, &modifier);
+ if (!gdm_parse_language_name (name,
+ &language_code,
+ &territory_code,
+ &codeset, &modifier)) {
+ return NULL;
+ }
normalized_name = construct_language_name (language_code,
territory_code,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]