[shotwell] picasa: Remove possibility to create new albums
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] picasa: Remove possibility to create new albums
- Date: Tue, 21 Feb 2017 22:03:32 +0000 (UTC)
commit b3fe24ea953ca86310dca39226a1b87f54bfb8ee
Author: Jens Georg <mail jensge org>
Date: Tue Feb 21 22:05:49 2017 +0100
picasa: Remove possibility to create new albums
This has been dropped from the Picasa Web API / Google Photos
Signed-off-by: Jens Georg <mail jensge org>
.../shotwell/GoogleAuthenticator.vala | 4 +-
plugins/shotwell-publishing/PicasaPublishing.vala | 193 ++------------------
.../picasa_publishing_options_pane.ui | 86 +--------
3 files changed, 24 insertions(+), 259 deletions(-)
---
diff --git a/plugins/authenticator/shotwell/GoogleAuthenticator.vala
b/plugins/authenticator/shotwell/GoogleAuthenticator.vala
index 5b884c8..9b40ad4 100644
--- a/plugins/authenticator/shotwell/GoogleAuthenticator.vala
+++ b/plugins/authenticator/shotwell/GoogleAuthenticator.vala
@@ -25,8 +25,7 @@ namespace Publishing.Authenticator.Shotwell.Google {
if (auth_code_field_start < 0)
return;
- string auth_code =
- page_title.substring(auth_code_field_start + 5); // 5 = "code=".length
+ string auth_code = page_title.substring(auth_code_field_start + 5); // 5 = "code=".length
cache_dirty = true;
@@ -237,6 +236,7 @@ namespace Publishing.Authenticator.Shotwell.Google {
on_access_token_available(access_token);
}
}
+
private void on_refresh_token_available(string token) {
debug("EVENT: an OAuth refresh token has become available; token = '%s'.", token);
this.params.insert("RefreshToken", new Variant.string(token));
diff --git a/plugins/shotwell-publishing/PicasaPublishing.vala
b/plugins/shotwell-publishing/PicasaPublishing.vala
index 33f9923..ba4018a 100644
--- a/plugins/shotwell-publishing/PicasaPublishing.vala
+++ b/plugins/shotwell-publishing/PicasaPublishing.vala
@@ -58,6 +58,7 @@ namespace Publishing.Picasa {
internal const string DEFAULT_ALBUM_NAME = _("Shotwell Connect");
public class PicasaPublisher : Publishing.RESTSupport.GooglePublisher {
+ private const string DEFAULT_ALBUM_FEED_URL =
"https://picasaweb.google.com/data/feed/api/user/default/albumid/default";;
private bool running;
private Spit.Publishing.ProgressCallback progress_reporter;
private PublishingParameters publishing_parameters;
@@ -91,6 +92,9 @@ public class PicasaPublisher : Publishing.RESTSupport.GooglePublisher {
throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("response root node " +
"isn't a <feed> or <entry>");
+ // Add album that will push to the default feed for all the new users
+ result += new Album(_("Default album"), DEFAULT_ALBUM_FEED_URL);
+
for ( ; doc_node_iter != null; doc_node_iter = doc_node_iter->next) {
if (doc_node_iter->name != "entry")
continue;
@@ -186,66 +190,9 @@ public class PicasaPublisher : Publishing.RESTSupport.GooglePublisher {
save_parameters_to_configuration_system(publishing_parameters);
- if (publishing_parameters.is_to_new_album()) {
- do_create_album();
- } else {
- do_upload();
- }
- }
-
- private void on_album_creation_complete(Publishing.RESTSupport.Transaction txn) {
- txn.completed.disconnect(on_album_creation_complete);
- txn.network_error.disconnect(on_album_creation_error);
-
- if (!is_running())
- return;
-
- debug("EVENT: finished creating album on remote server.");
-
- AlbumCreationTransaction downcast_txn = (AlbumCreationTransaction) txn;
- Publishing.RESTSupport.XmlDocument response_doc;
- try {
- response_doc = Publishing.RESTSupport.XmlDocument.parse_string(
- downcast_txn.get_response(), AlbumDirectoryTransaction.validate_xml);
- } catch (Spit.Publishing.PublishingError err) {
- get_host().post_error(err);
- return;
- }
-
- Album[] response_albums;
- try {
- response_albums = extract_albums_helper(response_doc.get_root_node());
- } catch (Spit.Publishing.PublishingError err) {
- get_host().post_error(err);
- return;
- }
-
- if (response_albums.length != 1) {
- get_host().post_error(new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("album " +
- "creation transaction responses must contain one and only one album directory " +
- "entry"));
- return;
- }
-
- publishing_parameters.set_target_album_entry_url(response_albums[0].url);
-
do_upload();
}
- private void on_album_creation_error(Publishing.RESTSupport.Transaction bad_txn,
- Spit.Publishing.PublishingError err) {
- bad_txn.completed.disconnect(on_album_creation_complete);
- bad_txn.network_error.disconnect(on_album_creation_error);
-
- if (!is_running())
- return;
-
- debug("EVENT: creating album on remote server failed; response = '%s'.",
- bad_txn.get_response());
-
- get_host().post_error(err);
- }
-
private void on_upload_status_updated(int file_number, double completed_fraction) {
if (!is_running())
return;
@@ -348,27 +295,6 @@ public class PicasaPublisher : Publishing.RESTSupport.GooglePublisher {
get_host().set_service_locked(false);
}
- private void do_create_album() {
- assert(publishing_parameters.is_to_new_album());
-
- debug("ACTION: creating new album '%s' on remote server.",
- publishing_parameters.get_target_album_name());
-
- get_host().install_static_message_pane(_("Creating album…"));
-
- get_host().set_service_locked(true);
-
- AlbumCreationTransaction creation_trans = new AlbumCreationTransaction(get_session(),
- publishing_parameters);
- creation_trans.network_error.connect(on_album_creation_error);
- creation_trans.completed.connect(on_album_creation_complete);
- try {
- creation_trans.execute();
- } catch (Spit.Publishing.PublishingError err) {
- get_host().post_error(err);
- }
- }
-
private void do_upload() {
debug("ACTION: uploading media items to remote server.");
@@ -471,24 +397,6 @@ internal class AlbumDirectoryTransaction :
}
}
-private class AlbumCreationTransaction :
- Publishing.RESTSupport.GooglePublisher.AuthenticatedTransaction {
- private const string ENDPOINT_URL = "https://picasaweb.google.com/data/feed/api/user/"; +
- "default";
- private const string ALBUM_ENTRY_TEMPLATE = "<?xml version='1.0' encoding='utf-8'?><entry
xmlns='http://www.w3.org/2005/Atom' xmlns:gphoto='http://schemas.google.com/photos/2007'><title
type='text'>%s</title><gphoto:access>%s</gphoto:access><category
scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/photos/2007#album'></category></entry>";
-
- public AlbumCreationTransaction(Publishing.RESTSupport.GoogleSession session,
- PublishingParameters parameters) {
- base(session, ENDPOINT_URL, Publishing.RESTSupport.HttpMethod.POST);
-
- string post_body = ALBUM_ENTRY_TEMPLATE.printf(Publishing.RESTSupport.decimal_entity_encode(
- parameters.get_target_album_name()), parameters.is_new_album_public() ?
- "public" : "private");
-
- set_custom_payload(post_body, "application/atom+xml");
- }
-}
-
internal class UploadTransaction :
Publishing.RESTSupport.GooglePublisher.AuthenticatedTransaction {
private PublishingParameters parameters;
@@ -599,10 +507,7 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
private Gtk.Box pane_widget = null;
private Gtk.Label login_identity_label = null;
private Gtk.Label publish_to_label = null;
- private Gtk.RadioButton use_existing_radio = null;
private Gtk.ComboBoxText existing_albums_combo = null;
- private Gtk.RadioButton create_new_radio = null;
- private Gtk.Entry new_album_entry = null;
private Gtk.CheckButton public_check = null;
private Gtk.ComboBoxText size_combo = null;
private Gtk.CheckButton strip_metadata_check = null;
@@ -627,10 +532,7 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
pane_widget = (Gtk.Box) builder.get_object("picasa_pane_widget");
login_identity_label = (Gtk.Label) builder.get_object("login_identity_label");
publish_to_label = (Gtk.Label) builder.get_object("publish_to_label");
- use_existing_radio = (Gtk.RadioButton) builder.get_object("use_existing_radio");
existing_albums_combo = (Gtk.ComboBoxText) builder.get_object("existing_albums_combo");
- create_new_radio = (Gtk.RadioButton) builder.get_object("create_new_radio");
- new_album_entry = (Gtk.Entry) builder.get_object("new_album_entry");
public_check = (Gtk.CheckButton) builder.get_object("public_check");
size_combo = (Gtk.ComboBoxText) builder.get_object("size_combo");
strip_metadata_check = (Gtk.CheckButton) this.builder.get_object("strip_metadata_check");
@@ -663,9 +565,6 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
}
// connect all signals.
- use_existing_radio.clicked.connect(on_use_existing_radio_clicked);
- create_new_radio.clicked.connect(on_create_new_radio_clicked);
- new_album_entry.changed.connect(on_new_album_entry_changed);
logout_button.clicked.connect(on_logout_clicked);
publish_button.clicked.connect(on_publish_clicked);
}
@@ -683,49 +582,15 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
Album[] albums = parameters.get_albums();
- if (create_new_radio.get_active()) {
- parameters.set_target_album_name(new_album_entry.get_text());
- parameters.set_is_to_new_album(true);
- parameters.set_is_new_album_public(public_check.get_active());
- publish();
- } else {
- parameters.set_target_album_name(albums[existing_albums_combo.get_active()].name);
- parameters.set_is_to_new_album(false);
- parameters.set_target_album_entry_url(albums[existing_albums_combo.get_active()].url);
- publish();
- }
- }
-
- private void on_use_existing_radio_clicked() {
- existing_albums_combo.set_sensitive(true);
- new_album_entry.set_sensitive(false);
- existing_albums_combo.grab_focus();
- update_publish_button_sensitivity();
- public_check.set_sensitive(false);
- }
-
- private void on_create_new_radio_clicked() {
- new_album_entry.set_sensitive(true);
- existing_albums_combo.set_sensitive(false);
- new_album_entry.grab_focus();
- update_publish_button_sensitivity();
- public_check.set_sensitive(true);
+ parameters.set_target_album_name(albums[existing_albums_combo.get_active()].name);
+ parameters.set_target_album_entry_url(albums[existing_albums_combo.get_active()].url);
+ publish();
}
private void on_logout_clicked() {
logout();
}
- private void update_publish_button_sensitivity() {
- string album_name = new_album_entry.get_text();
- publish_button.set_sensitive(!(album_name.strip() == "" &&
- create_new_radio.get_active()));
- }
-
- private void on_new_album_entry_changed() {
- update_publish_button_sensitivity();
- }
-
private SizeDescription[] create_size_descriptions() {
SizeDescription[] result = new SizeDescription[0];
@@ -746,32 +611,16 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
for (int i = 0; i < albums.length; i++) {
existing_albums_combo.append_text(albums[i].name);
+ // Activate last known album id. If none was chosen, either use the old default (Shotwell
connect)
+ // or the new "Default album" album for Google Photos
if (albums[i].name == last_album ||
- (albums[i].name == DEFAULT_ALBUM_NAME && default_album_id == -1))
+ ((albums[i].name == DEFAULT_ALBUM_NAME || albums[i].name == _("Default album")) &&
default_album_id == -1))
default_album_id = i;
}
- if (albums.length == 0) {
- existing_albums_combo.set_sensitive(false);
- use_existing_radio.set_sensitive(false);
- create_new_radio.set_active(true);
- new_album_entry.grab_focus();
- new_album_entry.set_text(DEFAULT_ALBUM_NAME);
- } else {
- if (default_album_id >= 0) {
- use_existing_radio.set_active(true);
- existing_albums_combo.set_active(default_album_id);
- new_album_entry.set_sensitive(false);
- public_check.set_sensitive(false);
- } else {
- create_new_radio.set_active(true);
- existing_albums_combo.set_active(0);
- new_album_entry.set_text(DEFAULT_ALBUM_NAME);
- new_album_entry.grab_focus();
- public_check.set_sensitive(true);
- }
+ if (default_album_id >= 0) {
+ existing_albums_combo.set_active(default_album_id);
}
- update_publish_button_sensitivity();
}
public Gtk.Widget get_widget() {
@@ -802,7 +651,6 @@ internal class PublishingParameters {
private string user_name;
private Album[] albums;
private Spit.Publishing.Publisher.MediaType media_type;
- private bool to_new_album;
public PublishingParameters() {
this.user_name = "[unknown]";
@@ -814,23 +662,6 @@ internal class PublishingParameters {
this.albums = null;
this.strip_metadata = false;
this.media_type = Spit.Publishing.Publisher.MediaType.PHOTO;
- this.to_new_album = true;
- }
-
- public bool is_to_new_album() {
- return to_new_album;
- }
-
- public void set_is_to_new_album(bool to_new_album) {
- this.to_new_album = to_new_album;
- }
-
- public void set_is_new_album_public(bool album_public) {
- this.album_public = album_public;
- }
-
- public bool is_new_album_public() {
- return album_public;
}
public string get_target_album_name() {
diff --git a/plugins/shotwell-publishing/picasa_publishing_options_pane.ui
b/plugins/shotwell-publishing/picasa_publishing_options_pane.ui
index 04d3948..11e79af 100644
--- a/plugins/shotwell-publishing/picasa_publishing_options_pane.ui
+++ b/plugins/shotwell-publishing/picasa_publishing_options_pane.ui
@@ -16,7 +16,7 @@
<property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="margin_bottom">32</property>
- <property name="label">'you are logged in as $name'
+ <property name="label" translatable="no">'you are logged in as $name'
(populated in the application code)</property>
</object>
<packing>
@@ -51,66 +51,25 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="new_album_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">•</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="use_existing_radio">
- <property name="label" translatable="yes">An _existing album:</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">create_new_radio</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">0</property>
</packing>
</child>
<child>
- <object class="GtkRadioButton" id="create_new_radio">
- <property name="label" translatable="yes">A _new album named:</property>
+ <object class="GtkCheckButton" id="strip_metadata_check">
+ <property name="label" translatable="yes">_Remove location, camera, and other identifying
information before uploading</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
+ <property name="margin_top">16</property>
+ <property name="hexpand">True</property>
<property name="use_underline">True</property>
- <property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="public_check">
- <property name="label" translatable="yes">L_ist album in public gallery</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="width">2</property>
</packing>
</child>
<child>
@@ -118,14 +77,12 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="margin_top">32</property>
- <property name="label">$mediatype will appear in
+ <property name="label" translatable="no">$mediatype will appear in
(populated in code)</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">2</property>
</packing>
</child>
<child>
@@ -133,48 +90,25 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="margin_top">32</property>
<property name="label" translatable="yes">Photo _size preset:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">size_combo</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="size_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_top">32</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="strip_metadata_check">
- <property name="label" translatable="yes">_Remove location, camera, and other identifying
information before uploading</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="margin_top">16</property>
- <property name="hexpand">True</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">5</property>
- <property name="width">2</property>
+ <property name="top_attach">1</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]