From 72e3d4c55a6569d966059f762824c38d06055871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 29 Oct 2016 23:24:31 +0200 Subject: New upstream version 0.25.0 --- plugins/common/WebAuthenticationPane.vala | 75 +++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 plugins/common/WebAuthenticationPane.vala (limited to 'plugins/common/WebAuthenticationPane.vala') diff --git a/plugins/common/WebAuthenticationPane.vala b/plugins/common/WebAuthenticationPane.vala new file mode 100644 index 0000000..0a77cf6 --- /dev/null +++ b/plugins/common/WebAuthenticationPane.vala @@ -0,0 +1,75 @@ +/* Copyright 2016 Jens Georg + * + * This software is licensed under the GNU LGPL (version 2.1 or later). + * See the COPYING file in this distribution. + */ +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; + } + + public string login_uri { owned get; construct; } + + private WebKit.WebView webview; + private Gtk.Box pane_widget; + + public override void constructed () { + base.constructed (); + + this.webview = new WebKit.WebView (); + this.webview.get_settings ().enable_plugins = false; + + this.webview.load_changed.connect (this.on_page_load_changed); + this.webview.context_menu.connect ( () => { return false; }); + + this.pane_widget = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + this.pane_widget.pack_start (this.webview, true, true, 0); + } + + public abstract void on_page_load (); + + protected void set_cursor (Gdk.CursorType type) { + var window = pane_widget.get_window (); + var display = window.get_display (); + var cursor = new Gdk.Cursor.for_display (display, type); + window.set_cursor (cursor); + } + + private void on_page_load_changed (WebKit.LoadEvent load_event) { + switch (load_event) { + case WebKit.LoadEvent.STARTED: + case WebKit.LoadEvent.REDIRECTED: + this.set_cursor (Gdk.CursorType.WATCH); + break; + case WebKit.LoadEvent.FINISHED: + this.set_cursor (Gdk.CursorType.LEFT_PTR); + this.on_page_load (); + break; + default: + break; + } + } + + public WebKit.WebView get_view () { + return this.webview; + } + + public DialogPane.GeometryOptions get_preferred_geometry() { + return this.preferred_geometry; + } + + public Gtk.Widget get_widget() { + return pane_widget; + } + + public void on_pane_installed () { + this.get_view ().load_uri (this.login_uri); + } + + public void on_pane_uninstalled() { + } + } +} -- cgit v1.2.3