2

I'm making my own RSS reader, I have a gi.repository.WebKit.WebView widget in which I read summary of RSS items.

What I want to make is to change default behaviour of WebView that clicking in link would load that URL in default system web browser.

How can I detect that user clicked some link in WebView widget, and react on that event?

BPS
  • 1,133
  • 1
  • 17
  • 38

1 Answers1

2

(Assuming this is WebKit1 because of gi.repository.WebKit.)

The navigation-policy-decision-requested signal is how to do it.

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • Although this did work before, if you are using the new WebKit2 (`from gi.repository import WebKit2`) it will not work. Unfortunately the old WebKit python module seems to be unavailable in Ubuntu 17.10 and other newer Debian systems so it would be great to know how to do this with WebKit2. – NoBugs Nov 26 '17 at 04:32
  • I think the best way to do this in WebKit2 would be to create a document level click handler in JS to detect clicks on 'A' elements and then use the script message handlers available in the context manager to send a signal back to the GTK app. – user2997100 Dec 02 '19 at 13:15