[gnome-control-center] user-accounts: Move more functions to common/
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] user-accounts: Move more functions to common/
- Date: Mon, 24 Jan 2011 18:21:11 +0000 (UTC)
commit 93832da41f5d0bad8527a9a6f76a2502468d9786
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jan 24 18:20:18 2011 +0000
user-accounts: Move more functions to common/
panels/common/cc-common-language.c | 14 +++--
panels/common/cc-common-language.h | 2 +
panels/user-accounts/um-language-dialog.c | 92 +----------------------------
3 files changed, 12 insertions(+), 96 deletions(-)
---
diff --git a/panels/common/cc-common-language.c b/panels/common/cc-common-language.c
index dcc71d5..a6d13fd 100644
--- a/panels/common/cc-common-language.c
+++ b/panels/common/cc-common-language.c
@@ -148,9 +148,10 @@ row_activated (GtkTreeView *tree_view,
{
gtk_dialog_response (GTK_DIALOG (chooser), GTK_RESPONSE_OK);
}
+#endif
-static gboolean
-language_has_font (const gchar *locale)
+gboolean
+cc_common_language_has_font (const gchar *locale)
{
const FcCharSet *charset;
FcPattern *pattern;
@@ -207,8 +208,8 @@ language_has_font (const gchar *locale)
return is_displayable;
}
-static void
-add_available_languages (GtkListStore *store)
+void
+cc_common_language_add_available_languages (GtkListStore *store)
{
char **languages;
int i;
@@ -221,7 +222,7 @@ add_available_languages (GtkListStore *store)
languages = gdm_get_all_language_names ();
for (i = 0; languages[i] != NULL; i++) {
- if (!language_has_font (languages[i]))
+ if (!cc_common_language_has_font (languages[i]))
continue;
name = gdm_normalize_language_name (languages[i]);
@@ -237,6 +238,7 @@ add_available_languages (GtkListStore *store)
g_strfreev (languages);
}
+#if 0
void
um_add_user_languages (GtkTreeModel *model)
{
@@ -262,7 +264,7 @@ um_add_user_languages (GtkTreeModel *model)
for (l = users; l; l = l->next) {
user = l->data;
lang = um_user_get_language (user);
- if (!lang || !language_has_font (lang)) {
+ if (!lang || !cc_common_language_has_font (lang)) {
continue;
}
diff --git a/panels/common/cc-common-language.h b/panels/common/cc-common-language.h
index 0342e62..4d16dae 100644
--- a/panels/common/cc-common-language.h
+++ b/panels/common/cc-common-language.h
@@ -41,6 +41,8 @@ gint cc_common_language_sort_languages (GtkTreeModel *model,
gboolean cc_common_language_get_iter_for_language (GtkTreeModel *model,
const gchar *lang,
GtkTreeIter *iter);
+void cc_common_language_add_available_languages (GtkListStore *store);
+gboolean cc_common_language_has_font (const gchar *locale);
G_END_DECLS
diff --git a/panels/user-accounts/um-language-dialog.c b/panels/user-accounts/um-language-dialog.c
index 9407ec0..5c24142 100644
--- a/panels/user-accounts/um-language-dialog.c
+++ b/panels/user-accounts/um-language-dialog.c
@@ -87,94 +87,6 @@ row_activated (GtkTreeView *tree_view,
gtk_dialog_response (GTK_DIALOG (chooser), GTK_RESPONSE_OK);
}
-static gboolean
-language_has_font (const gchar *locale)
-{
- const FcCharSet *charset;
- FcPattern *pattern;
- FcObjectSet *object_set;
- FcFontSet *font_set;
- gchar *language_code;
- gboolean is_displayable;
-
- is_displayable = FALSE;
- pattern = NULL;
- object_set = NULL;
- font_set = NULL;
-
- if (!gdm_parse_language_name (locale, &language_code, NULL, NULL, NULL))
- return FALSE;
-
- charset = FcLangGetCharSet ((FcChar8 *) language_code);
- if (!charset) {
- /* fontconfig does not know about this language */
- is_displayable = TRUE;
- }
- else {
- /* see if any fonts support rendering it */
- pattern = FcPatternBuild (NULL, FC_LANG, FcTypeString, language_code, NULL);
-
- if (pattern == NULL)
- goto done;
-
- object_set = FcObjectSetCreate ();
-
- if (object_set == NULL)
- goto done;
-
- font_set = FcFontList (NULL, pattern, object_set);
-
- if (font_set == NULL)
- goto done;
-
- is_displayable = (font_set->nfont > 0);
- }
-
- done:
- if (font_set != NULL)
- FcFontSetDestroy (font_set);
-
- if (object_set != NULL)
- FcObjectSetDestroy (object_set);
-
- if (pattern != NULL)
- FcPatternDestroy (pattern);
-
- g_free (language_code);
-
- return is_displayable;
-}
-
-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);
-}
-
void
um_add_user_languages (GtkTreeModel *model)
{
@@ -199,7 +111,7 @@ um_add_user_languages (GtkTreeModel *model)
for (l = users; l; l = l->next) {
user = l->data;
lang = um_user_get_language (user);
- if (!lang || !language_has_font (lang)) {
+ if (!lang || !cc_common_language_has_font (lang)) {
continue;
}
@@ -300,7 +212,7 @@ um_language_chooser_new (void)
gtk_tree_view_set_model (GTK_TREE_VIEW (list), GTK_TREE_MODEL (store));
- add_available_languages (store);
+ cc_common_language_add_available_languages (store);
g_object_unref (builder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]