Exemplo n.º 1
0
        private void PopulateGalleryOptionMenu(GalleryAccountManager manager, GalleryAccount changed_account)
        {
            this.account = changed_account;
            int pos = -1;

            accounts = manager.GetAccounts();
            if (accounts == null || accounts.Count == 0)
            {
                gallery_optionmenu.AppendText(Catalog.GetString("(No Gallery)"));

                gallery_optionmenu.Sensitive = false;
                edit_button.Sensitive        = false;
            }
            else
            {
                int i = 0;
                foreach (GalleryAccount account in accounts)
                {
                    if (account == changed_account)
                    {
                        pos = i;
                    }

                    gallery_optionmenu.AppendText(account.Name);
                    i++;
                }
                gallery_optionmenu.Sensitive = true;
                edit_button.Sensitive        = true;
            }

            gallery_optionmenu.Active = pos;
        }
Exemplo n.º 2
0
 public static GalleryAccountManager GetInstance()
 {
     if (instance == null) {
         instance = new GalleryAccountManager ();
     }
     return instance;
 }
Exemplo n.º 3
0
 public static GalleryAccountManager GetInstance()
 {
     if (instance == null)
     {
         instance = new GalleryAccountManager();
     }
     return(instance);
 }
Exemplo n.º 4
0
        public void Run(IBrowsableCollection selection)
        {
            var builder = new GtkBeans.Builder(null, "gallery_export_dialog.ui", null);

            builder.Autoconnect(this);
            export_dialog = new Gtk.Dialog(builder.GetRawObject("gallery_export_dialog"));

            album_optionmenu = new Gtk.ComboBox();
            (album_button.Parent as Gtk.HBox).PackStart(album_optionmenu);
            (album_button.Parent as Gtk.HBox).ReorderChild(album_optionmenu, 1);
            album_optionmenu.Show();

            gallery_optionmenu = new Gtk.ComboBox();
            (edit_button.Parent as Gtk.HBox).PackStart(gallery_optionmenu);
            (edit_button.Parent as Gtk.HBox).ReorderChild(gallery_optionmenu, 1);
            gallery_optionmenu.Show();

            this.items = selection.Items.ToArray();
            Array.Sort <IPhoto> (this.items, new IPhotoComparer.CompareDateName());
            album_button.Sensitive = false;
            var view = new TrayView(selection);

            view.DisplayDates = false;
            view.DisplayTags  = false;

            export_dialog.Modal        = false;
            export_dialog.TransientFor = null;

            thumb_scrolledwindow.Add(view);
            view.Show();
            export_dialog.Show();

            GalleryAccountManager manager = GalleryAccountManager.GetInstance();

            manager.AccountListChanged += PopulateGalleryOptionMenu;
            PopulateGalleryOptionMenu(manager, null);

            if (edit_button != null)
            {
                edit_button.Clicked += HandleEditGallery;
            }

            export_dialog.Response += HandleResponse;
            connect = true;
            HandleSizeActive(null, null);
            Connect();

            LoadPreference(SCALE_KEY);
            LoadPreference(SIZE_KEY);
            LoadPreference(BROWSER_KEY);
            LoadPreference(META_KEY);
        }
Exemplo n.º 5
0
 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);
     }
     add_dialog.Destroy();
 }
Exemplo n.º 6
0
        private void PopulateGalleryOptionMenu(GalleryAccountManager manager, GalleryAccount changed_account)
        {
            this.account = changed_account;
            int pos = -1;

            accounts = manager.GetAccounts ();
            if (accounts == null || accounts.Count == 0) {
                gallery_optionmenu.AppendText (Catalog.GetString ("(No Gallery)"));

                gallery_optionmenu.Sensitive = false;
                edit_button.Sensitive = false;
            } else {
                int i = 0;
                foreach (GalleryAccount account in accounts) {
                    if (account == changed_account)
                        pos = i;

                    gallery_optionmenu.AppendText (account.Name);
                    i++;
                }
                gallery_optionmenu.Sensitive = true;
                edit_button.Sensitive = true;
            }

            gallery_optionmenu.Active = pos;
        }
Exemplo n.º 7
0
        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();
                    }

                    //Check for name uniqueness
                    foreach (GalleryAccount acc in GalleryAccountManager.GetInstance().GetAccounts())
                    {
                        if (acc.Name == name)
                        {
                            throw new ArgumentException("name");
                        }
                    }
                    GalleryAccount created = new GalleryAccount(name,
                                                                url,
                                                                username,
                                                                password);

                    created.Connect();
                    GalleryAccountManager.GetInstance().AddAccount(created);
                    account = created;
                } catch (System.UriFormatException) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_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 (GalleryException e) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_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)
                    {
                        Log.Debug(e.Message);
                        Log.Debug(e.ResponseText);
                    }
                    md.Run();
                    md.Destroy();
                    return;
                } catch (ArgumentException ae) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_dialog,
                                             Gtk.DialogFlags.Modal |
                                             Gtk.DialogFlags.DestroyWithParent,
                                             Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                             Catalog.GetString("A Gallery with this name already exists"),
                                             string.Format(Catalog.GetString("There is already a Gallery with the same name in your registered Galleries. Please choose a unique name.")));
                    Log.Exception(ae);
                    md.Run();
                    md.Destroy();
                    return;
                } catch (System.Net.WebException we) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_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;
                } catch (System.Exception se) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_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}"), se.Message));
                    Log.Exception(se);
                    md.Run();
                    md.Destroy();
                    return;
                }
            }
            add_dialog.Destroy();
        }