826
private const int PACKER_VERTICAL_PADDING = 16;
827
private const int PACKER_HORIZ_PADDING = 128;
828
private const int INTERSTITIAL_VERTICAL_SPACING = 20;
829
private const int ACTION_BUTTON_SPACING = 48;
830
private const int ACTION_BUTTON_WIDTH = 128;
831
778
private const string DEFAULT_SIZE_CONFIG_KEY = "default_size";
832
779
private const string LAST_ALBUM_CONFIG_KEY = "last_album";
834
private Gtk.ComboBoxText existing_albums_combo;
835
private Gtk.Entry new_album_entry;
836
private Gtk.CheckButton public_check;
837
private Gtk.ComboBoxText size_combo;
838
private Gtk.RadioButton use_existing_radio;
839
private Gtk.RadioButton create_new_radio;
781
private Gtk.Builder builder = null;
783
private Gtk.Box pane_widget = null;
784
private Gtk.Label login_identity_label = null;
785
private Gtk.Label publish_to_label = null;
786
private Gtk.RadioButton use_existing_radio = null;
787
private Gtk.ComboBoxText existing_albums_combo = null;
788
private Gtk.RadioButton create_new_radio = null;
789
private Gtk.Entry new_album_entry = null;
790
private Gtk.CheckButton public_check = null;
791
private Gtk.ComboBoxText size_combo = null;
792
private Gtk.CheckButton strip_metadata_check = null;
793
private Gtk.Button publish_button = null;
794
private Gtk.Button logout_button = null;
840
796
private Album[] albums;
841
797
private SizeDescription[] size_descriptions;
842
private Gtk.Button publish_button;
843
798
private string username;
844
799
private weak Spit.Publishing.PluginHost host;
846
public signal void publish(PublishingParameters parameters);
801
public signal void publish(PublishingParameters parameters, bool strip_metadata);
847
802
public signal void logout();
849
public LegacyPublishingOptionsPane(Spit.Publishing.PluginHost host, string username,
850
Album[] albums, Spit.Publishing.Publisher.MediaType media_type) {
804
public PublishingOptionsPane(Spit.Publishing.PluginHost host, string username,
805
Album[] albums, Spit.Publishing.Publisher.MediaType media_type, Gtk.Builder builder,
806
bool strip_metadata) {
851
807
this.username = username;
852
808
this.albums = albums;
853
809
this.host = host;
854
810
size_descriptions = create_size_descriptions();
858
Gtk.Label login_identity_label =
859
new Gtk.Label(_("You are logged into Picasa Web Albums as %s.").printf(
862
add(login_identity_label);
864
Gtk.Box vert_packer = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
866
vert_packer.add(gtk_vspacer(INTERSTITIAL_VERTICAL_SPACING));
868
Gtk.Table main_table = new Gtk.Table(6, 3, false);
870
// Ticket #3212, part II - If we're onluy uploading video, alter the
871
// 'will appear in' message to reflect this.
872
Gtk.Label publish_to_label;
874
if((media_type & Spit.Publishing.Publisher.MediaType.PHOTO) == 0)
875
publish_to_label = new Gtk.Label(_("Videos will appear in:"));
877
publish_to_label = new Gtk.Label(_("Photos will appear in:"));
879
publish_to_label.set_alignment(0.0f, 0.5f);
880
main_table.attach(publish_to_label, 0, 2, 0, 1,
881
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
882
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
884
main_table.attach(gtk_hspacer(2), 0, 1, 1, 2,
885
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
886
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
888
use_existing_radio = new Gtk.RadioButton.with_mnemonic(null, _("An _existing album:"));
812
this.builder = builder;
813
assert(builder != null);
814
assert(builder.get_objects().length() > 0);
816
// pull in all widgets from builder.
817
pane_widget = (Gtk.Box) builder.get_object("picasa_pane_widget");
818
login_identity_label = (Gtk.Label) builder.get_object("login_identity_label");
819
publish_to_label = (Gtk.Label) builder.get_object("publish_to_label");
820
use_existing_radio = (Gtk.RadioButton) builder.get_object("use_existing_radio");
821
existing_albums_combo = (Gtk.ComboBoxText) builder.get_object("existing_albums_combo");
822
create_new_radio = (Gtk.RadioButton) builder.get_object("create_new_radio");
823
new_album_entry = (Gtk.Entry) builder.get_object("new_album_entry");
824
public_check = (Gtk.CheckButton) builder.get_object("public_check");
825
size_combo = (Gtk.ComboBoxText) builder.get_object("size_combo");
826
strip_metadata_check = (Gtk.CheckButton) this.builder.get_object("strip_metadata_check");
827
publish_button = (Gtk.Button) builder.get_object("publish_button");
828
logout_button = (Gtk.Button) builder.get_object("logout_button");
830
// populate any widgets whose contents are programmatically-generated.
831
login_identity_label.set_label(_("You are logged into Picasa Web Albums as %s.").printf(username));
832
strip_metadata_check.set_active(strip_metadata);
835
if((media_type & Spit.Publishing.Publisher.MediaType.PHOTO) == 0) {
836
publish_to_label.set_label(_("Videos will appear in:"));
837
size_combo.set_visible(false);
838
size_combo.set_sensitive(false);
841
publish_to_label.set_label(_("Photos will appear in:"));
842
foreach(SizeDescription desc in size_descriptions) {
843
size_combo.append_text(desc.name);
845
size_combo.set_visible(true);
846
size_combo.set_sensitive(true);
847
size_combo.set_active(host.get_config_int(DEFAULT_SIZE_CONFIG_KEY, 0));
850
// connect all signals.
889
851
use_existing_radio.clicked.connect(on_use_existing_radio_clicked);
890
main_table.attach(use_existing_radio, 1, 2, 1, 2,
891
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
892
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
894
existing_albums_combo = new Gtk.ComboBoxText();
895
Gtk.Alignment existing_albums_combo_frame = new Gtk.Alignment(0.0f, 0.5f, 0.0f, 0.0f);
896
existing_albums_combo_frame.add(existing_albums_combo);
897
main_table.attach(existing_albums_combo_frame, 2, 3, 1, 2,
898
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
899
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
901
create_new_radio = new Gtk.RadioButton.with_mnemonic(use_existing_radio.get_group(),
902
_("A _new album named:"));
903
852
create_new_radio.clicked.connect(on_create_new_radio_clicked);
904
main_table.attach(create_new_radio, 1, 2, 2, 3,
905
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
906
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
908
new_album_entry = new Gtk.Entry();
909
853
new_album_entry.changed.connect(on_new_album_entry_changed);
910
main_table.attach(new_album_entry, 2, 3, 2, 3,
911
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
912
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
914
public_check = new Gtk.CheckButton.with_mnemonic(_("L_ist album in public gallery"));
915
main_table.attach(public_check, 2, 3, 3, 4,
916
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
917
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
919
main_table.attach(gtk_vspacer(INTERSTITIAL_VERTICAL_SPACING / 2), 2, 3, 4, 5,
920
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
921
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
923
// Ticket #3212 - Only display the size chooser if we're uploading a
924
// photograph, since resizing of video isn't supported.
926
// If the media_type argument doesn't tell us we're getting at least
927
// one photo, do not create or add these widgets.
928
if((media_type & Spit.Publishing.Publisher.MediaType.PHOTO) != 0) {
929
Gtk.Label size_label = new Gtk.Label.with_mnemonic(_("Photo _size preset:"));
930
size_label.set_alignment(0.0f, 0.5f);
932
main_table.attach(size_label, 0, 2, 5, 6,
933
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
934
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
936
size_combo = new Gtk.ComboBoxText();
937
foreach(SizeDescription desc in size_descriptions)
938
size_combo.append_text(desc.name);
940
size_combo.set_active(host.get_config_int(DEFAULT_SIZE_CONFIG_KEY, 0));
941
Gtk.Alignment size_combo_frame = new Gtk.Alignment(0.0f, 0.5f, 0.0f, 0.0f);
943
size_combo_frame.add(size_combo);
944
main_table.attach(size_combo_frame, 2, 3, 5, 6,
945
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
946
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, 4, 4);
948
size_label.set_mnemonic_widget(size_combo);
951
vert_packer.add(main_table);
953
vert_packer.add(gtk_vspacer(INTERSTITIAL_VERTICAL_SPACING));
955
Gtk.Box action_button_layouter = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
956
action_button_layouter.homogeneous = true;
958
Gtk.Button logout_button = new Gtk.Button.with_mnemonic(_("_Logout"));
959
854
logout_button.clicked.connect(on_logout_clicked);
960
logout_button.set_size_request(ACTION_BUTTON_WIDTH, -1);
961
Gtk.Alignment logout_button_aligner = new Gtk.Alignment(0.5f, 0.5f, 0.0f, 0.0f);
962
logout_button_aligner.add(logout_button);
963
action_button_layouter.add(logout_button_aligner);
964
action_button_layouter.add(gtk_hspacer(ACTION_BUTTON_SPACING));
965
publish_button = new Gtk.Button.with_mnemonic(_("_Publish"));
966
855
publish_button.clicked.connect(on_publish_clicked);
967
publish_button.set_size_request(ACTION_BUTTON_WIDTH, -1);
968
Gtk.Alignment publish_button_aligner = new Gtk.Alignment(0.5f, 0.5f, 0.0f, 0.0f);
969
publish_button_aligner.add(publish_button);
970
action_button_layouter.add(publish_button_aligner);
972
Gtk.Alignment action_button_wrapper = new Gtk.Alignment(0.5f, 0.5f, 0.0f, 0.0f);
973
action_button_wrapper.add(action_button_layouter);
975
vert_packer.add(action_button_wrapper);
977
vert_packer.add(gtk_vspacer(2 * PACKER_VERTICAL_PADDING));
979
Gtk.Alignment vert_packer_wrapper = new Gtk.Alignment(0.5f, 0.5f, 0.0f, 0.0f);
980
vert_packer_wrapper.add(vert_packer);
982
add(vert_packer_wrapper);
985
858
private void on_publish_clicked() {
986
host.set_config_int(DEFAULT_SIZE_CONFIG_KEY, size_combo.get_active());
987
int photo_major_axis_size = size_descriptions[size_combo.get_active()].major_axis_pixels;
859
// size_combo won't have been set to anything useful if this is the first time we've
860
// published to Picasa, and/or we've only published video before, so it may be negative,
861
// indicating nothing was selected. Clamp it to a valid value...
862
int size_combo_last_active = (size_combo.get_active() >= 0) ? size_combo.get_active() : 0;
864
host.set_config_int(DEFAULT_SIZE_CONFIG_KEY, size_combo_last_active);
865
int photo_major_axis_size = size_descriptions[size_combo_last_active].major_axis_pixels;
988
866
string album_name;
989
867
if (create_new_radio.get_active()) {
990
868
album_name = new_album_entry.get_text();
991
869
host.set_config_string(LAST_ALBUM_CONFIG_KEY, album_name);
992
870
bool is_public = public_check.get_active();
993
871
publish(new PublishingParameters.to_new_album(photo_major_axis_size, album_name,
872
is_public), strip_metadata_check.get_active());
996
874
album_name = albums[existing_albums_combo.get_active()].name;
997
875
host.set_config_string(LAST_ALBUM_CONFIG_KEY, album_name);
998
876
string album_url = albums[existing_albums_combo.get_active()].url;
999
publish(new PublishingParameters.to_existing_album(photo_major_axis_size, album_url));
877
publish(new PublishingParameters.to_existing_album(photo_major_axis_size, album_url), strip_metadata_check.get_active());