void FillEncodings()
        {
            selectOption = -1;
            RadioMenuItem defaultActivated = null;

            Gtk.Menu menu = new Menu();

            // Don't show the auto-detection option when saving

            if (Action != Gtk.FileChooserAction.Save)
            {
                RadioMenuItem autodetect = new RadioMenuItem(GettextCatalog.GetString("Auto Detected"));
                autodetect.Group = new GLib.SList(typeof(object));
                menu.Append(autodetect);
                menu.Append(new Gtk.SeparatorMenuItem());
                autodetect.Active = true;
                defaultActivated  = autodetect;
                firstEncIndex     = 2;
            }
            else
            {
                firstEncIndex = 0;
            }

            foreach (var codePage in SelectedEncodings.ConversionEncodings)
            {
                var           enc   = Encoding.GetEncoding(codePage);
                RadioMenuItem mitem = new RadioMenuItem(enc.EncodingName + " (" + enc.WebName + ")");
                menu.Append(mitem);
                if (defaultActivated == null)
                {
                    defaultActivated       = mitem;
                    defaultActivated.Group = new GLib.SList(typeof(object));
                }
                else
                {
                    mitem.Group = defaultActivated.Group;
                }
                mitem.Active = false;
            }

            if (defaultActivated != null)
            {
                defaultActivated.Active = true;
            }

            menu.Append(new Gtk.SeparatorMenuItem());

            MenuItem select = new MenuItem(GettextCatalog.GetString("Add or _Remove..."));

            menu.Append(select);

            menu.ShowAll();
            encodingMenu.Menu = menu;

            encodingMenu.SetHistory(0);

            selectOption = firstEncIndex + SelectedEncodings.ConversionEncodings.Length + 1;
        }
        public FileSelectorDialog(string title, Gtk.FileChooserAction action) : base(title, action)
        {
            LocalOnly = true;

            // Add the text encoding selector
            Table table = new Table(2, 2, false);

            table.RowSpacing    = 6;
            table.ColumnSpacing = 6;

            encodingLabel        = new Label(GettextCatalog.GetString("_Character Coding:"));
            encodingLabel.Xalign = 0;
            table.Attach(encodingLabel, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            encodingMenu = new Gtk.OptionMenu();
            FillEncodings();
            encodingMenu.SetHistory(0);
            table.Attach(encodingMenu, 1, 2, 0, 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0);

            encodingMenu.Changed += EncodingChanged;

            // Add the viewer selector
            viewerLabel        = new Label(GettextCatalog.GetString("Open With:"));
            viewerLabel.Xalign = 0;
            table.Attach(viewerLabel, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            Gtk.HBox box = new HBox(false, 6);
            viewerSelector = Gtk.ComboBox.NewText();
            box.PackStart(viewerSelector, true, true, 0);
            closeWorkspaceCheck        = new CheckButton(GettextCatalog.GetString("Close current workspace"));
            closeWorkspaceCheck.Active = true;
            box.PackStart(closeWorkspaceCheck, false, false, 0);
            table.Attach(box, 1, 2, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0);
            FillViewers();
            viewerSelector.Changed += OnViewerChanged;

            table.ShowAll();
            this.ExtraWidget = table;

            // Give back the height that the extra widgets take
            int w, h;

            GetSize(out w, out h);
            Resize(w, h + table.SizeRequest().Height);

            if (action == Gtk.FileChooserAction.SelectFolder)
            {
                ShowEncodingSelector = false;
            }

            if (action != Gtk.FileChooserAction.Open)
            {
                closeWorkspaceCheck.Visible = ShowViewerSelector = false;
            }
        }
        private void HandleNewTagSelected(object sender, EventArgs args)
        {
            Tag new_tag = MainWindow.Toplevel.CreateTag(Dialog, null);

            if (new_tag != null)
            {
                CreateTagMenu();
                tag_option_menu.SetHistory((uint)(tag_option_menu.Menu as TagMenu).GetPosition(new_tag));
                selected_tags = new Tag [] { new_tag };
            }
        }
		public FileSelectorDialog (string title, Gtk.FileChooserAction action): base (title, action)
		{
			LocalOnly = true;
			
			// Add the text encoding selector
			Table table = new Table (2, 2, false);
			table.RowSpacing = 6;
			table.ColumnSpacing = 6;
			
			encodingLabel = new Label (GettextCatalog.GetString ("_Character Coding:"));
			encodingLabel.Xalign = 0;
			table.Attach (encodingLabel, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
			
			encodingMenu = new Gtk.OptionMenu ();
			FillEncodings ();
			encodingMenu.SetHistory (0);
			table.Attach (encodingMenu, 1, 2, 0, 1, AttachOptions.Expand|AttachOptions.Fill, AttachOptions.Expand|AttachOptions.Fill, 0, 0);

			encodingMenu.Changed += EncodingChanged;
			
			// Add the viewer selector
			viewerLabel = new Label (GettextCatalog.GetString ("Open With:"));
			viewerLabel.Xalign = 0;
			table.Attach (viewerLabel, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0);
			
			Gtk.HBox box = new HBox (false, 6);
			viewerSelector = Gtk.ComboBox.NewText ();
			box.PackStart (viewerSelector, true, true, 0);
			closeWorkspaceCheck = new CheckButton (GettextCatalog.GetString ("Close current workspace"));
			closeWorkspaceCheck.Active = true;
			box.PackStart (closeWorkspaceCheck, false, false, 0);
			table.Attach (box, 1, 2, 1, 2, AttachOptions.Expand|AttachOptions.Fill, AttachOptions.Expand|AttachOptions.Fill, 0, 0);
			FillViewers ();
			viewerSelector.Changed += OnViewerChanged;
			
			table.ShowAll ();
			this.ExtraWidget = table;
			
			// Give back the height that the extra widgets take
			int w, h;
			GetSize (out w, out h);
			Resize (w, h + table.SizeRequest ().Height);
			
			if (action == Gtk.FileChooserAction.SelectFolder)
				ShowEncodingSelector = false;
				
			if (action != Gtk.FileChooserAction.Open)
				closeWorkspaceCheck.Visible = ShowViewerSelector = false;
		}
示例#5
0
        public void HandleAlbumAdded(string title)
        {
            SmugMugAccount account = (SmugMugAccount)accounts [gallery_optionmenu.History];

            PopulateAlbumOptionMenu(account.SmugMug);

            // make the newly created album selected
            Album[] albums = account.SmugMug.GetAlbums();
            for (int i = 0; i < albums.Length; i++)
            {
                if (((Album)albums[i]).Title == title)
                {
                    album_optionmenu.SetHistory((uint)i);
                }
            }
        }
示例#6
0
        private void PopulateSmugMugOptionMenu(SmugMugAccountManager manager, SmugMugAccount 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(Mono.Unix.Catalog.GetString("(No Gallery)"));
                menu.Append(item);
                gallery_optionmenu.Sensitive = false;
                edit_button.Sensitive        = false;
            }
            else
            {
                int i = 0;
                foreach (SmugMugAccount account in accounts)
                {
                    if (account == changed_account)
                    {
                        pos = i;
                    }

                    Gtk.MenuItem item = new Gtk.MenuItem(account.Username);
                    menu.Append(item);
                    i++;
                }
                gallery_optionmenu.Sensitive = true;
                edit_button.Sensitive        = true;
            }

            menu.ShowAll();
            gallery_optionmenu.Menu = menu;
            gallery_optionmenu.SetHistory((uint)pos);
        }
    public int ImportFromFile(PhotoStore store, string path)
    {
        this.store = store;
        this.CreateDialog("import_dialog");

        this.Dialog.TransientFor   = main_window;
        this.Dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;
        this.Dialog.Response      += HandleDialogResponse;

        AllowFinish = false;

        this.Dialog.DefaultResponse = ResponseType.Ok;

        //import_folder_entry.Activated += HandleEntryActivate;
        recurse_check.Toggled += HandleRecurseToggled;
        copy_check.Toggled    += HandleRecurseToggled;

        menu = new SourceMenu(this);
        source_option_menu.Menu = menu;

        collection              = new FSpot.PhotoList(new Photo [0]);
        tray                    = new FSpot.ScalingIconView(collection);
        tray.Selection.Changed += HandleTraySelectionChanged;
        icon_scrolled.SetSizeRequest(200, 200);
        icon_scrolled.Add(tray);
        //icon_scrolled.Visible = false;
        tray.DisplayTags = false;
        tray.Show();

        photo_view = new FSpot.PhotoImageView(collection);
        photo_scrolled.Add(photo_view);
        photo_scrolled.SetSizeRequest(200, 200);
        photo_view.Show();

        //FSpot.Global.ModifyColors (frame_eventbox);
        FSpot.Global.ModifyColors(photo_scrolled);
        FSpot.Global.ModifyColors(photo_view);

        photo_view.Pixbuf = PixbufUtils.LoadFromAssembly("f-spot-48.png");
        photo_view.Fit    = true;

        tag_entry = new FSpot.Widgets.TagEntry(MainWindow.Toplevel.Database.Tags, false);
        tag_entry.UpdateFromTagNames(new string [] {});
        tagentry_box.Add(tag_entry);

        tag_entry.Show();

        this.Dialog.Show();
        //source_option_menu.Changed += HandleSourceChanged;
        if (path != null)
        {
            SetImportPath(path);
            int i = menu.FindItemPosition(path);

            if (i > 0)
            {
                source_option_menu.SetHistory((uint)i);
            }
            else if (Directory.Exists(path))
            {
                SourceItem path_item = new SourceItem(new VfsSource(path));
                menu.Prepend(path_item);
                path_item.ShowAll();
                SetImportPath(path);
                source_option_menu.SetHistory(0);
            }
            idle_start.Start();
        }

        ResponseType response = (ResponseType)this.Dialog.Run();

        while (response == ResponseType.Ok)
        {
            try {
                if (Directory.Exists(this.ImportPath))
                {
                    break;
                }
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                break;
            }

            HigMessageDialog md = new HigMessageDialog(this.Dialog,
                                                       DialogFlags.DestroyWithParent,
                                                       MessageType.Error,
                                                       ButtonsType.Ok,
                                                       Catalog.GetString("Directory does not exist."),
                                                       String.Format(Catalog.GetString("The directory you selected \"{0}\" does not exist.  " +
                                                                                       "Please choose a different directory"), this.ImportPath));

            md.Run();
            md.Destroy();

            response = (Gtk.ResponseType) this.Dialog.Run();
        }

        if (response == ResponseType.Ok)
        {
            this.UpdateTagStore(tag_entry.GetTypedTagNames());
            this.Finish();

            if (tags_selected != null && tags_selected.Count > 0)
            {
                for (int i = 0; i < collection.Count; i++)
                {
                    Photo p = collection [i] as Photo;

                    if (p == null)
                    {
                        continue;
                    }

                    p.AddTag((Tag [])tags_selected.ToArray(typeof(Tag)));
                    store.Commit(p);
                }
            }

            this.Dialog.Destroy();
            return(collection.Count);
        }
        else
        {
            this.Cancel();
            //this.Dialog.Destroy();
            return(0);
        }
    }