Commit 1ecd607b authored by Matthias Clasen's avatar Matthias Clasen Committed by Rui Matos
Browse files

Move cc_add_user_language

Move it to cc-common-language.c and rename it
to cc_common_language_add_user_languages
parent 148e311a
......@@ -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);
}
......@@ -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
......@@ -73,55 +73,6 @@ row_activated (GtkTreeView *tree_view,
gtk_dialog_response (GTK_DIALOG (chooser), GTK_RESPONSE_OK);
}
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)
......
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment