Exemplo n.º 1
0
        public static GalleryAccountManager GetInstance()
        {
            if (instance == null)
            {
                instance = new GalleryAccountManager();
            }

            return(instance);
        }
Exemplo n.º 2
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.º 3
0
        public void Run(IBrowsableCollection selection)
        {
            Glade.XML xml = new Glade.XML(null, "GalleryExport.glade", "gallery_export_dialog", "f-spot");
            xml.Autoconnect(this);
            export_dialog = (Gtk.Dialog)xml.GetWidget("gallery_export_dialog");

            this.items = selection.Items;
            Array.Sort <IBrowsableItem> (this.items as Photo[], new Photo.CompareDateName());
            album_button.Sensitive = false;
            IconView view = new IconView(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);
            LoadPreference(ROTATE_KEY);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
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 (GalleryRemote.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)
                    {
                        System.Console.WriteLine(e.Message);
                        System.Console.WriteLine(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.")));
                    System.Console.WriteLine(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));
                    Console.WriteLine(se);
                    md.Run();
                    md.Destroy();
                    return;
                }
            }
            add_dialog.Destroy();
        }