aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--ChangeLog29
-rw-r--r--embed/ephy-embed-single.c24
-rw-r--r--embed/ephy-embed-single.h15
-rw-r--r--embed/ephy-embed-utils.c23
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp222
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp43
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/ephy-encodings.c183
-rw-r--r--lib/ephy-encodings.h45
-rw-r--r--lib/ephy-langs.c144
-rw-r--r--lib/ephy-langs.h32
-rw-r--r--src/ephy-encoding-menu.c42
-rw-r--r--src/prefs-dialog.c52
13 files changed, 439 insertions, 417 deletions
diff --git a/ChangeLog b/ChangeLog
index 4096a1bc0..49c0406b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+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.
+
2003-10-13 Marco Pesenti Gritti <marco@gnome.org>
* data/art/Makefile.am:
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index 83c60026a..d09377552 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -18,7 +18,9 @@
* $Id$
*/
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "ephy-embed-shell.h"
#include "ephy-marshal.h"
@@ -35,7 +37,6 @@ enum
LAST_SIGNAL
};
-
#define EPHY_EMBED_SINGLE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED_SINGLE, EphyEmbedSinglePrivate))
struct EphyEmbedSinglePrivate
@@ -139,24 +140,6 @@ ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell,
}
gresult
-ephy_embed_single_get_encodings (EphyEmbedSingle *shell,
- LanguageGroup group,
- gboolean elide_underscores,
- GList **encodings)
-{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- return klass->get_encodings (shell, group, elide_underscores, encodings);
-}
-
-gresult
-ephy_embed_single_get_language_groups (EphyEmbedSingle *shell,
- GList **groups)
-{
- EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell);
- return klass->get_language_groups (shell, groups);
-}
-
-gresult
ephy_embed_single_get_font_list (EphyEmbedSingle *shell,
const char *langGroup,
GList **fontList)
@@ -277,4 +260,3 @@ ephy_embed_single_free_passwords (EphyEmbedSingle *shell,
return G_OK;
}
-
diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h
index 4ef689d3f..9a6e5e873 100644
--- a/embed/ephy-embed-single.h
+++ b/embed/ephy-embed-single.h
@@ -119,12 +119,6 @@ struct EphyEmbedSingleClass
const char* url);
gresult (* show_java_console) (EphyEmbedSingle *shell);
gresult (* show_js_console) (EphyEmbedSingle *shell);
- gresult (* get_language_groups) (EphyEmbedSingle *shell,
- GList **groups);
- gresult (* get_encodings) (EphyEmbedSingle *shell,
- LanguageGroup group,
- gboolean elide_underscores,
- GList **encodings);
gresult (* get_font_list) (EphyEmbedSingle *shell,
const char *langGroup,
GList **fontList);
@@ -159,15 +153,6 @@ gresult ephy_embed_single_set_offline_mode (EphyEmbedSingle *shell,
gresult ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell,
const char* url);
-/* Encodings */
-gresult ephy_embed_single_get_language_groups (EphyEmbedSingle *shell,
- GList **groups);
-
-gresult ephy_embed_single_get_encodings (EphyEmbedSingle *shell,
- LanguageGroup group,
- gboolean elide_underscores,
- GList **encodings);
-
gresult ephy_embed_single_get_font_list (EphyEmbedSingle *shell,
const char *langGroup,
GList **fontList);
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index ff3dcbef5..5da187c89 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -29,6 +29,7 @@
#include "ephy-gui.h"
#include "ephy-debug.h"
#include "ephy-langs.h"
+#include "ephy-encodings.h"
#include <gtk/gtkdialog.h>
#include <gtk/gtkmessagedialog.h>
@@ -210,34 +211,26 @@ ephy_embed_utils_build_encodings_submenu (BonoboUIComponent *ui_component,
GString *xml_string;
GList *groups, *gl, *encodings, *l;
GList *verbs = NULL;
- EphyEmbedSingle *single;
-
- single = ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (embed_shell));
- g_return_if_fail (EPHY_IS_EMBED_SHELL (embed_shell));
START_PROFILER ("Encodings menu")
- ephy_embed_single_get_language_groups (single, &groups);
- g_return_if_fail (groups != NULL);
-
xml_string = g_string_new (NULL);
g_string_append (xml_string, "<submenu name=\"Encoding\" _label=\"_Encoding\">");
+ groups = ephy_lang_get_group_list ();
for (gl = groups; gl != NULL; gl = gl->next)
{
- const LanguageGroupInfo *lang_info = (LanguageGroupInfo *) gl->data;
+ const EphyLanguageGroupInfo *lang_info = (EphyLanguageGroupInfo *) gl->data;
tmp = g_strdup_printf ("<submenu label=\"%s\" name=\"EncodingGroup%d\">\n",
lang_info->title, lang_info->group);
xml_string = g_string_append (xml_string, tmp);
g_free (tmp);
- ephy_embed_single_get_encodings (single, lang_info->group,
- FALSE, &encodings);
-
+ encodings = ephy_encodings_get_list (lang_info->group, FALSE);
for (l = encodings; l != NULL; l = l->next)
{
- const EncodingInfo *info = (EncodingInfo *) l->data;
+ const EphyEncodingInfo *info = (EphyEncodingInfo *) l->data;
verb = g_strdup_printf ("Encoding%s", info->encoding);
tmp = g_strdup_printf ("<menuitem label=\"%s\" name=\"%s\" verb=\"%s\"/>\n",
@@ -249,13 +242,13 @@ ephy_embed_utils_build_encodings_submenu (BonoboUIComponent *ui_component,
g_free (tmp);
}
- g_list_foreach (encodings, (GFunc) encoding_info_free, NULL);
+ g_list_foreach (encodings, (GFunc) ephy_encoding_info_free, NULL);
g_list_free (encodings);
g_string_append (xml_string, "</submenu>");
}
- g_list_foreach (groups, (GFunc) language_group_info_free, NULL);
+ g_list_foreach (groups, (GFunc) ephy_lang_group_info_free, NULL);
g_list_free (groups);
g_string_append (xml_string, "</submenu>");
@@ -263,8 +256,6 @@ ephy_embed_utils_build_encodings_submenu (BonoboUIComponent *ui_component,
bonobo_ui_component_set_translate (ui_component, path,
xml_string->str, NULL);
- verbs = g_list_reverse (verbs);
-
for (l = verbs; l != NULL; l = l->next)
{
bonobo_ui_component_add_verb (ui_component,
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 6491ce33d..8f1ce3939 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -23,7 +23,6 @@
#endif
#include "glib.h"
-#include "ephy-string.h"
#include "ephy-debug.h"
#include "gtkmozembed.h"
#include "mozilla-embed-single.h"
@@ -39,7 +38,6 @@
#include <time.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomevfs/gnome-vfs-utils.h>
-#include <string.h>
#include <nsICacheService.h>
#include <nsCOMPtr.h>
#include <nsIPrefService.h>
@@ -67,128 +65,6 @@
#define MOZILLA_PROFILE_FILE "prefs.js"
#define DEFAULT_PROFILE_FILE SHARE_DIR"/default-prefs.js"
-/* language groups names */
-static const
-struct
-{
- gchar *title;
- LanguageGroup group;
-}
-lang_groups[] =
-{
- { N_("_Arabic"), LG_ARABIC },
- { N_("_Baltic"), LG_BALTIC },
- { N_("Central _European"), LG_CENTRAL_EUROPEAN },
- { N_("Chi_nese"), LG_CHINESE },
- { N_("_Cyrillic"), LG_CYRILLIC },
- { N_("_Greek"), LG_GREEK },
- { N_("_Hebrew"), LG_HEBREW },
- { N_("_Indian"), LG_INDIAN },
- { N_("_Japanese"), LG_JAPANESE },
- { N_("_Korean"), LG_KOREAN },
- { N_("_Turkish"), LG_TURKISH },
- { N_("_Unicode"), LG_UNICODE },
- { N_("_Vietnamese"), LG_VIETNAMESE },
- { N_("_Western"), LG_WESTERN },
- { N_("_Other"), LG_OTHER }
-};
-static const guint n_lang_groups = G_N_ELEMENTS (lang_groups);
-
-/**
- * translatable encodings titles
- * NOTE: if you add /change encodings, please also update the schema file
- * epiphany.schemas.in
- */
-static const
-struct
-{
- gchar *title;
- gchar *name;
- LanguageGroup group;
-}
-encodings[] =
-{
- /* translators: access keys need only be unique within the same LG_group */
- { N_("Arabic (_IBM-864)"), "IBM864", LG_ARABIC },
- { N_("Arabic (ISO-_8859-6)"), "ISO-8859-6", LG_ARABIC },
- { N_("Arabic (_MacArabic)"), "x-mac-arabic", LG_ARABIC },
- { N_("Arabic (_Windows-1256)"), "windows-1256", LG_ARABIC },
- { N_("Baltic (_ISO-8859-13)"), "ISO-8859-13", LG_BALTIC },
- { N_("Baltic (I_SO-8859-4)"), "ISO-8859-4", LG_BALTIC },
- { N_("Baltic (_Windows-1257)"), "windows-1257", LG_BALTIC },
- { N_("Central European (_IBM-852)"), "IBM852", LG_CENTRAL_EUROPEAN },
- { N_("Central European (I_SO-8859-2)"), "ISO-8859-2", LG_CENTRAL_EUROPEAN },
- { N_("Central European (_MacCE)"), "x-mac-ce", LG_CENTRAL_EUROPEAN },
- { N_("Central European (_Windows-1250)"), "windows-1250", LG_CENTRAL_EUROPEAN },
- { N_("Croatian (Mac_Croatian)"), "x-mac-croatian", LG_CENTRAL_EUROPEAN },
- { N_("Chinese Simplified (_GB18030)"), "gb18030", LG_CHINESE },
- { N_("Chinese Simplified (G_B2312)"), "GB2312", LG_CHINESE },
- { N_("Chinese Simplified (GB_K)"), "x-gbk", LG_CHINESE },
- { N_("Chinese Simplified (_HZ)"), "HZ-GB-2312", LG_CHINESE },
- { N_("Chinese Simplified (_ISO-2022-CN)"), "ISO-2022-CN", LG_CHINESE },
- { N_("Chinese Traditional (Big_5)"), "Big5", LG_CHINESE },
- { N_("Chinese Traditional (Big5-HK_SCS)"), "Big5-HKSCS", LG_CHINESE },
- { N_("Chinese Traditional (_EUC-TW)"), "x-euc-tw", LG_CHINESE },
- { N_("Cyrillic (_IBM-855)"), "IBM855", LG_CYRILLIC },
- { N_("Cyrillic (I_SO-8859-5)"), "ISO-8859-5", LG_CYRILLIC },
- { N_("Cyrillic (IS_O-IR-111)"), "ISO-IR-111", LG_CYRILLIC },
- { N_("Cyrillic (_KOI8-R)"), "KOI8-R", LG_CYRILLIC },
- { N_("Cyrillic (_MacCyrillic)"), "x-mac-cyrillic", LG_CYRILLIC },
- { N_("Cyrillic (_Windows-1251)"), "windows-1251", LG_CYRILLIC },
- { N_("Cyrillic/Russian (_CP-866)"), "IBM866", LG_CYRILLIC },
- { N_("Cyrillic/Ukrainian (_KOI8-U)"), "KOI8-U", LG_CYRILLIC },
- { N_("Cyrillic/Ukrainian (Mac_Ukrainian)"), "x-mac-ukrainian", LG_CYRILLIC },
- { N_("Greek (_ISO-8859-7)"), "ISO-8859-7", LG_GREEK },
- { N_("Greek (_MacGreek)"), "x-mac-greek", LG_GREEK },
- { N_("Greek (_Windows-1253)"), "windows-1253", LG_GREEK },
- { N_("Gujarati (_MacGujarati)"), "x-mac-gujarati", LG_INDIAN },
- { N_("Gurmukhi (Mac_Gurmukhi)"), "x-mac-gurmukhi", LG_INDIAN },
- { N_("Hindi (Mac_Devanagari)"), "x-mac-devanagari", LG_INDIAN },
- { N_("Hebrew (_IBM-862)"), "IBM862", LG_HEBREW },
- { N_("Hebrew (IS_O-8859-8-I)"), "ISO-8859-8-I", LG_HEBREW },
- { N_("Hebrew (_MacHebrew)"), "x-mac-hebrew", LG_HEBREW },
- { N_("Hebrew (_Windows-1255)"), "windows-1255", LG_HEBREW },
- { N_("_Visual Hebrew (ISO-8859-8)"), "ISO-8859-8", LG_HEBREW },
- { N_("Japanese (_EUC-JP)"), "EUC-JP", LG_JAPANESE },
- { N_("Japanese (_ISO-2022-JP)"), "ISO-2022-JP", LG_JAPANESE },
- { N_("Japanese (_Shift-JIS)"), "Shift_JIS", LG_JAPANESE },
- { N_("Korean (_EUC-KR)"), "EUC-KR", LG_KOREAN },
- { N_("Korean (_ISO-2022-KR)"), "ISO-2022-KR", LG_KOREAN },
- { N_("Korean (_JOHAB)"), "x-johab", LG_KOREAN },
- { N_("Korean (_UHC)"), "x-windows-949", LG_KOREAN },
- { N_("Turkish (_IBM-857)"), "IBM857", LG_TURKISH },
- { N_("Turkish (I_SO-8859-9)"), "ISO-8859-9", LG_TURKISH },
- { N_("Turkish (_MacTurkish)"), "x-mac-turkish", LG_TURKISH },
- { N_("Turkish (_Windows-1254)"), "windows-1254", LG_TURKISH },
- { N_("Unicode (UTF-_7)"), "UTF-7", LG_UNICODE },
- { N_("Unicode (UTF-_8)"), "UTF-8", LG_UNICODE },
- { N_("Vietnamese (_TCVN)"), "x-viet-tcvn5712", LG_VIETNAMESE },
- { N_("Vietnamese (_VISCII)"), "VISCII", LG_VIETNAMESE },
- { N_("Vietnamese (V_PS)"), "x-viet-vps", LG_VIETNAMESE },
- { N_("Vietnamese (_Windows-1258)"), "windows-1258", LG_VIETNAMESE },
- { N_("Western (_IBM-850)"), "IBM850", LG_WESTERN },
- { N_("Western (I_SO-8859-1)"), "ISO-8859-1", LG_WESTERN },
- { N_("Western (IS_O-8859-15)"), "ISO-8859-15", LG_WESTERN },
- { N_("Western (_MacRoman)"), "x-mac-roman", LG_WESTERN },
- { N_("Western (_Windows-1252)"), "windows-1252", LG_WESTERN },
- { N_("_Armenian (ARMSCII-8)"), "armscii-8", LG_OTHER },
- { N_("_Celtic (ISO-8859-14)"), "ISO-8859-14", LG_OTHER },
- { N_("_Farsi (MacFarsi)"), "x-mac-farsi", LG_OTHER },
- { N_("_Georgian (GEOSTD8)"), "geostd8", LG_OTHER },
- { N_("_Icelandic (MacIcelandic)"), "x-mac-icelandic", LG_OTHER },
- { N_("_Nordic (ISO-8859-10)"), "ISO-8859-10", LG_OTHER },
- { N_("_Romanian (MacRomanian)"), "x-mac-romanian", LG_OTHER },
- { N_("R_omanian (ISO-8859-16)"), "ISO-8859-16", LG_OTHER },
- { N_("South _European (ISO-8859-3)"), "ISO-8859-3", LG_OTHER },
- { N_("Thai (TIS-_620)"), "TIS-620", LG_OTHER },
-#if MOZILLA_SNAPSHOT >= 10
- { N_("Thai (IS_O-8859-11)"), "iso-8859-11", LG_OTHER },
- { N_("_Thai (Windows-874)"), "windows-874", LG_OTHER },
-#endif
- { N_("_User Defined"), "x-user-defined", LG_OTHER },
-};
-static const guint n_encodings = G_N_ELEMENTS (encodings);
-
static void
mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass);
static void
@@ -204,14 +80,6 @@ impl_set_offline_mode (EphyEmbedSingle *shell,
static gresult
impl_load_proxy_autoconf (EphyEmbedSingle *shell,
const char* url);
-static gresult
-impl_get_encodings (EphyEmbedSingle *shell,
- LanguageGroup group,
- gboolean elide_underscores,
- GList **encodings_list);
-static gresult
-impl_get_language_groups (EphyEmbedSingle *shell,
- GList **groups);
static gresult
impl_get_font_list (EphyEmbedSingle *shell,
const char *langGroup,
@@ -299,8 +167,6 @@ mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass)
shell_class->clear_cache = impl_clear_cache;
shell_class->set_offline_mode = impl_set_offline_mode;
shell_class->load_proxy_autoconf = impl_load_proxy_autoconf;
- shell_class->get_encodings = impl_get_encodings;
- shell_class->get_language_groups = impl_get_language_groups;
shell_class->get_font_list = impl_get_font_list;
shell_class->list_cookies = impl_list_cookies;
shell_class->remove_cookies = impl_remove_cookies;
@@ -718,94 +584,6 @@ impl_load_proxy_autoconf (EphyEmbedSingle *shell,
return G_OK;
}
-static gint
-encoding_info_cmp (const EncodingInfo *i1, const EncodingInfo *i2)
-{
- return strcmp (i1->key, i2->key);
-}
-
-static gresult
-impl_get_encodings (EphyEmbedSingle *shell,
- LanguageGroup group,
- gboolean elide_underscores,
- GList **encodings_list)
-{
- GList *l = NULL;
- guint i;
-
- for (i = 0; i < n_encodings; i++)
- {
- if (group == LG_ALL || group == encodings[i].group)
- {
- EncodingInfo *info;
- gchar *elided = NULL;
-
- info = g_new0 (EncodingInfo, 1);
-
- info->encoding = g_strdup (encodings[i].name);
-
- elided = ephy_string_elide_underscores (_(encodings[i].title));
-
- if (elide_underscores)
- {
- info->title = g_strdup (elided);
- }
- else
- {
- info->title = g_strdup (_(encodings[i].title));
- }
-
- /* collate without underscores */
- info->key = g_utf8_collate_key (elided, -1);
-
- info->group = encodings[i].group;
-
- l = g_list_prepend (l, info);
- g_free (elided);
- }
- }
-
- *encodings_list = g_list_sort (l, (GCompareFunc) encoding_info_cmp);
-
- return G_OK;
-}
-
-static gint
-language_group_info_cmp (const LanguageGroupInfo *i1, const LanguageGroupInfo *i2)
-{
- return strcmp (i1->key, i2->key);
-}
-
-static gresult
-impl_get_language_groups (EphyEmbedSingle *shell,
- GList **groups)
-{
- GList *l = NULL;
- guint i;
-
- for (i = 0; i < n_lang_groups; i++)
- {
- LanguageGroupInfo *info;
- gchar *elided = NULL;
-
- info = g_new0 (LanguageGroupInfo, 1);
-
- info->title = g_strdup (_(lang_groups[i].title));
- info->group = lang_groups[i].group;
-
- /* collate without underscores */
- elided = ephy_string_elide_underscores (info->title);
- info->key = g_utf8_collate_key (elided, -1);
- g_free (elided);
-
- l = g_list_prepend (l, info);
- }
-
- *groups = g_list_sort (l, (GCompareFunc) language_group_info_cmp);
-
- return G_OK;
-}
-
static gresult
impl_get_font_list (EphyEmbedSingle *shell,
const char *langGroup,
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index 28049013b..0b170b555 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -387,8 +387,7 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
{
GConfClient *client = eel_gconf_client_get_global ();
guint i;
- guint n_fonts_languages;
- const FontsLanguageInfo *fonts_language;
+ GList *codes, *l;
for (i = 0; conversion_table[i].gconf_key != NULL; i++)
{
@@ -426,10 +425,10 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
}
/* fonts notifiers */
- n_fonts_languages = ephy_langs_get_n_font_languages ();
- fonts_language = ephy_langs_get_font_languages ();
- for (i = 0; i < n_fonts_languages; i++)
+ codes = ephy_font_langs_get_codes_list ();
+ for (l = codes; l != NULL; l = l->next)
{
+ const char *code = (char*) l->data;
guint k;
char *types [] = { "variable", "monospace" };
char key[255];
@@ -437,52 +436,46 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
for (k = 0; k < G_N_ELEMENTS (types); k++)
{
- info = g_strconcat (types[k], ".", fonts_language[i].code, NULL);
+ info = g_strconcat (types[k], ".", code, NULL);
g_snprintf (key, 255, "%s_%s_%s", CONF_RENDERING_FONT,
- types[k],
- fonts_language[i].code);
+ types[k], code);
add_notification_and_notify (client, key,
(GConfClientNotifyFunc)mozilla_font_notifier,
info);
- font_infos = g_list_append (font_infos, info);
+ font_infos = g_list_prepend (font_infos, info);
}
- g_snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_MIN_SIZE, fonts_language[i].code);
- info = g_strconcat ("minimum-size", ".", fonts_language[i].code, NULL);
+ g_snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_MIN_SIZE, code);
+ info = g_strconcat ("minimum-size", ".", code, NULL);
add_notification_and_notify (client, key,
(GConfClientNotifyFunc)mozilla_font_size_notifier,
info);
- font_infos = g_list_append (font_infos, info);
+ font_infos = g_list_prepend (font_infos, info);
- g_snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_FIXED_SIZE, fonts_language[i].code);
- info = g_strconcat ("size.fixed", ".", fonts_language[i].code, NULL);
+ g_snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_FIXED_SIZE, code);
+ info = g_strconcat ("size.fixed", ".", code, NULL);
add_notification_and_notify (client, key,
(GConfClientNotifyFunc)mozilla_font_size_notifier,
info);
- font_infos = g_list_append (font_infos, info);
+ font_infos = g_list_prepend (font_infos, info);
- g_snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_VAR_SIZE, fonts_language[i].code);
- info = g_strconcat ("size.variable", ".", fonts_language[i].code, NULL);
+ g_snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_VAR_SIZE, code);
+ info = g_strconcat ("size.variable", ".", code, NULL);
add_notification_and_notify (client, key,
(GConfClientNotifyFunc)mozilla_font_size_notifier,
info);
- font_infos = g_list_append (font_infos, info);
+ font_infos = g_list_prepend (font_infos, info);
}
+ g_list_free (codes);
}
void
mozilla_notifiers_free (void)
{
- GList *l;
-
ephy_notification_remove (&mozilla_notifiers);
- for (l = font_infos; l != NULL; l = l->next)
- {
- g_free (l->data);
- }
-
+ g_list_foreach (font_infos, (GFunc) g_free, NULL);
g_list_free (font_infos);
}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7caefb55d..64c469144 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -35,6 +35,7 @@ NOINST_H_FILES = \
INST_H_FILES = \
ephy-dialog.h \
ephy-langs.h \
+ ephy-encodings.h \
ephy-node.h \
ephy-node-db.h \
ephy-types.h
@@ -50,6 +51,7 @@ libephy_la_SOURCES = \
ephy-dialog.h \
ephy-dnd.c \
ephy-dnd.h \
+ ephy-encodings.c \
ephy-file-helpers.c \
ephy-file-helpers.h \
ephy-glade.c \
diff --git a/lib/ephy-encodings.c b/lib/ephy-encodings.c
new file mode 100644
index 000000000..c02705c72
--- /dev/null
+++ b/lib/ephy-encodings.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 2003 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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"
+#endif
+
+#include "ephy-encodings.h"
+#include "ephy-string.h"
+#include <bonobo/bonobo-i18n.h>
+#include <string.h>
+
+/**
+ * translatable encodings titles
+ * NOTE: if you add /change encodings, please also update the schema file
+ * epiphany.schemas.in
+ */
+static const
+struct
+{
+ char *title;
+ char *name;
+ EphyLanguageGroup group;
+}
+encodings[] =
+{
+ /* translators: access keys need only be unique within the same LG_group */
+ { N_("Arabic (_IBM-864)"), "IBM864", LG_ARABIC },
+ { N_("Arabic (ISO-_8859-6)"), "ISO-8859-6", LG_ARABIC },
+ { N_("Arabic (_MacArabic)"), "x-mac-arabic", LG_ARABIC },
+ { N_("Arabic (_Windows-1256)"), "windows-1256", LG_ARABIC },
+ { N_("Baltic (_ISO-8859-13)"), "ISO-8859-13", LG_BALTIC },
+ { N_("Baltic (I_SO-8859-4)"), "ISO-8859-4", LG_BALTIC },
+ { N_("Baltic (_Windows-1257)"), "windows-1257", LG_BALTIC },
+ { N_("Central European (_IBM-852)"), "IBM852", LG_CENTRAL_EUROPEAN },
+ { N_("Central European (I_SO-8859-2)"), "ISO-8859-2", LG_CENTRAL_EUROPEAN },
+ { N_("Central European (_MacCE)"), "x-mac-ce", LG_CENTRAL_EUROPEAN },
+ { N_("Central European (_Windows-1250)"), "windows-1250", LG_CENTRAL_EUROPEAN },
+ { N_("Croatian (Mac_Croatian)"), "x-mac-croatian", LG_CENTRAL_EUROPEAN },
+ { N_("Chinese Simplified (_GB18030)"), "gb18030", LG_CHINESE },
+ { N_("Chinese Simplified (G_B2312)"), "GB2312", LG_CHINESE },
+ { N_("Chinese Simplified (GB_K)"), "x-gbk", LG_CHINESE },
+ { N_("Chinese Simplified (_HZ)"), "HZ-GB-2312", LG_CHINESE },
+ { N_("Chinese Simplified (_ISO-2022-CN)"), "ISO-2022-CN", LG_CHINESE },
+ { N_("Chinese Traditional (Big_5)"), "Big5", LG_CHINESE },
+ { N_("Chinese Traditional (Big5-HK_SCS)"), "Big5-HKSCS", LG_CHINESE },
+ { N_("Chinese Traditional (_EUC-TW)"), "x-euc-tw", LG_CHINESE },
+ { N_("Cyrillic (_IBM-855)"), "IBM855", LG_CYRILLIC },
+ { N_("Cyrillic (I_SO-8859-5)"), "ISO-8859-5", LG_CYRILLIC },
+ { N_("Cyrillic (IS_O-IR-111)"), "ISO-IR-111", LG_CYRILLIC },
+ { N_("Cyrillic (_KOI8-R)"), "KOI8-R", LG_CYRILLIC },
+ { N_("Cyrillic (_MacCyrillic)"), "x-mac-cyrillic", LG_CYRILLIC },
+ { N_("Cyrillic (_Windows-1251)"), "windows-1251", LG_CYRILLIC },
+ { N_("Cyrillic/Russian (_CP-866)"), "IBM866", LG_CYRILLIC },
+ { N_("Cyrillic/Ukrainian (_KOI8-U)"), "KOI8-U", LG_CYRILLIC },
+ { N_("Cyrillic/Ukrainian (Mac_Ukrainian)"), "x-mac-ukrainian", LG_CYRILLIC },
+ { N_("Greek (_ISO-8859-7)"), "ISO-8859-7", LG_GREEK },
+ { N_("Greek (_MacGreek)"), "x-mac-greek", LG_GREEK },
+ { N_("Greek (_Windows-1253)"), "windows-1253", LG_GREEK },
+ { N_("Gujarati (_MacGujarati)"), "x-mac-gujarati", LG_INDIAN },
+ { N_("Gurmukhi (Mac_Gurmukhi)"), "x-mac-gurmukhi", LG_INDIAN },
+ { N_("Hindi (Mac_Devanagari)"), "x-mac-devanagari", LG_INDIAN },
+ { N_("Hebrew (_IBM-862)"), "IBM862", LG_HEBREW },
+ { N_("Hebrew (IS_O-8859-8-I)"), "ISO-8859-8-I", LG_HEBREW },
+ { N_("Hebrew (_MacHebrew)"), "x-mac-hebrew", LG_HEBREW },
+ { N_("Hebrew (_Windows-1255)"), "windows-1255", LG_HEBREW },
+ { N_("_Visual Hebrew (ISO-8859-8)"), "ISO-8859-8", LG_HEBREW },
+ { N_("Japanese (_EUC-JP)"), "EUC-JP", LG_JAPANESE },
+ { N_("Japanese (_ISO-2022-JP)"), "ISO-2022-JP", LG_JAPANESE },
+ { N_("Japanese (_Shift-JIS)"), "Shift_JIS", LG_JAPANESE },
+ { N_("Korean (_EUC-KR)"), "EUC-KR", LG_KOREAN },
+ { N_("Korean (_ISO-2022-KR)"), "ISO-2022-KR", LG_KOREAN },
+ { N_("Korean (_JOHAB)"), "x-johab", LG_KOREAN },
+ { N_("Korean (_UHC)"), "x-windows-949", LG_KOREAN },
+ { N_("Turkish (_IBM-857)"), "IBM857", LG_TURKISH },
+ { N_("Turkish (I_SO-8859-9)"), "ISO-8859-9", LG_TURKISH },
+ { N_("Turkish (_MacTurkish)"), "x-mac-turkish", LG_TURKISH },
+ { N_("Turkish (_Windows-1254)"), "windows-1254", LG_TURKISH },
+ { N_("Unicode (UTF-_7)"), "UTF-7", LG_UNICODE },
+ { N_("Unicode (UTF-_8)"), "UTF-8", LG_UNICODE },
+ { N_("Vietnamese (_TCVN)"), "x-viet-tcvn5712", LG_VIETNAMESE },
+ { N_("Vietnamese (_VISCII)"), "VISCII", LG_VIETNAMESE },
+ { N_("Vietnamese (V_PS)"), "x-viet-vps", LG_VIETNAMESE },
+ { N_("Vietnamese (_Windows-1258)"), "windows-1258", LG_VIETNAMESE },
+ { N_("Western (_IBM-850)"), "IBM850", LG_WESTERN },
+ { N_("Western (I_SO-8859-1)"), "ISO-8859-1", LG_WESTERN },
+ { N_("Western (IS_O-8859-15)"), "ISO-8859-15", LG_WESTERN },
+ { N_("Western (_MacRoman)"), "x-mac-roman", LG_WESTERN },
+ { N_("Western (_Windows-1252)"), "windows-1252", LG_WESTERN },
+ { N_("_Armenian (ARMSCII-8)"), "armscii-8", LG_OTHER },
+ { N_("_Celtic (ISO-8859-14)"), "ISO-8859-14", LG_OTHER },
+ { N_("_Farsi (MacFarsi)"), "x-mac-farsi", LG_OTHER },
+ { N_("_Georgian (GEOSTD8)"), "geostd8", LG_OTHER },
+ { N_("_Icelandic (MacIcelandic)"), "x-mac-icelandic", LG_OTHER },
+ { N_("_Nordic (ISO-8859-10)"), "ISO-8859-10", LG_OTHER },
+ { N_("_Romanian (MacRomanian)"), "x-mac-romanian", LG_OTHER },
+ { N_("R_omanian (ISO-8859-16)"), "ISO-8859-16", LG_OTHER },
+ { N_("South _European (ISO-8859-3)"), "ISO-8859-3", LG_OTHER },
+ { N_("Thai (TIS-_620)"), "TIS-620", LG_OTHER },
+#if MOZILLA_SNAPSHOT >= 10
+ { N_("Thai (IS_O-8859-11)"), "iso-8859-11", LG_OTHER },
+ { N_("_Thai (Windows-874)"), "windows-874", LG_OTHER },
+#endif
+ { N_("_User Defined"), "x-user-defined", LG_OTHER },
+};
+static const guint n_encodings = G_N_ELEMENTS (encodings);
+
+void
+ephy_encoding_info_free (EphyEncodingInfo *info)
+{
+ g_return_if_fail (info != NULL);
+
+ g_free (info->title);
+ g_free (info->key);
+ g_free (info->encoding);
+
+ g_free (info);
+}
+
+static int
+encodings_info_cmp (const EphyEncodingInfo *i1, const EphyEncodingInfo *i2)
+{
+ return strcmp (i1->key, i2->key);
+}
+
+GList *
+ephy_encodings_get_list (EphyLanguageGroup group, gboolean elide_underscores)
+{
+ GList *list = NULL;
+ guint i;
+
+ for (i = 0; i < n_encodings; i++)
+ {
+ if (group == LG_ALL || group == encodings[i].group)
+ {
+ EphyEncodingInfo *info;
+ char *elided = NULL;
+
+ info = g_new0 (EphyEncodingInfo, 1);
+
+ info->group = encodings[i].group;
+ info->encoding = g_strdup (encodings[i].name);
+
+ elided = ephy_string_elide_underscores (_(encodings[i].title));
+
+ /* collate without underscores */
+ info->key = g_utf8_collate_key (elided, -1);
+
+ if (elide_underscores)
+ {
+ info->title = elided;
+ }
+ else
+ {
+ g_free (elided);
+
+ info->title = g_strdup (_(encodings[i].title));
+ }
+
+ list = g_list_prepend (list, info);
+ }
+ }
+
+ return g_list_sort (list, (GCompareFunc) encodings_info_cmp);
+}
diff --git a/lib/ephy-encodings.h b/lib/ephy-encodings.h
new file mode 100644
index 000000000..59f14393e
--- /dev/null
+++ b/lib/ephy-encodings.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 2003 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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$
+ */
+
+#ifndef EPHY_ENCODINGS_H
+#define EPHY_ENCODINGS_H
+
+#include <glib.h>
+#include "ephy-langs.h"
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+ char *encoding;
+ EphyLanguageGroup group;
+ char *title;
+ char *key;
+} EphyEncodingInfo;
+
+GList *ephy_encodings_get_list (EphyLanguageGroup group,
+ gboolean elide_underscores);
+
+void ephy_encoding_info_free (EphyEncodingInfo *info);
+
+G_END_DECLS
+
+#endif
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);
}
diff --git a/lib/ephy-langs.h b/lib/ephy-langs.h
index 274d5a8a7..c4007dd73 100644
--- a/lib/ephy-langs.h
+++ b/lib/ephy-langs.h
@@ -46,38 +46,28 @@ typedef enum
LG_WESTERN,
LG_OTHER,
LG_ALL
-} LanguageGroup;
+} EphyLanguageGroup;
typedef struct
{
- gchar *title;
- gchar *key;
- LanguageGroup group;
-} LanguageGroupInfo;
+ EphyLanguageGroup group;
+ char *title;
+ char *key;
+} EphyLanguageGroupInfo;
typedef struct
{
- gchar *title;
- gchar *key;
- gchar *encoding;
- LanguageGroup group;
-} EncodingInfo;
-
-/* language encoding groups */
-typedef struct
-{
- gchar *title;
- gchar* code;
+ char *title;
+ char *code;
} FontsLanguageInfo;
-guint ephy_langs_get_n_font_languages (void);
-
-const FontsLanguageInfo *ephy_langs_get_font_languages (void);
+GList *ephy_font_langs_get_list (void);
-void language_group_info_free (LanguageGroupInfo *info);
+GList *ephy_font_langs_get_codes_list (void);
-void encoding_info_free (EncodingInfo *info);
+GList *ephy_lang_get_group_list (void);
+void ephy_lang_group_info_free (EphyLanguageGroupInfo *info);
G_END_DECLS
diff --git a/src/ephy-encoding-menu.c b/src/ephy-encoding-menu.c
index 2f3596c23..0773a9fc5 100644
--- a/src/ephy-encoding-menu.c
+++ b/src/ephy-encoding-menu.c
@@ -25,8 +25,9 @@
#endif
#include "ephy-encoding-menu.h"
+#include "ephy-langs.h"
+#include "ephy-encodings.h"
#include "ephy-string.h"
-#include "ephy-shell.h"
#include "ephy-debug.h"
#include <bonobo/bonobo-i18n.h>
@@ -174,7 +175,6 @@ update_encoding_menu_cb (GtkAction *dummy, EphyEncodingMenu *menu)
static void
ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
{
- EphyEmbedSingle *single;
GtkActionGroup *action_group;
GtkAction *action;
GList *encodings, *groups, *l;
@@ -188,14 +188,10 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
action_group = gtk_action_group_new ("EncodingActions");
menu->priv->action_group = action_group;
- single = ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (ephy_shell));
- g_return_if_fail (single != NULL);
-
- ephy_embed_single_get_encodings (single, LG_ALL, FALSE, &encodings);
-
+ encodings = ephy_encodings_get_list (LG_ALL, FALSE);
for (l = encodings; l != NULL; l = l->next)
{
- const EncodingInfo *info = (EncodingInfo *) l->data;
+ const EphyEncodingInfo *info = (EphyEncodingInfo *) l->data;
char name[32];
g_snprintf (name, 32, "Encoding%s", info->encoding);
@@ -215,14 +211,13 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
g_object_unref (action);
}
- g_list_foreach (encodings, (GFunc) encoding_info_free, NULL);
+ g_list_foreach (encodings, (GFunc) ephy_encoding_info_free, NULL);
g_list_free (encodings);
- ephy_embed_single_get_language_groups (single, &groups);
-
+ groups = ephy_lang_get_group_list ();
for (l = groups; l != NULL; l = l->next)
{
- const LanguageGroupInfo *info = (LanguageGroupInfo *) l->data;
+ const EphyLanguageGroupInfo *info = (EphyLanguageGroupInfo *) l->data;
char name[32];
g_snprintf (name, 32, "EncodingGroup%d", info->group);
@@ -235,7 +230,7 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
g_object_unref (action);
}
- g_list_foreach (groups, (GFunc) language_group_info_free, NULL);
+ g_list_foreach (groups, (GFunc) ephy_lang_group_info_free, NULL);
g_list_free (groups);
gtk_ui_manager_insert_action_group (menu->priv->manager,
@@ -319,12 +314,8 @@ ephy_encoding_menu_new (EphyWindow *window)
static void
ephy_encoding_menu_rebuild (EphyEncodingMenu *menu)
{
- EphyEmbedSingle *single;
EphyEncodingMenuPrivate *p = menu->priv;
- GList *encodings, *groups, *l;
-
- single = ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (ephy_shell));
- ephy_embed_single_get_language_groups (single, &groups);
+ GList *groups, *l;
if (p->merge_id > 0)
{
@@ -338,11 +329,12 @@ ephy_encoding_menu_rebuild (EphyEncodingMenu *menu)
"ViewEncodingMenu", "ViewEncoding",
GTK_UI_MANAGER_MENU, FALSE);
+ groups = ephy_lang_get_group_list ();
for (l = groups; l != NULL; l = l->next)
{
- const LanguageGroupInfo *info = (LanguageGroupInfo *) l->data;
+ const EphyLanguageGroupInfo *info = (EphyLanguageGroupInfo *) l->data;
char name[32], action[36], path[128];
- GList *enc;
+ GList *encodings, *enc;
g_snprintf (action, 32, "EncodingGroup%d", info->group);
g_snprintf (name, 36, "%sMenu", action);
@@ -353,12 +345,10 @@ ephy_encoding_menu_rebuild (EphyEncodingMenu *menu)
name, action,
GTK_UI_MANAGER_MENU, FALSE);
- ephy_embed_single_get_encodings (single, info->group,
- FALSE, &encodings);
-
+ encodings = ephy_encodings_get_list (info->group, FALSE);
for (enc = encodings; enc != NULL; enc = enc->next)
{
- const EncodingInfo *info = (EncodingInfo *) enc->data;
+ const EphyEncodingInfo *info = (EphyEncodingInfo *) enc->data;
g_snprintf (action, 32, "Encoding%s", info->encoding);
g_snprintf (name, 36, "%sItem", action);
@@ -368,10 +358,10 @@ ephy_encoding_menu_rebuild (EphyEncodingMenu *menu)
GTK_UI_MANAGER_MENUITEM, FALSE);
}
- g_list_foreach (encodings, (GFunc) encoding_info_free, NULL);
+ g_list_foreach (encodings, (GFunc) ephy_encoding_info_free, NULL);
g_list_free (encodings);
}
- g_list_foreach (groups, (GFunc) language_group_info_free, NULL);
+ g_list_foreach (groups, (GFunc) ephy_lang_group_info_free, NULL);
g_list_free (groups);
}
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 0ab2bdbe5..1b0999956 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -32,6 +32,7 @@
#include "eel-gconf-extensions.h"
#include "language-editor.h"
#include "ephy-langs.h"
+#include "ephy-encodings.h"
#include <bonobo/bonobo-i18n.h>
#include <gtk/gtkframe.h>
@@ -382,7 +383,7 @@ prefs_dialog_finalize (GObject *object)
g_list_foreach (pd->priv->langs, (GFunc) free_lang_item, NULL);
g_list_free (pd->priv->langs);
- g_list_foreach (pd->priv->encodings, (GFunc) encoding_info_free, NULL);
+ g_list_foreach (pd->priv->encodings, (GFunc) ephy_encoding_info_free, NULL);
g_list_free (pd->priv->encodings);
g_list_foreach (pd->priv->autodetectors, (GFunc) g_free, NULL);
@@ -418,7 +419,7 @@ static const gchar *
get_current_language_code (PrefsDialog *dialog)
{
GList *lang;
- FontsLanguageInfo *info;
+ const FontsLanguageInfo *info;
lang = g_list_nth (dialog->priv->fonts_languages, dialog->priv->language);
g_assert (lang != NULL);
@@ -629,12 +630,6 @@ setup_size_controls (PrefsDialog *dialog)
setup_size_control (dialog, CONF_RENDERING_FONT_MIN_SIZE, 7, spin);
}
-static gint
-fonts_language_info_cmp (const FontsLanguageInfo *i1, const FontsLanguageInfo *i2)
-{
- return g_utf8_collate (i1->title, i2->title);
-}
-
static void
setup_fonts (PrefsDialog *dialog)
{
@@ -658,33 +653,16 @@ create_fonts_language_menu (PrefsDialog *dialog)
{
GtkWidget *optionmenu, *menu;
GList *l = NULL;
- guint i;
- guint n_fonts_languages;
- const FontsLanguageInfo *fonts_language;
+ guint n_fonts_languages, i = 0;
char **lang_codes;
- n_fonts_languages = ephy_langs_get_n_font_languages ();
- fonts_language = ephy_langs_get_font_languages ();
-
- for (i = 0; i < n_fonts_languages; i++)
- {
- FontsLanguageInfo *info;
-
- info = g_new0 (FontsLanguageInfo, 1);
- info->title = _(fonts_language[i].title);
- info->code = fonts_language[i].code;
-
- l = g_list_prepend (l, info);
- }
-
- l = g_list_sort (l, (GCompareFunc) fonts_language_info_cmp);
- dialog->priv->fonts_languages = l;
-
optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog),
FONTS_LANGUAGE_PROP);
menu = gtk_menu_new ();
+ dialog->priv->fonts_languages = ephy_font_langs_get_list ();
+ n_fonts_languages = g_list_length (dialog->priv->fonts_languages);
for (l = dialog->priv->fonts_languages; l != NULL; l = l->next)
{
FontsLanguageInfo *info = (FontsLanguageInfo *) l->data;
@@ -698,7 +676,6 @@ create_fonts_language_menu (PrefsDialog *dialog)
gtk_option_menu_set_menu (GTK_OPTION_MENU(optionmenu), menu);
lang_codes = g_new0 (char *, n_fonts_languages);
- i = 0;
for (l = dialog->priv->fonts_languages; l != NULL; l = l->next)
{
FontsLanguageInfo *info = (FontsLanguageInfo *) l->data;
@@ -709,6 +686,7 @@ create_fonts_language_menu (PrefsDialog *dialog)
}
ephy_dialog_add_enum (EPHY_DIALOG (dialog), FONTS_LANGUAGE_PROP,
n_fonts_languages, (const char **) lang_codes);
+ /* the entries themselves are const, so don't use g_strfreev here */
g_free (lang_codes);
dialog->priv->language =
@@ -725,18 +703,18 @@ default_encoding_menu_changed_cb (GtkOptionMenu *option_menu,
{
GList *encoding;
gint i;
- EncodingInfo *info;
+ const EphyEncodingInfo *info;
i = gtk_option_menu_get_history (option_menu);
encoding = g_list_nth (dialog->priv->encodings, i);
g_assert (encoding != NULL);
- info = (EncodingInfo *) encoding->data;
+ info = (EphyEncodingInfo *) encoding->data;
eel_gconf_set_string (CONF_LANGUAGE_DEFAULT_ENCODING, info->encoding);
}
static gint
-find_encoding_in_list_cmp (const EncodingInfo *info, const gchar *encoding)
+find_encoding_in_list_cmp (const EphyEncodingInfo *info, const char *encoding)
{
return strcmp (info->encoding, encoding);
}
@@ -747,22 +725,16 @@ create_default_encoding_menu (PrefsDialog *dialog)
GList *l;
GtkWidget *menu, *optionmenu;
gchar *encoding;
- EphyEmbedSingle *single;
-
- single = ephy_embed_shell_get_embed_single
- (EPHY_EMBED_SHELL (ephy_shell));
-
- ephy_embed_single_get_encodings (single, LG_ALL, TRUE,
- &dialog->priv->encodings);
menu = gtk_menu_new ();
optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog),
DEFAULT_ENCODING_PROP);
+ dialog->priv->encodings = ephy_encodings_get_list (LG_ALL, TRUE);
for (l = dialog->priv->encodings; l != NULL; l = l->next)
{
- EncodingInfo *info = (EncodingInfo *) l->data;
+ const EphyEncodingInfo *info = (EphyEncodingInfo *) l->data;
GtkWidget *item;
item = gtk_menu_item_new_with_label (info->title);