diff options
author | Philip Chimento <philip@endlessm.com> | 2013-10-31 13:35:36 -0700 |
---|---|---|
committer | Philip Chimento <philip@endlessm.com> | 2013-10-31 13:35:36 -0700 |
commit | 694d86d1a31e23bb55904f09a7945e919c467ac8 (patch) | |
tree | 77d454ad7cf6221801ca2d839af7bcee1268bc99 | |
parent | a8d92de4fe00c9764aa5fb1d1cdd2046d7df1ab7 (diff) |
Show 'browser-' URIs in system browser
If the URI scheme starts with 'browser-', then show the corresponding
URI without 'browser-' in the system default browser. e.g. shows
browser-http://google.com as http://google.com in the system browser.
[endlessm/eos-sdk#383]
-rw-r--r-- | wikipedia/WikipediaWebView.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/wikipedia/WikipediaWebView.js b/wikipedia/WikipediaWebView.js index 8630c78..b898ba6 100644 --- a/wikipedia/WikipediaWebView.js +++ b/wikipedia/WikipediaWebView.js @@ -1,4 +1,6 @@ +const Gdk = imports.gi.Gdk; const Gio = imports.gi.Gio; +const GLib = imports.gi.GLib; const Gtk = imports.gi.Gtk; const GObject = imports.gi.GObject; const Lang = imports.lang; @@ -143,6 +145,13 @@ const WikipediaWebView = new Lang.Class({ let title = decodeURI(suffix.replace("_", " ", 'g')); this.loadArticleByTitle(title); return true; + } else if (GLib.uri_parse_scheme(uri).startsWith('browser-')) { + // Open everything that starts with 'browser-' in the system + // browser + let realURI = uri.slice('browser-'.length); + printerr('Showing', realURI); + Gtk.show_uri(null, realURI, Gdk.CURRENT_TIME); + return true; // handled } } return false; // not handled, default behavior |