From c3b87b404d803e2eaa6bf179b2bb370c874ffa75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 25 May 2020 20:17:19 +0200 Subject: New upstream version 0.30.10 --- plugins/common/WebAuthenticationPane.vala | 45 +++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'plugins/common/WebAuthenticationPane.vala') 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(); } } } -- cgit v1.2.3