[gnome-control-center/wip/region-panel: 2/43] Move cc_add_user_language



commit 7647a4892672cb98952e1b093fde93ff55f1a2d5
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 27 11:02:53 2013 -0500

    Move cc_add_user_language
    
    Move it to cc-common-language.c and rename it
    to cc_common_language_add_user_languages

 panels/common/cc-common-language.c   |   50 ++++++++++++++++++++++++++++++++++
 panels/common/cc-common-language.h   |    2 +
 panels/common/cc-language-chooser.c  |   49 ---------------------------------
 panels/common/cc-language-chooser.h  |    2 -
 panels/user-accounts/um-user-panel.c |    2 +-
 5 files changed, 53 insertions(+), 52 deletions(-)
---
diff --git a/panels/common/cc-common-language.c b/panels/common/cc-common-language.c
index 4c496da..741f564 100644
--- a/panels/common/cc-common-language.c
+++ b/panels/common/cc-common-language.c
@@ -709,3 +709,53 @@ cc_common_language_get_initial_regions (const gchar *lang)
 
         return ht;
 }
+
+static void
+foreach_user_lang_cb (gpointer key,
+                      gpointer value,
+                      gpointer user_data)
+{
+        GtkListStore *store = (GtkListStore *) user_data;
+        const char *locale = (const char *) key;
+        const char *display_locale = (const char *) value;
+        GtkTreeIter iter;
+
+        gtk_list_store_append (store, &iter);
+        gtk_list_store_set (store, &iter,
+                            LOCALE_COL, locale,
+                            DISPLAY_LOCALE_COL, display_locale,
+                            -1);
+}
+
+void
+cc_common_language_add_user_languages (GtkTreeModel *model)
+{
+        char *name;
+        GtkTreeIter iter;
+        GtkListStore *store = GTK_LIST_STORE (model);
+        GHashTable *user_langs;
+        const char *display;
+
+        gtk_list_store_clear (store);
+
+        user_langs = cc_common_language_get_initial_languages ();
+
+        /* Add the current locale first */
+        name = cc_common_language_get_current_language ();
+        display = g_hash_table_lookup (user_langs, name);
+
+        gtk_list_store_append (store, &iter);
+        gtk_list_store_set (store, &iter, LOCALE_COL, name, DISPLAY_LOCALE_COL, display, -1);
+        g_hash_table_remove (user_langs, name);
+        g_free (name);
+
+        /* The rest of the languages */
+        g_hash_table_foreach (user_langs, (GHFunc) foreach_user_lang_cb, store);
+
+        /* And now the "Otherâ" selection */
+        gtk_list_store_append (store, &iter);
+        gtk_list_store_set (store, &iter, LOCALE_COL, NULL, DISPLAY_LOCALE_COL, _("Otherâ"), -1);
+
+        g_hash_table_destroy (user_langs);
+}
+
diff --git a/panels/common/cc-common-language.h b/panels/common/cc-common-language.h
index f08d142..ae50035 100644
--- a/panels/common/cc-common-language.h
+++ b/panels/common/cc-common-language.h
@@ -55,6 +55,8 @@ void     cc_common_language_setup_list              (GtkWidget    *treeview,
                                                     GHashTable   *initial);
 void     cc_common_language_select_current_language (GtkTreeView  *treeview);
 
+void     cc_common_language_add_user_languages (GtkTreeModel *model);
+
 G_END_DECLS
 
 #endif
diff --git a/panels/common/cc-language-chooser.c b/panels/common/cc-language-chooser.c
index 63161c4..913e32a 100644
--- a/panels/common/cc-language-chooser.c
+++ b/panels/common/cc-language-chooser.c
@@ -74,55 +74,6 @@ row_activated (GtkTreeView       *tree_view,
 }
 
 static void
-languages_foreach_cb (gpointer key,
-                     gpointer value,
-                     gpointer user_data)
-{
-       GtkListStore *store = (GtkListStore *) user_data;
-       const char *locale = (const char *) key;
-       const char *display_locale = (const char *) value;
-       GtkTreeIter iter;
-
-       gtk_list_store_append (store, &iter);
-       gtk_list_store_set (store, &iter,
-                           LOCALE_COL, locale,
-                           DISPLAY_LOCALE_COL, display_locale,
-                           -1);
-}
-
-void
-cc_add_user_languages (GtkTreeModel *model)
-{
-        char *name;
-        GtkTreeIter iter;
-        GtkListStore *store = GTK_LIST_STORE (model);
-        GHashTable *user_langs;
-        const char *display;
-
-        gtk_list_store_clear (store);
-
-       user_langs = cc_common_language_get_initial_languages ();
-
-       /* Add the current locale first */
-       name = cc_common_language_get_current_language ();
-       display = g_hash_table_lookup (user_langs, name);
-
-        gtk_list_store_append (store, &iter);
-        gtk_list_store_set (store, &iter, LOCALE_COL, name, DISPLAY_LOCALE_COL, display, -1);
-        g_hash_table_remove (user_langs, name);
-        g_free (name);
-
-        /* The rest of the languages */
-       g_hash_table_foreach (user_langs, (GHFunc) languages_foreach_cb, store);
-
-       /* And now the "Otherâ" selection */
-        gtk_list_store_append (store, &iter);
-        gtk_list_store_set (store, &iter, LOCALE_COL, NULL, DISPLAY_LOCALE_COL, _("Otherâ"), -1);
-
-        g_hash_table_destroy (user_langs);
-}
-
-static void
 remove_timeout (gpointer data,
                GObject *where_the_object_was)
 {
diff --git a/panels/common/cc-language-chooser.h b/panels/common/cc-language-chooser.h
index da557dc..eeb686d 100644
--- a/panels/common/cc-language-chooser.h
+++ b/panels/common/cc-language-chooser.h
@@ -26,8 +26,6 @@
 
 G_BEGIN_DECLS
 
-void              cc_add_user_languages            (GtkTreeModel *model);
-
 GtkWidget        *cc_language_chooser_new          (GtkWidget *parent,
                                                     gboolean   regions);
 void              cc_language_chooser_clear_filter (GtkWidget *chooser);
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 71aeae8..224274f 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -641,7 +641,7 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
 
         widget = get_widget (d, "account-language-combo");
         model = um_editable_combo_get_model (UM_EDITABLE_COMBO (widget));
-        cc_add_user_languages (model);
+        cc_common_language_add_user_languages (model);
 
         lang = g_strdup (act_user_get_language (user));
         if (!lang)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]