Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
fix: navigate or open browser if new webview is requested
Browse files Browse the repository at this point in the history
  • Loading branch information
lleyton committed Aug 23, 2023
1 parent b8489a7 commit 577706b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ public class SkiffDesktop.MainWindow : He.ApplicationWindow {
);
}

private Gtk.Widget on_create (WebKit.NavigationAction navigation_action) {
var requst = navigation_action.get_request ();
var uri = requst.get_uri ();

if (uri.has_prefix (BASE_URL)) {
webview.load_uri (uri);
} else {
new Gtk.UriLauncher (uri).launch (this, null, null);
}

return null;
}

private bool on_decide_policy (
WebKit.WebView web_view,
WebKit.PolicyDecision policy_decision,
Expand Down Expand Up @@ -99,6 +112,7 @@ public class SkiffDesktop.MainWindow : He.ApplicationWindow {
settings.enable_developer_extras = true;

webview.decide_policy.connect (on_decide_policy);
webview.create.connect (on_create);

webview.vexpand = true;
main_box.append (webview);
Expand Down

0 comments on commit 577706b

Please sign in to comment.