diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-30 14:43:36 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-30 15:02:12 (EDT) |
commit | e1d31c94710bf76af6e0c4995ca1240287d01b8e (patch) | |
tree | a61adaa5acf7232849103af2397f864664343578 /src | |
parent | fac6c0ce9820aaf65b0baf1d275bf265a96d842f (diff) | |
download | marquee-e1d31c94710bf76af6e0c4995ca1240287d01b8e.zip marquee-e1d31c94710bf76af6e0c4995ca1240287d01b8e.tar.gz marquee-e1d31c94710bf76af6e0c4995ca1240287d01b8e.tar.bz2 |
MqTabChrome: Set back/forward button sensitivity on list change
The back/forward list apparently often changes after the URI changes,
e.g. when navigating between page fragments.
Diffstat (limited to 'src')
-rw-r--r-- | src/tab-chrome.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c index 548cd78..e368694 100644 --- a/src/tab-chrome.c +++ b/src/tab-chrome.c @@ -563,11 +563,6 @@ load_changed_cb(WebKitWebView *web_view, WebKitLoadEvent load_event, GTK_ENTRY(chrome->uri_entry), 0.0); break; } - - gtk_widget_set_sensitive(GTK_WIDGET(chrome->back_button), - webkit_web_view_can_go_back(web_view)); - gtk_widget_set_sensitive(GTK_WIDGET(chrome->forward_button), - webkit_web_view_can_go_forward(web_view)); } static gboolean @@ -671,11 +666,6 @@ uri_cb(WebKitWebView *web_view, GParamSpec __attribute__((unused)) *paramspec, gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry), uri); g_free(uri); gtk_entry_set_attributes(GTK_ENTRY(chrome->uri_entry), NULL); - - gtk_widget_set_sensitive(GTK_WIDGET(chrome->back_button), - webkit_web_view_can_go_back(web_view)); - gtk_widget_set_sensitive(GTK_WIDGET(chrome->forward_button), - webkit_web_view_can_go_forward(web_view)); } static void @@ -705,6 +695,18 @@ loading_cb(WebKitWebView *web_view, } static void +back_forward_list_changed_cb( + WebKitBackForwardList __attribute__((unused)) *back_forward_list, + WebKitBackForwardListItem __attribute__((unused)) *item_added, + gpointer __attribute__((unused)) items_removed, MqTabChrome *chrome) +{ + gtk_widget_set_sensitive(GTK_WIDGET(chrome->back_button), + webkit_web_view_can_go_back(chrome->web_view)); + gtk_widget_set_sensitive(GTK_WIDGET(chrome->forward_button), + webkit_web_view_can_go_forward(chrome->web_view)); +} + +static void connect_web_view(MqTabChrome *chrome) { chrome->hovered_link_uri = NULL; @@ -721,6 +723,9 @@ connect_web_view(MqTabChrome *chrome) G_CALLBACK(uri_cb), chrome); g_signal_connect(chrome->web_view, "notify::is-loading", G_CALLBACK(loading_cb), chrome); + g_signal_connect( + webkit_web_view_get_back_forward_list(chrome->web_view), + "changed", G_CALLBACK(back_forward_list_changed_cb), chrome); } void |