[devhelp] Tab: connect to decide-policy, not load-changed, to destroy the infobar
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Tab: connect to decide-policy, not load-changed, to destroy the infobar
- Date: Sat, 10 Feb 2018 18:32:05 +0000 (UTC)
commit d674f210f6f9dce3dbf76346e7db7711bbcf29ea
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Feb 10 19:19:47 2018 +0100
Tab: connect to decide-policy, not load-changed, to destroy the infobar
src/dh-tab.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/src/dh-tab.c b/src/dh-tab.c
index 5920529..5be80db 100644
--- a/src/dh-tab.c
+++ b/src/dh-tab.c
@@ -85,16 +85,23 @@ web_view_load_failed_cb (WebKitWebView *web_view,
return GDK_EVENT_STOP;
}
-static void
-web_view_load_changed_cb (WebKitWebView *web_view,
- WebKitLoadEvent load_event,
- DhTab *tab)
+static gboolean
+web_view_decide_policy_cb (WebKitWebView *web_view,
+ WebKitPolicyDecision *decision,
+ WebKitPolicyDecisionType decision_type,
+ DhTab *tab)
{
- if (load_event == WEBKIT_LOAD_STARTED &&
+ if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION &&
tab->priv->info_bar != NULL) {
- /* The error is no longer relevant. */
+ /* The error is no longer relevant. Do it here, not in
+ * ::load-changed, so that it works when clicking on a link to
+ * an anchor inside the same page too, not only when loading a
+ * different page.
+ */
gtk_widget_destroy (GTK_WIDGET (tab->priv->info_bar));
}
+
+ return GDK_EVENT_PROPAGATE;
}
static void
@@ -113,9 +120,14 @@ dh_tab_init (DhTab *tab)
G_CALLBACK (web_view_load_failed_cb),
tab);
+ /* Other ::decide-policy signal handlers that return GDK_EVENT_STOP must
+ * be connected *after* this one. This code relies on the fact that
+ * GObject executes the handlers in the same order than the connection
+ * order (for all the handlers belonging to the same emission stage).
+ */
g_signal_connect (tab->priv->web_view,
- "load-changed",
- G_CALLBACK (web_view_load_changed_cb),
+ "decide-policy",
+ G_CALLBACK (web_view_decide_policy_cb),
tab);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]