[shotwell/shotwell-0.24] picasa: Remove possibility to create new albums
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/shotwell-0.24] picasa: Remove possibility to create new albums
- Date: Sat, 4 Mar 2017 09:40:44 +0000 (UTC)
commit 154eefc3c56697add64698da64786f1b4ea9a8d7
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>
plugins/shotwell-publishing/PicasaPublishing.vala | 193 ++------------------
.../picasa_publishing_options_pane.ui | 115 ++----------
2 files changed, 26 insertions(+), 282 deletions(-)
---
diff --git a/plugins/shotwell-publishing/PicasaPublishing.vala
b/plugins/shotwell-publishing/PicasaPublishing.vala
index 130cabc..6ff7c39 100644
--- a/plugins/shotwell-publishing/PicasaPublishing.vala
+++ b/plugins/shotwell-publishing/PicasaPublishing.vala
@@ -60,6 +60,7 @@ internal const string SERVICE_WELCOME_MESSAGE =
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;
@@ -94,6 +95,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;
@@ -199,66 +203,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;
@@ -367,27 +314,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.");
@@ -486,24 +412,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;
@@ -614,10 +522,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;
@@ -642,10 +547,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");
@@ -674,9 +576,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);
}
@@ -694,49 +593,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];
@@ -757,32 +622,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() {
@@ -813,7 +662,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]";
@@ -825,23 +673,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 adee4d2..11e79af 100644
--- a/plugins/shotwell-publishing/picasa_publishing_options_pane.ui
+++ b/plugins/shotwell-publishing/picasa_publishing_options_pane.ui
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <!-- interface-requires gtk+ 3.0 -->
+<!-- Generated with glade 3.20.0 -->
+<interface domain="shotwell">
+ <requires lib="gtk+" version="3.14"/>
<object class="GtkBox" id="picasa_pane_widget">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -47,155 +48,67 @@
<object class="GtkComboBoxText" id="existing_albums_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">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>
- <property name="width">1</property>
- <property name="height">1</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="use_underline">True</property>
- <property name="xalign">0</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="width">1</property>
- <property name="height">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="xalign">0</property>
- <property name="yalign">0.47999998927116394</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>
- <property name="width">1</property>
- <property name="height">1</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="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
+ <property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="publish_to_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_top">32</property>
- <property name="xalign">0</property>
+ <property name="halign">start</property>
<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>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_top">32</property>
- <property name="xalign">0</property>
+ <property name="halign">start</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="width">1</property>
- <property name="height">1</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>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
- <property name="width">1</property>
- <property name="height">1</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">center</property>
- <property name="margin_top">16</property>
- <property name="hexpand">True</property>
- <property name="use_underline">True</property>
- <property name="xalign">0.20000000298023224</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="height">1</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]