aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWouter Bolsterlee <uws@xs4all.nl>2006-03-17 22:08:01 +0800
committerWouter Bolsterlee <wbolster@src.gnome.org>2006-03-17 22:08:01 +0800
commit095b733824dbab53cfd02d96142106015cef147e (patch)
treed30bfc29e2730aee74f768da4ec2085111447a5e
parentac26052cb211f8c82ebb7c75a0feb433b6020854 (diff)
downloadgsoc2013-epiphany-095b733824dbab53cfd02d96142106015cef147e.tar
gsoc2013-epiphany-095b733824dbab53cfd02d96142106015cef147e.tar.gz
gsoc2013-epiphany-095b733824dbab53cfd02d96142106015cef147e.tar.bz2
gsoc2013-epiphany-095b733824dbab53cfd02d96142106015cef147e.tar.lz
gsoc2013-epiphany-095b733824dbab53cfd02d96142106015cef147e.tar.xz
gsoc2013-epiphany-095b733824dbab53cfd02d96142106015cef147e.tar.zst
gsoc2013-epiphany-095b733824dbab53cfd02d96142106015cef147e.zip
Add support for local directory monitoring (in addition to local file
2006-03-17 Wouter Bolsterlee <uws@xs4all.nl> * src/ephy-tab.c: (ephy_tab_file_monitor_cb), (ephy_tab_update_file_monitor): Add support for local directory monitoring (in addition to local file monitoring). Bug #332049.
-rw-r--r--ChangeLog8
-rw-r--r--src/ephy-tab.c77
2 files changed, 59 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index c79689cab..536c851d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-03-17 Wouter Bolsterlee <uws@xs4all.nl>
+
+ * src/ephy-tab.c: (ephy_tab_file_monitor_cb),
+ (ephy_tab_update_file_monitor):
+
+ Add support for local directory monitoring (in addition to
+ local file monitoring). Bug #332049.
+
2006-03-13 Christian Persch <chpe@cvs.gnome.org>
* data/chrome/brand.dtd.in:
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 2fa0c31aa..0b4a904dc 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -58,6 +58,7 @@
#include <gtk/gtkmenu.h>
#include <gtk/gtkuimanager.h>
#include <gtk/gtkclipboard.h>
+#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-result.h>
#include <libgnomevfs/gnome-vfs-monitor.h>
#include <libgnomevfs/gnome-vfs-ops.h>
@@ -1312,47 +1313,63 @@ ephy_tab_file_monitor_cb (GnomeVFSMonitorHandle *handle,
GnomeVFSMonitorEventType event_type,
EphyTab *tab)
{
+ gboolean uri_is_directory;
+ gboolean should_reload;
+ char* local_path;
EphyTabPrivate *priv = tab->priv;
LOG ("File '%s' has changed, scheduling reload", monitor_uri);
+ local_path = gnome_vfs_get_local_path_from_uri(monitor_uri);
+ uri_is_directory = g_file_test(local_path, G_FILE_TEST_IS_DIR);
+ g_free(local_path);
+
switch (event_type)
{
+ /* These events will always trigger a reload: */
case GNOME_VFS_MONITOR_EVENT_CHANGED:
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.
- */
- if (priv->reload_delay_ticks == 0)
- {
- priv->reload_delay_ticks = 1;
- }
- else
- {
- /* Exponential backoff */
- priv->reload_delay_ticks = MIN (priv->reload_delay_ticks * 2,
- RELOAD_DELAY_MAX_TICKS);
- }
-
- if (priv->reload_scheduled_id == 0)
- {
- priv->reload_scheduled_id =
- g_timeout_add (RELOAD_DELAY,
- (GSourceFunc) ephy_file_monitor_reload_cb,
- tab);
- }
-
+ should_reload = TRUE;
break;
+ /* These events will only trigger a reload for directories: */
case GNOME_VFS_MONITOR_EVENT_DELETED:
+ case GNOME_VFS_MONITOR_EVENT_METADATA_CHANGED:
+ should_reload = uri_is_directory;
+ break;
+
+ /* These events don't trigger a reload: */
case GNOME_VFS_MONITOR_EVENT_STARTEXECUTING:
case GNOME_VFS_MONITOR_EVENT_STOPEXECUTING:
- case GNOME_VFS_MONITOR_EVENT_METADATA_CHANGED:
default:
+ should_reload = FALSE;
break;
}
+
+ if (should_reload) {
+ /* 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.
+ */
+ if (priv->reload_delay_ticks == 0)
+ {
+ priv->reload_delay_ticks = 1;
+ }
+ else
+ {
+ /* Exponential backoff */
+ priv->reload_delay_ticks = MIN (priv->reload_delay_ticks * 2,
+ RELOAD_DELAY_MAX_TICKS);
+ }
+
+ if (priv->reload_scheduled_id == 0)
+ {
+ priv->reload_scheduled_id =
+ g_timeout_add (RELOAD_DELAY,
+ (GSourceFunc) ephy_file_monitor_reload_cb, tab);
+ }
+ }
}
static void
@@ -1362,6 +1379,8 @@ ephy_tab_update_file_monitor (EphyTab *tab,
EphyTabPrivate *priv = tab->priv;
GnomeVFSMonitorHandle *handle = NULL;
gboolean local;
+ char* local_path;
+ GnomeVFSMonitorType monitor_type;
if (priv->monitor != NULL &&
priv->address != NULL && address != NULL &&
@@ -1377,8 +1396,14 @@ ephy_tab_update_file_monitor (EphyTab *tab,
local = g_str_has_prefix (address, "file://");
if (local == FALSE) return;
+ local_path = gnome_vfs_get_local_path_from_uri(address);
+ monitor_type = g_file_test(local_path, G_FILE_TEST_IS_DIR)
+ ? GNOME_VFS_MONITOR_DIRECTORY
+ : GNOME_VFS_MONITOR_FILE;
+ g_free(local_path);
+
if (gnome_vfs_monitor_add (&handle, address,
- GNOME_VFS_MONITOR_FILE,
+ monitor_type,
(GnomeVFSMonitorCallback) ephy_tab_file_monitor_cb,
tab) == GNOME_VFS_OK)
{