diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-10-12 01:36:32 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-10-12 01:36:32 +0800 |
commit | 0b5f13ef5a9f6a28812cfa959ad9f5b786312ad2 (patch) | |
tree | 0ea5527c72c09963efef6ae55938c3b36969ad04 /embed/mozilla | |
parent | 6c4b99d210e3391080ce18502a507dc38869189c (diff) | |
download | gsoc2013-epiphany-0b5f13ef5a9f6a28812cfa959ad9f5b786312ad2.tar gsoc2013-epiphany-0b5f13ef5a9f6a28812cfa959ad9f5b786312ad2.tar.gz gsoc2013-epiphany-0b5f13ef5a9f6a28812cfa959ad9f5b786312ad2.tar.bz2 gsoc2013-epiphany-0b5f13ef5a9f6a28812cfa959ad9f5b786312ad2.tar.lz gsoc2013-epiphany-0b5f13ef5a9f6a28812cfa959ad9f5b786312ad2.tar.xz gsoc2013-epiphany-0b5f13ef5a9f6a28812cfa959ad9f5b786312ad2.tar.zst gsoc2013-epiphany-0b5f13ef5a9f6a28812cfa959ad9f5b786312ad2.zip |
Encoding menu improvements, part 2: Implement ephy_embed_get_encoding, and
2003-10-11 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed.c: (ephy_embed_get_encoding):
* embed/ephy-embed.h:
* embed/mozilla/EphyWrapper.cpp:
* embed/mozilla/EphyWrapper.h:
* embed/mozilla/mozilla-embed.cpp:
* src/ephy-encoding-menu.c: (ephy_encoding_menu_verb_cb),
(update_encoding_menu_cb), (ephy_encoding_menu_set_window):
Encoding menu improvements, part 2: Implement ephy_embed_get_encoding,
and use it in the menu to indicate the encoding of the loaded page.
Diffstat (limited to 'embed/mozilla')
-rw-r--r-- | embed/mozilla/EphyWrapper.cpp | 18 | ||||
-rw-r--r-- | embed/mozilla/EphyWrapper.h | 6 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 29 |
3 files changed, 49 insertions, 4 deletions
diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp index 8bd7051d4..bd3fe3ab4 100644 --- a/embed/mozilla/EphyWrapper.cpp +++ b/embed/mozilla/EphyWrapper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 Marco Pesenti Gritti + * Copyright (C) 2000-2003 Marco Pesenti Gritti * * 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 @@ -14,6 +14,8 @@ * 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$ */ #include "EphyWrapper.h" @@ -749,3 +751,17 @@ nsresult EphyWrapper::PopTargetDocument () return NS_OK; } + +nsresult EphyWrapper::GetEncoding (nsCString &aEncoding) +{ + nsresult result; + + nsCOMPtr<nsIDOMDocument> domDoc; + result = GetDOMDocument (getter_AddRefs(domDoc)); + if (NS_FAILED (result) || !domDoc) return NS_ERROR_FAILURE; + + nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc, &result); + if (NS_FAILED (result) || !doc) return NS_ERROR_FAILURE; + + return doc->GetDocumentCharacterSet (aEncoding); +} diff --git a/embed/mozilla/EphyWrapper.h b/embed/mozilla/EphyWrapper.h index 2f5131ee6..51e99ad66 100644 --- a/embed/mozilla/EphyWrapper.h +++ b/embed/mozilla/EphyWrapper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 Marco Pesenti Gritti + * Copyright (C) 2000-2003 Marco Pesenti Gritti * * 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 @@ -14,6 +14,8 @@ * 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_WRAPPER_H @@ -76,6 +78,8 @@ public: nsresult ForceEncoding (const char *encoding); + nsresult GetEncoding (nsCString &aEncoding); + nsresult CanCutSelection(PRBool *result); nsresult CanCopySelection(PRBool *result); diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index 0ca866a05..ae1f7f7b1 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -147,7 +147,9 @@ impl_get_security_level (EphyEmbed *embed, static gresult impl_set_encoding (EphyEmbed *embed, const char *encoding); - +static gresult +impl_get_encoding (EphyEmbed *embed, + char **encoding); static gresult impl_print (EphyEmbed *embed, EmbedPrintInfo *info); @@ -378,6 +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->select_all = impl_select_all; embed_class->print = impl_print; embed_class->print_preview_close = impl_print_preview_close; @@ -1173,7 +1176,7 @@ static gresult impl_set_encoding (EphyEmbed *embed, const char *encoding) { - nsresult result = NS_OK; + nsresult result; EphyWrapper *wrapper; wrapper = MOZILLA_EMBED(embed)->priv->wrapper; @@ -1188,6 +1191,28 @@ impl_set_encoding (EphyEmbed *embed, return NS_SUCCEEDED(result) ? G_OK : G_FAILED; } +static gresult +impl_get_encoding (EphyEmbed *embed, + char **encoding) +{ + nsresult result; + EphyWrapper *wrapper; + nsCAutoString enc; + + g_return_val_if_fail (encoding != NULL, G_FAILED); + *encoding = NULL; + + wrapper = MOZILLA_EMBED(embed)->priv->wrapper; + g_return_val_if_fail (wrapper != NULL, G_FAILED); + + result = wrapper->GetEncoding (enc); + if (NS_FAILED (result)) return G_FAILED; + + *encoding = g_strdup (enc.get()); + + return G_OK; +} + static void mozilla_embed_location_changed_cb (GtkMozEmbed *embed, MozillaEmbed *membed) |