summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-09-17 05:07:42 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-09-17 05:07:42 (EDT)
commitaef05e105fb157d8856863c7858d1ce596bd6f2e (patch)
treefb8b5f7d2b67ed904979078987a64527aa04c9e9 /src
parente8507a09988fb4307051d34fb5facf8621df3e7e (diff)
downloadmarquee-aef05e105fb157d8856863c7858d1ce596bd6f2e.zip
marquee-aef05e105fb157d8856863c7858d1ce596bd6f2e.tar.gz
marquee-aef05e105fb157d8856863c7858d1ce596bd6f2e.tar.bz2
src/tab-chrome.[ch]: Hack around progress bar issue
If loading fails, the WebKitWebView's "estimated-load-progress" is set to 1.0 after signals like "load-changed" and "load-failed" are emitted. So the only way to avoid leaving behind a full progress bar after, for example, canceling a page load is to save a flag on a failed load and only update the progress bar if the flag is unset.
Diffstat (limited to 'src')
-rw-r--r--src/tab-chrome.c18
-rw-r--r--src/tab-chrome.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c
index c3d5860..719d362 100644
--- a/src/tab-chrome.c
+++ b/src/tab-chrome.c
@@ -113,6 +113,8 @@ navigation_toolbar_new(MqTabChrome *chrome, gchar *uri)
gtk_widget_set_hexpand(GTK_WIDGET(navigation_toolbar), TRUE);
+ chrome->load_failed = FALSE;
+
return GTK_WIDGET(navigation_toolbar);
}
@@ -184,10 +186,24 @@ load_changed_cb(WebKitWebView *web_view, WebKitLoadEvent load_event,
webkit_web_view_can_go_forward(web_view));
}
+static gboolean
+load_failed_cb(WebKitWebView __attribute__((unused)) *web_view,
+ WebKitLoadEvent __attribute__((unused)) load_event,
+ gchar __attribute__((unused)) *failing_uri,
+ GError __attribute__((unused)) *error, MqTabChrome *chrome)
+{
+ chrome->load_failed = TRUE;
+ return FALSE;
+}
+
static void
load_progress_cb(WebKitWebView *web_view,
GParamSpec __attribute__((unused)) *paramspec, MqTabChrome *chrome)
{
+ if (chrome->load_failed) {
+ chrome->load_failed = FALSE;
+ return;
+ }
gtk_entry_set_progress_fraction(GTK_ENTRY(chrome->uri_entry),
webkit_web_view_get_estimated_load_progress(web_view));
}
@@ -239,6 +255,8 @@ connect_web_view(MqTabChrome *chrome)
{
g_signal_connect(chrome->web_view, "load-changed",
G_CALLBACK(load_changed_cb), chrome);
+ g_signal_connect(chrome->web_view, "load-failed",
+ G_CALLBACK(load_failed_cb), chrome);
g_signal_connect(chrome->web_view, "notify::estimated-load-progress",
G_CALLBACK(load_progress_cb), chrome);
g_signal_connect(chrome->web_view, "notify::uri",
diff --git a/src/tab-chrome.h b/src/tab-chrome.h
index 90182ef..aef59f9 100644
--- a/src/tab-chrome.h
+++ b/src/tab-chrome.h
@@ -37,6 +37,7 @@ typedef struct {
GtkToolItem *stop_reload_button;
GtkWidget *uri_entry;
WebKitWebView *web_view;
+ gboolean load_failed;
} MqTabChrome;
MqTabChrome *