aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/Makefile.am2
-rw-r--r--embed/ephy-embed-shell.c28
-rw-r--r--embed/ephy-embed-shell.h2
-rw-r--r--embed/ephy-embed-utils.c81
-rw-r--r--embed/ephy-embed-utils.h5
-rw-r--r--embed/ephy-embed.c6
-rw-r--r--embed/ephy-embed.h9
-rw-r--r--embed/ephy-encodings.c545
-rw-r--r--embed/ephy-encodings.h151
-rw-r--r--embed/mozilla/EphyWrapper.cpp94
-rw-r--r--embed/mozilla/EphyWrapper.h4
-rw-r--r--embed/mozilla/Makefile.am1
-rw-r--r--embed/mozilla/mozilla-embed.cpp20
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp12
14 files changed, 841 insertions, 119 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am
index e2d94f622..35d86aea8 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -36,6 +36,7 @@ INST_H_FILES = \
ephy-embed-single.h \
ephy-embed-shell.h \
ephy-embed-types.h \
+ ephy-encodings.h \
ephy-history.h
libephyembed_la_SOURCES = \
@@ -49,6 +50,7 @@ libephyembed_la_SOURCES = \
ephy-embed-single.c \
ephy-embed-shell.c \
ephy-embed-utils.c \
+ ephy-encodings.c \
ephy-favicon-cache.c \
ephy-history.c \
find-dialog.c \
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index bcf9c0d00..0a0dbeb04 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -25,6 +25,7 @@
#include "ephy-favicon-cache.h"
#include "mozilla-embed-single.h"
#include "downloader-view.h"
+#include "ephy-encodings.h"
#include "ephy-debug.h"
#include <string.h>
@@ -37,6 +38,7 @@ struct EphyEmbedShellPrivate
DownloaderView *downloader_view;
EphyFaviconCache *favicon_cache;
EphyEmbedSingle *embed_single;
+ EphyEncodings *encodings;
};
static void
@@ -109,6 +111,7 @@ ephy_embed_shell_init (EphyEmbedShell *ges)
ges->priv->global_history = NULL;
ges->priv->downloader_view = NULL;
ges->priv->favicon_cache = NULL;
+ ges->priv->encodings = NULL;
}
static void
@@ -137,6 +140,12 @@ ephy_embed_shell_finalize (GObject *object)
g_object_unref (G_OBJECT (ges->priv->favicon_cache));
}
+ LOG ("Unref encodings")
+ if (ges->priv->encodings)
+ {
+ g_object_unref (G_OBJECT (ges->priv->encodings));
+ }
+
LOG ("Unref embed single")
if (ges->priv->embed_single)
{
@@ -149,14 +158,7 @@ ephy_embed_shell_finalize (GObject *object)
EphyEmbedShell *
ephy_embed_shell_new (const char *type)
{
- if (strcmp (type, "mozilla") == 0)
- {
- return EPHY_EMBED_SHELL (g_object_new
- (EPHY_TYPE_EMBED_SHELL, NULL));
- }
-
- g_assert_not_reached ();
- return NULL;
+ return g_object_new (EPHY_TYPE_EMBED_SHELL, NULL);
}
/**
@@ -243,3 +245,13 @@ impl_get_downloader_view (EphyEmbedShell *shell)
return G_OBJECT (shell->priv->downloader_view);
}
+GObject *
+ephy_embed_shell_get_encodings (EphyEmbedShell *shell)
+{
+ if (shell->priv->encodings == NULL)
+ {
+ shell->priv->encodings = ephy_encodings_new ();
+ }
+
+ return G_OBJECT (shell->priv->encodings);
+}
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index ec0b26215..610123eb0 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -69,6 +69,8 @@ EphyHistory *ephy_embed_shell_get_global_history (EphyEmbedShell *shell);
GObject *ephy_embed_shell_get_downloader_view (EphyEmbedShell *shell);
+GObject *ephy_embed_shell_get_encodings (EphyEmbedShell *shell);
+
EphyEmbedSingle *ephy_embed_shell_get_embed_single (EphyEmbedShell *shell);
G_END_DECLS
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index c6e113042..0bcd6bb52 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -29,7 +29,6 @@
#include "ephy-gui.h"
#include "ephy-debug.h"
#include "ephy-langs.h"
-#include "ephy-encodings.h"
#include <gtk/gtkdialog.h>
#include <gtk/gtkmessagedialog.h>
@@ -189,86 +188,6 @@ ephy_embed_utils_save (GtkWidget *window,
}
/**
- * 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 encodings
- * @data: the data passed to the callback
- *
- * Create a encoding submenu using bonobo ui.
- **/
-void
-ephy_embed_utils_build_encodings_submenu (BonoboUIComponent *ui_component,
- const char *path,
- BonoboUIVerbFn fn,
- gpointer view)
-{
- gchar *tmp, *verb;
- GString *xml_string;
- GList *groups, *gl, *encodings, *l;
- GList *verbs = NULL;
-
- START_PROFILER ("Encodings menu")
-
- 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 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);
-
- encodings = ephy_encodings_get_list (lang_info->group, FALSE);
- for (l = encodings; l != NULL; l = l->next)
- {
- 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",
- info->title, verb, verb);
- xml_string = g_string_append (xml_string, tmp);
-
- verbs = g_list_prepend (verbs, verb);
-
- g_free (tmp);
- }
-
- 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) ephy_lang_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);
-
- 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_string_free (xml_string, TRUE);
-
- STOP_PROFILER ("Encodings menu")
-}
-
-/**
* ephy_embed_utils_handlernotfound_dialog_run:
* @parent: the dialog parent window
*
diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h
index 8a0a52591..312e51026 100644
--- a/embed/ephy-embed-utils.h
+++ b/embed/ephy-embed-utils.h
@@ -32,11 +32,6 @@ void ephy_embed_utils_save (GtkWidget *window,
gboolean ask_dest,
EphyEmbedPersist *persist);
-void ephy_embed_utils_build_encodings_submenu (BonoboUIComponent *ui_component,
- const char *path,
- BonoboUIVerbFn fn,
- gpointer view);
-
void ephy_embed_utils_nohandler_dialog_run (GtkWidget *parent);
G_END_DECLS
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 145498665..4bc9de42e 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -575,11 +575,11 @@ ephy_embed_set_encoding (EphyEmbed *embed,
}
gresult
-ephy_embed_get_encoding (EphyEmbed *embed,
- char **encoding)
+ephy_embed_get_encoding_info (EphyEmbed *embed,
+ EphyEncodingInfo **info)
{
EphyEmbedClass *klass = EPHY_EMBED_GET_CLASS (embed);
- return klass->get_encoding (embed, encoding);
+ return klass->get_encoding_info (embed, info);
}
gresult
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index 5bcac1ae1..811fa91e6 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -21,6 +21,7 @@
#include "ephy-embed-types.h"
#include "ephy-embed-event.h"
+#include "ephy-encodings.h"
#include <glib-object.h>
#include <glib.h>
@@ -270,8 +271,8 @@ struct EphyEmbedClass
gint pageNum);
gresult (* set_encoding) (EphyEmbed *embed,
const char *encoding);
- gresult (* get_encoding) (EphyEmbed *embed,
- char **encoding);
+ gresult (* get_encoding_info) (EphyEmbed *embed,
+ EphyEncodingInfo **info);
};
GType ephy_embed_get_type (void);
@@ -392,8 +393,8 @@ gresult ephy_embed_find_next (EphyEmbed *embed,
gresult ephy_embed_set_encoding (EphyEmbed *embed,
const char *encoding);
-gresult ephy_embed_get_encoding (EphyEmbed *embed,
- char **encoding);
+gresult ephy_embed_get_encoding_info (EphyEmbed *embed,
+ EphyEncodingInfo **info);
gresult ephy_embed_activate (EphyEmbed *embed);
diff --git a/embed/ephy-encodings.c b/embed/ephy-encodings.c
new file mode 100644
index 000000000..1105207df
--- /dev/null
+++ b/embed/ephy-encodings.c
@@ -0,0 +1,545 @@
+/*
+ * 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 "ephy-node-db.h"
+#include "ephy-file-helpers.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-debug.h"
+
+#include <bonobo/bonobo-i18n.h>
+#include <string.h>
+
+#define EPHY_ENCODINGS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ENCODINGS, EphyEncodingsPrivate))
+
+struct EphyEncodingsPrivate
+{
+ EphyNodeDb *db;
+ EphyNode *root;
+ EphyNode *encodings;
+ EphyNode *detectors;
+ EphyNode *categories;
+ GHashTable *hash;
+ GSList *recent;
+};
+
+/**
+ * translatable encodings titles
+ * NOTE: if you add/remove/change encodings, please also update the schema in
+ * epiphany.schemas.in
+ */
+static const
+struct
+{
+ char *title;
+ char *code;
+ EphyLanguageGroup groups;
+ gboolean is_autodetector;
+}
+encoding_entries [] =
+{
+ { N_("Arabic (_IBM-864)"), "IBM864", LG_ARABIC, FALSE },
+ { N_("Arabic (ISO-_8859-6)"), "ISO-8859-6", LG_ARABIC, FALSE },
+ { N_("Arabic (_MacArabic)"), "x-mac-arabic", LG_ARABIC, FALSE },
+ { N_("Arabic (_Windows-1256)"), "windows-1256", LG_ARABIC, FALSE },
+ { N_("Baltic (_ISO-8859-13)"), "ISO-8859-13", LG_BALTIC, FALSE },
+ { N_("Baltic (I_SO-8859-4)"), "ISO-8859-4", LG_BALTIC, FALSE },
+ { N_("Baltic (_Windows-1257)"), "windows-1257", LG_BALTIC, FALSE },
+ { N_("_Armenian (ARMSCII-8)"), "armscii-8", LG_CAUCASIAN, FALSE },
+ { N_("_Georgian (GEOSTD8)"), "geostd8", LG_CAUCASIAN, FALSE },
+ { N_("Central European (_IBM-852)"), "IBM852", LG_C_EUROPEAN, FALSE },
+ { N_("Central European (I_SO-8859-2)"), "ISO-8859-2", LG_C_EUROPEAN, FALSE },
+ { N_("Central European (_MacCE)"), "x-mac-ce", LG_C_EUROPEAN, FALSE },
+ { N_("Central European (_Windows-1250)"), "windows-1250", LG_C_EUROPEAN, FALSE },
+ { N_("Chinese Simplified (_GB18030)"), "gb18030", LG_CHINESE_SIMP, FALSE },
+ { N_("Chinese Simplified (G_B2312)"), "GB2312", LG_CHINESE_SIMP, FALSE },
+ { N_("Chinese Simplified (GB_K)"), "x-gbk", LG_CHINESE_SIMP, FALSE },
+ { N_("Chinese Simplified (_HZ)"), "HZ-GB-2312", LG_CHINESE_SIMP, FALSE },
+ { N_("Chinese Simplified (_ISO-2022-CN)"), "ISO-2022-CN", LG_CHINESE_SIMP, FALSE },
+ { N_("Chinese Traditional (Big_5)"), "Big5", LG_CHINESE_TRAD, FALSE },
+ { N_("Chinese Traditional (Big5-HK_SCS)"), "Big5-HKSCS", LG_CHINESE_TRAD, FALSE },
+ { N_("Chinese Traditional (_EUC-TW)"), "x-euc-tw", LG_CHINESE_TRAD, FALSE },
+ { N_("Cyrillic (_IBM-855)"), "IBM855", LG_CYRILLIC, FALSE },
+ { N_("Cyrillic (I_SO-8859-5)"), "ISO-8859-5", LG_CYRILLIC, FALSE },
+ { N_("Cyrillic (IS_O-IR-111)"), "ISO-IR-111", LG_CYRILLIC, FALSE },
+ { N_("Cyrillic (_KOI8-R)"), "KOI8-R", LG_CYRILLIC, FALSE },
+ { N_("Cyrillic (_MacCyrillic)"), "x-mac-cyrillic", LG_CYRILLIC, FALSE },
+ { N_("Cyrillic (_Windows-1251)"), "windows-1251", LG_CYRILLIC, FALSE },
+ { N_("Cyrillic/_Russian (IBM-866)"), "IBM866", LG_CYRILLIC, FALSE },
+ { N_("Greek (_ISO-8859-7)"), "ISO-8859-7", LG_GREEK, FALSE },
+ { N_("Greek (_MacGreek)"), "x-mac-greek", LG_GREEK, FALSE },
+ { N_("Greek (_Windows-1253)"), "windows-1253", LG_GREEK, FALSE },
+ { N_("Gujarati (_MacGujarati)"), "x-mac-gujarati", LG_INDIAN, FALSE },
+ { N_("Gurmukhi (Mac_Gurmukhi)"), "x-mac-gurmukhi", LG_INDIAN, FALSE },
+ { N_("Hindi (Mac_Devanagari)"), "x-mac-devanagari", LG_INDIAN, FALSE },
+ { N_("Hebrew (_IBM-862)"), "IBM862", LG_HEBREW, FALSE },
+ { N_("Hebrew (IS_O-8859-8-I)"), "ISO-8859-8-I", LG_HEBREW, FALSE },
+ { N_("Hebrew (_MacHebrew)"), "x-mac-hebrew", LG_HEBREW, FALSE },
+ { N_("Hebrew (_Windows-1255)"), "windows-1255", LG_HEBREW, FALSE },
+ { N_("_Visual Hebrew (ISO-8859-8)"), "ISO-8859-8", LG_HEBREW, FALSE },
+ { N_("Japanese (_EUC-JP)"), "EUC-JP", LG_JAPANESE, FALSE },
+ { N_("Japanese (_ISO-2022-JP)"), "ISO-2022-JP", LG_JAPANESE, FALSE },
+ { N_("Japanese (_Shift-JIS)"), "Shift_JIS", LG_JAPANESE, FALSE },
+ { N_("Korean (_EUC-KR)"), "EUC-KR", LG_KOREAN, FALSE },
+ { N_("Korean (_ISO-2022-KR)"), "ISO-2022-KR", LG_KOREAN, FALSE },
+ { N_("Korean (_JOHAB)"), "x-johab", LG_KOREAN, FALSE },
+ { N_("Korean (_UHC)"), "x-windows-949", LG_KOREAN, FALSE },
+ { N_("_Celtic (ISO-8859-14)"), "ISO-8859-14", LG_NORDIC, FALSE },
+ { N_("_Icelandic (MacIcelandic)"), "x-mac-icelandic", LG_NORDIC, FALSE },
+ { N_("_Nordic (ISO-8859-10)"), "ISO-8859-10", LG_NORDIC, FALSE },
+ { N_("_Persian (MacFarsi)"), "x-mac-farsi", LG_PERSIAN, FALSE },
+ { N_("Croatian (Mac_Croatian)"), "x-mac-croatian", LG_SE_EUROPEAN, FALSE },
+ { N_("_Romanian (MacRomanian)"), "x-mac-romanian", LG_SE_EUROPEAN, FALSE },
+ { N_("R_omanian (ISO-8859-16)"), "ISO-8859-16", LG_SE_EUROPEAN, FALSE },
+ { N_("South _European (ISO-8859-3)"), "ISO-8859-3", LG_SE_EUROPEAN, FALSE },
+ { N_("Thai (TIS-_620)"), "TIS-620", LG_THAI, FALSE },
+#if MOZILLA_SNAPSHOT >= 10
+ { N_("Thai (IS_O-8859-11)"), "iso-8859-11", LG_THAI, FALSE },
+ { N_("_Thai (Windows-874)"), "windows-874", LG_THAI, FALSE },
+#endif
+ { N_("Turkish (_IBM-857)"), "IBM857", LG_TURKISH, FALSE },
+ { N_("Turkish (I_SO-8859-9)"), "ISO-8859-9", LG_TURKISH, FALSE },
+ { N_("Turkish (_MacTurkish)"), "x-mac-turkish", LG_TURKISH, FALSE },
+ { N_("Turkish (_Windows-1254)"), "windows-1254", LG_TURKISH, FALSE },
+ { N_("Unicode (UTF-_8)"), "UTF-8", LG_UNICODE, FALSE },
+ { N_("Unicode (UTF-_7)"), "UTF-7", LG_UNICODE, FALSE },
+ { N_("Cyrillic/Ukrainian (_KOI8-U)"), "KOI8-U", LG_UKRAINIAN, FALSE },
+ { N_("Cyrillic/Ukrainian (Mac_Ukrainian)"), "x-mac-ukrainian", LG_UKRAINIAN, FALSE },
+ { N_("Vietnamese (_TCVN)"), "x-viet-tcvn5712", LG_VIETNAMESE, FALSE },
+ { N_("Vietnamese (_VISCII)"), "VISCII", LG_VIETNAMESE, FALSE },
+ { N_("Vietnamese (V_PS)"), "x-viet-vps", LG_VIETNAMESE, FALSE },
+ { N_("Vietnamese (_Windows-1258)"), "windows-1258", LG_VIETNAMESE, FALSE },
+ { N_("Western (_IBM-850)"), "IBM850", LG_WESTERN, FALSE },
+ { N_("Western (_ISO-8859-1)"), "ISO-8859-1", LG_WESTERN, FALSE },
+ { N_("Western (IS_O-8859-15)"), "ISO-8859-15", LG_WESTERN, FALSE },
+ { N_("Western (_MacRoman)"), "x-mac-roman", LG_WESTERN, FALSE },
+ { N_("Western (_Windows-1252)"), "windows-1252", LG_WESTERN, FALSE },
+
+ { N_("Off"), "", LG_NONE, TRUE },
+ { N_("Chinese"), "zh_parallel_state_machine", LG_CHINESE_TRAD | LG_CHINESE_SIMP, TRUE },
+ { N_("Chinese Simplified"), "zhcn_parallel_state_machine", LG_CHINESE_SIMP, TRUE },
+ { N_("Chinese Traditional"), "zhtw_parallel_state_machine", LG_CHINESE_TRAD, TRUE },
+ { N_("East Asian"), "cjk_parallel_state_machine", LG_CHINESE_TRAD | LG_CHINESE_SIMP | LG_JAPANESE | LG_KOREAN, TRUE },
+ { N_("Japanese"), "ja_parallel_state_machine", LG_JAPANESE, TRUE },
+ { N_("Korean"), "ko_parallel_state_machine", LG_KOREAN, TRUE },
+ { N_("Russian"), "ruprob", LG_CYRILLIC | LG_UKRAINIAN, TRUE },
+ { N_("Universal"), "universal_charset_detector", LG_ALL, TRUE },
+ { N_("Ukrainian"), "ukprob", LG_UKRAINIAN, TRUE }
+};
+static const guint n_encoding_entries = G_N_ELEMENTS (encoding_entries);
+
+/* make sure this covers all LG_* groups ! */
+/* FIXME: those categories are pretty bad :( */
+static const struct
+{
+ char *title;
+ EphyLanguageGroup groups;
+}
+geo_entries [] =
+{
+ { N_("Universal"), LG_UNICODE },
+ { N_("Eastern Asia"), LG_CHINESE_SIMP | LG_CHINESE_TRAD | LG_JAPANESE | LG_KOREAN | LG_VIETNAMESE | LG_THAI },
+ { N_("Western Asia"), LG_CAUCASIAN | LG_TURKISH | LG_INDIAN },
+ { N_("Eastern European"), LG_BALTIC | LG_CYRILLIC | LG_UKRAINIAN | LG_C_EUROPEAN },
+ { N_("Western European"), LG_WESTERN | LG_GREEK | LG_NORDIC | LG_SE_EUROPEAN },
+ { N_("Middle Eastern"), LG_ARABIC | LG_PERSIAN | LG_HEBREW }
+};
+static const guint n_geo_entries = G_N_ELEMENTS (geo_entries);
+
+enum
+{
+ ALL_NODE_ID = 2,
+ ENCODINGS_NODE_ID = 3,
+ DETECTORS_NODE_ID = 5,
+ CATEGORIES_NODE_ID = 7
+};
+
+#define RECENT_KEY "/apps/epiphany/general/recent_encodings"
+#define RECENT_MAX 4
+
+static void ephy_encodings_class_init (EphyEncodingsClass *klass);
+static void ephy_encodings_init (EphyEncodings *ma);
+
+static GObjectClass *parent_class = NULL;
+
+GType
+ephy_encodings_get_type (void)
+{
+ static GType ephy_encodings_type = 0;
+
+ if (ephy_encodings_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyEncodingsClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) ephy_encodings_class_init,
+ NULL,
+ NULL,
+ sizeof (EphyEncodings),
+ 0,
+ (GInstanceInitFunc) ephy_encodings_init
+ };
+
+ ephy_encodings_type = g_type_register_static (G_TYPE_OBJECT,
+ "EphyEncodings",
+ &our_info, 0);
+ }
+
+ return ephy_encodings_type;
+}
+
+static void
+ephy_encodings_finalize (GObject *object)
+{
+ EphyEncodings *encodings = EPHY_ENCODINGS (object);
+
+ g_hash_table_destroy (encodings->priv->hash);
+
+ ephy_node_unref (encodings->priv->encodings);
+ ephy_node_unref (encodings->priv->detectors);
+ ephy_node_unref (encodings->priv->categories);
+ ephy_node_unref (encodings->priv->root);
+
+ g_slist_foreach (encodings->priv->recent, (GFunc) g_free, NULL);
+ g_slist_free (encodings->priv->recent);
+
+ g_object_unref (encodings->priv->db);
+
+ LOG ("EphyEncodings finalised")
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+ephy_encodings_class_init (EphyEncodingsClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ephy_encodings_finalize;
+
+ g_type_class_add_private (object_class, sizeof (EphyEncodingsPrivate));
+}
+
+EphyNode *
+ephy_encodings_get_node (EphyEncodings *encodings,
+ const char *code)
+{
+ g_return_val_if_fail (EPHY_IS_ENCODINGS (encodings), NULL);
+
+ return g_hash_table_lookup (encodings->priv->hash, code);
+}
+
+GList *
+ephy_encodings_get_encodings (EphyEncodings *encodings,
+ EphyLanguageGroup group_mask)
+{
+ GList *list = NULL;
+ GPtrArray *children;
+ int i, n_items;
+
+ children = ephy_node_get_children (encodings->priv->encodings);
+ n_items = children->len;
+ for (i = 0; i < n_items; i++)
+ {
+ EphyNode *kid;
+ EphyLanguageGroup group;
+
+ kid = g_ptr_array_index (children, i);
+ group = ephy_node_get_property_int
+ (kid, EPHY_NODE_ENCODING_PROP_LANGUAGE_GROUPS);
+
+ if ((group & group_mask) != 0)
+ {
+ list = g_list_prepend (list, kid);
+ }
+ }
+ ephy_node_thaw (encodings->priv->encodings);
+
+ return list;
+}
+
+GList *
+ephy_encodings_get_detectors (EphyEncodings *encodings)
+{
+ GList *list = NULL;
+ GPtrArray *children;
+ int i, n_items;
+
+ children = ephy_node_get_children (encodings->priv->detectors);
+ n_items = children->len;
+ for (i = 0; i < n_items; i++)
+ {
+ EphyNode *kid;
+
+ kid = g_ptr_array_index (children, i);
+
+ list = g_list_prepend (list, kid);
+ }
+ ephy_node_thaw (encodings->priv->detectors);
+
+ return list;
+}
+
+EphyNode *
+ephy_encodings_get_all (EphyEncodings *encodings)
+{
+ g_return_val_if_fail (EPHY_IS_ENCODINGS (encodings), NULL);
+
+ return encodings->priv->encodings;
+}
+
+EphyNode *
+ephy_encodings_get_categories (EphyEncodings *encodings)
+{
+ g_return_val_if_fail (EPHY_IS_ENCODINGS (encodings), NULL);
+
+ return encodings->priv->categories;
+}
+
+void
+ephy_encodings_add_recent (EphyEncodings *encodings,
+ const char *code)
+{
+ GSList *element;
+
+ g_return_if_fail (EPHY_IS_ENCODINGS (encodings));
+ g_return_if_fail (code != NULL);
+ g_return_if_fail (ephy_encodings_get_node (encodings, code) != NULL);
+
+ /* keep the list elements unique */
+ element = g_slist_find_custom (encodings->priv->recent, code,
+ (GCompareFunc) strcmp);
+ if (element != NULL)
+ {
+ encodings->priv->recent =
+ g_slist_remove_link (encodings->priv->recent, element);
+ }
+
+ /* add the new code upfront */
+ encodings->priv->recent =
+ g_slist_prepend (encodings->priv->recent, g_strdup (code));
+
+ /* truncate the list if necessary; it's at most 1 element too much */
+ if (g_slist_length (encodings->priv->recent) > RECENT_MAX)
+ {
+ GSList *tail;
+
+ tail = g_slist_last (encodings->priv->recent);
+ g_free (tail->data);
+ encodings->priv->recent =
+ g_slist_remove_link (encodings->priv->recent, tail);
+ }
+
+ /* persist the list */
+ eel_gconf_set_string_list (RECENT_KEY, encodings->priv->recent);
+}
+
+GList *
+ephy_encodings_get_recent (EphyEncodings *encodings)
+{
+ GSList *l;
+ GList *list = NULL;
+
+ for (l = encodings->priv->recent; l != NULL; l = l->next)
+ {
+ EphyNode *node;
+
+ node = ephy_encodings_get_node (encodings, (char *) l->data);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+
+ list = g_list_prepend (list, node);
+ }
+
+ return list;
+}
+
+static void
+ephy_encodings_init (EphyEncodings *encodings)
+{
+ EphyNodeDb *db;
+ GSList *list, *l;
+ guint i;
+
+ encodings->priv = EPHY_ENCODINGS_GET_PRIVATE (encodings);
+
+ LOG ("EphyEncodings initialising")
+
+ db = ephy_node_db_new ("EncodingsDB");
+ encodings->priv->db = db;
+
+ encodings->priv->hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ encodings->priv->root = ephy_node_new_with_id (db, ALL_NODE_ID);
+ encodings->priv->encodings = ephy_node_new_with_id (db, ENCODINGS_NODE_ID);
+ encodings->priv->detectors = ephy_node_new_with_id (db, DETECTORS_NODE_ID);
+ encodings->priv->categories = ephy_node_new_with_id (db, CATEGORIES_NODE_ID);
+
+ ephy_node_ref (encodings->priv->root);
+ ephy_node_ref (encodings->priv->encodings);
+ ephy_node_ref (encodings->priv->detectors);
+ ephy_node_ref (encodings->priv->categories);
+
+ /* now fill the db */
+ for (i = 0; i < n_encoding_entries; i++)
+ {
+ EphyNode *node;
+ char *elided, *normalised;
+ GValue value = { 0, };
+
+ node = ephy_node_new (db);
+ ephy_node_add_child (encodings->priv->root, node);
+ g_hash_table_insert (encodings->priv->hash, encoding_entries[i].code, node);
+
+ if (encoding_entries[i].is_autodetector)
+ {
+ ephy_node_add_child (encodings->priv->detectors, node);
+ }
+ else
+ {
+ ephy_node_add_child (encodings->priv->encodings, node);
+ }
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, _(encoding_entries[i].title));
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_TITLE, &value);
+ g_value_unset (&value);
+
+ elided = ephy_string_elide_underscores (_(encoding_entries[i].title));
+ normalised = g_utf8_normalize (elided, -1, G_NORMALIZE_DEFAULT);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_take_string (&value, g_utf8_collate_key (normalised, -1));
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_COLLATION_KEY, &value);
+ g_value_unset (&value);
+
+ g_free (normalised);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_take_string (&value, elided);
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_TITLE_ELIDED, &value);
+ g_value_unset (&value);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, encoding_entries[i].code);
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_ENCODING, &value);
+ g_value_unset (&value);
+
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, encoding_entries[i].groups);
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_LANGUAGE_GROUPS, &value);
+ g_value_unset (&value);
+
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, encoding_entries[i].is_autodetector);
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_IS_AUTODETECTOR, &value);
+ g_value_unset (&value);
+ }
+
+ /* setup list of categories for 2-pane view in ephy-encoding-dialog */
+ for (i=0; i < n_geo_entries; i++)
+ {
+ EphyNode *node;
+ GValue value = { 0, };
+ GList *list, *l;
+
+ node = ephy_node_new (db);
+ ephy_node_add_child (encodings->priv->categories, node);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, _(geo_entries[i].title));
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_TITLE, &value);
+ g_value_unset (&value);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_take_string (&value, g_utf8_collate_key (_(geo_entries[i].title), -1));
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_COLLATION_KEY, &value);
+ g_value_unset (&value);
+
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, encoding_entries[i].groups);
+ ephy_node_set_property (node, EPHY_NODE_ENCODING_PROP_LANGUAGE_GROUPS, &value);
+ g_value_unset (&value);
+
+ /* add the encodings to the category */
+ list = ephy_encodings_get_encodings (encodings, geo_entries[i].groups);
+ for (l = list; l != NULL; l = l->next)
+ {
+ ephy_node_add_child (node, (EphyNode *) l->data);
+ }
+ g_list_free (list);
+
+ }
+
+ /* get the list of recently used encodings */
+ list = eel_gconf_get_string_list (RECENT_KEY);
+
+ /* make sure the list has no duplicates (GtkUIManager goes
+ * crazy otherwise), and only valid entries
+ */
+ encodings->priv->recent = NULL;
+ for (l = list; l != NULL; l = l->next)
+ {
+ if (g_slist_find (encodings->priv->recent, l->data) == NULL
+ && g_slist_length (encodings->priv->recent) < RECENT_MAX
+ && ephy_encodings_get_node (encodings, l->data) != NULL)
+ {
+ encodings->priv->recent =
+ g_slist_prepend (encodings->priv->recent,
+ l->data);
+ }
+ else
+ {
+ g_free (l->data);
+ }
+ }
+ encodings->priv->recent = g_slist_reverse (encodings->priv->recent);
+ g_slist_free (list);
+}
+
+void
+ephy_encoding_info_free (EphyEncodingInfo *info)
+{
+ if (info)
+ {
+ g_free (info->encoding);
+ g_free (info->hint_encoding);
+ g_free (info->parent_encoding);
+ g_free (info->prev_doc_encoding);
+ g_free (info->forced_encoding);
+ g_free (info->default_encoding);
+ g_free (info);
+ }
+}
+
+EphyEncodings *
+ephy_encodings_new (void)
+{
+ return g_object_new (EPHY_TYPE_ENCODINGS, NULL);
+}
diff --git a/embed/ephy-encodings.h b/embed/ephy-encodings.h
new file mode 100644
index 000000000..29034e13a
--- /dev/null
+++ b/embed/ephy-encodings.h
@@ -0,0 +1,151 @@
+/*
+ * 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-object.h>
+#include <glib.h>
+
+#include "ephy-node.h"
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_ENCODINGS (ephy_encodings_get_type ())
+#define EPHY_ENCODINGS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_ENCODINGS, EphyEncodings))
+#define EPHY_ENCODINGS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EPHY_TYPE_ENCODINGS, EphyEncodingsClass))
+#define EPHY_IS_ENCODINGS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_ENCODINGS))
+#define EPHY_IS_ENCODINGS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_ENCODINGS))
+#define EPHY_ENCODINGS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_ENCODINGS, EphyEncodingsClass))
+
+typedef struct EphyEncodingsPrivate EphyEncodingsPrivate;
+
+typedef enum
+{
+ LG_NONE = 0,
+ LG_ARABIC = 1 << 0,
+ LG_BALTIC = 1 << 1,
+ LG_CAUCASIAN = 1 << 2,
+ LG_C_EUROPEAN = 1 << 3,
+ LG_CHINESE_TRAD = 1 << 4,
+ LG_CHINESE_SIMP = 1 << 5,
+ LG_CYRILLIC = 1 << 6,
+ LG_GREEK = 1 << 7,
+ LG_HEBREW = 1 << 8,
+ LG_INDIAN = 1 << 9,
+ LG_JAPANESE = 1 << 10,
+ LG_KOREAN = 1 << 12,
+ LG_NORDIC = 1 << 13,
+ LG_PERSIAN = 1 << 14,
+ LG_SE_EUROPEAN = 1 << 15,
+ LG_THAI = 1 << 16,
+ LG_TURKISH = 1 << 17,
+ LG_UKRAINIAN = 1 << 18,
+ LG_UNICODE = 1 << 19,
+ LG_VIETNAMESE = 1 << 20,
+ LG_WESTERN = 1 << 21,
+ LG_ALL = 0x3fffff,
+}
+EphyLanguageGroup;
+
+/* from htmlparser/nsIParser.h */
+/* note: the value order defines the priority */
+typedef enum
+{
+ EMBED_ENCODING_UNINITIALISED = 0,
+ EMBED_ENCODING_WEAK_DOCTYPE_DEFAULT = 1,
+ EMBED_ENCODING_USER_DEFAULT = 2,
+ EMBED_ENCODING_DOCTYPE_DEFAULT = 3,
+ EMBED_ENCODING_CACHE = 4,
+ EMBED_ENCODING_PARENT_FRAME = 5,
+ EMBED_ENCODING_BOOKMARKS = 6,
+ EMBED_ENCODING_AUTODETECTION = 7,
+ EMBED_ENCODING_HINT_PREV_DOC = 8,
+ EMBED_ENCODING_META_TAG = 9,
+ EMBED_ENCODING_BOM = 10,
+ EMBED_ENCODING_CHANNEL = 11,
+ EMBED_ENCODING_PARENT_FORCED = 12,
+ EMBED_ENCODING_USER_FORCED = 13,
+ EMBED_ENCODING_OTHER_COMPONENT = 14,
+ EMBED_ENCODING_PREV_LOADING = 15
+}
+EphyEncodingSource;
+
+typedef struct
+{
+ char *encoding;
+ char *default_encoding;
+ char *hint_encoding;
+ char *prev_doc_encoding;
+ char *forced_encoding;
+ char *parent_encoding;
+ EphyEncodingSource encoding_source;
+ EphyEncodingSource hint_encoding_source;
+ EphyEncodingSource parent_encoding_source;
+}
+EphyEncodingInfo;
+
+enum
+{
+ EPHY_NODE_ENCODING_PROP_TITLE = 1,
+ EPHY_NODE_ENCODING_PROP_TITLE_ELIDED = 2,
+ EPHY_NODE_ENCODING_PROP_COLLATION_KEY = 3,
+ EPHY_NODE_ENCODING_PROP_ENCODING = 4,
+ EPHY_NODE_ENCODING_PROP_LANGUAGE_GROUPS = 5,
+ EPHY_NODE_ENCODING_PROP_IS_AUTODETECTOR = 6
+};
+
+typedef struct
+{
+ GObject parent;
+ EphyEncodingsPrivate *priv;
+} EphyEncodings;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} EphyEncodingsClass;
+
+GType ephy_encodings_get_type (void);
+
+EphyEncodings *ephy_encodings_new (void);
+
+EphyNode *ephy_encodings_get_node (EphyEncodings *encodings,
+ const char *code);
+
+GList *ephy_encodings_get_encodings (EphyEncodings *encodings,
+ EphyLanguageGroup group_mask);
+
+EphyNode *ephy_encodings_get_all (EphyEncodings *encodings);
+
+EphyNode *ephy_encodings_get_categories (EphyEncodings *encodings);
+
+GList *ephy_encodings_get_detectors (EphyEncodings *encodings);
+
+void ephy_encodings_add_recent (EphyEncodings *encodings,
+ const char *code);
+
+GList *ephy_encodings_get_recent (EphyEncodings *encodings);
+
+void ephy_encoding_info_free (EphyEncodingInfo *info);
+
+G_END_DECLS
+
+#endif
diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp
index 71194438f..371e87134 100644
--- a/embed/mozilla/EphyWrapper.cpp
+++ b/embed/mozilla/EphyWrapper.cpp
@@ -72,6 +72,8 @@
#include "nsIDOMHTMLElement.h"
#include "nsIDeviceContext.h"
#include "nsIPresContext.h"
+#include "nsIAtom.h"
+#include "nsIDocumentCharsetInfo.h"
#include "ContentHandler.h"
#include "EphyEventListener.h"
@@ -756,9 +758,10 @@ nsresult EphyWrapper::PopTargetDocument ()
return NS_OK;
}
-nsresult EphyWrapper::GetEncoding (char **aEncoding)
+nsresult EphyWrapper::GetEncodingInfo (EphyEncodingInfo **infoptr)
{
nsresult result;
+ EphyEncodingInfo *info;
nsCOMPtr<nsIDOMDocument> domDoc;
result = GetDOMDocument (getter_AddRefs(domDoc));
@@ -767,19 +770,104 @@ nsresult EphyWrapper::GetEncoding (char **aEncoding)
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc, &result);
if (NS_FAILED (result) || !doc) return NS_ERROR_FAILURE;
+ info = g_new0 (EphyEncodingInfo, 1);
+ *infoptr = info;
+
#if MOZILLA_SNAPSHOT >= 10
nsCAutoString enc;
result = doc->GetDocumentCharacterSet (enc);
if (NS_FAILED (result)) return NS_ERROR_FAILURE;
- *aEncoding = g_strdup (enc.get());
+ info->encoding = g_strdup (enc.get());
#else
nsAutoString enc;
result = doc->GetDocumentCharacterSet (enc);
if (NS_FAILED (result)) return NS_ERROR_FAILURE;
- *aEncoding = g_strdup (NS_ConvertUCS2toUTF8(enc).get());
+ info->encoding = g_strdup (NS_ConvertUCS2toUTF8(enc).get());
+#endif
+
+ PRInt32 source;
+ result = doc->GetDocumentCharacterSetSource (&source);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->encoding_source = (EphyEncodingSource) source;
+
+ nsCOMPtr<nsIDocShell> ds;
+ result = GetDocShell (getter_AddRefs(ds));
+ if (NS_FAILED(result) || !ds) return NS_ERROR_FAILURE;
+
+ nsCOMPtr<nsIDocumentCharsetInfo> ci;
+ result = ds->GetDocumentCharsetInfo (getter_AddRefs (ci));
+ if (NS_FAILED(result) || !ci) return NS_ERROR_FAILURE;
+
+ nsCOMPtr<nsIAtom> atom;
+ result = ci->GetForcedCharset (getter_AddRefs (atom));
+ if (NS_FAILED(result)) return NS_ERROR_FAILURE;
+ if (atom)
+ {
+ nsCAutoString atomstr;
+ atom->ToUTF8String (atomstr);
+ info->forced_encoding = g_strdup (atomstr.get());
+ }
+
+ result = ci->GetParentCharset (getter_AddRefs (atom));
+ if (NS_FAILED(result)) return NS_ERROR_FAILURE;
+ if (atom)
+ {
+ nsCAutoString atomstr;
+ atom->ToUTF8String (atomstr);
+ info->parent_encoding = g_strdup (atomstr.get());
+ }
+
+ result = ci->GetParentCharsetSource (&source);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->parent_encoding_source = (EphyEncodingSource) source;
+
+ nsCOMPtr<nsIContentViewer> contentViewer;
+ result = ds->GetContentViewer (getter_AddRefs(contentViewer));
+ if (!NS_SUCCEEDED (result) || !contentViewer) return NS_ERROR_FAILURE;
+
+ nsCOMPtr<nsIMarkupDocumentViewer> mdv = do_QueryInterface(contentViewer,
+ &result);
+ if (NS_FAILED(result) || !mdv) return NS_ERROR_FAILURE;
+
+#if MOZILLA_SNAPSHOT >= 10
+ result = mdv->GetDefaultCharacterSet (enc);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->default_encoding = g_strdup (enc.get());
+
+ result = mdv->GetForceCharacterSet (enc);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->forced_encoding = g_strdup (enc.get());
+
+ result = mdv->GetHintCharacterSet (enc);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->hint_encoding = g_strdup (enc.get());
+
+ result = mdv->GetPrevDocCharacterSet (enc);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->prev_doc_encoding = g_strdup (enc.get());
+#else
+ result = mdv->GetDefaultCharacterSet (enc);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->default_encoding = g_strdup (NS_ConvertUCS2toUTF8(enc).get());
+
+ result = mdv->GetForceCharacterSet (enc);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->forced_encoding = g_strdup (NS_ConvertUCS2toUTF8(enc).get());
+
+ result = mdv->GetHintCharacterSet (enc);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->hint_encoding = g_strdup (NS_ConvertUCS2toUTF8(enc).get());
+
+ result = mdv->GetPrevDocCharacterSet (enc);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->prev_doc__encoding = g_strdup (NS_ConvertUCS2toUTF8(enc).get());
#endif
+ mdv->GetHintCharacterSetSource (&source);
+ if (NS_FAILED (result)) return NS_ERROR_FAILURE;
+ info->hint_encoding_source = (EphyEncodingSource) source;
+
return NS_OK;
}
diff --git a/embed/mozilla/EphyWrapper.h b/embed/mozilla/EphyWrapper.h
index cfedf6ccc..5f5ed7bf3 100644
--- a/embed/mozilla/EphyWrapper.h
+++ b/embed/mozilla/EphyWrapper.h
@@ -21,6 +21,8 @@
#ifndef EPHY_WRAPPER_H
#define EPHY_WRAPPER_H
+#include "ephy-encodings.h"
+
#include "nsIDocShell.h"
//#include "ProgressListener.h"
#include "nsIWebNavigation.h"
@@ -78,7 +80,7 @@ public:
nsresult ForceEncoding (const char *encoding);
- nsresult GetEncoding (char **aEncoding);
+ nsresult GetEncodingInfo (EphyEncodingInfo **infoptr);
nsresult CanCutSelection(PRBool *result);
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index 22ef72829..12922c1e7 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -6,6 +6,7 @@ INCLUDES = \
$(WARN_CXXFLAGS) \
$(MOZILLA_COMPONENT_CFLAGS) \
-I$(MOZILLA_INCLUDE_ROOT)/appcomps \
+ -I$(MOZILLA_INCLUDE_ROOT)/chardet \
-I$(MOZILLA_INCLUDE_ROOT)/chrome \
-I$(MOZILLA_INCLUDE_ROOT)/content \
-I$(MOZILLA_INCLUDE_ROOT)/cookie \
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index de87457e3..e00738e4f 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -148,8 +148,8 @@ static gresult
impl_set_encoding (EphyEmbed *embed,
const char *encoding);
static gresult
-impl_get_encoding (EphyEmbed *embed,
- char **encoding);
+impl_get_encoding_info (EphyEmbed *embed,
+ EphyEncodingInfo **info);
static gresult
impl_print (EphyEmbed *embed,
EmbedPrintInfo *info);
@@ -380,7 +380,7 @@ ephy_embed_init (EphyEmbedClass *embed_class)
embed_class->activate = impl_activate;
embed_class->find_set_properties = impl_find_set_properties;
embed_class->set_encoding = impl_set_encoding;
- embed_class->get_encoding = impl_get_encoding;
+ embed_class->get_encoding_info = impl_get_encoding_info;
embed_class->select_all = impl_select_all;
embed_class->print = impl_print;
embed_class->print_preview_close = impl_print_preview_close;
@@ -1192,19 +1192,21 @@ impl_set_encoding (EphyEmbed *embed,
}
static gresult
-impl_get_encoding (EphyEmbed *embed,
- char **encoding)
+impl_get_encoding_info (EphyEmbed *embed,
+ EphyEncodingInfo **info)
{
nsresult result;
EphyWrapper *wrapper;
- g_return_val_if_fail (encoding != NULL, G_FAILED);
- *encoding = NULL;
+ g_return_val_if_fail (info != NULL, G_FAILED);
+ *info = NULL;
wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
+ // we want to use get_encoding_info on newly opened tabs too :/
+ //g_return_val_if_fail (wrapper != NULL, G_FAILED);
+ if (wrapper == NULL) return G_FAILED;
- result = wrapper->GetEncoding (encoding);
+ result = wrapper->GetEncodingInfo (info);
return NS_SUCCEEDED(result) ? G_OK : G_FAILED;
}
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index 0b170b555..7dde69462 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -387,7 +387,8 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
{
GConfClient *client = eel_gconf_client_get_global ();
guint i;
- GList *codes, *l;
+ const EphyFontsLanguageInfo *font_languages;
+ guint n_font_languages;
for (i = 0; conversion_table[i].gconf_key != NULL; i++)
{
@@ -425,10 +426,12 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
}
/* fonts notifiers */
- codes = ephy_font_langs_get_codes_list ();
- for (l = codes; l != NULL; l = l->next)
+ font_languages = ephy_font_languages ();
+ n_font_languages = ephy_font_n_languages ();
+
+ for (i=0; i < n_font_languages; i++)
{
- const char *code = (char*) l->data;
+ const char *code = font_languages[i].code;
guint k;
char *types [] = { "variable", "monospace" };
char key[255];
@@ -467,7 +470,6 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
info);
font_infos = g_list_prepend (font_infos, info);
}
- g_list_free (codes);
}
void