diff options
author | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-02-06 04:28:09 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-02-06 04:28:09 +0800 |
commit | 768eae4a4874a7fe0eada98423f61d84f6416bde (patch) | |
tree | 707977820ddbc47121fb107c8569cbb5bb2ef566 /embed/mozilla | |
parent | 4e522c23a0650605cf8270f381ca10f2f35bbf78 (diff) | |
download | gsoc2013-epiphany-768eae4a4874a7fe0eada98423f61d84f6416bde.tar gsoc2013-epiphany-768eae4a4874a7fe0eada98423f61d84f6416bde.tar.gz gsoc2013-epiphany-768eae4a4874a7fe0eada98423f61d84f6416bde.tar.bz2 gsoc2013-epiphany-768eae4a4874a7fe0eada98423f61d84f6416bde.tar.lz gsoc2013-epiphany-768eae4a4874a7fe0eada98423f61d84f6416bde.tar.xz gsoc2013-epiphany-768eae4a4874a7fe0eada98423f61d84f6416bde.tar.zst gsoc2013-epiphany-768eae4a4874a7fe0eada98423f61d84f6416bde.zip |
*** empty log message ***
Diffstat (limited to 'embed/mozilla')
-rw-r--r-- | embed/mozilla/ContentHandler.h | 2 | ||||
-rw-r--r-- | embed/mozilla/EventContext.cpp | 4 | ||||
-rw-r--r-- | embed/mozilla/GlobalHistory.cpp | 2 | ||||
-rw-r--r-- | embed/mozilla/Makefile.am | 13 | ||||
-rw-r--r-- | embed/mozilla/MozRegisterComponents.cpp | 24 | ||||
-rw-r--r-- | embed/mozilla/PromptService.cpp | 1 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-shell.h | 55 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp (renamed from embed/mozilla/mozilla-embed-shell.cpp) | 222 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.h | 53 | ||||
-rw-r--r-- | embed/mozilla/mozilla-notifiers.cpp | 19 | ||||
-rw-r--r-- | embed/mozilla/mozilla-notifiers.h | 4 | ||||
-rw-r--r-- | embed/mozilla/mozilla-prefs.cpp | 55 | ||||
-rw-r--r-- | embed/mozilla/mozilla-prefs.h | 10 |
13 files changed, 208 insertions, 256 deletions
diff --git a/embed/mozilla/ContentHandler.h b/embed/mozilla/ContentHandler.h index 6ae61f657..4a6d816d7 100644 --- a/embed/mozilla/ContentHandler.h +++ b/embed/mozilla/ContentHandler.h @@ -19,7 +19,7 @@ #ifndef __ContentHandler_h #define __ContentHandler_h -#include "mozilla-embed-shell.h" +#include "ephy-embed-shell.h" #include <libgnomevfs/gnome-vfs-mime-handlers.h> #include "nsIHelperAppLauncherDialog.h" diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp index 9d4e312b6..78a01e451 100644 --- a/embed/mozilla/EventContext.cpp +++ b/embed/mozilla/EventContext.cpp @@ -525,16 +525,12 @@ nsresult EventContext::GetCSSBackground (nsIDOMNode *node, nsAutoString& url) nsresult EventContext::GetMouseEventInfo (EphyEmbedEvent *info) { nsresult result; - DOMTimeStamp ts; nsIDOMMouseEvent *aMouseEvent = (nsIDOMMouseEvent*)mEvent; aMouseEvent->GetButton ((PRUint16*)&info->mouse_button); aMouseEvent->GetScreenX ((PRInt32*)&info->mouse_x); aMouseEvent->GetScreenY ((PRInt32*)&info->mouse_y); - aMouseEvent->GetTimeStamp(&ts); - info->timestamp = ts; - /* be sure we are not clicking on the scroolbars */ nsCOMPtr<nsIDOMNSEvent> nsEvent = do_QueryInterface(aMouseEvent, &result); diff --git a/embed/mozilla/GlobalHistory.cpp b/embed/mozilla/GlobalHistory.cpp index 054b7a5df..8507ad7e9 100644 --- a/embed/mozilla/GlobalHistory.cpp +++ b/embed/mozilla/GlobalHistory.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "mozilla-embed-shell.h" +#include "ephy-embed-shell.h" #include "nsCOMPtr.h" #include "nsISupportsArray.h" diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am index dd24d6c1e..34db7859e 100644 --- a/embed/mozilla/Makefile.am +++ b/embed/mozilla/Makefile.am @@ -61,6 +61,8 @@ libephymozillaembed_la_SOURCES = \ BaseProtocolContentHandler.h \ ContentHandler.cpp \ ContentHandler.h \ + EphyEventListener.cpp \ + EphyEventListener.h \ EphyWrapper.cpp \ EphyWrapper.h \ EventContext.cpp \ @@ -91,14 +93,12 @@ libephymozillaembed_la_SOURCES = \ ProgressListener.h \ StartHereProtocolHandler.cpp \ StartHereProtocolHandler.h \ - EphyEventListener.cpp \ - EphyEventListener.h \ mozilla-embed.cpp \ mozilla-embed.h \ mozilla-embed-persist.cpp \ mozilla-embed-persist.h \ - mozilla-embed-shell.cpp \ - mozilla-embed-shell.h \ + mozilla-embed-single.cpp \ + mozilla-embed-single.h \ mozilla-i18n.c \ mozilla-i18n.h \ mozilla-notifiers.cpp \ @@ -107,3 +107,8 @@ libephymozillaembed_la_SOURCES = \ mozilla-prefs.h \ nsUnicharUtils.cpp \ nsUnicharUtils.h + +mozilla_DATA = default-prefs.js +mozilladir = $(pkgdatadir) + +EXTRA_DIST = $(mozilla_DATA) diff --git a/embed/mozilla/MozRegisterComponents.cpp b/embed/mozilla/MozRegisterComponents.cpp index 3c5e64be7..a8950fc70 100644 --- a/embed/mozilla/MozRegisterComponents.cpp +++ b/embed/mozilla/MozRegisterComponents.cpp @@ -34,7 +34,6 @@ #include <nsIFactory.h> #include <nsIComponentManager.h> #include <nsCOMPtr.h> -#include <nsILocalFile.h> #include <glib.h> @@ -55,10 +54,6 @@ NS_METHOD RegisterFactory (nsresult (aFactoryFunc)(nsIFactory** aFactory), const nsCID & aClass, const char *aClassName, const char *aContractID, PRBool aReplace); -NS_METHOD RegisterComponent (const nsCID & aClass, const char *aClassName, - const char *aContractID, const char *aDLLPath, - PRBool aReplace); - //Annoying globals to track the mozilla ftp handler so it can be restored. static PRBool ftpRegistered = PR_FALSE; static nsCOMPtr<nsIFactory> nsFtpFactory; @@ -144,25 +139,6 @@ NS_METHOD RegisterFactory (nsresult (aFactoryFunc)(nsIFactory** aFactory), return rv; } -NS_METHOD RegisterComponent (const nsCID & aClass, const char *aClassName, - const char *aContractID, const char *aDLLPath, - PRBool aReplace) -{ - nsresult rv = NS_OK; - - nsCOMPtr<nsILocalFile> dllFile; - rv = NS_NewLocalFile (NS_ConvertUTF8toUCS2(aDLLPath), PR_TRUE, getter_AddRefs (dllFile)); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - - rv = nsComponentManager::RegisterComponentSpec (aClass, - aClassName, - aContractID, - dllFile, - aReplace, - PR_FALSE); - return rv; -} - /** * mozilla_register_FtpProtocolHandler: Register Ftp Protocol Handler */ diff --git a/embed/mozilla/PromptService.cpp b/embed/mozilla/PromptService.cpp index e6181ae32..6674bdd63 100644 --- a/embed/mozilla/PromptService.cpp +++ b/embed/mozilla/PromptService.cpp @@ -143,6 +143,7 @@ NS_IMETHODIMP CPromptService::AlertCheck (nsIDOMWindow *parent, set_title (dialog, dialogTitle); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_dialog_run (GTK_DIALOG (dialog)); get_check_button (check_button, checkValue); gtk_widget_destroy (dialog); diff --git a/embed/mozilla/mozilla-embed-shell.h b/embed/mozilla/mozilla-embed-shell.h deleted file mode 100644 index daedb2948..000000000 --- a/embed/mozilla/mozilla-embed-shell.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2000, 2001, 2002 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 - * 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. - */ - -#ifndef MOZILLA_EMBED_SHELL_H -#define MOZILLA_EMBED_SHELL_H - -#include "glib.h" -#include "ephy-embed-shell.h" -#include <glib-object.h> - -G_BEGIN_DECLS - -#define MOZILLA_EMBED_SHELL_TYPE (mozilla_embed_shell_get_type ()) -#define MOZILLA_EMBED_SHELL(obj) (GTK_CHECK_CAST ((obj), MOZILLA_EMBED_SHELL_TYPE, MozillaEmbedShell)) -#define MOZILLA_EMBED_SHELL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), MOZILLA_EMBED_SHELL_TYPE, MozillaEmbedShellClass)) -#define IS_MOZILLA_EMBED_SHELL(obj) (GTK_CHECK_TYPE ((obj), MOZILLA_EMBED_SHELL_TYPE)) -#define IS_MOZILLA_EMBED_SHELL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), MOZILLA_EMBED_SHELL)) -#define MOZILLA_EMBED_SHELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOZILLA_EMBED_SHELL_TYPE, MozillaEmbedShellClass)) - -typedef struct MozillaEmbedShell MozillaEmbedShell; -typedef struct MozillaEmbedShellPrivate MozillaEmbedShellPrivate; - -extern GObject *mozilla_js_console; - -struct MozillaEmbedShell -{ - EphyEmbedShell parent; - MozillaEmbedShellPrivate *priv; -}; - -struct MozillaEmbedShellClass -{ - EphyEmbedShellClass parent_class; -}; - -GType mozilla_embed_shell_get_type (void); - -G_END_DECLS - -#endif diff --git a/embed/mozilla/mozilla-embed-shell.cpp b/embed/mozilla/mozilla-embed-single.cpp index 58c692eb4..fe1fbd1f0 100644 --- a/embed/mozilla/mozilla-embed-shell.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -19,7 +19,7 @@ #include "glib.h" #include "ephy-string.h" #include "gtkmozembed.h" -#include "mozilla-embed-shell.h" +#include "mozilla-embed-single.h" #include "mozilla-prefs.h" #include "ephy-prefs.h" #include "ephy-file-helpers.h" @@ -58,53 +58,50 @@ #define MOZILLA_PROFILE_FILE "prefs.js" static void -mozilla_embed_shell_class_init (MozillaEmbedShellClass *klass); +mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass); static void -mozilla_embed_shell_init (MozillaEmbedShell *ges); +mozilla_embed_single_init (MozillaEmbedSingle *ges); static void -mozilla_embed_shell_finalize (GObject *object); +mozilla_embed_single_finalize (GObject *object); -static void -impl_get_capabilities (EphyEmbedShell *shell, - EmbedShellCapabilities *caps); static gresult -impl_clear_cache (EphyEmbedShell *shell, +impl_clear_cache (EphyEmbedSingle *shell, CacheType type); static gresult -impl_set_offline_mode (EphyEmbedShell *shell, +impl_set_offline_mode (EphyEmbedSingle *shell, gboolean offline); static gresult -impl_load_proxy_autoconf (EphyEmbedShell *shell, +impl_load_proxy_autoconf (EphyEmbedSingle *shell, const char* url); static gresult -impl_get_charset_titles (EphyEmbedShell *shell, +impl_get_charset_titles (EphyEmbedSingle *shell, const char *group, GList **charsets); static gresult -impl_get_charset_groups (EphyEmbedShell *shell, +impl_get_charset_groups (EphyEmbedSingle *shell, GList **groups); static gresult -impl_get_font_list (EphyEmbedShell *shell, +impl_get_font_list (EphyEmbedSingle *shell, const char *langGroup, const char *fontType, GList **fontList, char **default_font); static gresult -impl_list_cookies (EphyEmbedShell *shell, +impl_list_cookies (EphyEmbedSingle *shell, GList **cookies); static gresult -impl_remove_cookies (EphyEmbedShell *shell, +impl_remove_cookies (EphyEmbedSingle *shell, GList *cookies); static gresult -impl_list_passwords (EphyEmbedShell *shell, +impl_list_passwords (EphyEmbedSingle *shell, PasswordType type, GList **passwords); static gresult -impl_remove_passwords (EphyEmbedShell *shell, +impl_remove_passwords (EphyEmbedSingle *shell, GList *passwords, PasswordType type); static gresult -impl_show_file_picker (EphyEmbedShell *shell, +impl_show_file_picker (EphyEmbedSingle *shell, GtkWidget *parentWidget, const char *title, const char *directory, @@ -115,13 +112,14 @@ impl_show_file_picker (EphyEmbedShell *shell, FileFormat *file_formats, int *ret_file_format); -static void mozilla_embed_shell_new_window_orphan_cb (GtkMozEmbedSingle *embed, +static void mozilla_embed_single_new_window_orphan_cb (GtkMozEmbedSingle *embed, GtkMozEmbed **retval, guint chrome_mask, - EphyEmbedShell *shell); + EphyEmbedSingle *shell); -struct MozillaEmbedShellPrivate +struct MozillaEmbedSinglePrivate { + char *user_prefs; GHashTable *charsets_hash; GList *sorted_charsets_titles; }; @@ -131,45 +129,44 @@ static NS_DEFINE_CID(kJVMManagerCID, NS_JVMMANAGER_CID); static GObjectClass *parent_class = NULL; GType -mozilla_embed_shell_get_type (void) +mozilla_embed_single_get_type (void) { - static GType mozilla_embed_shell_type = 0; + static GType mozilla_embed_single_type = 0; - if (mozilla_embed_shell_type == 0) + if (mozilla_embed_single_type == 0) { static const GTypeInfo our_info = { - sizeof (MozillaEmbedShellClass), + sizeof (MozillaEmbedSingleClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) mozilla_embed_shell_class_init, + (GClassInitFunc) mozilla_embed_single_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof (MozillaEmbedShell), + sizeof (MozillaEmbedSingle), 0, /* n_preallocs */ - (GInstanceInitFunc) mozilla_embed_shell_init + (GInstanceInitFunc) mozilla_embed_single_init }; - mozilla_embed_shell_type = g_type_register_static (EPHY_EMBED_SHELL_TYPE, - "MozillaEmbedShell", + mozilla_embed_single_type = g_type_register_static (EPHY_EMBED_SINGLE_TYPE, + "MozillaEmbedSingle", &our_info, (GTypeFlags)0); } - return mozilla_embed_shell_type; + return mozilla_embed_single_type; } static void -mozilla_embed_shell_class_init (MozillaEmbedShellClass *klass) +mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - EphyEmbedShellClass *shell_class; + EphyEmbedSingleClass *shell_class; parent_class = (GObjectClass *) g_type_class_peek_parent (klass); - shell_class = EPHY_EMBED_SHELL_CLASS (klass); + shell_class = EPHY_EMBED_SINGLE_CLASS (klass); - object_class->finalize = mozilla_embed_shell_finalize; + object_class->finalize = mozilla_embed_single_finalize; - shell_class->get_capabilities = impl_get_capabilities; 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; @@ -184,7 +181,7 @@ mozilla_embed_shell_class_init (MozillaEmbedShellClass *klass) } static void -mozilla_load_proxy_prefs (MozillaEmbedShell *shell) +mozilla_load_proxy_prefs (MozillaEmbedSingle *shell) { char *tmp; int i, mozilla_mode = 0; @@ -244,48 +241,20 @@ mozilla_load_proxy_prefs (MozillaEmbedShell *shell) /* Autoconfiguration */ tmp = eel_gconf_get_string (CONF_NETWORK_PROXY_AUTO_URL); g_return_if_fail (tmp != NULL); - ephy_embed_shell_load_proxy_autoconf - (EPHY_EMBED_SHELL (shell), tmp); + ephy_embed_single_load_proxy_autoconf + (EPHY_EMBED_SINGLE (shell), tmp); g_free (tmp); } static void -mozilla_set_default_prefs (void) +mozilla_set_default_prefs (MozillaEmbedSingle *mes) { - mozilla_prefs_set_boolean ("mozilla.widget.raise-on-setfocus", - FALSE); - mozilla_prefs_set_boolean ("browser.display.use_system_colors", - FALSE); - - /* set default search engine */ - mozilla_prefs_set_string ("keyword.URL",_("http://www.google.com/search?q=")); - mozilla_prefs_set_boolean ("keyword.enabled", TRUE); - mozilla_prefs_set_boolean ("security.checkloaduri", FALSE); - - /* while we have no UI */ - mozilla_prefs_set_boolean ("wallet.captureForms", FALSE); - - /* deactivate mailcap and mime.types support */ - mozilla_prefs_set_string ("helpers.global_mime_types_file", ""); - mozilla_prefs_set_string ("helpers.global_mailcap_file", ""); - mozilla_prefs_set_string ("helpers.private_mime_types_file", ""); - mozilla_prefs_set_string ("helpers.private_mailcap_file", ""); - - /* dont allow xpi installs from epiphany, there are crashes */ - mozilla_prefs_set_boolean ("xpinstall.enabled", FALSE); - - /* disable sucky XUL ftp view, have nice ns4-like html page instead */ - mozilla_prefs_set_boolean ("network.dir.generate_html", TRUE); - - /* set the right accept encoding flags */ - mozilla_prefs_set_string ("network.http.accept-encoding" , - "gzip, deflate, compress;q=0.9"); - - mozilla_prefs_save (); + mozilla_prefs_load (ephy_file ("default-prefs.js")); + mozilla_prefs_save (mes->priv->user_prefs); } static void -mozilla_init_single (MozillaEmbedShell *mes) +mozilla_init_single (MozillaEmbedSingle *mes) { GtkMozEmbedSingle *single; @@ -298,7 +267,7 @@ mozilla_init_single (MozillaEmbedShell *mes) /* allow creation of orphan windows */ g_signal_connect (G_OBJECT (single), "new_window_orphan", - GTK_SIGNAL_FUNC (mozilla_embed_shell_new_window_orphan_cb), + GTK_SIGNAL_FUNC (mozilla_embed_single_new_window_orphan_cb), mes); } @@ -323,20 +292,21 @@ mozilla_init_profile (void) } static gboolean -is_new_build (void) +is_new_build (MozillaEmbedSingle *mes) { gboolean new_build = FALSE; - char *mozprefs, *build_test; + char *build_test; + char *prefs_file; - mozprefs = g_build_filename (ephy_dot_dir (), - MOZILLA_PROFILE_DIR, - MOZILLA_PROFILE_NAME, - MOZILLA_PROFILE_FILE, - NULL); + prefs_file = g_build_filename (ephy_dot_dir (), + MOZILLA_PROFILE_DIR, + MOZILLA_PROFILE_NAME, + MOZILLA_PROFILE_FILE, + NULL); /* no mozilla prefs ? or new epiphany build */ build_test = eel_gconf_get_string ("/apps/epiphany/gconf_test"); - if (!g_file_test(mozprefs, G_FILE_TEST_EXISTS) || + if (!g_file_test(mes->priv->user_prefs, G_FILE_TEST_EXISTS) || build_test == NULL || strncmp (build_test, __TIME__, 8) != 0) { @@ -344,16 +314,15 @@ is_new_build (void) eel_gconf_set_string ("/apps/epiphany/gconf_test", __TIME__); } - g_free (mozprefs); g_free (build_test); return new_build; } static void -mozilla_init_prefs (void) +mozilla_init_prefs (MozillaEmbedSingle *mes) { - mozilla_set_default_prefs (); + mozilla_set_default_prefs (mes); mozilla_notifiers_set_defaults (); } @@ -398,19 +367,25 @@ mozilla_register_external_protocols (void) } static void -mozilla_embed_shell_init (MozillaEmbedShell *mes) +mozilla_embed_single_init (MozillaEmbedSingle *mes) { gboolean new_build; - - mes->priv = g_new0 (MozillaEmbedShellPrivate, 1); - + + mes->priv = g_new0 (MozillaEmbedSinglePrivate, 1); mes->priv->charsets_hash = NULL; mes->priv->sorted_charsets_titles = NULL; - new_build = is_new_build (); + mes->priv->user_prefs = + g_build_filename (ephy_dot_dir (), + MOZILLA_PROFILE_DIR, + MOZILLA_PROFILE_NAME, + MOZILLA_PROFILE_FILE, + NULL); + + new_build = is_new_build (mes); /* Pre initialization */ - mozilla_notifiers_init (mes); + mozilla_notifiers_init (EPHY_EMBED_SINGLE (mes)); mozilla_init_home (); mozilla_init_profile (); @@ -420,7 +395,7 @@ mozilla_embed_shell_init (MozillaEmbedShell *mes) /* Post initialization */ if (new_build) { - mozilla_init_prefs (); + mozilla_init_prefs (mes); } mozilla_load_proxy_prefs (mes); @@ -435,10 +410,10 @@ mozilla_embed_shell_init (MozillaEmbedShell *mes) } static void -mozilla_embed_shell_new_window_orphan_cb (GtkMozEmbedSingle *embed, +mozilla_embed_single_new_window_orphan_cb (GtkMozEmbedSingle *embed, GtkMozEmbed **retval, guint chrome_mask, - EphyEmbedShell *shell) + EphyEmbedSingle *shell) { /* FIXME conversion duped in mozilla_embed */ EphyEmbed *new_embed; @@ -480,51 +455,34 @@ mozilla_embed_shell_new_window_orphan_cb (GtkMozEmbedSingle *embed, } static void -mozilla_embed_shell_finalize (GObject *object) +mozilla_embed_single_finalize (GObject *object) { - MozillaEmbedShell *mes; + MozillaEmbedSingle *mes; - /* Destroy EphyEmbedShell before because some + /* Destroy EphyEmbedSingle before because some * services depend on xpcom */ G_OBJECT_CLASS (parent_class)->finalize (object); g_return_if_fail (object != NULL); - g_return_if_fail (IS_MOZILLA_EMBED_SHELL (object)); + g_return_if_fail (IS_MOZILLA_EMBED_SINGLE (object)); - mes = MOZILLA_EMBED_SHELL (object); + mes = MOZILLA_EMBED_SINGLE (object); g_return_if_fail (mes->priv != NULL); mozilla_notifiers_free (); - mozilla_prefs_save (); + mozilla_prefs_save (mes->priv->user_prefs); gtk_moz_embed_pop_startup (); - - g_free (mes->priv); -} -static void -impl_get_capabilities (EphyEmbedShell *shell, - EmbedShellCapabilities *caps) -{ - EmbedShellCapabilities mycaps; - - mycaps = (EmbedShellCapabilities) - (CACHE_CLEAR_CAP | - OFFLINE_CAP | - PROXY_AUTOCONF_CAP | - JAVA_CONSOLE_CAP | - JS_CONSOLE_CAP | - CHARSETS_CAP | - COOKIES_CAP | - PASSWORDS_CAP); + g_free (mes->priv->user_prefs); - *caps = mycaps; + g_free (mes->priv); } static gresult -impl_clear_cache (EphyEmbedShell *shell, +impl_clear_cache (EphyEmbedSingle *shell, CacheType type) { nsresult rv; @@ -539,7 +497,7 @@ impl_clear_cache (EphyEmbedShell *shell, } static gresult -impl_set_offline_mode (EphyEmbedShell *shell, +impl_set_offline_mode (EphyEmbedSingle *shell, gboolean offline) { nsresult rv; @@ -555,7 +513,7 @@ impl_set_offline_mode (EphyEmbedShell *shell, } static gresult -impl_load_proxy_autoconf (EphyEmbedShell *shell, +impl_load_proxy_autoconf (EphyEmbedSingle *shell, const char* url) { nsresult rv; @@ -572,7 +530,7 @@ impl_load_proxy_autoconf (EphyEmbedShell *shell, } static gresult -fill_charsets_lists (MozillaEmbedShellPrivate *priv) +fill_charsets_lists (MozillaEmbedSinglePrivate *priv) { nsresult rv; char *tmp; @@ -650,7 +608,7 @@ fill_charsets_lists (MozillaEmbedShellPrivate *priv) } static void -ensure_charsets_tables (MozillaEmbedShell *shell) +ensure_charsets_tables (MozillaEmbedSingle *shell) { if (!shell->priv->charsets_hash) { @@ -659,15 +617,15 @@ ensure_charsets_tables (MozillaEmbedShell *shell) } static gresult -impl_get_charset_titles (EphyEmbedShell *shell, +impl_get_charset_titles (EphyEmbedSingle *shell, const char *group, GList **charsets) { - MozillaEmbedShell *mshell = MOZILLA_EMBED_SHELL(shell); + MozillaEmbedSingle *mshell = MOZILLA_EMBED_SINGLE(shell); int count = get_translated_cscount (); GList *l = NULL; int j; - + ensure_charsets_tables (mshell); g_return_val_if_fail (mshell->priv->charsets_hash != NULL, G_FAILED); @@ -693,7 +651,7 @@ impl_get_charset_titles (EphyEmbedShell *shell, } static gresult -impl_get_charset_groups (EphyEmbedShell *shell, +impl_get_charset_groups (EphyEmbedSingle *shell, GList **groups) { GList *l = NULL; @@ -710,7 +668,7 @@ impl_get_charset_groups (EphyEmbedShell *shell, } static gresult -impl_get_font_list (EphyEmbedShell *shell, +impl_get_font_list (EphyEmbedSingle *shell, const char *langGroup, const char *fontType, GList **fontList, @@ -760,7 +718,7 @@ impl_get_font_list (EphyEmbedShell *shell, } static gresult -impl_list_cookies (EphyEmbedShell *shell, +impl_list_cookies (EphyEmbedSingle *shell, GList **cookies) { nsresult result; @@ -819,7 +777,7 @@ impl_list_cookies (EphyEmbedShell *shell, } static gresult -impl_remove_cookies (EphyEmbedShell *shell, +impl_remove_cookies (EphyEmbedSingle *shell, GList *cookies) { nsresult result; @@ -843,7 +801,7 @@ impl_remove_cookies (EphyEmbedShell *shell, } static gresult -impl_list_passwords (EphyEmbedShell *shell, +impl_list_passwords (EphyEmbedSingle *shell, PasswordType type, GList **passwords) { @@ -892,7 +850,7 @@ impl_list_passwords (EphyEmbedShell *shell, } static gresult -impl_remove_passwords (EphyEmbedShell *shell, +impl_remove_passwords (EphyEmbedSingle *shell, GList *passwords, PasswordType type) { @@ -922,7 +880,7 @@ impl_remove_passwords (EphyEmbedShell *shell, } static gresult -impl_show_file_picker (EphyEmbedShell *shell, +impl_show_file_picker (EphyEmbedSingle *shell, GtkWidget *parentWidget, const char *title, const char *directory, diff --git a/embed/mozilla/mozilla-embed-single.h b/embed/mozilla/mozilla-embed-single.h new file mode 100644 index 000000000..f46760d0c --- /dev/null +++ b/embed/mozilla/mozilla-embed-single.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2000, 2001, 2002 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 + * 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. + */ + +#ifndef MOZILLA_EMBED_SINGLE_H +#define MOZILLA_EMBED_SINGLE_H + +#include "glib.h" +#include "ephy-embed-shell.h" +#include <glib-object.h> + +G_BEGIN_DECLS + +#define MOZILLA_EMBED_SINGLE_TYPE (mozilla_embed_single_get_type ()) +#define MOZILLA_EMBED_SINGLE(obj) (GTK_CHECK_CAST ((obj), MOZILLA_EMBED_SINGLE_TYPE, MozillaEmbedSingle)) +#define MOZILLA_EMBED_SINGLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), MOZILLA_EMBED_SINGLE_TYPE, MozillaEmbedSingleClass)) +#define IS_MOZILLA_EMBED_SINGLE(obj) (GTK_CHECK_TYPE ((obj), MOZILLA_EMBED_SINGLE_TYPE)) +#define IS_MOZILLA_EMBED_SINGLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), MOZILLA_EMBED_SINGLE)) +#define MOZILLA_EMBED_SINGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOZILLA_EMBED_SINGLE_TYPE, MozillaEmbedSingleClass)) + +typedef struct MozillaEmbedSingle MozillaEmbedSingle; +typedef struct MozillaEmbedSinglePrivate MozillaEmbedSinglePrivate; + +struct MozillaEmbedSingle +{ + EphyEmbedSingle parent; + MozillaEmbedSinglePrivate *priv; +}; + +struct MozillaEmbedSingleClass +{ + EphyEmbedSingleClass parent_class; +}; + +GType mozilla_embed_single_get_type (void); + +G_END_DECLS + +#endif diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp index 24dfbb7a5..e188ecb99 100644 --- a/embed/mozilla/mozilla-notifiers.cpp +++ b/embed/mozilla/mozilla-notifiers.cpp @@ -19,6 +19,7 @@ #include "config.h" #include "ephy-embed-shell.h" +#include "ephy-embed-single.h" #include "mozilla-notifiers.h" #include "eel-gconf-extensions.h" #include "mozilla-prefs.h" @@ -82,7 +83,7 @@ static void mozilla_autodetect_charset_notifier(GConfClient *client, guint cnxn_id, GConfEntry *entry, - EphyEmbedShell *shell); + EphyEmbedSingle *single); static void mozilla_default_font_notifier(GConfClient *client, @@ -111,7 +112,7 @@ static void mozilla_default_charset_notifier (GConfClient *client, guint cnxn_id, GConfEntry *entry, - EphyEmbedShell *shell); + EphyEmbedSingle *single); static void mozilla_socks_version_notifier (GConfClient *client, guint cnxn_id, @@ -256,12 +257,14 @@ mozilla_proxy_autoconfig_notifier (GConfClient *client, GConfEntry *entry, char *pref) { - ephy_embed_shell_load_proxy_autoconf - (embed_shell, gconf_value_get_string(entry->value)); + EphyEmbedSingle *single; + single = ephy_embed_shell_get_embed_single (embed_shell); + ephy_embed_single_load_proxy_autoconf + (single, gconf_value_get_string(entry->value)); } void -mozilla_notifiers_init(MozillaEmbedShell *shell) +mozilla_notifiers_init(EphyEmbedSingle *single) { int i; @@ -296,7 +299,7 @@ mozilla_notifiers_init(MozillaEmbedShell *shell) ephy_notification_add( custom_notifiers[i].gconf_key, custom_notifiers[i].func, - (gpointer)shell, + (gpointer)single, &mozilla_notifiers); } @@ -482,7 +485,7 @@ static void mozilla_default_charset_notifier(GConfClient *client, guint cnxn_id, GConfEntry *entry, - EphyEmbedShell *shell) + EphyEmbedSingle *single) { /* FIXME */ } @@ -594,7 +597,7 @@ static void mozilla_autodetect_charset_notifier(GConfClient *client, guint cnxn_id, GConfEntry *entry, - EphyEmbedShell *shell) + EphyEmbedSingle *single) { int charset = eel_gconf_get_integer (CONF_LANGUAGE_AUTODETECT_CHARSET); if (charset < 0 || diff --git a/embed/mozilla/mozilla-notifiers.h b/embed/mozilla/mozilla-notifiers.h index 6718365f7..f7882b83f 100644 --- a/embed/mozilla/mozilla-notifiers.h +++ b/embed/mozilla/mozilla-notifiers.h @@ -19,9 +19,9 @@ #ifndef MOZILLA_NOTIFIERS_H #define MOZILLA_NOTIFIERS_H -#include "mozilla-embed-shell.h" +#include "ephy-embed-single.h" -void mozilla_notifiers_init (MozillaEmbedShell *shell); +void mozilla_notifiers_init (EphyEmbedSingle *single); void mozilla_notifiers_set_defaults (void); diff --git a/embed/mozilla/mozilla-prefs.cpp b/embed/mozilla/mozilla-prefs.cpp index e5b8c68e2..55f9dcc6b 100644 --- a/embed/mozilla/mozilla-prefs.cpp +++ b/embed/mozilla/mozilla-prefs.cpp @@ -22,17 +22,50 @@ #include <nsIPrefService.h> #include <nsIServiceManager.h> #include <nsMemory.h> +#include <nsILocalFile.h> +#include <nsString.h> #include <glib/gmessages.h> #include <glib/gstrfuncs.h> +void +mozilla_prefs_load (const char *filename) +{ + nsresult rv; + + nsCOMPtr<nsILocalFile> prefsLocalFile; + rv = NS_NewLocalFile (NS_ConvertUTF8toUCS2(filename), PR_TRUE, getter_AddRefs (prefsLocalFile)); + g_return_if_fail (NS_SUCCEEDED(rv)); + + nsCOMPtr<nsIPrefService> prefService = + do_GetService (NS_PREFSERVICE_CONTRACTID); + g_return_if_fail (prefService != nsnull); + + nsCOMPtr<nsIFile> prefsFile; + prefsLocalFile->QueryInterface(NS_GET_IID(nsIFile), (void **)&prefsFile); + g_return_if_fail (prefsFile != nsnull); + + prefService->ReadUserPrefs (prefsFile); +} + gboolean -mozilla_prefs_save (void) +mozilla_prefs_save (const char *filename) { + nsresult rv; + + nsCOMPtr<nsILocalFile> prefsLocalFile; + rv = NS_NewLocalFile (NS_ConvertUTF8toUCS2(filename), PR_TRUE, getter_AddRefs (prefsLocalFile)); + g_return_val_if_fail (NS_SUCCEEDED(rv), FALSE); + nsCOMPtr<nsIPrefService> prefService = do_GetService (NS_PREFSERVICE_CONTRACTID); g_return_val_if_fail (prefService != nsnull, FALSE); - nsresult rv = prefService->SavePrefFile (nsnull); + nsCOMPtr<nsIFile> prefsFile; + prefsLocalFile->QueryInterface(NS_GET_IID(nsIFile), (void **)&prefsFile); + g_return_val_if_fail (prefsFile != nsnull, FALSE); + + rv = prefService->SavePrefFile (prefsFile); + return NS_SUCCEEDED (rv) ? TRUE : FALSE; } @@ -165,21 +198,3 @@ mozilla_prefs_get_string(const char *preference_name) return result; } -gboolean -mozilla_prefs_remove (const char *preference_name) -{ - g_return_val_if_fail (preference_name != NULL, FALSE); - - nsCOMPtr<nsIPrefService> prefService = - do_GetService (NS_PREFSERVICE_CONTRACTID); - nsCOMPtr<nsIPrefBranch> pref; - prefService->GetBranch ("", getter_AddRefs(pref)); - - if (pref) - { - nsresult rv = pref->ClearUserPref (preference_name); - return NS_SUCCEEDED (rv) ? TRUE : FALSE; - } - - return FALSE; -} diff --git a/embed/mozilla/mozilla-prefs.h b/embed/mozilla/mozilla-prefs.h index 82055c4a7..91d98c2e0 100644 --- a/embed/mozilla/mozilla-prefs.h +++ b/embed/mozilla/mozilla-prefs.h @@ -21,15 +21,17 @@ #include "glib/gtypes.h" -gboolean mozilla_prefs_save (void); +void mozilla_prefs_load (const char *filename); -gboolean mozilla_prefs_set_string (const char *preference_name, +gboolean mozilla_prefs_save (const char *filename); + +gboolean mozilla_prefs_set_string (const char *preference_name, const char *new_value); gboolean mozilla_prefs_set_boolean (const char *preference_name, gboolean new_boolean_value); -gboolean mozilla_prefs_set_int (const char *preference_name, +gboolean mozilla_prefs_set_int (const char *preference_name, int new_int_value); gboolean mozilla_prefs_get_boolean (const char *preference_name, @@ -39,6 +41,4 @@ int mozilla_prefs_get_int (const char *preference_name); gchar *mozilla_prefs_get_string (const char *preference_name); -gboolean mozilla_prefs_remove (const char *preference_name); - #endif |