diff options
Diffstat (limited to 'plugins/shotwell-publishing-extras')
3 files changed, 49 insertions, 22 deletions
diff --git a/plugins/shotwell-publishing-extras/Makefile b/plugins/shotwell-publishing-extras/Makefile index 9259fbb..91452cf 100644 --- a/plugins/shotwell-publishing-extras/Makefile +++ b/plugins/shotwell-publishing-extras/Makefile @@ -5,7 +5,7 @@ PLUGIN_PKGS := \ gtk+-3.0 \ libsoup-2.4 \ libxml-2.0 \ - webkitgtk-3.0 \ + webkit2gtk-4.0 \ gee-0.8 \ rest-0.7 \ json-glib-1.0 diff --git a/plugins/shotwell-publishing-extras/YandexPublishing.vala b/plugins/shotwell-publishing-extras/YandexPublishing.vala index 36a3ede..ec99c2b 100644 --- a/plugins/shotwell-publishing-extras/YandexPublishing.vala +++ b/plugins/shotwell-publishing-extras/YandexPublishing.vala @@ -120,43 +120,70 @@ internal class WebAuthPane : Spit.Publishing.DialogPane, GLib.Object { webview = new WebKit.WebView(); webview.get_settings().enable_plugins = false; - webview.get_settings().enable_default_context_menu = false; - webview.load_finished.connect(on_page_load); - webview.load_started.connect(on_load_started); - webview.navigation_requested.connect(navigation_requested); + webview.load_changed.connect(on_page_load_changed); + webview.decide_policy.connect(on_decide_policy); + webview.context_menu.connect(() => { return false; }); webview_frame.add(webview); pane_widget.pack_start(webview_frame, true, true, 0); } - private void on_page_load(WebKit.WebFrame origin_frame) { + private void on_page_load() { pane_widget.get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.LEFT_PTR)); } - private WebKit.NavigationResponse navigation_requested (WebKit.WebFrame frame, WebKit.NetworkRequest req) { - debug("Navigating to '%s'", req.uri); + private bool on_decide_policy (WebKit.PolicyDecision decision, + WebKit.PolicyDecisionType type) { + switch (type) { + case WebKit.PolicyDecisionType.NAVIGATION_ACTION: + WebKit.NavigationPolicyDecision n_decision = (WebKit.NavigationPolicyDecision) decision; + WebKit.NavigationAction action = n_decision.navigation_action; + string uri = action.get_request().uri; + debug("Navigating to '%s'", uri); - MatchInfo info = null; + MatchInfo info = null; - if (re.match(req.uri, 0, out info)) { - string access_token = info.fetch_all()[2]; + if (re.match(uri, 0, out info)) { + string access_token = info.fetch_all()[2]; - debug("Load completed: %s", access_token); - pane_widget.get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.LEFT_PTR)); - if (access_token != null) { - login_succeeded(access_token); - return WebKit.NavigationResponse.IGNORE; - } else - login_failed(); + debug("Load completed: %s", access_token); + pane_widget.get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.LEFT_PTR)); + if (access_token != null) { + login_succeeded(access_token); + decision.ignore(); + break; + } else + login_failed(); + } + decision.use(); + break; + case WebKit.PolicyDecisionType.RESPONSE: + decision.use(); + break; + default: + return false; } - return WebKit.NavigationResponse.ACCEPT; + return true; } - private void on_load_started(WebKit.WebFrame frame) { + private void on_load_started() { pane_widget.get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.WATCH)); } + private void on_page_load_changed (WebKit.LoadEvent load_event) { + switch (load_event) { + case WebKit.LoadEvent.STARTED: + on_load_started(); + break; + case WebKit.LoadEvent.FINISHED: + on_page_load(); + break; + } + + return; + } + public Gtk.Widget get_widget() { return pane_widget; } @@ -166,7 +193,7 @@ internal class WebAuthPane : Spit.Publishing.DialogPane, GLib.Object { } public void on_pane_installed() { - webview.open(login_url); + webview.load_uri(login_url); } public void on_pane_uninstalled() { diff --git a/plugins/shotwell-publishing-extras/shotwell-publishing-extras.vala b/plugins/shotwell-publishing-extras/shotwell-publishing-extras.vala index 24f7ea2..9e70d30 100644 --- a/plugins/shotwell-publishing-extras/shotwell-publishing-extras.vala +++ b/plugins/shotwell-publishing-extras/shotwell-publishing-extras.vala @@ -1,4 +1,4 @@ -/* Copyright 2011-2015 Yorba Foundation +/* Copyright 2016 Software Freedom Conservancy Inc. * * This software is licensed under the GNU Lesser General Public License * (version 2.1 or later). See the COPYING file in this distribution. |