public static GalleryAccountManager GetInstance() { if (instance == null) { instance = new GalleryAccountManager(); } return(instance); }
protected void HandleEditResponse(object sender, Gtk.ResponseArgs args) { if (args.ResponseId == Gtk.ResponseType.Ok) { account.Name = name; account.Url = url; account.Username = username; account.Password = password; GalleryAccountManager.GetInstance().MarkChanged(true, account); } else if (args.ResponseId == Gtk.ResponseType.Reject) { // NOTE we are using Reject to signal the remove action. GalleryAccountManager.GetInstance().RemoveAccount(account); } Dialog.Destroy(); }
public void Run(IBrowsableCollection selection) { this.items = selection.Items; album_button.Sensitive = false; IconView view = new IconView(selection); view.DisplayDates = false; view.DisplayTags = false; Dialog.Modal = false; Dialog.TransientFor = null; thumb_scrolledwindow.Add(view); view.Show(); Dialog.Show(); GalleryAccountManager manager = GalleryAccountManager.GetInstance(); manager.AccountListChanged += PopulateGalleryOptionMenu; PopulateGalleryOptionMenu(manager, null); if (edit_button != null) { edit_button.Clicked += HandleEditGallery; } Dialog.Response += HandleResponse; connect = true; HandleSizeActive(null, null); Connect(); LoadPreference(Preferences.EXPORT_GALLERY_SCALE); LoadPreference(Preferences.EXPORT_GALLERY_SIZE); LoadPreference(Preferences.EXPORT_GALLERY_BROWSER); LoadPreference(Preferences.EXPORT_GALLERY_META); LoadPreference(Preferences.EXPORT_GALLERY_ROTATE); }
private void PopulateGalleryOptionMenu(GalleryAccountManager manager, GalleryAccount changed_account) { Gtk.Menu menu = new Gtk.Menu(); this.account = changed_account; int pos = -1; accounts = manager.GetAccounts(); if (accounts == null || accounts.Count == 0) { Gtk.MenuItem item = new Gtk.MenuItem(Catalog.GetString("(No Gallery)")); menu.Append(item); gallery_optionmenu.Sensitive = false; edit_button.Sensitive = false; } else { int i = 0; foreach (GalleryAccount account in accounts) { if (account == changed_account) { pos = i; } Gtk.MenuItem item = new Gtk.MenuItem(account.Name); menu.Append(item); i++; } gallery_optionmenu.Sensitive = true; edit_button.Sensitive = true; } menu.ShowAll(); gallery_optionmenu.Menu = menu; gallery_optionmenu.SetHistory((uint)pos); }
private void PopulateGalleryOptionMenu (GalleryAccountManager manager, GalleryAccount changed_account) { Gtk.Menu menu = new Gtk.Menu (); this.account = changed_account; int pos = -1; accounts = manager.GetAccounts (); if (accounts == null || accounts.Count == 0) { Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("(No Gallery)")); menu.Append (item); gallery_optionmenu.Sensitive = false; edit_button.Sensitive = false; } else { int i = 0; foreach (GalleryAccount account in accounts) { if (account == changed_account) pos = i; Gtk.MenuItem item = new Gtk.MenuItem (account.Name); menu.Append (item); i++; } gallery_optionmenu.Sensitive = true; edit_button.Sensitive = true; } menu.ShowAll (); gallery_optionmenu.Menu = menu; gallery_optionmenu.SetHistory ((uint)pos); }
public static GalleryAccountManager GetInstance () { if (instance == null) { instance = new GalleryAccountManager (); } return instance; }
protected void HandleAddResponse(object sender, Gtk.ResponseArgs args) { if (args.ResponseId == Gtk.ResponseType.Ok) { try { Uri uri = new Uri(url); if (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps) { throw new System.UriFormatException(); } GalleryAccount created = new GalleryAccount(name, url, username, password); created.Connect(); GalleryAccountManager.GetInstance().AddAccount(created); account = created; } catch (System.UriFormatException) { HigMessageDialog md = new HigMessageDialog(Dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString("Invalid URL"), Catalog.GetString("The gallery URL entry does not appear to be a valid URL")); md.Run(); md.Destroy(); return; } catch (GalleryRemote.GalleryException e) { HigMessageDialog md = new HigMessageDialog(Dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString("Error while connecting to Gallery"), String.Format(Catalog.GetString("The following error was encountered while attempting to log in: {0}"), e.Message)); if (e.ResponseText != null) { System.Console.WriteLine(e.Message); System.Console.WriteLine(e.ResponseText); } md.Run(); md.Destroy(); return; } catch (System.Net.WebException we) { HigMessageDialog md = new HigMessageDialog(Dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString("Error while connecting to Gallery"), String.Format(Catalog.GetString("The following error was encountered while attempting to log in: {0}"), we.Message)); md.Run(); md.Destroy(); return; } } Dialog.Destroy(); }