Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

Commit

Permalink
Handle target='blank' links
Browse files Browse the repository at this point in the history
  • Loading branch information
cassidyjames committed Jan 9, 2019
1 parent 4ea7508 commit 1a95f3c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class MainWindow : Gtk.Window {

List<AppInfo> external_apps = GLib.AppInfo.get_all_for_type ("x-scheme-handler/http");

// TODO: Don't dump these all into the headerbar
foreach (AppInfo app_info in external_apps) {
if (app_info.get_id () == GLib.Application.get_default ().application_id + ".desktop") {
continue;
Expand Down Expand Up @@ -165,6 +166,20 @@ public class MainWindow : Gtk.Window {
}
});

web_view.decide_policy.connect ((decision, type) => {
debug ("Decide policy");

if (type == WebKit.PolicyDecisionType.NEW_WINDOW_ACTION) {
debug ("New window");

var nav_decision = (WebKit.NavigationPolicyDecision) decision;
var uri = nav_decision.navigation_action.get_request ().uri;
web_view.load_uri (uri);
}

return false;
});

url_entry.activate.connect (() => {
// TODO: Search?
var url = url_entry.text;
Expand Down

0 comments on commit 1a95f3c

Please sign in to comment.