示例#1
0
        public void ShowDialog()
        {
            Glade.XML xml = new Glade.XML(null, "MetaPixel.glade", "metapixel_dialog", "f-spot");
            xml.Autoconnect(this);
            metapixel_dialog.Modal        = false;
            metapixel_dialog.TransientFor = null;

            miniatures_tags = new FSpot.Widgets.TagEntry(App.Instance.Database.Tags, false);
            miniatures_tags.UpdateFromTagNames(new string [] {});
            tagentry_box.Add(miniatures_tags);

            metapixel_dialog.Response += on_dialog_response;
            current_radio.Active       = true;
            tags_radio.Toggled        += HandleTagsRadioToggled;
            HandleTagsRadioToggled(null, null);
            metapixel_dialog.ShowAll();
        }
    private void UpdateTagStore(string [] new_tags)
    {
        if (new_tags == null || new_tags.Length == 0)
        {
            return;
        }

        tags_selected = new ArrayList();
        Db db = MainWindow.Toplevel.Database;

        db.BeginTransaction();
        foreach (string tagname in new_tags)
        {
            Tag t = db.Tags.GetTagByName(tagname);
            if (t == null)
            {
                // Note for translators: 'Import Tags' is no command, it means 'Tags used in Import'
                Category default_category = db.Tags.GetTagByName(Catalog.GetString("Import Tags")) as Category;
                if (default_category == null)
                {
                    default_category = db.Tags.CreateCategory(null, Catalog.GetString("Import Tags"));
                    default_category.ThemeIconName = "f-spot-imported-xmp-tags.png";
                }
                t = db.Tags.CreateCategory(default_category, tagname) as Tag;
                db.Tags.Commit(t);
            }

            tags_selected.Add(t);
        }
        db.CommitTransaction();

        ArrayList tagnames = new ArrayList();

        foreach (Tag t in tags_selected)
        {
            tagnames.Add(t.Name);
        }
        tag_entry.UpdateFromTagNames((string [])tagnames.ToArray(typeof(string)));
    }
示例#3
0
        public void ShowDialog()
        {
            Glade.XML xml = new Glade.XML (null, "MetaPixel.glade", "metapixel_dialog", "f-spot");
            xml.Autoconnect (this);
            metapixel_dialog.Modal = false;
            metapixel_dialog.TransientFor = null;

            miniatures_tags = new FSpot.Widgets.TagEntry (App.Instance.Database.Tags, false);
            miniatures_tags.UpdateFromTagNames (new string []{});
            tagentry_box.Add (miniatures_tags);

            metapixel_dialog.Response += on_dialog_response;
            current_radio.Active = true;
            tags_radio.Toggled += HandleTagsRadioToggled;
            HandleTagsRadioToggled (null, null);
            metapixel_dialog.ShowAll ();
        }
	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;
		}
	}
示例#5
0
		void BuildUI (Window parent)
		{
			TransientFor = parent;
			WindowPosition = WindowPosition.CenterOnParent;

			photo_view = new PhotoImageView (Controller.Photos);
			photo_scrolled.Add (photo_view);
			photo_scrolled.SetSizeRequest (200, 200);
			photo_view.Show ();

			GtkUtil.ModifyColors (photo_scrolled);
			GtkUtil.ModifyColors (photo_view);

			var tray = new BrowseablePointerGridView (photo_view.Item) {
				DisplayTags = false
			};
			icon_scrolled.Add (tray);
			tray.Show ();

			progress_bar.Hide ();

			import_button.Sensitive = false;

			tag_entry = new TagEntry (App.Instance.Database.Tags, false);
			tag_entry.UpdateFromTagNames (new string []{});
			tagentry_box.Add (tag_entry);
			tag_entry.Show ();
			attachtags_label.MnemonicWidget = tag_entry;
		}
    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);
        }
    }