diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2020-05-25 20:17:19 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2020-05-25 20:17:19 +0200 |
commit | c3b87b404d803e2eaa6bf179b2bb370c874ffa75 (patch) | |
tree | 057c19e3afcf8e79f25f66340ee666614e2978c4 /plugins/common/WebAuthenticationPane.vala | |
parent | 959dc1b29b9d4dd9d3fc56c7759afc77788ec256 (diff) |
New upstream version 0.30.10upstream/0.30.10
Diffstat (limited to 'plugins/common/WebAuthenticationPane.vala')
-rw-r--r-- | plugins/common/WebAuthenticationPane.vala | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/plugins/common/WebAuthenticationPane.vala b/plugins/common/WebAuthenticationPane.vala index 43afe65..669e339 100644 --- a/plugins/common/WebAuthenticationPane.vala +++ b/plugins/common/WebAuthenticationPane.vala @@ -8,23 +8,63 @@ using Spit.Publishing; namespace Shotwell.Plugins.Common { public abstract class WebAuthenticationPane : Spit.Publishing.DialogPane, Object { public DialogPane.GeometryOptions preferred_geometry { - get; construct; default = DialogPane.GeometryOptions.NONE; + get; construct; default = DialogPane.GeometryOptions.COLOSSAL_SIZE; } public string login_uri { owned get; construct; } public Error load_error { get; private set; default = null; } private WebKit.WebView webview; + private Gtk.Widget widget; + private Gtk.Entry entry; + + public void clear() { + try { + debug("Clearing the data of WebKit..."); + this.webview.get_website_data_manager().clear.begin(WebKit.WebsiteDataTypes.ALL, (GLib.TimeSpan)0); + } catch (Error e) { + // Do nothing + message("Failed to clear data: %s", e.message); + } + } public override void constructed () { base.constructed (); + var box = new Gtk.Box(Gtk.Orientation.VERTICAL, 4); + this.widget = box; + this.entry = new Gtk.Entry(); + this.entry.editable = false; + this.entry.get_style_context().add_class("flat"); + this.entry.get_style_context().add_class("read-only"); + box.pack_start (entry, false, false, 6); + this.webview = new WebKit.WebView (); this.webview.get_settings ().enable_plugins = false; this.webview.load_changed.connect (this.on_page_load_changed); this.webview.load_failed.connect (this.on_page_load_failed); this.webview.context_menu.connect ( () => { return false; }); + this.webview.decide_policy.connect (this.on_decide_policy); + this.webview.bind_property("uri", this.entry, "text", GLib.BindingFlags.DEFAULT); + box.pack_end (this.webview); + } + + private bool on_decide_policy(WebKit.PolicyDecision decision, WebKit.PolicyDecisionType type) { + switch (type) { + case WebKit.PolicyDecisionType.NEW_WINDOW_ACTION: { + var navigation = (WebKit.NavigationPolicyDecision) decision; + var action = navigation.get_navigation_action(); + var uri = action.get_request().uri; + decision.ignore(); + AppInfo.launch_default_for_uri_async.begin(uri, null); + return true; + } + default: + break; + } + + return false; } public abstract void on_page_load (); @@ -78,7 +118,7 @@ namespace Shotwell.Plugins.Common { } public Gtk.Widget get_widget() { - return this.webview; + return this.widget; } public void on_pane_installed () { @@ -86,6 +126,7 @@ namespace Shotwell.Plugins.Common { } public void on_pane_uninstalled() { + this.clear(); } } } |