diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-11-19 02:37:36 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-11-19 02:37:36 +0800 |
commit | d79367d043e812c59ccd6893d981a4eb528bd532 (patch) | |
tree | 17e195582e2b02cffa897deb662ffb485797a366 /src | |
parent | abf92fe9de040606889df2a839b55b1228235292 (diff) | |
download | gsoc2013-epiphany-d79367d043e812c59ccd6893d981a4eb528bd532.tar gsoc2013-epiphany-d79367d043e812c59ccd6893d981a4eb528bd532.tar.gz gsoc2013-epiphany-d79367d043e812c59ccd6893d981a4eb528bd532.tar.bz2 gsoc2013-epiphany-d79367d043e812c59ccd6893d981a4eb528bd532.tar.lz gsoc2013-epiphany-d79367d043e812c59ccd6893d981a4eb528bd532.tar.xz gsoc2013-epiphany-d79367d043e812c59ccd6893d981a4eb528bd532.tar.zst gsoc2013-epiphany-d79367d043e812c59ccd6893d981a4eb528bd532.zip |
Delay reloads when we get many change notifications in a short time. Fixes
2005-11-18 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-tab.c:
Delay reloads when we get many change notifications in a short time.
Fixes bug #319993.
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-tab.c | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/src/ephy-tab.c b/src/ephy-tab.c index 84fbe4e00..3d7a5dce0 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -72,6 +72,7 @@ #define MAX_HIDDEN_POPUPS 5 #define RELOAD_DELAY 250 /* ms */ +#define RELOAD_DELAY_MAX_TICKS 40 /* RELOAD_DELAY * RELOAD_DELAY_MAX_TICKS = 10 s */ #define MAX_TITLE_LENGTH 512 /* characters */ struct _EphyTabPrivate @@ -108,7 +109,8 @@ struct _EphyTabPrivate /* File watch */ GnomeVFSMonitorHandle *monitor; - guint reload_scheduled_id; + guint reload_scheduled_id; + guint reload_delay_ticks; }; static void ephy_tab_class_init (EphyTabClass *klass); @@ -359,17 +361,6 @@ ephy_tab_grab_focus (GtkWidget *widget) gtk_widget_grab_focus (GTK_WIDGET (ephy_tab_get_embed (tab))); } -static EphyWindow * -ephy_tab_get_window (EphyTab *tab) -{ - GtkWidget *toplevel; - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (tab)); - g_return_val_if_fail (toplevel != NULL, NULL); - - return EPHY_WINDOW (toplevel); -} - static void ephy_tab_class_init (EphyTabClass *class) { @@ -1271,6 +1262,8 @@ ephy_tab_file_monitor_cancel (EphyTab *tab) g_source_remove (priv->reload_scheduled_id); priv->reload_scheduled_id = 0; } + + priv->reload_delay_ticks = 0; } static gboolean @@ -1279,7 +1272,24 @@ ephy_file_monitor_reload_cb (EphyTab *tab) EphyTabPrivate *priv = tab->priv; EphyEmbed *embed; - LOG ("Reloading file '%s'\n", priv->address); + if (priv->reload_delay_ticks > 0) + { + priv->reload_delay_ticks--; + + /* Run again */ + return TRUE; + } + + if (priv->is_loading) + { + /* Wait a bit to reload if we're still loading! */ + priv->reload_delay_ticks = RELOAD_DELAY_MAX_TICKS / 2; + + /* Run again */ + return TRUE; + } + + LOG ("Reloading file '%s'", priv->address); priv->reload_scheduled_id = 0; @@ -1312,15 +1322,25 @@ ephy_tab_file_monitor_cb (GnomeVFSMonitorHandle *handle, * Delay the reload a little bit so we don't endlessly * reload while a file is written. */ - if (priv->reload_scheduled_id != 0) + if (priv->reload_delay_ticks == 0) + { + priv->reload_delay_ticks = 1; + } + else { - g_source_remove (priv->reload_scheduled_id); + /* 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); } - priv->reload_scheduled_id = - g_timeout_add (RELOAD_DELAY, - (GSourceFunc) ephy_file_monitor_reload_cb, - tab); break; case GNOME_VFS_MONITOR_EVENT_DELETED: @@ -1816,12 +1836,8 @@ static gboolean open_link_in_new_tab (EphyTab *tab, const char *link_address) { - EphyWindow *window; gboolean new_tab; - window = ephy_tab_get_window (tab); - g_return_val_if_fail (window != NULL, FALSE); - new_tab = address_has_web_scheme (link_address); if (new_tab) @@ -2016,6 +2032,7 @@ ephy_tab_init (EphyTab *tab) priv->title = NULL; priv->loading_title = NULL; priv->address_expire = EPHY_TAB_ADDRESS_EXPIRE_NOW; + priv->reload_delay_ticks = 0; embed = ephy_embed_factory_new_object (EPHY_TYPE_EMBED); g_assert (embed != NULL); |