5
using System.Collections;
6
using System.Collections.Specialized;
14
using FSpot.UI.Dialog;
15
using FSpot.Extensions;
20
public class GalleryAccount {
21
public GalleryAccount (string name, string url, string username, string password) : this (name, url, username, password, GalleryVersion.VersionUnknown) {}
22
public GalleryAccount (string name, string url, string username, string password, GalleryVersion version)
25
this.username = username;
26
this.password = password;
29
if (version != GalleryVersion.VersionUnknown) {
30
this.version = version;
32
this.version = Gallery.DetectGalleryVersion(Url);
36
public const string EXPORT_SERVICE = "gallery/";
37
public const string LIGHTTPD_WORKAROUND_KEY = Preferences.APP_FSPOT_EXPORT + EXPORT_SERVICE + "lighttpd_workaround";
39
public Gallery Connect ()
41
//System.Console.WriteLine ("GalleryAccount.Connect()");
44
if (version == GalleryVersion.VersionUnknown)
45
this.version = Gallery.DetectGalleryVersion(Url);
47
if (version == GalleryVersion.Version1) {
48
gal = new Gallery1 (url, url);
49
} else if (version == GalleryVersion.Version2) {
50
gal = new Gallery2 (url, url);
52
throw new GalleryException (Catalog.GetString("Cannot connect to a Gallery for which the version is unknown.\nPlease check that you have Remote plugin 1.0.8 or later"));
55
System.Console.WriteLine ("Gallery created: " + gal);
57
gal.Login (username, password);
62
object val = Preferences.Get (LIGHTTPD_WORKAROUND_KEY);
64
gallery.expect_continue = !(bool)val;
69
GalleryVersion version;
70
public GalleryVersion Version{
76
private bool connected;
77
public bool Connected {
81
retVal = gallery.IsConnected ();
83
if (connected != retVal) {
84
System.Console.WriteLine ("Connected and retVal for IsConnected() don't agree");
90
public void MarkChanged ()
97
public Gallery Gallery {
127
public string Username {
132
if (username != value) {
140
public string Password {
145
if (password != value) {
154
public class GalleryAccountManager
156
private static GalleryAccountManager instance;
160
public delegate void AccountListChangedHandler (GalleryAccountManager manager, GalleryAccount changed_account);
161
public event AccountListChangedHandler AccountListChanged;
163
public static GalleryAccountManager GetInstance ()
165
if (instance == null) {
166
instance = new GalleryAccountManager ();
172
private GalleryAccountManager ()
174
// FIXME this xml file path should be be retrieved from a central location not hard coded there
175
this.xml_path = System.IO.Path.Combine (FSpot.Global.BaseDirectory, "Accounts.xml");
177
accounts = new ArrayList ();
181
public void MarkChanged ()
183
MarkChanged (true, null);
186
public void MarkChanged (bool write, GalleryAccount changed_account)
191
if (AccountListChanged != null)
192
AccountListChanged (this, changed_account);
195
public ArrayList GetAccounts ()
200
public void AddAccount (GalleryAccount account)
202
AddAccount (account, true);
205
public void AddAccount (GalleryAccount account, bool write)
207
accounts.Add (account);
208
MarkChanged (write, account);
211
public void RemoveAccount (GalleryAccount account)
213
accounts.Remove (account);
217
public void WriteAccounts ()
219
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter (xml_path, System.Text.Encoding.Default);
221
writer.Formatting = System.Xml.Formatting.Indented;
222
writer.Indentation = 2;
223
writer.IndentChar = ' ';
225
writer.WriteStartDocument (true);
227
writer.WriteStartElement ("GalleryRemote");
228
foreach (GalleryAccount account in accounts) {
229
writer.WriteStartElement ("Account");
230
writer.WriteElementString ("Name", account.Name);
232
writer.WriteElementString ("Url", account.Url);
233
writer.WriteElementString ("Username", account.Username);
234
writer.WriteElementString ("Password", account.Password);
235
writer.WriteElementString ("Version", account.Version.ToString());
236
writer.WriteEndElement (); //Account
238
writer.WriteEndElement ();
239
writer.WriteEndDocument ();
243
private GalleryAccount ParseAccount (System.Xml.XmlNode node)
245
if (node.Name != "Account")
251
string username = null;
252
string password = null;
253
GalleryVersion version = GalleryVersion.VersionUnknown;
255
foreach (System.Xml.XmlNode child in node.ChildNodes) {
256
if (child.Name == "Name") {
257
name = child.ChildNodes [0].Value;
259
} else if (child.Name == "Url") {
260
url = child.ChildNodes [0].Value;
261
} else if (child.Name == "Password") {
262
password = child.ChildNodes [0].Value;
263
} else if (child.Name == "Username") {
264
username = child.ChildNodes [0].Value;
265
} else if (child.Name == "Version") {
266
string versionString = child.ChildNodes [0].Value;
267
if (versionString == "Version1")
268
version = GalleryVersion.Version1;
269
else if (versionString == "Version2")
270
version = GalleryVersion.Version2;
272
Console.WriteLine ("Unexpected versions string: " + versionString);
275
return new GalleryAccount (name, url, username, password, version);
278
private void ReadAccounts ()
281
if (! File.Exists (xml_path)) {
287
string query = "//GalleryRemote/Account";
288
System.Xml.XmlDocument doc = new System.Xml.XmlDocument ();
290
//System.Console.WriteLine ("xml_path: " + xml_path);
292
System.Xml.XmlNodeList nodes = doc.SelectNodes (query);
294
//System.Console.WriteLine ("selected {0} nodes match {1}", nodes.Count, query);
295
foreach (System.Xml.XmlNode node in nodes) {
296
GalleryAccount account = ParseAccount (node);
298
AddAccount (account, false);
301
} catch (System.Exception e) {
302
// FIXME do something
303
System.Console.WriteLine ("Exception loading gallery accounts");
304
System.Console.WriteLine (e);
311
public class AccountDialog {
312
public AccountDialog (Gtk.Window parent) : this (parent, null, false) {
313
add_dialog.Response += HandleAddResponse;
314
add_button.Sensitive = false;
317
public AccountDialog (Gtk.Window parent, GalleryAccount account, bool show_error)
319
Glade.XML xml = new Glade.XML (null, "GalleryExport.glade", "gallery_add_dialog", "f-spot");
320
xml.Autoconnect (this);
321
add_dialog = (Gtk.Dialog) xml.GetWidget ("gallery_add_dialog");
322
add_dialog.Modal = false;
323
add_dialog.TransientFor = parent;
324
add_dialog.DefaultResponse = Gtk.ResponseType.Ok;
326
this.account = account;
328
status_area.Visible = show_error;
330
if (account != null) {
331
gallery_entry.Text = account.Name;
332
url_entry.Text = account.Url;
333
password_entry.Text = account.Password;
334
username_entry.Text = account.Username;
335
add_button.Label = Gtk.Stock.Ok;
336
add_dialog.Response += HandleEditResponse;
339
if (remove_button != null)
340
remove_button.Visible = account != null;
344
gallery_entry.Changed += HandleChanged;
345
url_entry.Changed += HandleChanged;
346
password_entry.Changed += HandleChanged;
347
username_entry.Changed += HandleChanged;
348
HandleChanged (null, null);
351
private void HandleChanged (object sender, System.EventArgs args)
353
name = gallery_entry.Text;
354
url = url_entry.Text;
355
password = password_entry.Text;
356
username = username_entry.Text;
358
if (name == String.Empty || url == String.Empty || password == String.Empty || username == String.Empty)
359
add_button.Sensitive = false;
361
add_button.Sensitive = true;
366
protected void HandleAddResponse (object sender, Gtk.ResponseArgs args)
368
if (args.ResponseId == Gtk.ResponseType.Ok) {
370
Uri uri = new Uri (url);
371
if (uri.Scheme != Uri.UriSchemeHttp &&
372
uri.Scheme != Uri.UriSchemeHttps)
373
throw new System.UriFormatException ();
375
//Check for name uniqueness
376
foreach (GalleryAccount acc in GalleryAccountManager.GetInstance ().GetAccounts ())
377
if (acc.Name == name)
378
throw new ArgumentException ("name");
379
GalleryAccount created = new GalleryAccount (name,
385
GalleryAccountManager.GetInstance ().AddAccount (created);
387
} catch (System.UriFormatException) {
388
HigMessageDialog md =
389
new HigMessageDialog (add_dialog,
390
Gtk.DialogFlags.Modal |
391
Gtk.DialogFlags.DestroyWithParent,
392
Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
393
Catalog.GetString ("Invalid URL"),
394
Catalog.GetString ("The gallery URL entry does not appear to be a valid URL"));
398
} catch (GalleryRemote.GalleryException e) {
399
HigMessageDialog md =
400
new HigMessageDialog (add_dialog,
401
Gtk.DialogFlags.Modal |
402
Gtk.DialogFlags.DestroyWithParent,
403
Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
404
Catalog.GetString ("Error while connecting to Gallery"),
405
String.Format (Catalog.GetString ("The following error was encountered while attempting to log in: {0}"), e.Message));
406
if (e.ResponseText != null) {
407
System.Console.WriteLine (e.Message);
408
System.Console.WriteLine (e.ResponseText);
413
} catch (ArgumentException ae) {
414
HigMessageDialog md =
415
new HigMessageDialog (add_dialog,
416
Gtk.DialogFlags.Modal |
417
Gtk.DialogFlags.DestroyWithParent,
418
Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
419
Catalog.GetString ("A Gallery with this name already exists"),
420
String.Format (Catalog.GetString ("There is already a Gallery with the same name in your registered Galleries. Please choose a unique name.")));
421
System.Console.WriteLine (ae);
425
} catch (System.Net.WebException we) {
426
HigMessageDialog md =
427
new HigMessageDialog (add_dialog,
428
Gtk.DialogFlags.Modal |
429
Gtk.DialogFlags.DestroyWithParent,
430
Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
431
Catalog.GetString ("Error while connecting to Gallery"),
432
String.Format (Catalog.GetString ("The following error was encountered while attempting to log in: {0}"), we.Message));
436
} catch (System.Exception se) {
437
HigMessageDialog md =
438
new HigMessageDialog (add_dialog,
439
Gtk.DialogFlags.Modal |
440
Gtk.DialogFlags.DestroyWithParent,
441
Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
442
Catalog.GetString ("Error while connecting to Gallery"),
443
String.Format (Catalog.GetString ("The following error was encountered while attempting to log in: {0}"), se.Message));
444
Console.WriteLine (se);
450
add_dialog.Destroy ();
453
protected void HandleEditResponse (object sender, Gtk.ResponseArgs args)
455
if (args.ResponseId == Gtk.ResponseType.Ok) {
458
account.Username = username;
459
account.Password = password;
460
GalleryAccountManager.GetInstance ().MarkChanged (true, account);
461
} else if (args.ResponseId == Gtk.ResponseType.Reject) {
462
// NOTE we are using Reject to signal the remove action.
463
GalleryAccountManager.GetInstance ().RemoveAccount (account);
465
add_dialog.Destroy ();
468
private GalleryAccount account;
471
private string password;
472
private string username;
475
[Glade.Widget] Gtk.Dialog add_dialog;
477
[Glade.Widget] Gtk.Entry url_entry;
478
[Glade.Widget] Gtk.Entry password_entry;
479
[Glade.Widget] Gtk.Entry gallery_entry;
480
[Glade.Widget] Gtk.Entry username_entry;
482
[Glade.Widget] Gtk.Button add_button;
483
[Glade.Widget] Gtk.Button remove_button;
484
[Glade.Widget] Gtk.Button cancel_button;
486
[Glade.Widget] Gtk.HBox status_area;
489
public class GalleryAddAlbum
491
[Glade.Widget] Gtk.Dialog add_album_dialog;
492
[Glade.Widget] Gtk.OptionMenu album_optionmenu;
494
[Glade.Widget] Gtk.Entry name_entry;
495
[Glade.Widget] Gtk.Entry description_entry;
496
[Glade.Widget] Gtk.Entry title_entry;
498
[Glade.Widget] Gtk.Button add_button;
499
[Glade.Widget] Gtk.Button cancel_button;
501
private GalleryExport export;
502
private Gallery gallery;
503
private string parent;
505
private string description;
506
private string title;
508
public GalleryAddAlbum (GalleryExport export, Gallery gallery)
510
Glade.XML xml = new Glade.XML (null, "GalleryExport.glade", "gallery_add_album_dialog", "f-spot");
511
xml.Autoconnect (this);
512
add_album_dialog = (Gtk.Dialog) xml.GetWidget ("gallery_add_album_dialog");
513
add_album_dialog.Modal = true;
514
this.export = export;
515
this.gallery = gallery;
518
add_album_dialog.Response += HandleAddResponse;
520
name_entry.Changed += HandleChanged;
521
description_entry.Changed += HandleChanged;
522
title_entry.Changed += HandleChanged;
523
HandleChanged (null, null);
526
private void PopulateAlbums ()
528
Gtk.Menu menu = new Gtk.Menu ();
529
if (gallery.Version == GalleryVersion.Version1) {
530
Gtk.MenuItem top_item = new Gtk.MenuItem (Catalog.GetString ("(TopLevel)"));
531
menu.Append (top_item);
534
foreach (Album album in gallery.Albums) {
535
System.Text.StringBuilder label_builder = new System.Text.StringBuilder ();
537
for (int i=0; i < album.Parents.Count; i++) {
538
label_builder.Append (" ");
540
label_builder.Append (album.Title);
542
Gtk.MenuItem item = new Gtk.MenuItem (label_builder.ToString ());
543
((Gtk.Label)item.Child).UseUnderline = false;
546
AlbumPermission create_sub = album.Perms & AlbumPermission.CreateSubAlbum;
549
item.Sensitive = false;
552
album_optionmenu.Sensitive = true;
554
album_optionmenu.Menu = menu;
557
private void HandleChanged (object sender, EventArgs args)
559
if (gallery.Version == GalleryVersion.Version1) {
560
if (gallery.Albums.Count == 0 || album_optionmenu.History <= 0) {
561
parent = String.Empty;
563
parent = ((Album) gallery.Albums [album_optionmenu.History-1]).Name;
566
if (gallery.Albums.Count == 0 || album_optionmenu.History < 0) {
567
parent = String.Empty;
569
parent = ((Album) gallery.Albums [album_optionmenu.History]).Name;
572
name = name_entry.Text;
573
description = description_entry.Text;
574
title = title_entry.Text;
576
if (name == String.Empty || title == String.Empty)
577
add_button.Sensitive = false;
579
add_button.Sensitive = true;
583
protected void HandleAddResponse (object sender, Gtk.ResponseArgs args)
585
if (args.ResponseId == Gtk.ResponseType.Ok) {
586
if (!System.Text.RegularExpressions.Regex.IsMatch (name, "^[A-Za-z0-9_-]+$")) {
587
HigMessageDialog md =
588
new HigMessageDialog (add_album_dialog,
589
Gtk.DialogFlags.Modal |
590
Gtk.DialogFlags.DestroyWithParent,
591
Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
592
Catalog.GetString ("Invalid Gallery name"),
593
Catalog.GetString ("The gallery name contains invalid characters.\nOnly letters, numbers, - and _ are allowed"));
599
gallery.NewAlbum (parent, name, title, description);
600
export.HandleAlbumAdded (title);
601
} catch (GalleryCommandException e) {
602
gallery.PopupException(e, add_album_dialog);
606
add_album_dialog.Destroy ();
611
public class GalleryExport : IExporter {
612
public GalleryExport ()
616
public void Run (IBrowsableCollection selection)
618
Glade.XML xml = new Glade.XML (null, "GalleryExport.glade", "gallery_export_dialog", "f-spot");
619
xml.Autoconnect (this);
620
export_dialog = (Gtk.Dialog) xml.GetWidget ("gallery_export_dialog");
622
this.items = selection.Items;
623
Array.Sort<IBrowsableItem> (this.items as Photo[], new Photo.CompareDateName());
624
album_button.Sensitive = false;
625
IconView view = new IconView (selection);
626
view.DisplayDates = false;
627
view.DisplayTags = false;
629
export_dialog.Modal = false;
630
export_dialog.TransientFor = null;
632
thumb_scrolledwindow.Add (view);
634
export_dialog.Show ();
636
GalleryAccountManager manager = GalleryAccountManager.GetInstance ();
637
manager.AccountListChanged += PopulateGalleryOptionMenu;
638
PopulateGalleryOptionMenu (manager, null);
640
if (edit_button != null)
641
edit_button.Clicked += HandleEditGallery;
643
export_dialog.Response += HandleResponse;
645
HandleSizeActive (null, null);
648
LoadPreference (SCALE_KEY);
649
LoadPreference (SIZE_KEY);
650
LoadPreference (BROWSER_KEY);
651
LoadPreference (META_KEY);
652
LoadPreference (ROTATE_KEY);
655
public const string EXPORT_SERVICE = "gallery/";
656
public const string SCALE_KEY = Preferences.APP_FSPOT_EXPORT + EXPORT_SERVICE + "scale";
657
public const string SIZE_KEY = Preferences.APP_FSPOT_EXPORT + EXPORT_SERVICE + "size";
658
public const string BROWSER_KEY = Preferences.APP_FSPOT_EXPORT + EXPORT_SERVICE + "browser";
659
public const string META_KEY = Preferences.APP_FSPOT_EXPORT + EXPORT_SERVICE + "meta";
660
public const string ROTATE_KEY = Preferences.APP_FSPOT_EXPORT + EXPORT_SERVICE + "rotate";
661
public const string LIGHTTPD_WORKAROUND_KEY = Preferences.APP_FSPOT_EXPORT + EXPORT_SERVICE + "lighttpd_workaround";
666
private bool browser;
668
private bool connect = false;
670
IBrowsableItem[] items;
672
FSpot.ThreadProgressDialog progress_dialog;
675
private GalleryAccount account;
678
private string xml_path;
681
[Glade.Widget] Gtk.Dialog export_dialog;
682
[Glade.Widget] Gtk.OptionMenu gallery_optionmenu;
683
[Glade.Widget] Gtk.OptionMenu album_optionmenu;
685
[Glade.Widget] Gtk.Entry width_entry;
686
[Glade.Widget] Gtk.Entry height_entry;
688
[Glade.Widget] Gtk.CheckButton browser_check;
689
[Glade.Widget] Gtk.CheckButton scale_check;
690
[Glade.Widget] Gtk.CheckButton meta_check;
691
[Glade.Widget] Gtk.CheckButton rotate_check;
693
[Glade.Widget] Gtk.SpinButton size_spin;
695
[Glade.Widget] Gtk.Button album_button;
696
[Glade.Widget] Gtk.Button add_button;
697
[Glade.Widget] Gtk.Button edit_button;
699
[Glade.Widget] Gtk.Button export_button;
700
[Glade.Widget] Gtk.Button cancel_button;
702
[Glade.Widget] Gtk.ScrolledWindow thumb_scrolledwindow;
704
System.Threading.Thread command_thread;
707
private void HandleResponse (object sender, Gtk.ResponseArgs args)
709
if (args.ResponseId != Gtk.ResponseType.Ok) {
710
export_dialog.Destroy ();
714
if (scale_check != null) {
715
scale = scale_check.Active;
716
size = size_spin.ValueAsInt;
720
browser = browser_check.Active;
721
meta = meta_check.Active;
722
rotate = rotate_check.Active;
724
if (account != null) {
725
//System.Console.WriteLine ("history = {0}", album_optionmenu.History);
726
album = (Album) account.Gallery.Albums [Math.Max (0, album_optionmenu.History)];
729
export_dialog.Destroy ();
731
command_thread = new System.Threading.Thread (new System.Threading.ThreadStart (this.Upload));
732
command_thread.Name = Catalog.GetString ("Uploading Pictures");
734
progress_dialog = new FSpot.ThreadProgressDialog (command_thread, items.Length);
735
progress_dialog.Start ();
737
// Save these settings for next time
738
Preferences.Set (SCALE_KEY, scale);
739
Preferences.Set (SIZE_KEY, size);
740
Preferences.Set (BROWSER_KEY, browser);
741
Preferences.Set (META_KEY, meta);
742
Preferences.Set (ROTATE_KEY, rotate);
746
private void HandleProgressChanged (ProgressItem item)
748
//System.Console.WriteLine ("Changed value = {0}", item.Value);
749
progress_dialog.Fraction = (photo_index - 1.0 + item.Value) / (double) items.Length;
752
public void HandleSizeActive (object sender, EventArgs args)
754
size_spin.Sensitive = scale_check.Active;
758
private void Upload ()
760
account.Gallery.Progress = new ProgressItem ();
761
account.Gallery.Progress.Changed += HandleProgressChanged;
763
System.Console.WriteLine ("Starting upload");
765
FilterSet filters = new FilterSet ();
766
if (account.Version == GalleryVersion.Version1)
767
filters.Add (new WhiteListFilter (new string []{".jpg", ".jpeg", ".png", ".gif"}));
769
filters.Add (new ResizeFilter ((uint) size));
771
filters.Add (new OrientationFilter ());
774
while (photo_index < items.Length) {
775
IBrowsableItem item = items [photo_index];
777
System.Console.WriteLine ("uploading {0}", photo_index);
779
progress_dialog.Message = System.String.Format (Catalog.GetString ("Uploading picture \"{0}\""), item.Name);
780
progress_dialog.Fraction = photo_index / (double) items.Length;
783
progress_dialog.ProgressText = System.String.Format (Catalog.GetString ("{0} of {1}"), photo_index, items.Length);
786
FilterRequest req = new FilterRequest (item.DefaultVersionUri);
788
filters.Convert (req);
790
int id = album.Add (item, req.Current.LocalPath);
792
if (item != null && item is Photo && Core.Database != null && id != 0) {
793
Core.Database.Exports.Create ((item as Photo).Id, (item as Photo).DefaultVersionId,
794
ExportStore.Gallery2ExportType,
795
String.Format("{0}:{1}",album.Gallery.Uri.ToString (), id.ToString ()));
797
} catch (System.Exception e) {
798
progress_dialog.Message = String.Format (Catalog.GetString ("Error uploading picture \"{0}\" to Gallery: {1}"), item.Name, e.Message);
799
progress_dialog.ProgressText = Catalog.GetString ("Error");
800
Console.WriteLine (e);
802
if (progress_dialog.PerformRetrySkip ()) {
808
progress_dialog.Message = Catalog.GetString ("Done Sending Photos");
809
progress_dialog.Fraction = 1.0;
810
progress_dialog.ProgressText = Catalog.GetString ("Upload Complete");
811
progress_dialog.ButtonLabel = Gtk.Stock.Ok;
814
GnomeUtil.UrlShow (album.GetUrl());
818
private void PopulateGalleryOptionMenu (GalleryAccountManager manager, GalleryAccount changed_account)
820
Gtk.Menu menu = new Gtk.Menu ();
821
this.account = changed_account;
824
accounts = manager.GetAccounts ();
825
if (accounts == null || accounts.Count == 0) {
826
Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("(No Gallery)"));
828
gallery_optionmenu.Sensitive = false;
829
edit_button.Sensitive = false;
832
foreach (GalleryAccount account in accounts) {
833
if (account == changed_account)
836
Gtk.MenuItem item = new Gtk.MenuItem (account.Name);
840
gallery_optionmenu.Sensitive = true;
841
edit_button.Sensitive = true;
845
gallery_optionmenu.Menu = menu;
846
gallery_optionmenu.SetHistory ((uint)pos);
849
private void Connect ()
854
private void Connect (GalleryAccount selected)
857
if (accounts.Count != 0 && connect) {
858
if (selected == null)
859
account = (GalleryAccount) accounts [gallery_optionmenu.History];
863
if (!account.Connected)
866
PopulateAlbumOptionMenu (account.Gallery);
867
album_button.Sensitive = true;
869
} catch (System.Exception ex) {
870
if (selected != null)
873
System.Console.WriteLine ("{0}",ex);
874
PopulateAlbumOptionMenu (account.Gallery);
875
album_button.Sensitive = false;
877
new AccountDialog (export_dialog, account, true);
881
private void HandleAccountSelected (object sender, System.EventArgs args)
886
public void HandleAlbumAdded (string title) {
887
GalleryAccount account = (GalleryAccount) accounts [gallery_optionmenu.History];
888
PopulateAlbumOptionMenu (account.Gallery);
890
// make the newly created album selected
891
ArrayList albums = account.Gallery.Albums;
892
for (int i=0; i < albums.Count; i++) {
893
if (((Album)albums[i]).Title == title) {
894
album_optionmenu.SetHistory((uint)i);
899
private void PopulateAlbumOptionMenu (Gallery gallery)
901
System.Collections.ArrayList albums = null;
902
if (gallery != null) {
903
//gallery.FetchAlbumsPrune ();
905
gallery.FetchAlbums ();
906
albums = gallery.Albums;
907
} catch (GalleryCommandException e) {
908
gallery.PopupException (e, export_dialog);
913
Gtk.Menu menu = new Gtk.Menu ();
915
bool disconnected = gallery == null || !account.Connected || albums == null;
917
if (disconnected || albums.Count == 0) {
918
string msg = disconnected ? Catalog.GetString ("(Not Connected)")
919
: Catalog.GetString ("(No Albums)");
921
Gtk.MenuItem item = new Gtk.MenuItem (msg);
924
export_button.Sensitive = false;
925
album_optionmenu.Sensitive = false;
926
album_button.Sensitive = false;
929
album_button.Sensitive = false;
931
foreach (Album album in albums) {
932
System.Text.StringBuilder label_builder = new System.Text.StringBuilder ();
934
for (int i=0; i < album.Parents.Count; i++) {
935
label_builder.Append (" ");
937
label_builder.Append (album.Title);
939
Gtk.MenuItem item = new Gtk.MenuItem (label_builder.ToString ());
940
((Gtk.Label)item.Child).UseUnderline = false;
943
AlbumPermission add_permission = album.Perms & AlbumPermission.Add;
945
if (add_permission == 0)
946
item.Sensitive = false;
949
export_button.Sensitive = items.Length > 0;
950
album_optionmenu.Sensitive = true;
951
album_button.Sensitive = true;
955
album_optionmenu.Menu = menu;
958
public void HandleAddGallery (object sender, System.EventArgs args)
960
new AccountDialog (export_dialog);
963
public void HandleEditGallery (object sender, System.EventArgs args)
965
new AccountDialog (export_dialog, account, false);
968
public void HandleAddAlbum (object sender, System.EventArgs args)
971
throw new GalleryException (Catalog.GetString ("No account selected"));
973
new GalleryAddAlbum (this, account.Gallery);
976
void LoadPreference (string key)
978
object val = Preferences.Get (key);
983
//System.Console.WriteLine ("Setting {0} to {1}", key, val);
987
if (scale_check.Active != (bool) val)
988
scale_check.Active = (bool) val;
992
size_spin.Value = (double) (int) val;
996
if (browser_check.Active != (bool) val)
997
browser_check.Active = (bool) val;
1001
if (meta_check.Active != (bool) val)
1002
meta_check.Active = (bool) val;
1005
if (rotate_check.Active != (bool) val)
1006
rotate_check.Active = (bool) val;