summaryrefslogtreecommitdiff
path: root/plugins/common
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2020-05-31 12:05:32 +0200
committerJörg Frings-Fürst <debian@jff.email>2020-05-31 12:05:32 +0200
commita03d7d2e5151332bbe89e5bc36965956cfa7af35 (patch)
tree1667c3a269ad810db3a7a4a592a5721955dbdf01 /plugins/common
parent2db2a00a812ec31ee59c3920ff457290e1f4a05e (diff)
parenta99b581716d7972a62ed6c227a807e304a98d6af (diff)
Merge branch 'release/debian/0.30.10-1'debian/0.30.10-1
Diffstat (limited to 'plugins/common')
-rw-r--r--plugins/common/Resources.vala2
-rw-r--r--plugins/common/WebAuthenticationPane.vala45
2 files changed, 44 insertions, 3 deletions
diff --git a/plugins/common/Resources.vala b/plugins/common/Resources.vala
index ecbf2f8..16306f2 100644
--- a/plugins/common/Resources.vala
+++ b/plugins/common/Resources.vala
@@ -58,7 +58,7 @@ public Gdk.Pixbuf[]? load_from_resource (string resource_path) {
Gdk.Pixbuf? icon = null;
try {
debug ("Loading icon from %s", resource_path);
- icon = new Gdk.Pixbuf.from_resource_at_scale (resource_path, 24, 24, true);
+ icon = new Gdk.Pixbuf.from_resource_at_scale (resource_path, -1, 24, true);
} catch (Error error) {
warning ("Couldn't load icon set from %s: %s", resource_path, error.message);
}
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();
}
}
}