diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-05-28 23:43:24 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-05-28 23:43:24 +0800 |
commit | bbda044fa543cce525dd4b585941ea2a6f1f249f (patch) | |
tree | 359c60a50a270a34b843b5d290724775132ce441 /embed | |
parent | 6d3a2386b12ff5505fa9a78a7130240c94df3986 (diff) | |
download | gsoc2013-epiphany-bbda044fa543cce525dd4b585941ea2a6f1f249f.tar.gz gsoc2013-epiphany-bbda044fa543cce525dd4b585941ea2a6f1f249f.tar.zst gsoc2013-epiphany-bbda044fa543cce525dd4b585941ea2a6f1f249f.zip |
continuing checkin of previous patch (cvs aborted "broken pipe")
2003-05-28 Christian Persch <chpe@cvs.gnome.org>
continuing checkin of previous patch (cvs aborted "broken pipe")
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-embed-prefs.h | 4 | ||||
-rw-r--r-- | embed/ephy-embed-single.c | 15 | ||||
-rw-r--r-- | embed/ephy-embed-single.h | 27 | ||||
-rw-r--r-- | embed/ephy-embed-utils.c | 134 | ||||
-rw-r--r-- | embed/ephy-embed-utils.h | 10 | ||||
-rw-r--r-- | embed/ephy-embed.c | 6 | ||||
-rw-r--r-- | embed/ephy-embed.h | 10 | ||||
-rw-r--r-- | embed/mozilla/EphyWrapper.cpp | 4 | ||||
-rw-r--r-- | embed/mozilla/EphyWrapper.h | 2 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 254 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 14 | ||||
-rw-r--r-- | embed/mozilla/mozilla-notifiers.cpp | 50 |
12 files changed, 252 insertions, 278 deletions
diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h index 3ced536ee..7a723f6ca 100644 --- a/embed/ephy-embed-prefs.h +++ b/embed/ephy-embed-prefs.h @@ -16,8 +16,8 @@ #define CONF_SECURITY_JAVA_ENABLED "/apps/epiphany/security/java_enabled" #define CONF_SECURITY_JAVASCRIPT_ENABLED "/apps/epiphany/security/javascript_enabled" #define CONF_SECURITY_COOKIES_ACCEPT "/apps/epiphany/security/cookie_accept" -#define CONF_LANGUAGE_AUTODETECT_CHARSET "/apps/epiphany/rendering/autodetect_charset" -#define CONF_LANGUAGE_DEFAULT_CHARSET "/apps/epiphany/rendering/default_charset" +#define CONF_LANGUAGE_AUTODETECT_ENCODING "/apps/epiphany/rendering/autodetect_encoding" +#define CONF_LANGUAGE_DEFAULT_ENCODING "/apps/epiphany/rendering/default_encoding" #define CONF_RENDERING_DEFAULT_FONT "/apps/epiphany/rendering/default_font" #define CONF_FILTERING_DEFAULT_STATUSBAR "/apps/epiphany/filtering/default_allow_statusbar" diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index dfeaf4c44..0e383499a 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -167,20 +167,21 @@ ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell, } gresult -ephy_embed_single_get_charset_titles (EphyEmbedSingle *shell, - const char *group, - GList **charsets) +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_charset_titles (shell, group, charsets); + return klass->get_encodings (shell, group, elide_underscores, encodings); } gresult -ephy_embed_single_get_charset_groups (EphyEmbedSingle *shell, - GList **groups) +ephy_embed_single_get_language_groups (EphyEmbedSingle *shell, + GList **groups) { EphyEmbedSingleClass *klass = EPHY_EMBED_SINGLE_GET_CLASS (shell); - return klass->get_charset_groups (shell, groups); + return klass->get_language_groups (shell, groups); } gresult diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h index ebd065a92..3d271842e 100644 --- a/embed/ephy-embed-single.h +++ b/embed/ephy-embed-single.h @@ -23,6 +23,7 @@ #include "ephy-favicon-cache.h" #include "ephy-history.h" #include "downloader-view.h" +#include "ephy-langs.h" #include <glib-object.h> #include <glib.h> @@ -82,12 +83,6 @@ typedef struct gchar *username; } PasswordInfo; -typedef struct -{ - const char *name; - const char *title; -} CharsetInfo; - /** * PasswordType: To distinguish actual passwords from blocked password sites */ @@ -134,11 +129,12 @@ struct EphyEmbedSingleClass const char* url); gresult (* show_java_console) (EphyEmbedSingle *shell); gresult (* show_js_console) (EphyEmbedSingle *shell); - gresult (* get_charset_groups) (EphyEmbedSingle *shell, + gresult (* get_language_groups) (EphyEmbedSingle *shell, GList **groups); - gresult (* get_charset_titles) (EphyEmbedSingle *shell, - const char *group, - GList **charsets); + gresult (* get_encodings) (EphyEmbedSingle *shell, + LanguageGroup group, + gboolean elide_underscores, + GList **encodings); gresult (* get_font_list) (EphyEmbedSingle *shell, const char *langGroup, const char *fontType, @@ -178,13 +174,14 @@ gresult ephy_embed_single_set_offline_mode (EphyEmbedSingle *shell, gresult ephy_embed_single_load_proxy_autoconf (EphyEmbedSingle *shell, const char* url); -/* Charsets */ -gresult ephy_embed_single_get_charset_groups (EphyEmbedSingle *shell, +/* Encodings */ +gresult ephy_embed_single_get_language_groups (EphyEmbedSingle *shell, GList **groups); -gresult ephy_embed_single_get_charset_titles (EphyEmbedSingle *shell, - const char *group, - GList **charsets); +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, diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c index 76ddd699e..57ef3beb4 100644 --- a/embed/ephy-embed-utils.c +++ b/embed/ephy-embed-utils.c @@ -26,6 +26,7 @@ #include "ephy-bonobo-extensions.h" #include "ephy-gui.h" #include "ephy-debug.h" +#include "ephy-langs.h" #include <gtk/gtkdialog.h> #include <gtk/gtkmessagedialog.h> @@ -168,129 +169,94 @@ ephy_embed_utils_save (GtkWidget *window, g_free (fileName); } -static void -build_group (GString *xml_string, const char *group, int index) -{ - char *tmp; - - tmp = g_strdup_printf ("<submenu label=\"%s\" name=\"CharsetGroup%d\">\n", - group, index); - xml_string = g_string_append (xml_string, tmp); - g_free (tmp); -} - -static void -build_charset (GString *xml_string, const CharsetInfo *info, int index) -{ - char *tmp; - char *verb; - - verb = g_strdup_printf ("Charset%d", index); - tmp = g_strdup_printf ("<menuitem label=\"%s\" name=\"%s\" verb=\"%s\"/>\n", - info->title, verb, verb); - xml_string = g_string_append (xml_string, tmp); - - g_free (tmp); - g_free (verb); -} - -static void -add_verbs (BonoboUIComponent *ui_component, - BonoboUIVerbFn fn, GList *verbs) -{ - GList *l; - char verb[15]; - int charset_index = 0; - - for (l = verbs; l != NULL; l = l->next) - { - EncodingMenuData *edata = (EncodingMenuData *)l->data; - - sprintf (verb, "Charset%d", charset_index); - charset_index++; - bonobo_ui_component_add_verb_full - (ui_component, verb, - g_cclosure_new (G_CALLBACK (fn), edata, - (GClosureNotify)g_free)); - } -} - /** - * ephy_embed_utils_build_charsets_submenu: + * ephy_embed_utils_build_encodings_submenu: * @ui_component: the parent #BonoboUIComponent * @path: the bonoboui path where to create the submenu. * It's recommended to use a <placeholder/> - * @fn: callback to report the selected charsets + * @fn: callback to report the selected encodings * @data: the data passed to the callback * - * Create a charset submenu using bonobo ui. + * Create a encoding submenu using bonobo ui. **/ void -ephy_embed_utils_build_charsets_submenu (BonoboUIComponent *ui_component, - const char *path, - BonoboUIVerbFn fn, - gpointer data) +ephy_embed_utils_build_encodings_submenu (BonoboUIComponent *ui_component, + const char *path, + BonoboUIVerbFn fn, + gpointer view) { - GList *groups, *gl; + gchar *tmp, *verb; GString *xml_string; + GList *groups, *gl, *encodings, *l; GList *verbs = NULL; - int group_index = 0; - int charset_index = 0; EphyEmbedSingle *single; - single = ephy_embed_shell_get_embed_single - (EPHY_EMBED_SHELL (embed_shell)); - - START_PROFILER ("Charsets menu") - + single = ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (embed_shell)); g_return_if_fail (IS_EPHY_EMBED_SHELL (embed_shell)); - g_return_if_fail (ephy_embed_single_get_charset_groups (single, &groups) == G_OK); + 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\">"); for (gl = groups; gl != NULL; gl = gl->next) { - GList *charsets, *cl; - const char *group = (const char *)gl->data; - - build_group (xml_string, group, group_index); + const LanguageGroupInfo *lang_info = (LanguageGroupInfo *) gl->data; - ephy_embed_single_get_charset_titles (single, - group, - &charsets); + 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); - for (cl = charsets; cl != NULL; cl = cl->next) + ephy_embed_single_get_encodings (single, lang_info->group, + FALSE, &encodings); + + for (l = encodings; l != NULL; l = l->next) { - const CharsetInfo *info = cl->data; - EncodingMenuData *edata; + const EncodingInfo *info = (EncodingInfo *) l->data; - edata = g_new0 (EncodingMenuData, 1); - edata->encoding = info->name; - edata->data = data; - verbs = g_list_append (verbs, edata); + verb = g_strdup_printf ("Encoding%s", info->encoding); + tmp = g_strdup_printf ("<menuitem label=\"%s\" name=\"%s\" verb=\"%s\"/>\n", + info->title, verb, verb); + xml_string = g_string_append (xml_string, tmp); - build_charset (xml_string, info, charset_index); - charset_index++; + verbs = g_list_prepend (verbs, verb); + + g_free (tmp); } + g_list_foreach (encodings, (GFunc) encoding_info_free, NULL); + g_list_free (encodings); - g_list_free (charsets); g_string_append (xml_string, "</submenu>"); - group_index++; } + g_list_foreach (groups, (GFunc) language_group_info_free, NULL); + g_list_free (groups); + g_string_append (xml_string, "</submenu>"); bonobo_ui_component_set_translate (ui_component, path, xml_string->str, NULL); - add_verbs (ui_component, fn, verbs); + verbs = g_list_reverse (verbs); + + for (l = verbs; l != NULL; l = l->next) + { + bonobo_ui_component_add_verb (ui_component, + (const char *) l->data, + fn, view); + } + + g_list_foreach (verbs, (GFunc) g_free, NULL); g_list_free (verbs); - g_list_free (groups); + g_string_free (xml_string, TRUE); - STOP_PROFILER ("Charsets menu") + STOP_PROFILER ("Encodings menu") } /** diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h index c24119828..5ce61cb7e 100644 --- a/embed/ephy-embed-utils.h +++ b/embed/ephy-embed-utils.h @@ -26,22 +26,16 @@ G_BEGIN_DECLS -typedef struct -{ - const char *encoding; - gpointer data; -} EncodingMenuData; - void ephy_embed_utils_save (GtkWidget *window, const char *default_dir_pref, gboolean ask_dest, gboolean with_content, EphyEmbedPersist *persist); -void ephy_embed_utils_build_charsets_submenu (BonoboUIComponent *ui_component, +void ephy_embed_utils_build_encodings_submenu (BonoboUIComponent *ui_component, const char *path, BonoboUIVerbFn fn, - gpointer data); + gpointer view); void ephy_embed_utils_nohandler_dialog_run (GtkWidget *parent); diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index c0858a32f..3360e9e67 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -536,11 +536,11 @@ ephy_embed_find (EphyEmbed *embed, } gresult -ephy_embed_set_charset (EphyEmbed *embed, - const char *charset) +ephy_embed_set_encoding (EphyEmbed *embed, + const char *encoding) { EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed); - return klass->set_charset (embed, charset); + return klass->set_encoding (embed, encoding); } gresult diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index c8e732e09..c4cac0aef 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -64,7 +64,7 @@ typedef enum EMBED_FIND_CAP = 1 << 7, EMBED_SCROLL_CAP = 1 << 8, EMBED_SECURITY_CAP = 1 << 9, - EMBED_CHARSET_CAP = 1 << 10, + EMBED_ENCODING_CAP = 1 << 10, EMBED_SHISTORY_CAP = 1 << 11 } EmbedCapabilities; @@ -272,8 +272,8 @@ struct EphyEmbedClass gresult (* print_preview_navigate) (EphyEmbed *embed, EmbedPrintPreviewNavType navType, gint pageNum); - gresult (* set_charset) (EphyEmbed *embed, - const char *charset); + gresult (* set_encoding) (EphyEmbed *embed, + const char *encoding); }; GType ephy_embed_get_type (void); @@ -386,8 +386,8 @@ gresult ephy_embed_get_security_level (EphyEmbed *embed, gresult ephy_embed_find (EphyEmbed *embed, EmbedFindInfo *find); -gresult ephy_embed_set_charset (EphyEmbed *embed, - const char *charset); +gresult ephy_embed_set_encoding (EphyEmbed *embed, + const char *encoding); /* Printing */ diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp index 7268c4a69..b08447145 100644 --- a/embed/mozilla/EphyWrapper.cpp +++ b/embed/mozilla/EphyWrapper.cpp @@ -714,7 +714,7 @@ nsresult EphyWrapper::CopyHistoryTo (EphyWrapper *dest) return NS_OK; } -nsresult EphyWrapper::ForceCharacterSet (const char *charset) +nsresult EphyWrapper::ForceEncoding (const char *encoding) { nsresult result; @@ -730,7 +730,7 @@ nsresult EphyWrapper::ForceCharacterSet (const char *charset) &result); if (NS_FAILED(result) || !mdv) return NS_ERROR_FAILURE; - result = mdv->SetForceCharacterSet (NS_ConvertUTF8toUCS2(charset).get()); + result = mdv->SetForceCharacterSet (NS_ConvertUTF8toUCS2(encoding).get()); return result; } diff --git a/embed/mozilla/EphyWrapper.h b/embed/mozilla/EphyWrapper.h index d083da44a..dd9d1c228 100644 --- a/embed/mozilla/EphyWrapper.h +++ b/embed/mozilla/EphyWrapper.h @@ -75,7 +75,7 @@ public: nsresult GoToHistoryIndex (PRInt16 index); - nsresult ForceCharacterSet (const char *charset); + nsresult ForceEncoding (const char *encoding); nsresult CanCutSelection(PRBool *result); diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index bc6084d7b..51377f6c8 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -62,56 +62,46 @@ #define MOZILLA_PROFILE_NAME "epiphany" #define MOZILLA_PROFILE_FILE "prefs.js" -/* language groups */ -typedef enum -{ - LG_ARABIC, - LG_BALTIC, - LG_CENTRAL_EUROPEAN, - LG_CHINESE, - LG_CYRILLIC, - LG_GREEK, - LG_HEBREW, - LG_INDIAN, - LG_JAPANESE, - LG_KOREAN, - LG_TURKISH, - LG_UNICODE, - LG_VIETNAMESE, - LG_WESTERN, - LG_OTHER, -} LanguageGroup; - /* language groups names */ -static const gchar *lgroups[] = +static const +struct +{ + gchar *title; + LanguageGroup group; +} +lang_groups[] = { - N_("Arabic"), - N_("Baltic"), - N_("Central European"), - N_("Chinese"), - N_("Cyrillic"), - N_("Greek"), - N_("Hebrew"), - N_("Indian"), - N_("Japanese"), - N_("Korean"), - N_("Turkish"), - N_("Unicode"), - N_("Vietnamese"), - N_("Western"), - N_("Other") + { N_("Arabic"), LG_ARABIC }, + { N_("Baltic"), LG_BALTIC }, + { N_("Central European"), LG_CENTRAL_EUROPEAN }, + { N_("Chinese"), 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_lgroups = G_N_ELEMENTS (lgroups); +static const guint n_lang_groups = G_N_ELEMENTS (lang_groups); -/* translated charset titles */ -static const +/** + * translatable encodings titles + * NOTE: if you add /change encodings, please also update the schema file + * epiphany.schemas.in + */ +static const struct { - gchar *charset_title; - gchar *charset_name; - LanguageGroup lgroup; + gchar *title; + gchar *name; + LanguageGroup group; } -charset_trans_array[] = +encodings[] = { { N_("Arabic (IBM-864)"), "IBM864", LG_ARABIC }, { N_("Arabic (IBM-864-I)"), "IBM864i", LG_ARABIC }, @@ -196,12 +186,12 @@ charset_trans_array[] = { N_("Western (ISO-8859-15)"), "ISO-8859-15", LG_WESTERN }, { N_("Western (MacRoman)"), "x-mac-roman", LG_WESTERN }, { N_("Western (Windows-1252)"), "windows-1252", LG_WESTERN }, - /* charsets whithout posibly translatable names */ + /* encodings whithout posibly translatable names */ { "T.61-8bit", "T.61-8bit", LG_OTHER }, { "x-imap4-modified-utf7", "x-imap4-modified-utf7", LG_UNICODE }, { "x-u-escaped", "x-u-escaped", LG_OTHER } }; -static const guint n_charset_trans_array = G_N_ELEMENTS (charset_trans_array); +static const guint n_encodings = G_N_ELEMENTS (encodings); static void mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass); @@ -220,12 +210,13 @@ static gresult impl_load_proxy_autoconf (EphyEmbedSingle *shell, const char* url); static gresult -impl_get_charset_titles (EphyEmbedSingle *shell, - const char *group, - GList **charsets); +impl_get_encodings (EphyEmbedSingle *shell, + LanguageGroup group, + gboolean elide_underscores, + GList **encodings_list); static gresult -impl_get_charset_groups (EphyEmbedSingle *shell, - GList **groups); +impl_get_language_groups (EphyEmbedSingle *shell, + GList **groups); static gresult impl_get_font_list (EphyEmbedSingle *shell, const char *langGroup, @@ -262,11 +253,13 @@ static void mozilla_embed_single_new_window_orphan_cb (GtkMozEmbedSingle *embed, guint chrome_mask, EphyEmbedSingle *shell); +#ifdef GNOME_ENABLE_DEBUG +static gresult control_encodings_list (void); +#endif + struct MozillaEmbedSinglePrivate { char *user_prefs; - GHashTable *charsets_hash; - GList *sorted_charsets_titles; }; static NS_DEFINE_CID(kJVMManagerCID, NS_JVMMANAGER_CID); @@ -315,8 +308,8 @@ 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_charset_titles = impl_get_charset_titles; - shell_class->get_charset_groups = impl_get_charset_groups; + 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; @@ -472,8 +465,6 @@ static void mozilla_embed_single_init (MozillaEmbedSingle *mes) { mes->priv = g_new0 (MozillaEmbedSinglePrivate, 1); - mes->priv->charsets_hash = NULL; - mes->priv->sorted_charsets_titles = NULL; mes->priv->user_prefs = g_build_filename (ephy_dot_dir (), @@ -501,6 +492,9 @@ mozilla_embed_single_init (MozillaEmbedSingle *mes) mozilla_register_external_protocols (); +#ifdef GNOME_ENABLE_DEBUG + control_encodings_list (); +#endif /* FIXME alert if fails */ } @@ -622,13 +616,15 @@ impl_load_proxy_autoconf (EphyEmbedSingle *shell, return G_OK; } +#ifdef GNOME_ENABLE_DEBUG static gresult -fill_charsets_lists (MozillaEmbedSinglePrivate *priv) +control_encodings_list (void) { nsresult rv; char *tmp; PRUint32 cscount; - char *charset_str, *charset_title_str; + char *encoding_str, *encoding_title_str; + gresult ret = G_OK; nsCOMPtr<nsIAtom> docCharsetAtom; nsCOMPtr<nsICharsetConverterManager2> ccm2 = @@ -640,131 +636,151 @@ fill_charsets_lists (MozillaEmbedSinglePrivate *priv) if (!NS_SUCCEEDED(rv)) return G_FAILED; rv = cs_list->Count(&cscount); - priv->charsets_hash = g_hash_table_new (g_str_hash, g_str_equal); for (PRUint32 i = 0; i < cscount; i++) { nsCOMPtr<nsISupports> cssupports = (dont_AddRef)(cs_list->ElementAt(i)); nsCOMPtr<nsIAtom> csatom ( do_QueryInterface(cssupports) ); - nsAutoString charset_ns, charset_title_ns; + nsAutoString encoding_ns, encoding_title_ns; - /* charset name */ - rv = csatom->ToString(charset_ns); - tmp = ToNewCString (charset_ns); + /* encoding name */ + rv = csatom->ToString(encoding_ns); + tmp = ToNewCString (encoding_ns); if (tmp == NULL || strlen (tmp) == 0) { continue; } - charset_str = g_strdup (tmp); + encoding_str = g_strdup (tmp); nsMemory::Free (tmp); tmp = nsnull; - /* charset readable title */ - rv = ccm2->GetCharsetTitle2(csatom, &charset_title_ns); - tmp = ToNewCString (charset_title_ns); + /* encoding readable title */ + rv = ccm2->GetCharsetTitle2(csatom, &encoding_title_ns); + tmp = ToNewCString (encoding_title_ns); if (tmp == NULL || strlen (tmp) == 0) { - charset_title_str = g_strdup (charset_str); + encoding_title_str = g_strdup (encoding_str); } else { - charset_title_str = g_strdup (tmp); + encoding_title_str = g_strdup (tmp); } if (tmp) nsMemory::Free (tmp); tmp = nsnull; -#ifdef GNOME_ENABLE_DEBUG gboolean found = FALSE; -#endif - for (PRUint32 j = 0; j < n_charset_trans_array; j++) + for (PRUint32 j = 0; j < n_encodings; j++) { if (g_ascii_strcasecmp ( - charset_str, - charset_trans_array[j].charset_name) == 0) + encoding_str, + encodings[j].name) == 0) { - g_free (charset_title_str); - charset_title_str = (char *) - _(charset_trans_array[j].charset_title); -#ifdef GNOME_ENABLE_DEBUG + LOG ("Mozilla reported encoding %s with title %s found in our list.", + encoding_str, encoding_title_str) + found = TRUE; -#endif break; } } -#ifdef GNOME_ENABLE_DEBUG if (found == FALSE) { - g_warning ("Charset %s with title %s not in list!", - charset_str, charset_title_str); + g_warning ("Mozilla reported encoding %s with title %s NOT found in our list!", + encoding_str, encoding_title_str); + ret = G_FAILED; } -#endif - - /* fill the hash and the sorted list */ - g_hash_table_insert (priv->charsets_hash, charset_title_str, charset_str); - priv->sorted_charsets_titles = - g_list_insert_sorted (priv->sorted_charsets_titles, - (gpointer)charset_title_str, - (GCompareFunc)g_ascii_strcasecmp); } - return G_OK; + return ret; } +#endif -static void -ensure_charsets_tables (MozillaEmbedSingle *shell) +static gint +encoding_info_cmp (const EncodingInfo *i1, const EncodingInfo *i2) { - if (!shell->priv->charsets_hash) - { - fill_charsets_lists (shell->priv); - } + return strcmp (i1->key, i2->key); } static gresult -impl_get_charset_titles (EphyEmbedSingle *shell, - const char *group, - GList **charsets) +impl_get_encodings (EphyEmbedSingle *shell, + LanguageGroup group, + gboolean elide_underscores, + GList **encodings_list) { - MozillaEmbedSingle *mshell = MOZILLA_EMBED_SINGLE(shell); GList *l = NULL; - guint j; - - ensure_charsets_tables (mshell); - g_return_val_if_fail (mshell->priv->charsets_hash != NULL, G_FAILED); + guint i; - for (j = 0; j < n_charset_trans_array; j++) - { - if (group == NULL || - strcmp (group, lgroups[charset_trans_array[j].lgroup]) == 0) + for (i = 0; i < n_encodings; i++) + { + if (group == LG_ALL || group == encodings[i].group) { - CharsetInfo *info; - info = g_new0 (CharsetInfo, 1); - info->name = charset_trans_array[j].charset_name; - info->title = charset_trans_array[j].charset_title; + EncodingInfo *info; + gchar *elided = NULL; + + info = g_new0 (EncodingInfo, 1); + + info->encoding = g_strdup (encodings[i].name); + + elided = ephy_str_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); } } - *charsets = g_list_reverse (l); + *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_charset_groups (EphyEmbedSingle *shell, - GList **groups) +impl_get_language_groups (EphyEmbedSingle *shell, + GList **groups) { GList *l = NULL; guint i; - for (i = 0; i < n_lgroups; i++) + for (i = 0; i < n_lang_groups; i++) { - l = g_list_prepend (l, (gpointer)lgroups[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_str_elide_underscores (info->title); + info->key = g_utf8_collate_key (elided, -1); + g_free (elided); + + l = g_list_prepend (l, info); } - *groups = g_list_reverse (l); + *groups = g_list_sort (l, (GCompareFunc) language_group_info_cmp); return G_OK; } diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index 06c12b032..6d6a34726 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -149,8 +149,8 @@ impl_find (EphyEmbed *embed, EmbedFindInfo *info); static gresult -impl_set_charset (EphyEmbed *embed, - const char *charset); +impl_set_encoding (EphyEmbed *embed, + const char *encoding); static gresult impl_print (EphyEmbed *embed, @@ -327,7 +327,7 @@ ephy_embed_init (EphyEmbedClass *embed_class) embed_class->shistory_copy = impl_shistory_copy; embed_class->get_security_level = impl_get_security_level; embed_class->find = impl_find; - embed_class->set_charset = impl_set_charset; + embed_class->set_encoding = impl_set_encoding; embed_class->select_all = impl_select_all; embed_class->print = impl_print; embed_class->print_preview_close = impl_print_preview_close; @@ -437,7 +437,7 @@ impl_get_capabilities (EphyEmbed *embed, EMBED_PRINT_CAP | EMBED_FIND_CAP | EMBED_SECURITY_CAP | - EMBED_CHARSET_CAP | + EMBED_ENCODING_CAP | EMBED_SHISTORY_CAP ); *caps = mozilla_caps; @@ -1155,8 +1155,8 @@ impl_find (EphyEmbed *embed, } static gresult -impl_set_charset (EphyEmbed *embed, - const char *charset) +impl_set_encoding (EphyEmbed *embed, + const char *encoding) { nsresult result = NS_OK; EphyWrapper *wrapper; @@ -1164,7 +1164,7 @@ impl_set_charset (EphyEmbed *embed, wrapper = MOZILLA_EMBED(embed)->priv->wrapper; g_return_val_if_fail (wrapper != NULL, G_FAILED); - result = wrapper->ForceCharacterSet (charset); + result = wrapper->ForceEncoding (encoding); if (NS_FAILED (result)) return G_FAILED; gtk_moz_embed_reload (GTK_MOZ_EMBED (embed), diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp index 1f05f5abd..de02d9a38 100644 --- a/embed/mozilla/mozilla-notifiers.cpp +++ b/embed/mozilla/mozilla-notifiers.cpp @@ -80,10 +80,10 @@ mozilla_language_notifier(GConfClient *client, EphyEmbedSingle *single); static void -mozilla_autodetect_charset_notifier(GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EphyEmbedSingle *single); +mozilla_autodetect_encoding_notifier(GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + EphyEmbedSingle *single); static void mozilla_default_font_notifier(GConfClient *client, @@ -109,10 +109,10 @@ mozilla_user_agent_notifier(GConfClient *client, EphyEmbedSingle *single); static void -mozilla_default_charset_notifier (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EphyEmbedSingle *single); +mozilla_default_encoding_notifier (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + EphyEmbedSingle *single); static void mozilla_socks_version_notifier (GConfClient *client, guint cnxn_id, @@ -174,12 +174,12 @@ custom_notifiers [] = (GConfClientNotifyFunc) mozilla_own_fonts_notifier }, { CONF_SECURITY_ALLOW_POPUPS, (GConfClientNotifyFunc) mozilla_allow_popups_notifier }, - { CONF_LANGUAGE_DEFAULT_CHARSET, - (GConfClientNotifyFunc) mozilla_default_charset_notifier }, + { CONF_LANGUAGE_DEFAULT_ENCODING, + (GConfClientNotifyFunc) mozilla_default_encoding_notifier }, { CONF_RENDERING_LANGUAGE, (GConfClientNotifyFunc) mozilla_language_notifier }, - { CONF_LANGUAGE_AUTODETECT_CHARSET, - (GConfClientNotifyFunc) mozilla_autodetect_charset_notifier }, + { CONF_LANGUAGE_AUTODETECT_ENCODING, + (GConfClientNotifyFunc) mozilla_autodetect_encoding_notifier }, { CONF_RENDERING_DEFAULT_FONT, (GConfClientNotifyFunc) mozilla_default_font_notifier }, { CONF_NETWORK_SOCKS_PROXY_VERSION, @@ -527,10 +527,10 @@ generic_mozilla_bool_notifier(GConfClient *client, } static void -mozilla_default_charset_notifier(GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EphyEmbedSingle *single) +mozilla_default_encoding_notifier(GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + EphyEmbedSingle *single) { /* FIXME */ } @@ -633,7 +633,7 @@ mozilla_language_notifier(GConfClient *client, g_slist_free (languages); } -static char *autodetect_charset_prefs[] = +static char *autodetect_encoding_prefs[] = { "", "zh_parallel_state_machine", @@ -647,22 +647,22 @@ static char *autodetect_charset_prefs[] = }; static void -mozilla_autodetect_charset_notifier(GConfClient *client, +mozilla_autodetect_encoding_notifier(GConfClient *client, guint cnxn_id, GConfEntry *entry, EphyEmbedSingle *single) { - int charset = eel_gconf_get_integer (CONF_LANGUAGE_AUTODETECT_CHARSET); - if (charset < 0 || - charset >= (int)(sizeof(autodetect_charset_prefs) - / sizeof(autodetect_charset_prefs[0]))) + int encoding = eel_gconf_get_integer (CONF_LANGUAGE_AUTODETECT_ENCODING); + if (encoding < 0 || + encoding >= (int)(sizeof(autodetect_encoding_prefs) + / sizeof(autodetect_encoding_prefs[0]))) { - g_warning ("mozilla_autodetect_charset_notifier: " - "unsupported value: %d", charset); + g_warning ("mozilla_autodetect_encoding_notifier: " + "unsupported value: %d", encoding); return; } mozilla_prefs_set_string ("intl.charset.detector", - autodetect_charset_prefs[charset]); + autodetect_encoding_prefs[encoding]); } static void |