aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-01-17 21:58:21 +0800
committerChristian Persch <chpe@src.gnome.org>2006-01-17 21:58:21 +0800
commitf220f9282e63ca352def47b86ec5f9c5c5c57696 (patch)
tree131d1dff90041138a058eaa8e3844f19f5293f3e /embed/mozilla
parentb89fb9d5a5860e5349115717d48b240cf9715f4b (diff)
downloadgsoc2013-epiphany-f220f9282e63ca352def47b86ec5f9c5c5c57696.tar
gsoc2013-epiphany-f220f9282e63ca352def47b86ec5f9c5c5c57696.tar.gz
gsoc2013-epiphany-f220f9282e63ca352def47b86ec5f9c5c5c57696.tar.bz2
gsoc2013-epiphany-f220f9282e63ca352def47b86ec5f9c5c5c57696.tar.lz
gsoc2013-epiphany-f220f9282e63ca352def47b86ec5f9c5c5c57696.tar.xz
gsoc2013-epiphany-f220f9282e63ca352def47b86ec5f9c5c5c57696.tar.zst
gsoc2013-epiphany-f220f9282e63ca352def47b86ec5f9c5c5c57696.zip
Add event type to the callback.
2006-01-17 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-file-helpers.c: (ephy_file_monitor_timeout_cb), (ephy_file_monitor_cb): * lib/ephy-file-helpers.h: Add event type to the callback. * embed/mozilla/EphyUtils.cpp: * embed/mozilla/EphyUtils.h: New function, like NS_NewFileURI (which we can't use since nsNetUtil.h conflicts with embed strings). * embed/mozilla/mozilla-embed-single.cpp: * embed/mozilla/mozilla-notifiers.cpp: Check that the user CSS file exists before registering it. Also handle file-deleted events. * src/bookmarks/ephy-bookmarks-menu.c: (ephy_bookmarks_menu_build): * src/bookmarks/ephy-topics-palette.c: (ephy_topics_palette_constructor), (ephy_topics_palette_class_init): Build fixes.
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/EphyUtils.cpp16
-rw-r--r--embed/mozilla/EphyUtils.h4
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp74
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp7
4 files changed, 76 insertions, 25 deletions
diff --git a/embed/mozilla/EphyUtils.cpp b/embed/mozilla/EphyUtils.cpp
index 24e674591..a043b7e66 100644
--- a/embed/mozilla/EphyUtils.cpp
+++ b/embed/mozilla/EphyUtils.cpp
@@ -30,6 +30,7 @@
#include <nsIIOService.h>
#include <nsIURI.h>
+#include <nsIFile.h>
#include <nsIDOMWindow.h>
#include <nsIServiceManager.h>
#undef MOZILLA_INTERNAL_API
@@ -75,14 +76,23 @@ EphyUtils::NewURI (nsIURI **result,
nsIURI *baseURI)
{
nsresult rv;
-
nsCOMPtr<nsIIOService> ioService;
rv = EphyUtils::GetIOService (getter_AddRefs (ioService));
NS_ENSURE_SUCCESS (rv, rv);
- rv = ioService->NewURI (spec, charset, baseURI, result);
+ return ioService->NewURI (spec, charset, baseURI, result);
+}
- return rv;
+nsresult
+EphyUtils::NewFileURI (nsIURI **result,
+ nsIFile *spec)
+{
+ nsresult rv;
+ nsCOMPtr<nsIIOService> ioService;
+ rv = EphyUtils::GetIOService (getter_AddRefs (ioService));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ return ioService->NewFileURI (spec, result);
}
GtkWidget *
diff --git a/embed/mozilla/EphyUtils.h b/embed/mozilla/EphyUtils.h
index 368e1e59f..a9357a3ba 100644
--- a/embed/mozilla/EphyUtils.h
+++ b/embed/mozilla/EphyUtils.h
@@ -30,6 +30,7 @@ class nsIDOMWindow;
class nsIIOService;
class nsIPrintSettings;
class nsIURI;
+class nsIFile;
struct _EmbedPrintInfo;
namespace EphyUtils
@@ -46,6 +47,9 @@ namespace EphyUtils
const char *charset = nsnull,
nsIURI *baseURI = nsnull);
+ nsresult NewFileURI (nsIURI **result,
+ nsIFile *spec);
+
GtkWidget *FindEmbed (nsIDOMWindow *aDOMWindow);
GtkWidget *FindGtkParent (nsIDOMWindow *aDOMWindow);
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 21b9d7462..0c7d04e0a 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -70,6 +70,7 @@
#include <nsCPasswordManager.h>
#include <nsIPermission.h>
#include <nsIPermissionManager.h>
+#include <nsIFile.h>
#include <nsILocalFile.h>
#include <nsIURI.h>
@@ -138,7 +139,7 @@ struct MozillaEmbedSinglePrivate
guint nm_callback_id;
#endif
#ifdef HAVE_GECKO_1_8
- char *user_css_uri;
+ char *user_css_file;
guint user_css_enabled_notifier_id;
EphyFileMonitor *user_css_file_monitor;
guint user_css_enabled : 1;
@@ -610,15 +611,31 @@ user_css_register (MozillaEmbedSingle *single)
MozillaEmbedSinglePrivate *priv = single->priv;
nsresult rv;
+ nsCOMPtr<nsILocalFile> file;
+ rv = NS_NewNativeLocalFile (nsDependentCString (priv->user_css_file),
+ PR_TRUE, getter_AddRefs (file));
+ NS_ENSURE_SUCCESS (rv, );
+
+ PRBool exists = PR_FALSE;
+ rv = file->Exists (&exists);
+ if (NS_FAILED (rv) || !exists) return;
+
nsCOMPtr<nsIURI> uri;
- rv = EphyUtils::NewURI (getter_AddRefs (uri),
- nsDependentCString (priv->user_css_uri));
+ rv = EphyUtils::NewFileURI (getter_AddRefs (uri), file);
NS_ENSURE_SUCCESS (rv, );
nsCOMPtr<nsIStyleSheetService> service
(do_GetService ("@mozilla.org/content/style-sheet-service;1", &rv));
NS_ENSURE_SUCCESS (rv, );
+ PRBool isRegistered = PR_FALSE;
+ rv = service->SheetRegistered (uri, nsIStyleSheetService::USER_SHEET,
+ &isRegistered);
+ if (NS_SUCCEEDED (rv) && isRegistered)
+ {
+ rv = service->UnregisterSheet (uri, nsIStyleSheetService::USER_SHEET);
+ }
+
rv = service->LoadAndRegisterSheet (uri, nsIStyleSheetService::AGENT_SHEET);
if (NS_FAILED (rv))
{
@@ -632,9 +649,13 @@ user_css_unregister (MozillaEmbedSingle *single)
MozillaEmbedSinglePrivate *priv = single->priv;
nsresult rv;
+ nsCOMPtr<nsILocalFile> file;
+ rv = NS_NewNativeLocalFile (nsDependentCString (priv->user_css_file),
+ PR_TRUE, getter_AddRefs (file));
+ NS_ENSURE_SUCCESS (rv, );
+
nsCOMPtr<nsIURI> uri;
- rv = EphyUtils::NewURI (getter_AddRefs (uri),
- nsDependentCString (priv->user_css_uri));
+ rv = EphyUtils::NewFileURI (getter_AddRefs (uri), file);
NS_ENSURE_SUCCESS (rv, );
nsCOMPtr<nsIStyleSheetService> service
@@ -657,12 +678,19 @@ user_css_unregister (MozillaEmbedSingle *single)
static void
user_css_file_monitor_func (EphyFileMonitor *,
const char *,
+ GnomeVFSMonitorEventType event_type,
MozillaEmbedSingle *single)
{
LOG ("Reregistering the user style sheet");
- user_css_unregister (single);
- user_css_register (single);
+ if (event_type == GNOME_VFS_MONITOR_EVENT_DELETED)
+ {
+ user_css_unregister (single);
+ }
+ else
+ {
+ user_css_register (single);
+ }
}
static void
@@ -683,16 +711,21 @@ user_css_enabled_notify (GConfClient *client,
if (enabled)
{
+ char *uri;
+
user_css_register (single);
+ uri = gnome_vfs_get_uri_from_local_path (priv->user_css_file);
+
g_assert (priv->user_css_file_monitor == NULL);
priv->user_css_file_monitor =
- ephy_file_monitor_add (priv->user_css_uri,
- GNOME_VFS_MONITOR_FILE,
- USER_CSS_LOAD_DELAY,
- (EphyFileMonitorFunc) user_css_file_monitor_func,
- NULL,
- single);
+ ephy_file_monitor_add (uri,
+ GNOME_VFS_MONITOR_FILE,
+ USER_CSS_LOAD_DELAY,
+ (EphyFileMonitorFunc) user_css_file_monitor_func,
+ NULL,
+ single);
+ g_free (uri);
}
else
{
@@ -710,13 +743,10 @@ static void
mozilla_stylesheet_init (MozillaEmbedSingle *single)
{
MozillaEmbedSinglePrivate *priv = single->priv;
- char *user_css_file;
- user_css_file = g_build_filename (ephy_dot_dir (),
- USER_STYLESHEET_FILENAME,
- NULL);
- priv->user_css_uri = gnome_vfs_get_uri_from_local_path (user_css_file);
- g_free (user_css_file);
+ priv->user_css_file = g_build_filename (ephy_dot_dir (),
+ USER_STYLESHEET_FILENAME,
+ NULL);
user_css_enabled_notify (NULL, 0, NULL, single);
priv->user_css_enabled_notifier_id =
@@ -743,10 +773,10 @@ mozilla_stylesheet_shutdown (MozillaEmbedSingle *single)
priv->user_css_file_monitor = NULL;
}
- if (priv->user_css_uri != NULL)
+ if (priv->user_css_file != NULL)
{
- g_free (priv->user_css_uri);
- priv->user_css_uri = NULL;
+ g_free (priv->user_css_file);
+ priv->user_css_file = NULL;
}
}
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index 711d401eb..0166bd980 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -921,6 +921,8 @@ mozilla_font_notifiers_init (void)
const EphyFontsLanguageInfo *font_languages;
guint n_font_languages, i;
+ eel_gconf_monitor_add ("/desktop/gnome/interface");
+
font_languages = ephy_font_languages ();
n_font_languages = ephy_font_n_languages ();
@@ -1071,6 +1073,8 @@ mozilla_font_notifiers_init (void)
static void
mozilla_font_notifiers_shutdown (void)
{
+ eel_gconf_monitor_remove ("/desktop/gnome/interface");
+
eel_gconf_notification_remove (desktop_font_data[0].cnxn_id);
eel_gconf_notification_remove (desktop_font_data[1].cnxn_id);
eel_gconf_notification_remove (minimum_font_size_data->cnxn_id);
@@ -1083,6 +1087,9 @@ mozilla_font_notifiers_shutdown (void)
g_strfreev (desktop_font_data[1].font_name_prefs);
g_strfreev (desktop_font_data[1].font_size_prefs);
g_strfreev (minimum_font_size_data->prefs);
+
+ g_free (desktop_font_data);
+ g_free (minimum_font_size_data);
}
extern "C" gboolean