aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/mozilla-embed.cpp
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-05-02 04:47:00 +0800
committerChristian Persch <chpe@src.gnome.org>2004-05-02 04:47:00 +0800
commit7093f6ad148d62a9ddc77f8080cf9822d5d24f1f (patch)
tree672ab4fb4d9e9853b14903b6c9019e911773fd93 /embed/mozilla/mozilla-embed.cpp
parent8493f7c5d64b577b3f6b8de91e5bb6c82a8b96ae (diff)
downloadgsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.gz
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.bz2
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.lz
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.xz
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.zst
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.zip
Clean up encoding handling.
2004-05-01 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-embed.c: (ephy_embed_get_encoding), (ephy_embed_has_automatic_encoding): * embed/ephy-embed.h: * embed/ephy-encodings.c: * embed/ephy-encodings.h: * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: * embed/mozilla/MozRegisterComponents.cpp: * embed/mozilla/mozilla-embed.cpp: * src/ephy-encoding-dialog.c: (sync_embed_cb), (activate_choice): * src/ephy-encoding-menu.c: (update_encoding_menu_cb), (encoding_activate_cb): Clean up encoding handling.
Diffstat (limited to 'embed/mozilla/mozilla-embed.cpp')
-rw-r--r--embed/mozilla/mozilla-embed.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 82b8adf14..4452fa334 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -724,31 +724,56 @@ impl_set_encoding (EphyEmbed *embed,
{
MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
nsresult result;
+ nsCAutoString currEnc;
- result = mpriv->browser->ForceEncoding (encoding);
+ g_return_if_fail (encoding != NULL);
+
+ result = mpriv->browser->GetEncoding (currEnc);
if (NS_FAILED (result)) return;
+ if (!currEnc.Equals(encoding) ||
+ encoding[0] == '\0' && !ephy_embed_has_automatic_encoding (embed))
+ {
+ result = mpriv->browser->ForceEncoding (encoding);
+ if (NS_FAILED (result)) return;
+ }
+
gtk_moz_embed_reload (GTK_MOZ_EMBED (embed),
GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE);
}
-static EphyEncodingInfo *
-impl_get_encoding_info (EphyEmbed *embed)
+static char *
+impl_get_encoding (EphyEmbed *embed)
{
MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
nsresult result;
- EphyEncodingInfo *info = NULL;
+ nsCAutoString encoding;
- result = mpriv->browser->GetEncodingInfo (&info);
+ result = mpriv->browser->GetEncoding (encoding);
- if (NS_FAILED (result))
+ if (NS_FAILED (result) || encoding.IsEmpty())
{
- ephy_encoding_info_free (info);
-
return NULL;
}
- return info;
+ return g_strdup (encoding.get());
+}
+
+static gboolean
+impl_has_automatic_encoding (EphyEmbed *embed)
+{
+ MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
+ nsresult result;
+ nsCAutoString encoding;
+
+ result = mpriv->browser->GetForcedEncoding (encoding);
+
+ if (NS_FAILED (result) || encoding.IsEmpty())
+ {
+ return TRUE;
+ }
+
+ return FALSE;
}
static gboolean
@@ -1103,7 +1128,8 @@ ephy_embed_iface_init (EphyEmbedIface *iface)
iface->activate = impl_activate;
iface->find_set_properties = impl_find_set_properties;
iface->set_encoding = impl_set_encoding;
- iface->get_encoding_info = impl_get_encoding_info;
+ iface->get_encoding = impl_get_encoding;
+ iface->has_automatic_encoding = impl_has_automatic_encoding;
iface->print = impl_print;
iface->print_preview_close = impl_print_preview_close;
iface->print_preview_n_pages = impl_print_preview_n_pages;