aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-10-18 06:40:17 +0800
committerChristian Persch <chpe@src.gnome.org>2003-10-18 06:40:17 +0800
commit0e078cd9825b89e128d0501d4a7b5885670c2347 (patch)
tree932814c057bd8d2c6cdee449dc6b267091cef6c5 /embed/mozilla
parent4d9d732ba340aae6430bd687f0cf3252bff2217d (diff)
downloadgsoc2013-epiphany-0e078cd9825b89e128d0501d4a7b5885670c2347.tar
gsoc2013-epiphany-0e078cd9825b89e128d0501d4a7b5885670c2347.tar.gz
gsoc2013-epiphany-0e078cd9825b89e128d0501d4a7b5885670c2347.tar.bz2
gsoc2013-epiphany-0e078cd9825b89e128d0501d4a7b5885670c2347.tar.lz
gsoc2013-epiphany-0e078cd9825b89e128d0501d4a7b5885670c2347.tar.xz
gsoc2013-epiphany-0e078cd9825b89e128d0501d4a7b5885670c2347.tar.zst
gsoc2013-epiphany-0e078cd9825b89e128d0501d4a7b5885670c2347.zip
Encoding menu improvements, Part 4: The Rewrite.
2003-10-18 Christian Persch <chpe@cvs.gnome.org> Encoding menu improvements, Part 4: The Rewrite. * data/glade/epiphany.glade: * data/ui/epiphany-ui.xml: * data/ui/nautilus-epiphany-view.xml.in: * embed/Makefile.am: * embed/ephy-embed-shell.c: (ephy_embed_shell_init), (ephy_embed_shell_finalize), (ephy_embed_shell_new), (ephy_embed_shell_get_encodings): * embed/ephy-embed-shell.h: * embed/ephy-embed-utils.c: (ephy_embed_utils_save): * embed/ephy-embed-utils.h: * embed/ephy-embed.c: (ephy_embed_get_encoding_info): * embed/ephy-embed.h: * embed/ephy-encodings.c: (ephy_encodings_get_type), (ephy_encodings_finalize), (ephy_encodings_class_init), (ephy_encodings_get_node), (ephy_encodings_get_encodings), (ephy_encodings_get_detectors), (ephy_encodings_get_all), (ephy_encodings_get_categories), (ephy_encodings_add_recent), (ephy_encodings_get_recent), (ephy_encodings_init), (ephy_encoding_info_free), (ephy_encodings_new): * embed/ephy-encodings.h: * embed/mozilla/EphyWrapper.cpp: * embed/mozilla/EphyWrapper.h: * embed/mozilla/Makefile.am: * embed/mozilla/mozilla-embed.cpp: * embed/mozilla/mozilla-notifiers.cpp: * lib/Makefile.am: * lib/ephy-encodings.c: * lib/ephy-encodings.h: * lib/ephy-langs.c: (ephy_font_languages), (ephy_font_n_languages): * lib/ephy-langs.h: * src/Makefile.am: * src/ephy-encoding-dialog.c: (ephy_encoding_dialog_get_type), (setup_filter), (sync_embed_cb), (sync_active_tab), (ephy_encoding_dialog_set_window), (activate_choice), (activate_automatic), (ephy_encoding_dialog_response_cb), (category_node_selected_cb), (view_node_selected_cb), (view_node_activated_cb), (ephy_encoding_dialog_init), (ephy_encoding_dialog_finalize), (ephy_encoding_dialog_set_property), (ephy_encoding_dialog_get_property), (ephy_encoding_dialog_class_init), (ephy_encoding_dialog_new): * src/ephy-encoding-dialog.h: * src/ephy-encoding-menu.c: (ephy_encoding_menu_init), (sort_encodings), (add_menu_item), (update_encoding_menu_cb), (encoding_activate_cb), (add_action), (ephy_encoding_menu_view_dialog_cb), (ephy_encoding_menu_automatic_cb), (ephy_encoding_menu_set_window), (ephy_encoding_menu_finalize), (ephy_encoding_menu_class_init), (ephy_encoding_menu_new): * src/ephy-nautilus-view.c: (gnv_bonobo_control_activate_cb), (gnv_cmd_select_encoding), (gnv_cmd_edit_find): * src/ephy-window.c: (ephy_window_set_active_tab), (setup_notebook), (ephy_window_set_property), (ephy_window_get_property), (ephy_window_class_init): * src/language-editor.h: * src/pdm-dialog.c: (setup_passwords_treeview), (setup_cookies_treeview): * src/prefs-dialog.c: (prefs_dialog_finalize), (get_current_language_code), (fonts_language_info_cmp), (create_fonts_language_menu), (find_encoding_in_list_cmp), (sort_encodings), (create_optionmenu), (prefs_dialog_init): Made encodings menu dynamic, containing recently used items + items related to the currently active encoding. Split encodings out as a embed shell service, port all users over to that. Harvest all encoding info we can get from mozilla.
Diffstat (limited to 'embed/mozilla')
-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
5 files changed, 113 insertions, 18 deletions
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