aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-langs.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-10-14 01:38:16 +0800
committerChristian Persch <chpe@src.gnome.org>2003-10-14 01:38:16 +0800
commit442741fc4fb9b63c78c37f305d443f8aa57ff67e (patch)
tree834a2350618ff9378d1aaea422e1db9e0e9a304b /lib/ephy-langs.c
parentab827f639671b79f2b802b19f86e937a92612ad7 (diff)
downloadgsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar
gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.gz
gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.bz2
gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.lz
gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.xz
gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.zst
gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.zip
Encodings menu improvements, part 3: Refactored the encodings list; it no
2003-10-13 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-embed-single.c: (ephy_embed_single_free_passwords): * embed/ephy-embed-single.h: * embed/ephy-embed-utils.c: (ephy_embed_utils_build_encodings_submenu): * embed/mozilla/mozilla-embed-single.cpp: * embed/mozilla/mozilla-notifiers.cpp: * lib/Makefile.am: * lib/ephy-encodings.c: (ephy_encoding_info_free), (encodings_info_cmp), (ephy_encodings_get_list): * lib/ephy-encodings.h: * lib/ephy-langs.c: (ephy_lang_group_info_free), (lang_group_info_cmp), (ephy_lang_get_group_list), (fonts_language_info_cmp), (ephy_font_langs_get_codes_list), (ephy_font_langs_get_list): * lib/ephy-langs.h: * po/POTFILES.in: * src/ephy-encoding-menu.c: (ephy_encoding_menu_set_window), (ephy_encoding_menu_rebuild): * src/prefs-dialog.c: (prefs_dialog_finalize), (get_current_language_code), (create_fonts_language_menu), (default_encoding_menu_changed_cb), (find_encoding_in_list_cmp), (create_default_encoding_menu): Encodings menu improvements, part 3: Refactored the encodings list; it no longer is neccessary to have it in the embed single. Ported all callers to new infrastructure.
Diffstat (limited to 'lib/ephy-langs.c')
-rw-r--r--lib/ephy-langs.c144
1 files changed, 113 insertions, 31 deletions
diff --git a/lib/ephy-langs.c b/lib/ephy-langs.c
index 55f339e3b..dee178846 100644
--- a/lib/ephy-langs.c
+++ b/lib/ephy-langs.c
@@ -14,38 +14,71 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
#endif
#include "ephy-langs.h"
+#include "ephy-string.h"
#include <bonobo/bonobo-i18n.h>
+#include <string.h>
static const FontsLanguageInfo font_languages[] =
{
- { N_("Arabic"), "ar" },
- { N_("Baltic"), "x-baltic" },
- { N_("Central European"), "x-central-euro" },
- { N_("Cyrillic"), "x-cyrillic" },
- { N_("Devanagari"), "x-devanagari" },
- { N_("Greek"), "el" },
- { N_("Hebrew"), "he" },
- { N_("Japanese"), "ja" },
- { N_("Korean"), "ko" },
- { N_("Simplified Chinese"), "zh-CN" },
- { N_("Tamil"), "x-tamil" },
- { N_("Thai"), "th" },
- { N_("Traditional Chinese"), "zh-TW" },
- { N_("Turkish"), "tr" },
- { N_("Unicode"), "x-unicode" },
- { N_("Western"), "x-western" },
+ { N_("Arabic"), "ar" },
+ { N_("Baltic"), "x-baltic" },
+ { N_("Central European"), "x-central-euro" },
+ { N_("Cyrillic"), "x-cyrillic" },
+ { N_("Devanagari"), "x-devanagari" },
+ { N_("Greek"), "el" },
+ { N_("Hebrew"), "he" },
+ { N_("Japanese"), "ja" },
+ { N_("Korean"), "ko" },
+ { N_("Simplified Chinese"), "zh-CN" },
+ { N_("Tamil"), "x-tamil" },
+ { N_("Thai"), "th" },
+ { N_("Traditional Chinese"), "zh-TW" },
+#if MOZILLA_SNAPSHOT >= 11
+ { N_("Traditional Chinese (Hong Kong)"), "zh-HK" },
+#endif
+ { N_("Turkish"), "tr" },
+ { N_("Unicode"), "x-unicode" },
+ { N_("Western"), "x-western" }
};
static const guint n_font_languages = G_N_ELEMENTS (font_languages);
+static const
+struct
+{
+ EphyLanguageGroup group;
+ char *title;
+}
+lang_group_names[] =
+{
+ { LG_ARABIC, N_("_Arabic") },
+ { LG_BALTIC, N_("_Baltic") },
+ { LG_CENTRAL_EUROPEAN, N_("Central _European") },
+ { LG_CHINESE, N_("Chi_nese") },
+ { LG_CYRILLIC, N_("_Cyrillic") },
+ { LG_GREEK, N_("_Greek") },
+ { LG_HEBREW, N_("_Hebrew") },
+ { LG_INDIAN, N_("_Indian") },
+ { LG_JAPANESE, N_("_Japanese") },
+ { LG_KOREAN, N_("_Korean") },
+ { LG_TURKISH, N_("_Turkish") },
+ { LG_UNICODE, N_("_Unicode") },
+ { LG_VIETNAMESE, N_("_Vietnamese") },
+ { LG_WESTERN, N_("_Western") },
+ { LG_OTHER, N_("_Other") }
+};
+static const guint n_lang_group_names = G_N_ELEMENTS (lang_group_names);
+
void
-language_group_info_free (LanguageGroupInfo *info)
+ephy_lang_group_info_free (EphyLanguageGroupInfo *info)
{
g_return_if_fail (info != NULL);
@@ -55,26 +88,75 @@ language_group_info_free (LanguageGroupInfo *info)
g_free (info);
}
-void
-encoding_info_free (EncodingInfo *info)
+static gint
+lang_group_info_cmp (const EphyLanguageGroupInfo *i1, const EphyLanguageGroupInfo *i2)
{
- g_return_if_fail (info != NULL);
+ return strcmp (i1->key, i2->key);
+}
- g_free (info->title);
- g_free (info->key);
- g_free (info->encoding);
+GList *
+ephy_lang_get_group_list (void)
+{
+ GList *list = NULL;
+ guint i;
- g_free (info);
+ for (i = 0; i < n_lang_group_names; i++)
+ {
+ EphyLanguageGroupInfo *info;
+ char *elided = NULL;
+
+ info = g_new0 (EphyLanguageGroupInfo, 1);
+
+ info->title = g_strdup (_(lang_group_names[i].title));
+ info->group = lang_group_names[i].group;
+
+ /* collate without underscores */
+ elided = ephy_string_elide_underscores (info->title);
+ info->key = g_utf8_collate_key (elided, -1);
+ g_free (elided);
+
+ list = g_list_prepend (list, info);
+ }
+
+ return g_list_sort (list, (GCompareFunc) lang_group_info_cmp);
+}
+
+static int
+fonts_language_info_cmp (const FontsLanguageInfo *i1, const FontsLanguageInfo *i2)
+{
+ return g_utf8_collate (i1->title, i2->title);
}
-guint
-ephy_langs_get_n_font_languages (void)
+GList *
+ephy_font_langs_get_codes_list (void)
{
- return n_font_languages;
+ guint i;
+ GList *list = NULL;
+
+ for (i=0; i < n_font_languages; i++)
+ {
+ list = g_list_prepend (list, font_languages[i].code);
+ }
+
+ return list;
}
-const FontsLanguageInfo *
-ephy_langs_get_font_languages (void)
+GList *
+ephy_font_langs_get_list (void)
{
- return font_languages;
+ GList *list = NULL;
+ guint i;
+
+ for (i = 0; i < n_font_languages; i++)
+ {
+ FontsLanguageInfo *info;
+
+ info = g_new0 (FontsLanguageInfo, 1);
+ info->title = _(font_languages[i].title);
+ info->code = font_languages[i].code;
+
+ list = g_list_prepend (list, info);
+ }
+
+ return g_list_sort (list, (GCompareFunc) fonts_language_info_cmp);
}