? ImportXmpTags4.diff
? src/XmpTagsImporter.cs
? src/XmpTagsMetadata.cs
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/f-spot/ChangeLog,v
retrieving revision 1.1510
diff -u -p -r1.1510 ChangeLog
--- ChangeLog	15 Jun 2006 01:34:14 -0000	1.1510
+++ ChangeLog	1 Jul 2006 10:44:38 -0000
@@ -1,3 +1,17 @@
+2006-07-01  Bengt Thuree <bengt@thuree.com> 
+
+	* src/XmpTagsMetadata.cs: Reads the XMP tags from a photo during import
+	
+	* src/XmpTagsImporter.cs: Creates XMP tags during import
+	
+	* src/FileImportBackend.cs: Calls XmpTagsImporter during import.
+	
+	* src/Makefile.am: Added XmpTagsMetadata.cs and XmpTagsImporter.cs
+	
+	* src/ImportCommand.cs: disable DisplayTags since otherwise we get a crash. 
+	Cancel do not seem to remove all...
+
+
 2006-06-14  Larry Ewing  <lewing@novell.com>
 
 	* src/IthmbDb.cs: update the entries drop the db loader for now.
Index: src/FileImportBackend.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/FileImportBackend.cs,v
retrieving revision 1.35
diff -u -p -r1.35 FileImportBackend.cs
--- src/FileImportBackend.cs	6 Jun 2006 17:11:46 -0000	1.35
+++ src/FileImportBackend.cs	1 Jul 2006 10:44:38 -0000
@@ -3,6 +3,7 @@ using Gtk;
 using Gnome;
 using System.Collections;
 using System;
+using FSpot;
 using System.IO;
 
 public class ImportException : System.Exception {
@@ -13,13 +14,17 @@ public class ImportException : System.Ex
 
 public class FileImportBackend : ImportBackend {
 	PhotoStore store;
+	TagStore tag_store = FSpot.Core.Database.Tags;
 	bool recurse;
 	bool copy;
 	string [] base_paths;
 	Tag [] tags;
+	Gtk.Dialog dialog;
 
 	int count;
 
+	XmpTagsImporter xmptags;
+
 	ArrayList file_paths;
 	ArrayList imported_photos;
 	Stack directories;
@@ -95,6 +100,7 @@ public class FileImportBackend : ImportB
 
 		imported_photos = new ArrayList ();
 		directories = new Stack ();
+		xmptags = new XmpTagsImporter (dialog, store, tag_store);
 
 		return file_paths.Count;
 	}
@@ -179,6 +185,8 @@ public class FileImportBackend : ImportB
 
 		// FIXME Need to get the EXIF info etc.
 		string path = (string) file_paths [this.count];
+		string orig_path = path;
+		bool needs_commit = false;
 		
 		try {
 			string dest = path;
@@ -204,14 +212,21 @@ public class FileImportBackend : ImportB
 
 				path = dest;
 			}
-			
+			photo = store.Create (dest, path, out thumbnail);
+			path = dest;
 			if (tags != null) {
 				foreach (Tag t in tags)
 					photo.AddTag (t);
 
-				store.Commit(photo);
+				needs_commit = true;
 			}
 
+
+			needs_commit |= xmptags.Import (photo, path, orig_path);
+
+			if (needs_commit)
+				store.Commit(photo);
+
 			imported_photos.Add (photo);
 			
 		} catch (System.Exception e) {
@@ -255,6 +270,8 @@ public class FileImportBackend : ImportB
 					info.Delete ();
 			}
 		}
+		// Clean up just created tags
+		xmptags.Cancel();
 	}
 
 	public override void Finish ()
@@ -269,13 +286,15 @@ public class FileImportBackend : ImportB
 		}
 
 		imported_photos = null;
+		xmptags.Finish();
 		count = 0;
 	}
 
-	public FileImportBackend (PhotoStore store, string [] base_paths, bool recurse) : this (store, base_paths, false, recurse, null) {}
+	public FileImportBackend (Gtk.Dialog dialog, PhotoStore store, string [] base_paths, bool recurse) : this (dialog, store, base_paths, false, recurse, null) {}
 
-	public FileImportBackend (PhotoStore store, string [] base_paths, bool copy, bool recurse, Tag [] tags)
+	public FileImportBackend (Gtk.Dialog dialog, PhotoStore store, string [] base_paths, bool copy, bool recurse, Tag [] tags)
 	{
+		this.dialog = dialog;
 		this.store = store;
 		this.copy = copy;
 		this.base_paths = base_paths;
Index: src/ImportCommand.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/ImportCommand.cs,v
retrieving revision 1.63
diff -u -p -r1.63 ImportCommand.cs
--- src/ImportCommand.cs	9 Jun 2006 22:53:02 -0000	1.63
+++ src/ImportCommand.cs	1 Jul 2006 10:44:39 -0000
@@ -346,7 +346,6 @@ public class ImportCommand : FSpot.Glade
 
 			if (item.Source is BrowseSource) {
 				string path = ChoosePath ();
-				
 				if (path != null) {
 					SourceItem path_item = new SourceItem (new VfsSource (path));
 					menu.Prepend (path_item);
@@ -512,7 +511,6 @@ public class ImportCommand : FSpot.Glade
 	public string ChoosePath ()
 	{
 		string path = null;
-
 		CompatFileChooserDialog file_selector =
 			new CompatFileChooserDialog ("Import", this.Dialog,
 						     CompatFileChooserDialog.Action.SelectFolder);
@@ -529,7 +527,6 @@ public class ImportCommand : FSpot.Glade
 		if ((ResponseType) response == ResponseType.Ok) {
 			path = file_selector.Filename;
 		}
-
 		file_selector.Destroy ();
 		return path;
 	}
@@ -562,6 +559,7 @@ public class ImportCommand : FSpot.Glade
 		this.Dialog.TransientFor = main_window;
 		this.Dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;
 		this.Dialog.Response += HandleDialogResponse;
+		bool SavedDisplayTags;
 
 		CreateTagMenu ();
 		
@@ -578,6 +576,8 @@ public class ImportCommand : FSpot.Glade
 
 		collection = new FSpot.PhotoList (new Photo [0]);
 		tray = new FSpot.ScalingIconView (collection);
+		SavedDisplayTags = tray.DisplayTags;	// So we know which state we had.
+		tray.DisplayTags = false;		// Otherwise deleting just created XMP tags will crash.
 		tray.Selection.Changed += HandleTraySelectionChanged;
 		icon_scrolled.SetSizeRequest (200, 200);
 		icon_scrolled.Add (tray);
@@ -659,12 +659,13 @@ public class ImportCommand : FSpot.Glade
 					store.Commit (p);
 				}
 			}
-
+			tray.DisplayTags = SavedDisplayTags;
 			this.Dialog.Destroy ();
 			return collection.Count;
 		} else {
 			this.Cancel ();
 			//this.Dialog.Destroy();
+			tray.DisplayTags = SavedDisplayTags;
 			return 0;
 		}
 	}
@@ -699,6 +700,7 @@ public class ImportCommand : FSpot.Glade
 	{
 		idle_start.Stop ();
 		step.Stop ();
+		
 		if (importer != null) {
 			importer.Cancel ();
 			importer = null;
@@ -732,7 +734,7 @@ public class ImportCommand : FSpot.Glade
 		if (recurse_check != null)
 			recurse = recurse_check.Active;
 		
-		importer = new FileImportBackend (store, pathimport, copy, recurse, null);
+		importer = new FileImportBackend (this.Dialog, store, pathimport, copy, recurse, null);
 		AllowFinish = false;
 		
 		total = importer.Prepare ();
@@ -762,7 +764,7 @@ public class ImportCommand : FSpot.Glade
 	public int ImportFromPaths (PhotoStore store, string [] paths, Tag [] tags, bool copy)
 	{
 		collection = new FSpot.PhotoList (new Photo [0]);
-		int count = DoImport (new FileImportBackend (store, paths, copy, true, tags));
+		int count = DoImport (new FileImportBackend (this.Dialog, store, paths, copy, true, tags));
 
 		Finish ();
 
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/f-spot/src/Makefile.am,v
retrieving revision 1.63
diff -u -p -r1.63 Makefile.am
--- src/Makefile.am	26 Apr 2006 20:31:07 -0000	1.63
+++ src/Makefile.am	1 Jul 2006 10:44:39 -0000
@@ -118,6 +118,8 @@ F_SPOT_CSDISTFILES =				\
 	$(srcdir)/TagSelectionDialog.cs		\
 	$(srcdir)/X3fFile.cs			\
 	$(srcdir)/XmpFile.cs			\
+	$(srcdir)/XmpTagsImporter.cs		\
+	$(srcdir)/XmpTagsMetadata.cs		\
 	$(srcdir)/main.cs
 
 ASSEMBLIES =					\
