[shotwell/wip/pluggable-auth: 16/16] wip: Only show logout button if authenticator supports it
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/pluggable-auth: 16/16] wip: Only show logout button if authenticator supports it
- Date: Sat, 11 Feb 2017 18:21:10 +0000 (UTC)
commit d2e21ab6b85bc3808c357b0c9d7faf4727baff0b
Author: Jens Georg <mail jensge org>
Date: Sat Feb 11 00:04:20 2017 +0100
wip: Only show logout button if authenticator supports it
Signed-off-by: Jens Georg <mail jensge org>
plugins/shotwell-publishing/FlickrPublishing.vala | 10 +++++++++-
plugins/shotwell-publishing/PicasaPublishing.vala | 15 ++++++++++++---
plugins/shotwell-publishing/YouTubePublishing.vala | 20 +++++++++++++++-----
3 files changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/plugins/shotwell-publishing/FlickrPublishing.vala
b/plugins/shotwell-publishing/FlickrPublishing.vala
index a5109d1..24b2b61 100644
--- a/plugins/shotwell-publishing/FlickrPublishing.vala
+++ b/plugins/shotwell-publishing/FlickrPublishing.vala
@@ -103,7 +103,7 @@ public class FlickrPublisher : Spit.Publishing.Publisher, GLib.Object {
private PublishingParameters parameters = null;
public FlickrPublisher(Spit.Publishing.Service service,
- Spit.Publishing.PluginHost host) {
+ Spit.Publishing.PluginHost host) {
debug("FlickrPublisher instantiated.");
this.service = service;
this.host = host;
@@ -118,6 +118,10 @@ public class FlickrPublisher : Spit.Publishing.Publisher, GLib.Object {
this.authenticator.authenticated.disconnect(on_session_authenticated);
}
+ public Spit.Publishing.Authenticator get_authenticator() {
+ return this.authenticator;
+ }
+
private bool get_persistent_strip_metadata() {
return host.get_config_bool("strip_metadata", false);
}
@@ -782,6 +786,10 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
size_label = (Gtk.Label) this.builder.get_object("size_label");
strip_metadata_check = (Gtk.CheckButton) this.builder.get_object("strip_metadata_check");
+ if (!publisher.get_authenticator().can_logout()) {
+ logout_button.parent.remove(logout_button);
+ }
+
this.parameters = parameters;
this.publisher = publisher;
this.media_type = media_type;
diff --git a/plugins/shotwell-publishing/PicasaPublishing.vala
b/plugins/shotwell-publishing/PicasaPublishing.vala
index f81417e..caa8e37 100644
--- a/plugins/shotwell-publishing/PicasaPublishing.vala
+++ b/plugins/shotwell-publishing/PicasaPublishing.vala
@@ -61,6 +61,7 @@ public class PicasaPublisher : Publishing.RESTSupport.GooglePublisher {
private bool running;
private Spit.Publishing.ProgressCallback progress_reporter;
private PublishingParameters publishing_parameters;
+ private Spit.Publishing.Authenticator authenticator;
public PicasaPublisher(Spit.Publishing.Service service,
Spit.Publishing.PluginHost host) {
@@ -342,7 +343,7 @@ public class PicasaPublisher : Publishing.RESTSupport.GooglePublisher {
return;
}
- PublishingOptionsPane opts_pane = new PublishingOptionsPane(builder, publishing_parameters);
+ var opts_pane = new PublishingOptionsPane(builder, publishing_parameters,
this.authenticator.can_logout());
opts_pane.publish.connect(on_publishing_options_publish);
opts_pane.logout.connect(on_publishing_options_logout);
get_host().install_dialog_pane(opts_pane);
@@ -437,7 +438,11 @@ public class PicasaPublisher : Publishing.RESTSupport.GooglePublisher {
}
protected override Spit.Publishing.Authenticator get_authenticator() {
- return Publishing.Authenticator.Factory.get_instance().create("picasa", get_host());
+ if (this.authenticator == null) {
+ this.authenticator = Publishing.Authenticator.Factory.get_instance().create("picasa",
get_host());
+ }
+
+ return this.authenticator;
}
}
@@ -612,7 +617,7 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
public signal void publish();
public signal void logout();
- public PublishingOptionsPane(Gtk.Builder builder, PublishingParameters parameters) {
+ public PublishingOptionsPane(Gtk.Builder builder, PublishingParameters parameters, bool can_logout) {
size_descriptions = create_size_descriptions();
this.builder = builder;
@@ -635,6 +640,10 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
publish_button = (Gtk.Button) builder.get_object("publish_button");
logout_button = (Gtk.Button) builder.get_object("logout_button");
+ if (!can_logout) {
+ logout_button.parent.remove(logout_button);
+ }
+
// populate any widgets whose contents are programmatically-generated.
login_identity_label.set_label(_("You are logged into Picasa Web Albums as %s.").printf(
parameters.get_user_name()));
diff --git a/plugins/shotwell-publishing/YouTubePublishing.vala
b/plugins/shotwell-publishing/YouTubePublishing.vala
index 1578601..425d262 100644
--- a/plugins/shotwell-publishing/YouTubePublishing.vala
+++ b/plugins/shotwell-publishing/YouTubePublishing.vala
@@ -120,6 +120,7 @@ public class YouTubePublisher : Publishing.RESTSupport.GooglePublisher {
private bool running;
private PublishingParameters publishing_parameters;
private Spit.Publishing.ProgressCallback? progress_reporter;
+ private Spit.Publishing.Authenticator authenticator;
public YouTubePublisher(Spit.Publishing.Service service, Spit.Publishing.PluginHost host) {
base(service, host, "https://gdata.youtube.com/");
@@ -340,8 +341,7 @@ public class YouTubePublisher : Publishing.RESTSupport.GooglePublisher {
return;
}
- PublishingOptionsPane opts_pane = new PublishingOptionsPane(get_host(), builder,
- publishing_parameters);
+ PublishingOptionsPane opts_pane = new PublishingOptionsPane(authenticator, get_host(), builder,
publishing_parameters);
opts_pane.publish.connect(on_publishing_options_publish);
opts_pane.logout.connect(on_publishing_options_logout);
get_host().install_dialog_pane(opts_pane);
@@ -391,7 +391,11 @@ public class YouTubePublisher : Publishing.RESTSupport.GooglePublisher {
}
protected override Spit.Publishing.Authenticator get_authenticator() {
- return Publishing.Authenticator.Factory.get_instance().create("picasa", get_host());
+ if (this.authenticator == null) {
+ this.authenticator = Publishing.Authenticator.Factory.get_instance().create("picasa",
get_host());
+ }
+
+ return this.authenticator;
}
}
@@ -420,8 +424,10 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
private PrivacyDescription[] privacy_descriptions;
private PublishingParameters publishing_parameters;
- public PublishingOptionsPane(Spit.Publishing.PluginHost host, Gtk.Builder builder,
- PublishingParameters publishing_parameters) {
+ public PublishingOptionsPane(Spit.Publishing.Authenticator authenticator,
+ Spit.Publishing.PluginHost host,
+ Gtk.Builder builder,
+ PublishingParameters publishing_parameters) {
this.privacy_descriptions = create_privacy_descriptions();
this.publishing_parameters = publishing_parameters;
@@ -437,6 +443,10 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
pane_widget = this.builder.get_object("youtube_pane_widget") as Gtk.Box;
privacy_label = this.builder.get_object("privacy_label") as Gtk.Label;
+ if (!authenticator.can_logout()) {
+ logout_button.parent.remove(logout_button);
+ }
+
login_identity_label.set_label(_("You are logged into YouTube as %s.").printf(
publishing_parameters.get_user_name()));
publish_to_label.set_label(_("Videos will appear in ā%sā").printf(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]