diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-01-17 21:58:21 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-01-17 21:58:21 +0800 |
commit | f220f9282e63ca352def47b86ec5f9c5c5c57696 (patch) | |
tree | 131d1dff90041138a058eaa8e3844f19f5293f3e | |
parent | b89fb9d5a5860e5349115717d48b240cf9715f4b (diff) | |
download | gsoc2013-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.
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | embed/mozilla/EphyUtils.cpp | 16 | ||||
-rw-r--r-- | embed/mozilla/EphyUtils.h | 4 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 74 | ||||
-rw-r--r-- | embed/mozilla/mozilla-notifiers.cpp | 7 | ||||
-rw-r--r-- | lib/ephy-file-helpers.c | 21 | ||||
-rw-r--r-- | lib/ephy-file-helpers.h | 2 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-menu.c | 4 | ||||
-rw-r--r-- | src/bookmarks/ephy-topics-palette.c | 10 |
9 files changed, 126 insertions, 39 deletions
@@ -1,5 +1,32 @@ 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. + +2006-01-17 Christian Persch <chpe@cvs.gnome.org> + * src/ephy-main.c: Fix compile with libgnome HEAD. 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 diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index 60d9a8790..b8acb26fb 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -53,6 +53,9 @@ #define EPHY_UUID_ENVVAR "EPHY_UNIQUE" #define EPHY_UUID_ENVSTRING EPHY_UUID_ENVVAR "=" EPHY_UUID +#define DELAY_MAX_TICKS 64 +#define INITIAL_TICKS 2 + static GHashTable *files = NULL; static GHashTable *mime_table = NULL; @@ -955,8 +958,6 @@ ephy_file_launch_handler (const char *mime_type, return ret; } -#define DELAY_MAX_TICKS 64 - struct _EphyFileMonitor { GnomeVFSMonitorHandle *handle; @@ -967,6 +968,7 @@ struct _EphyFileMonitor guint delay; guint timeout_id; guint ticks; + GnomeVFSMonitorEventType type; }; static gboolean @@ -991,7 +993,7 @@ ephy_file_monitor_timeout_cb (EphyFileMonitor *monitor) monitor->timeout_id = 0; - monitor->callback (monitor, monitor->uri, monitor->user_data); + monitor->callback (monitor, monitor->uri, monitor->type, monitor->user_data); /* don't run again */ return FALSE; @@ -1009,12 +1011,16 @@ ephy_file_monitor_cb (GnomeVFSMonitorHandle *handle, switch (event_type) { case GNOME_VFS_MONITOR_EVENT_CHANGED: + monitor->ticks = INITIAL_TICKS; + /* fall-through */ case GNOME_VFS_MONITOR_EVENT_CREATED: /* We make a lot of assumptions here, but basically we know * that we just have to reload, by construction. * Delay the reload a little bit so we don't endlessly * reload while a file is written. */ + monitor->type = event_type; + if (monitor->ticks == 0) { monitor->ticks = 1; @@ -1037,6 +1043,15 @@ ephy_file_monitor_cb (GnomeVFSMonitorHandle *handle, break; case GNOME_VFS_MONITOR_EVENT_DELETED: + if (monitor->timeout_id != 0) + { + g_source_remove (monitor->timeout_id); + monitor->timeout_id = 0; + } + monitor->ticks = 0; + + monitor->callback (monitor, monitor->uri, event_type, monitor->user_data); + break; case GNOME_VFS_MONITOR_EVENT_STARTEXECUTING: case GNOME_VFS_MONITOR_EVENT_STOPEXECUTING: case GNOME_VFS_MONITOR_EVENT_METADATA_CHANGED: diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h index 709ff77b0..15a1ff825 100644 --- a/lib/ephy-file-helpers.h +++ b/lib/ephy-file-helpers.h @@ -37,7 +37,7 @@ typedef enum } EphyMimePermission; typedef struct _EphyFileMonitor EphyFileMonitor; -typedef void (* EphyFileMonitorFunc) (EphyFileMonitor*, const char*, gpointer); +typedef void (* EphyFileMonitorFunc) (EphyFileMonitor*, const char*, GnomeVFSMonitorEventType, gpointer); typedef gboolean (* EphyFileMonitorDelayFunc) (EphyFileMonitor*, gpointer); const char *ephy_file (const char *filename); diff --git a/src/bookmarks/ephy-bookmarks-menu.c b/src/bookmarks/ephy-bookmarks-menu.c index 15126fd11..71f7ba3b4 100644 --- a/src/bookmarks/ephy-bookmarks-menu.c +++ b/src/bookmarks/ephy-bookmarks-menu.c @@ -252,10 +252,12 @@ ephy_bookmarks_menu_build (GString *string, EphyNode *parent) /* Otherwise, build the menu with "Open in tabs". */ else { + char *name; + append_menu (string, topics, children, flags); g_ptr_array_free (topics, TRUE); - char *name = ephy_open_tabs_action_name (node); + name = ephy_open_tabs_action_name (node); g_string_append_printf (string, "<separator/><menuitem action=\"%s\" name=\"OpenTabs\"/>", name); g_free (name); diff --git a/src/bookmarks/ephy-topics-palette.c b/src/bookmarks/ephy-topics-palette.c index ad2731dec..6c6f643aa 100644 --- a/src/bookmarks/ephy-topics-palette.c +++ b/src/bookmarks/ephy-topics-palette.c @@ -430,6 +430,7 @@ ephy_topics_palette_constructor (GType type, priv->store = gtk_list_store_new (COLUMNS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (priv->store)); + g_object_unref (priv->store); column = gtk_tree_view_column_new (); @@ -464,14 +465,6 @@ ephy_topics_palette_init (EphyTopicsPalette *palette) palette->priv = EPHY_TOPICS_PALETTE_GET_PRIVATE (palette); } -static void -ephy_topics_palette_finalize (GObject *object) -{ - EphyTopicsPalette *palette = EPHY_TOPICS_PALETTE (object); - - parent_class->finalize (object); -} - GtkWidget * ephy_topics_palette_new (EphyBookmarks *bookmarks, EphyNode *bookmark) @@ -498,7 +491,6 @@ ephy_topics_palette_class_init (EphyTopicsPaletteClass *klass) object_class->set_property = ephy_topics_palette_set_property; object_class->constructor = ephy_topics_palette_constructor; - object_class->finalize = ephy_topics_palette_finalize; g_object_class_install_property (object_class, PROP_BOOKMARKS, |