--- ../f-spot.ImportXMP/ChangeLog	2006-07-22 13:35:17.000000000 +1000
+++ ./ChangeLog	2006-07-22 14:19:09.000000000 +1000
@@ -1,3 +1,28 @@
+2006-07-27 Bengt Thuree <bengt@thuree.com> 
+
+	* : The below changes are for bug #321770
+	* src/ImportStore.cs: Reworked this class. Creating two tables, 
+	imports and imports_data, to track the last 10 or so imports (fixes #321770).
+	
+	* src/FileImportBackend.cs: Adding the import session for each 
+	imported photo, as well as Removing on cancel, or Finish on finish.
+	
+	* src/CameraFileSelectionDialog.cs: 
+	* src/ImportCommand.cs:
+	* src/MainWindow.cs: Added ImportStore parameter
+	
+	* src/Updater.cs: Creating the extra imports_data table (to keep import id and photo id)
+	
+	* src/PhotoQuery.cs: Added query on last import session id.
+	
+	* src/QueryDisplay.cs: Added indication of Import Roll filter, as well as clearing it.
+	
+	* src/PhotoStore.cs: Added PhotoStore.ImportIdRange, as well as sql filter on last import session id.
+	Minor modifications on creating a query to handle (AND or WHERE text)
+
+	* src/f-spot.glade:
+	* src/LastRollDialog.cs: Added a dialog for the Last Imported Roll history and selection.
+
  2006-07-27  Bengt Thuree <bengt@thuree.com> 
  
  	* src/XmpTagsMetadata.cs: Reads the XMP tags from a photo during import
--- ../f-spot.ImportXMP/src/CameraFileSelectionDialog.cs	2006-07-22 13:32:47.000000000 +1000
+++ src/CameraFileSelectionDialog.cs	2006-07-22 14:16:43.000000000 +1000
@@ -265,7 +265,7 @@ namespace FSpot {
 			
 			if (saved_files != null && import_files_checkbox.Active) {
 				ImportCommand command = new ImportCommand (null);
-				command.ImportFromPaths (db.Photos, saved_files, selected_tags);
+				command.ImportFromPaths (db.Photos, db.Imports, saved_files, selected_tags);
 			}
 		}
 		
--- ../f-spot.ImportXMP/src/FileImportBackend.cs	2006-07-22 14:03:36.000000000 +1000
+++ src/FileImportBackend.cs	2006-07-22 14:25:54.000000000 +1000
@@ -14,6 +14,7 @@ public class ImportException : System.Ex
 
 public class FileImportBackend : ImportBackend {
 	PhotoStore store;
+ 	ImportStore imports;
 	TagStore tag_store = FSpot.Core.Database.Tags;
 	bool recurse;
 	bool copy;
@@ -240,6 +241,8 @@ public class FileImportBackend : ImportB
 				store.Commit(photo);
 			
 			info.Photo = photo;
+                        imports.AddPhotoToSession (photo.Id);
+
 		} catch (System.Exception e) {
 			System.Console.WriteLine ("Error importing {0}\n{1}", info.OriginalPath, e.ToString ());
 			thumbnail = null;
@@ -285,6 +288,9 @@ public class FileImportBackend : ImportB
 		}
 		// Clean up just created tags
 		xmptags.Cancel();
+		
+		// Remove the imported session
+		imports.DeleteCurrent(); 
 	}
 
 	public override void Finish ()
@@ -300,13 +306,16 @@ public class FileImportBackend : ImportB
 		import_info = null;
 		xmptags.Finish();
 		count = 0;
+		
+		imports.EndImport();    // Clean up the imported session.
 	}
 
-	public FileImportBackend (PhotoStore store, string [] base_paths, bool recurse) : this (store, base_paths, false, recurse, null) {}
+	public FileImportBackend (PhotoStore store, ImportStore imports, string [] base_paths, bool recurse) : this (store, imports, base_paths, false, recurse, null) {}
 
-	public FileImportBackend (PhotoStore store, string [] base_paths, bool copy, bool recurse, Tag [] tags)
+	public FileImportBackend (PhotoStore store, ImportStore imports, string [] base_paths, bool copy, bool recurse, Tag [] tags)
 	{
 		this.store = store;
+		this.imports = imports;
 		this.copy = copy;
 		this.base_paths = base_paths;
 		this.recurse = recurse;
@@ -327,7 +336,7 @@ public class FileImportBackend : ImportB
 
 		Db db = new Db (path, true);
 
-		FileImportBackend import = new FileImportBackend (db.Photos, args [0],true);
+		FileImportBackend import = new FileImportBackend (db.Photos, db.Imports, args [0],true);
 
 		Console.WriteLine ("Preparing...");
 
--- ../f-spot.ImportXMP/src/ImportCommand.cs	2006-07-22 13:33:29.000000000 +1000
+++ src/ImportCommand.cs	2006-07-22 14:16:43.000000000 +1000
@@ -313,6 +313,7 @@ public class ImportCommand : FSpot.Glade
 
 	int total;
 	PhotoStore store;
+	ImportStore import_sessions;
 	FSpot.Delay step;
 	
 	FSpot.PhotoImageView photo_view;
@@ -551,9 +552,10 @@ public class ImportCommand : FSpot.Glade
 		idle_start.Start ();
 	}
 
-	public int ImportFromFile (PhotoStore store, string path)
+	public int ImportFromFile (PhotoStore store, ImportStore import_sessions, string path)
 	{
 		this.store = store;
+		this.import_sessions = import_sessions;
 		this.CreateDialog ("import_dialog");
 		
 		this.Dialog.TransientFor = main_window;
@@ -734,7 +736,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 (store, import_sessions, pathimport, copy, recurse, null);
 		AllowFinish = false;
 		
 		total = importer.Prepare ();
@@ -751,20 +753,20 @@ public class ImportCommand : FSpot.Glade
 		return false;
 	}
 
-	public int ImportFromPaths (PhotoStore store, string [] paths, bool copy)
+	public int ImportFromPaths (PhotoStore store, ImportStore import_sessions, string [] paths, bool copy)
 	{
-		return ImportFromPaths (store, paths, null, copy);
+		return ImportFromPaths (store, import_sessions, paths, null, copy);
 	}
 	
-	public int ImportFromPaths (PhotoStore store, string [] paths, Tag [] tags)
+	public int ImportFromPaths (PhotoStore store,  ImportStore import_sessions, string [] paths, Tag [] tags)
 	{
-		return ImportFromPaths (store, paths, tags, false);
+		return ImportFromPaths (store, import_sessions, paths, tags, false);
 	}
 	
-	public int ImportFromPaths (PhotoStore store, string [] paths, Tag [] tags, bool copy)
+	public int ImportFromPaths (PhotoStore store,  ImportStore import_sessions, 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 (store, import_sessions, paths, copy, true, tags));
 
 		Finish ();
 
--- ../f-spot.ImportXMP/src/ImportStore.cs	2006-07-22 13:32:47.000000000 +1000
+++ src/ImportStore.cs	2006-07-22 14:16:43.000000000 +1000
@@ -3,25 +3,29 @@ using System.Collections;
 using System.IO;
 using System;
 
-
-public class ImportStore : DbStore {
-
-	public class Import : DbItem {
-		// The time is always in UTC.
-		private DateTime time;
-		public DateTime Time {
-			get {
-				return time;
-			}
+public class Import : DbItem {
+	// The time is always in UTC.
+	private DateTime time;
+	public DateTime Time {
+		get {
+			return time;
 		}
+	}
 
 		public Import (uint id, long unix_time)
-			: base (id)
-		{
-			time = DbUtils.DateTimeFromUnixTime (unix_time);
-		}
+		: base (id)
+	{
+		time = DbUtils.DateTimeFromUnixTime (unix_time);
 	}
+}
+
 
+
+public class ImportStore : DbStore {
+        
+	Import import_session;                         // This import session.
+	public const int MaxNumberImports = 20;
+	        
 	private class ImportComparerByDate : IComparer {
 		public int Compare (Object a, Object b) {
 			return DateTime.Compare ((a as Import).Time, (b as Import).Time);
@@ -33,6 +37,9 @@ public class ImportStore : DbStore {
 	public ImportStore (SqliteConnection connection, bool is_new)
 		: base (connection, false)
 	{
+
+                this.import_session = null;
+
 		if (! is_new)
 			return;
 		
@@ -42,7 +49,19 @@ public class ImportStore : DbStore {
 		command.CommandText =
 			"CREATE TABLE imports (                            " +
 			"	id          INTEGER PRIMARY KEY NOT NULL,  " +
-			"       time        INTEGER			   " +
+			"       time        INTEGER not null               " +
+			")";
+
+		command.ExecuteNonQuery ();
+		command.Dispose ();
+		
+		command = new SqliteCommand ();
+		command.Connection = Connection;
+
+		command.CommandText =
+			"CREATE TABLE imports_data (                       " +
+			"	import_id   INTEGER,                       " +
+			"       photo_id    INTEGER            		   " +
 			")";
 
 		command.ExecuteNonQuery ();
@@ -56,8 +75,7 @@ public class ImportStore : DbStore {
 		SqliteCommand command = new SqliteCommand ();
 		command.Connection = Connection;
 
-		command.CommandText = String.Format ("INSERT INTO import (time) VALUES ({0})  ",
-						     unix_time);
+		command.CommandText = String.Format ("INSERT INTO imports (time) VALUES ({0})  ", unix_time);
 		command.ExecuteScalar ();
 		command.Dispose ();
 
@@ -68,6 +86,12 @@ public class ImportStore : DbStore {
 		return import;
 	}
 
+	public Import Create ()
+	{
+		return Create (System.DateTime.Now);
+	}
+
+
 	public override DbItem Get (uint id)
 	{
 		Import import = LookupInCache (id) as Import;
@@ -101,12 +125,237 @@ public class ImportStore : DbStore {
 		command.ExecuteNonQuery ();
 
 		command.Dispose ();
+
+		command = new SqliteCommand ();
+		command.Connection = Connection;
+
+		command.CommandText = String.Format ("DELETE FROM imports_data WHERE import_id = {0}", item.Id);
+		command.ExecuteNonQuery ();
+
+		command.Dispose ();
 	}
 
 	public override void Commit (DbItem item)
+	{ 
+                // Nothing to be done here
+	}
+	
+	public uint GetNumberOfPhotosInRoll (uint rollid)
+	{
+		uint number_of_photos_in_roll = 0;
+                SqliteCommand command = new SqliteCommand ();
+		command.Connection = Connection;
+
+		command.CommandText = String.Format ("SELECT count(*) FROM imports_data WHERE import_id = {0}", rollid);
+
+                SqliteDataReader reader = command.ExecuteReader ();
+                if (reader.Read ()) {
+                        number_of_photos_in_roll = Convert.ToUInt32 (reader[0]);
+                }
+                
+		command.Dispose ();
+                
+                return number_of_photos_in_roll;	
+	}
+
+	public System.DateTime GetDateForRoll (uint rollid)
+	{
+		System.DateTime date_for_roll = System.DateTime.MinValue;
+                SqliteCommand command = new SqliteCommand ();
+		command.Connection = Connection;
+
+		command.CommandText = String.Format ("SELECT time FROM imports WHERE id = {0}", rollid);
+
+                SqliteDataReader reader = command.ExecuteReader ();
+                if (reader.Read ()) {
+                        date_for_roll = DbUtils.DateTimeFromUnixTime (Convert.ToUInt32 (reader[0]));
+                }
+                
+		command.Dispose ();
+                
+                return date_for_roll;	
+	}
+		
+		
+	
+	public uint [] GetActiveRolls()
+	{
+		// Before we return any rows, lets purge out any old empty rows.
+		PurgeOldData();
+
+		// Ok, now we only should have real data there, so lets return them.
+		ArrayList result = new ArrayList();
+		SqliteCommand command = new SqliteCommand ();
+		command.Connection = Connection;
+		
+	        command.CommandText = "SELECT id, time FROM imports ORDER BY id DESC";
+                
+                SqliteDataReader reader = command.ExecuteReader ();
+		
+		while (reader.Read ()) {
+			// Note that we get both time and ID from the database, but we have to see
+			// if the item is already in the cache first to make sure we return always
+			// the same object for a given ID.
+			
+			uint id = Convert.ToUInt32 (reader[0]);
+
+			Import import = LookupInCache (id) as Import;
+			if (import == null) {
+				import = new Import (id, Convert.ToUInt32 (reader[1]));
+				AddToCache (import);
+			}
+			result.Add (id);
+		}
+		command.Dispose ();
+		return (uint [])result.ToArray(typeof(uint));
+	}
+	
+	public uint GetLastRollId()
+	{
+		// Lets remove any old empty sessions first.
+		// These are caused by user deleting photos from an import session.
+		// Then the photo_id is deleted from imports_data, but the import_session
+		// is not deleted from imports if the session is empty.
+		PurgeOldData();	
+
+		uint last_roll_id = 0;
+                SqliteCommand command = new SqliteCommand ();
+		command.Connection = Connection;
+
+		command.CommandText = "SELECT MAX (id) FROM imports";
+
+                SqliteDataReader reader = command.ExecuteReader ();
+                if (reader.Read ()) {
+                        last_roll_id = Convert.ToUInt32 (reader[0]);
+                }
+                
+		command.Dispose ();
+                
+                return last_roll_id;
+	}
+	
+        public uint NumberOfRows()
+        {
+                uint rows = 0;
+                SqliteCommand command = new SqliteCommand ();
+		command.Connection = Connection;
+
+		// Lets do the awkward select by searching the imports_data, since 
+		// if user deleted photos, the imports table is not updated.
+		// The imports table is purged during next import or filter.
+//		command.CommandText = "SELECT count(*) FROM imports";
+		command.CommandText = "SELECT COUNT(import_id) FROM (SELECT DISTINCT import_id FROM imports_data)";
+
+                SqliteDataReader reader = command.ExecuteReader ();
+                if (reader.Read ()) {
+                        rows = Convert.ToUInt32 (reader[0]);
+                }
+                
+		command.Dispose ();
+                return rows;
+        }
+	
+	private void RemoveOldestImportSession()
 	{
-		// Nothing to do here, since all the properties of an import are immutable.
+		SqliteCommand command = new SqliteCommand ();
+		command.Connection = Connection;
+		
+	        command.CommandText = String.Format 
+		      ("SELECT id, time FROM imports WHERE id = (select MIN(id) from imports)"); 
+                
+                SqliteDataReader reader = command.ExecuteReader ();
+		
+		if (reader.Read ()) {
+			// Note that we get both time and ID from the database, but we have to see
+			// if the item is already in the cache first to make sure we return always
+			// the same object for a given ID.
+			
+			uint id = Convert.ToUInt32 (reader[0]);
+
+			Import import = LookupInCache (id) as Import;
+			if (import == null) {
+				import = new Import (id, Convert.ToUInt32 (reader[1]));
+				AddToCache (import);
+			}
+
+			Remove (import);     // Delete this item
+		}
+		command.Dispose ();
+        }
+        
+        private void PurgeOldData()
+        {
+                // First we remove all import sessions that do not have any photos associated with it.
+                // I am doing it the slow way (select, and delete each one individually) since
+                // the cache also needs to be updated.
+
+                Import import;
+		SqliteCommand command = new SqliteCommand ();
+		command.Connection = Connection;
+
+	        command.CommandText = String.Format 
+		      ("SELECT id, time FROM imports WHERE id NOT in (SELECT DISTINCT import_id FROM imports_data)"); 
+
+                SqliteDataReader reader = command.ExecuteReader ();
+
+		while (reader.Read ()) {
+			// Note that we get both time and ID from the database, but we have to see
+			// if the item is already in the cache first to make sure we return always
+			// the same object for a given ID.
+			
+			uint id = Convert.ToUInt32 (reader[0]);
+
+			import = LookupInCache (id) as Import;
+			if (import == null) {
+				import = new Import (id, Convert.ToUInt32 (reader[1]));
+				AddToCache (import);
+			}
+			Remove (import);     // Delete this item
+		}
+		
+		// Then we remove all old history so we only keep MaxNumberImports
+		while (NumberOfRows() > MaxNumberImports)
+		{
+		      RemoveOldestImportSession();
+		}
+
+		command.Dispose ();
+        }
+
+	public void EndImport ()
+	{ 
+	       import_session = null;          // So next time we import, we create a new import session.
+	       PurgeOldData();
 	}
+	
+	public void DeleteCurrent ()
+	{ 
+		if (import_session != null)
+	        
+	                Remove (import_session);
+		EndImport();
+	}
+
+        public void AddPhotoToSession (uint imported_photo_id)
+        {
+        
+                // I wanted to store each imported_photo_id in an CollectionArray, 
+                // and do the database update in Commit. But if something goes wrong during the import
+                // the database would not be updated. So...
+        
+                // Add this photo id to the import session.
+                if (import_session == null) {
+                        import_session = Create ();
+                }
+		
+		SqliteCommand command = new SqliteCommand ();
+		command.Connection = Connection;
+	        command.CommandText = String.Format 
+		      ("INSERT INTO imports_data (import_id, photo_id) VALUES ({0}, {1})", 
+		      import_session.Id, imported_photo_id);
+		command.ExecuteNonQuery();
+		command.Dispose ();
+        }
 
 	// FIXME: Maybe this should be an abstract method in the base class?
 	public ArrayList GetAll ()
--- ../f-spot.ImportXMP/src/MainWindow.cs	2006-07-22 13:32:47.000000000 +1000
+++ src/MainWindow.cs	2006-07-22 14:16:43.000000000 +1000
@@ -85,6 +85,10 @@ public class MainWindow {
 	[Glade.Widget] MenuItem find_tag;
 	[Glade.Widget] CheckMenuItem find_untagged;
 	
+	[Glade.Widget] CheckMenuItem last_import_roll;
+	[Glade.Widget] MenuItem last_import_rolls;
+	[Glade.Widget] MenuItem clear_last_import_filter;	
+	
 	// Tags
 	[Glade.Widget] MenuItem edit_selected_tag;
 	[Glade.Widget] MenuItem delete_selected_tag;
@@ -127,6 +131,7 @@ public class MainWindow {
 	string last_import_path;
 	ModeType view_mode;
 	bool write_metadata = false;
+	bool last_import_roll_active = false; // to ensure the checkmenuitem can be controlled from other area.
 
 	// Drag and Drop
 	enum TargetType {
@@ -1052,7 +1057,7 @@ public class MainWindow {
 	public void ImportUriList (UriList list, bool copy) 
 	{
 		ImportCommand command = new ImportCommand (main_window);
-		if (command.ImportFromPaths (db.Photos, list.ToLocalPaths (), copy) > 0) {
+		if (command.ImportFromPaths (db.Photos, db.Imports, list.ToLocalPaths (), copy) > 0) {
 			UpdateQuery ();
 		}
 	}
@@ -1060,7 +1065,7 @@ public class MainWindow {
 	public void ImportFile (string path)
 	{
 		ImportCommand command = new ImportCommand (main_window);
-		if (command.ImportFromFile (db.Photos, path) > 0) {
+		if (command.ImportFromFile (db.Photos, db.Imports, path) > 0) {
 			UpdateQuery ();
 		}
 	}
@@ -1261,7 +1266,7 @@ public class MainWindow {
 	{
 		db.Sync = false;
 		ImportCommand command = new ImportCommand (main_window);
-		if (command.ImportFromFile (db.Photos, null) > 0) {
+		if (command.ImportFromFile (db.Photos, db.Imports, null) > 0) {
 			this.last_import_path = command.ImportPath;
 			UpdateQuery ();
 		}
@@ -2309,6 +2314,36 @@ public class MainWindow {
 		}
 		query.Range = null;
 	}
+
+	void HandleSetLastImportRoll (object sender, EventArgs args) {
+		if (last_import_roll.Active) {
+			query.ImportIdRange = new PhotoStore.ImportIdRange (db.Imports.GetLastRollId());
+			last_import_roll_active = true;		
+		} else {
+			if (last_import_roll_active) {
+				query.ImportIdRange = null;
+				last_import_roll_active = false;
+			}
+		}
+	}
+
+	void HandleSetLastImportRolls (object sender, EventArgs args) {
+		LastRolls.Set set_command = new LastRolls.Set (query, db.Imports, main_window);
+		if (set_command.Execute ()) {
+			last_import_roll_active = false;
+			last_import_roll.Active = false;	// Since user manually opened the gui, we clear the last roll filter.
+		} else {
+			if (!last_import_roll_active)
+				query.ImportIdRange = null;
+		}
+	}
+
+	void HandleClearLastImportFilter (object sender, EventArgs args) {
+		query.ImportIdRange = null;
+		last_import_roll.Active = false;
+
+	}
+
 	
 	void HandleFindUntagged (object sender, EventArgs args) {
 		if (query.Untagged == find_untagged.Active)
@@ -2522,7 +2557,15 @@ public class MainWindow {
 		exif_data.Sensitive = active_selection;
 		sharpen.Sensitive = active_selection;
 		remove_from_catalog.Sensitive = active_selection;
-
+		
+		last_import_roll.Sensitive = (db.Imports.NumberOfRows() > 0);
+		last_import_rolls.Sensitive = (db.Imports.NumberOfRows() > 1);
+		clear_last_import_filter.Sensitive = (last_import_rolls.Sensitive);
+		if ((last_import_roll.Active) && (query.ImportIdRange == null))	{	// Clean up tick, if roll filter is not active.
+			last_import_roll_active = false;
+			last_import_roll.Active = false;
+		}
+		
 		delete_selected_tag.Sensitive = tag_sensitive;
 		edit_selected_tag.Sensitive = tag_sensitive;
 
--- ../f-spot.ImportXMP/src/Makefile.am	2006-07-22 13:33:29.000000000 +1000
+++ src/Makefile.am	2006-07-22 14:16:43.000000000 +1000
@@ -57,6 +57,7 @@ F_SPOT_CSDISTFILES =				\
 	$(srcdir)/JpegHeader.cs			\
 	$(srcdir)/JpegUtils.cs			\
 	$(srcdir)/Cms.cs			\
+	$(srcdir)/LastRollDialog.cs		\
 	$(srcdir)/Loupe.cs			\
 	$(srcdir)/MainWindow.cs			\
 	$(srcdir)/MetaStore.cs			\
--- ../f-spot.ImportXMP/src/PhotoQuery.cs	2006-07-22 13:32:47.000000000 +1000
+++ src/PhotoQuery.cs	2006-07-22 14:16:43.000000000 +1000
@@ -8,12 +8,13 @@ namespace FSpot {
 		private PhotoStore store;
 		private Tag [] tags;
 		private PhotoStore.DateRange range = null;
+		private PhotoStore.ImportIdRange importidrange = null;
 		
 		// Constructor
 		public PhotoQuery (PhotoStore store)
 		{
 			this.store = store;
-			photos = store.Query (null, range);
+			photos = store.Query (null, range, importidrange);
 		}
 
 		public int Count {
@@ -61,7 +62,7 @@ namespace FSpot {
 			
 			set {
 				tags = value;
-				photos = store.Query (tags, range);
+				photos = store.Query (tags, range, importidrange);
 				untagged = false;
 				RequestReload ();
 			}
@@ -75,9 +76,25 @@ namespace FSpot {
 				range = value;
 				
 				if (untagged)
-					photos = store.QueryUntagged (range);
+					photos = store.QueryUntagged (range, importidrange);
 				else
-					photos = store.Query (tags, range);
+					photos = store.Query (tags, range, importidrange);
+
+				RequestReload ();
+			}
+		}
+		
+		public PhotoStore.ImportIdRange ImportIdRange {
+			get {
+				return importidrange;
+			}
+			set {
+				importidrange = value;
+				
+				if (untagged)
+					photos = store.QueryUntagged (range, importidrange);
+				else
+					photos = store.Query (tags, range, importidrange);
 
 				RequestReload ();
 			}
@@ -94,9 +111,9 @@ namespace FSpot {
 
 					if (untagged) {
 						tags = null;
-						photos = store.QueryUntagged (range);
+						photos = store.QueryUntagged (range, importidrange);
 					} else
-						photos = store.Query (tags, range);
+						photos = store.Query (tags, range, importidrange);
 					
 					RequestReload ();
 				}
--- ../f-spot.ImportXMP/src/PhotoStore.cs	2006-07-22 13:32:47.000000000 +1000
+++ src/PhotoStore.cs	2006-07-22 14:30:28.000000000 +1000
@@ -1042,6 +1042,15 @@ public class PhotoStore : DbStore {
 		command.ExecuteNonQuery ();
 
 		command.Dispose ();
+
+		command = new SqliteCommand ();
+		command.Connection = Connection;
+
+		command.CommandText = String.Format ("DELETE FROM imports_data WHERE {0}", tv_query_builder.ToString ());
+		command.ExecuteNonQuery ();
+
+		command.Dispose ();
+
 	}
 
 	public override void Remove (DbItem item)
@@ -1149,15 +1158,106 @@ public class PhotoStore : DbStore {
 			this.end = end;
 		}
 	}
+	
+	public class ImportIdRange 
+	// This class contains the active import sessions the user wants to filter on.
+	// For instance, if he is interested on import session, 1, 2, 5 and 8
+	// the first 4 values in importidhistory would be 1, 2, 5, 8
+	{
+		private uint [] importidhistory = new uint [ImportStore.MaxNumberImports];
+		
+
+		public bool FilterOnImports {
+			get {
+				return numberofimportfilters > 0;
+			}
+		}		
+		private uint numberofimportfilters;		// Index starts from 0, and this counter is always incremented after setting. 
+		public uint GetNumberOfImportFilters {
+			get {
+				return numberofimportfilters;
+			}
+		}		
+		public uint GetImportId (uint val)
+		{
+			return importidhistory[val];
+		}
+		public void SetImportId (uint id)
+		{
+			if (numberofimportfilters < ImportStore.MaxNumberImports) 
+			{
+				importidhistory[numberofimportfilters] = id;
+				numberofimportfilters++;
+			}
+		}
+		public ImportIdRange (uint [] ids)
+		{
+			numberofimportfilters = 0;
+			for (int k=0; k < ids.Length; k++) {
+				if (ids[k] > 0)
+					if (numberofimportfilters < ImportStore.MaxNumberImports) 
+					{
+						importidhistory[numberofimportfilters] = ids[k];
+						numberofimportfilters++;
+					}
+			} // for
+		}
+		public ImportIdRange (uint id)
+		{
+			numberofimportfilters = 0;
+			importidhistory[numberofimportfilters] = id;
+			numberofimportfilters++;
+		}
+
+	}
 
 	// Queries.
+	
+	private String AddLastImportFilter (ImportIdRange importidrange, bool added_where)
+	{
+/* 
+Building something like this
+	where photos.id in (select photo_id from imports_data where import_id in (3, 4, 5))
+*/	
+		string q = null;		// contains the resulting sub-query
+		bool add_comma = false;		// If ", " should be added before the parameter.
+		
+		if (importidrange == null)	// return directly, if importidrange is not set.
+			return q;
+
+		q = String.Format (" {0} photos.id IN ( ", added_where ? " AND " : " WHERE " );
+		q = q + 	  ("		SELECT photo_id from imports_data where " );
+		q = q + 	  ("			import_id IN ( " );
+
+		for (uint k = 0; k < importidrange.GetNumberOfImportFilters; k++) {
+				q = q + String.Format ("{0}{1}", add_comma ? ", " : "", importidrange.GetImportId(k));
+				add_comma = true;
+		} // for
+		q = q + (" 		) " );	// WHERE imports_id 		
+		q = q + (" ) " ); // AND id IN
+		//System.Console.WriteLine ("Last Import filter = >>{0}<<", q);
+		return q;
+	}
+
+	
+	
+	public Photo [] Query (Tag [] tags, DateTime start, DateTime end, uint [] importrange)
+	{
+		return Query (tags, new DateRange (start, end), new ImportIdRange (importrange));
+	}
+
+	public Photo [] Query (Tag [] tags, uint [] importrange)
+	{
+		return Query (tags, null, importrange == null ? null : new ImportIdRange (importrange));
+	}
+
 	public Photo [] Query (Tag [] tags, DateTime start, DateTime end)
 	{
-		return Query (tags, new DateRange (start, end));
+		return Query (tags, new DateRange (start, end), null);
 	}
 	
 	public Photo [] Query (Tag [] tags) {
-		return Query (tags, null);
+		return Query (tags, null, null);
 	}
 
 	public Photo [] Query (string query)
@@ -1166,6 +1266,7 @@ public class PhotoStore : DbStore {
 		command.Connection = Connection;
 		command.CommandText = query;
 		SqliteDataReader reader = command.ExecuteReader ();
+		//System.Console.WriteLine ("Query == >>{0}<<", query);		
 		
 		ArrayList version_list = new ArrayList ();
 		ArrayList id_list = new ArrayList ();
@@ -1223,29 +1324,37 @@ public class PhotoStore : DbStore {
 		return Query (query_string);
 	}
 
-	public Photo [] QueryUntagged (DateRange range)
+	public Photo [] QueryUntagged (DateRange range, ImportIdRange importidrange)
 	{
 		StringBuilder query_builder = new StringBuilder ();
 
 		query_builder.Append ("SELECT * FROM photos WHERE id NOT IN " +
 					"(SELECT DISTINCT photo_id FROM photo_tags) ");
 		
+		bool added_where = true;
 		if (range != null) {
 			query_builder.Append (String.Format ("AND photos.time >= {0} AND photos.time <= {1} ",
 							     DbUtils.UnixTimeFromDateTime (range.Start), 
 							     DbUtils.UnixTimeFromDateTime (range.End)));
+			added_where = true;
 		}
 
+		if (importidrange != null) {
+			query_builder.Append (AddLastImportFilter (importidrange, added_where));
+			added_where = true;
+ 		}
+
 		query_builder.Append("ORDER BY time");
 
 		return Query (query_builder.ToString ());
 	}
 
-	public Photo [] Query (Tag [] tags, DateRange range)
+	public Photo [] Query (Tag [] tags, DateRange range, ImportIdRange importidrange)
 	{
 		string query;
 
 		bool hide = true;
+		bool added_where = false;
 		if (tags != null) {
 			foreach (Tag t in tags) {
 				if (tag_store.Hidden == null || t.Id == tag_store.Hidden.Id) 
@@ -1282,11 +1391,18 @@ public class PhotoStore : DbStore {
 			query_builder.Append (String.Format ("WHERE photos.time >= {0} AND photos.time <= {1} ",
 							     DbUtils.UnixTimeFromDateTime (range.Start), 
 							     DbUtils.UnixTimeFromDateTime (range.End)));
+			added_where = true;
 		}
+
+		if (importidrange != null) {
+			query_builder.Append (AddLastImportFilter (importidrange, added_where));
+			added_where = true;
+		}		
 		
 		if (hide) {
 			query_builder.Append (String.Format ("{0} photos.id NOT IN (SELECT photo_id FROM photo_tags WHERE tag_id = {1})", 
-							     range != null ? " AND " : " WHERE ", tag_store.Hidden.Id));
+							     added_where ? " AND " : " WHERE ", tag_store.Hidden.Id));
+			added_where = true;
 		}
 		
 		if (tags != null && tags.Length > 0) {
@@ -1300,12 +1416,13 @@ public class PhotoStore : DbStore {
 				
 				if (first) {
 					query_builder.Append (String.Format ("{0} photos.id IN (SELECT photo_id FROM photo_tags WHERE tag_id IN (",
-									     hide || range != null ? " AND " : " WHERE "));
+									     added_where ? " AND " : " WHERE "));
+					added_where = true;
 				}
 				
 				query_builder.Append (String.Format ("{0}{1} ", first ? "" : ", ", t.Id));
 				
-					first = false;
+				first = false;
 			}
 			
 			if (!first)
--- ../f-spot.ImportXMP/src/QueryDisplay.cs	2006-07-22 13:32:48.000000000 +1000
+++ src/QueryDisplay.cs	2006-07-22 14:16:43.000000000 +1000
@@ -9,6 +9,8 @@ public class QueryDisplay : Gtk.VBox {
 	Gtk.EventBox tag_view_box;
 	Gtk.Label label;
 	Gtk.Label untagged;
+	Gtk.Label comma_label;
+	Gtk.Label rollfilter;
 	Gtk.HBox warning_box;
 	Gtk.Button clear_button;
 	TagSelectionWidget selector;
@@ -40,6 +42,15 @@ public class QueryDisplay : Gtk.VBox {
 		untagged.Visible = false;
 		hbox.PackStart (untagged, false, false, 0);
 
+		comma_label = new Gtk.Label (", ");
+		comma_label.Visible = false;
+		hbox.PackStart (comma_label, false, false, 0);
+
+		rollfilter = new Gtk.Label (Catalog.GetString ("Import roll"));
+		rollfilter.Visible = false;
+		hbox.PackStart (rollfilter, false, false, 0);
+
+
 		tag_view_box = new EventBox ();
 		tag_view = new TagView (tag_view_box);
 		tag_view.Show ();
@@ -67,6 +78,7 @@ public class QueryDisplay : Gtk.VBox {
 	public void HandleClearButtonClicked (object sender, System.EventArgs args)
 	{
 		query.Untagged = false;
+		query.ImportIdRange = null;
 		selector.TagSelection = new Tag [] { };
 	}
 
@@ -76,11 +88,13 @@ public class QueryDisplay : Gtk.VBox {
 		
 		Tag [] tags = query.Tags;
 		tag_view.Tags = tags;
-		if ((tags != null && tags.Length > 0) || query.Untagged)
+		if ((tags != null && tags.Length > 0) || query.Untagged || (query.ImportIdRange != null))
 			active_search = true;
 		
 		this.Visible = active_search;
 		untagged.Visible = query.Untagged;
+		comma_label.Visible = query.Untagged && (query.ImportIdRange != null);
+		rollfilter.Visible = (query.ImportIdRange != null);
 		warning_box.Visible = (query.Count < 1);
 	}
 }
--- ../f-spot.ImportXMP/src/Updater.cs	2006-07-22 13:32:48.000000000 +1000
+++ src/Updater.cs	2006-07-22 14:40:58.000000000 +1000
@@ -68,6 +68,18 @@ namespace FSpot.Database {
 			});
 			
 			// Update from version 3 to 4
+			// Creating a new table to keep the Import sessions.
+			AddUpdate (delegate (SqliteConnection connection) {
+
+				ExecuteScalar ("CREATE TABLE imports_data (" +
+				"	import_id   INTEGER," +
+				"       photo_id    INTEGER " +
+				")");
+
+				System.Console.WriteLine ("Extra imports_data table have been created!");
+			});
+
+			// Update from version 4 to 5
 			//AddUpdate (delegate (SqliteConnection connection) {
 			//	do update here
 			//});
--- ../f-spot.ImportXMP/src/f-spot.glade	2006-07-22 13:32:48.000000000 +1000
+++ src/f-spot.glade	2006-07-22 14:16:43.000000000 +1000
@@ -22,7 +22,7 @@
   <property name="urgency_hint">False</property>
   <property name="has_separator">False</property>
 
-  <child internal-child="vbox">
+  <child internal-child="vbox">C
     <widget class="GtkVBox" id="dialog-vbox1">
       <property name="visible">True</property>
       <property name="homogeneous">False</property>
@@ -7702,11 +7702,45 @@ Photo Details</property>
 		    </widget>
 		  </child>
 
-		  <child>
-		    <widget class="GtkSeparatorMenuItem" id="separator115">
-		      <property name="visible">True</property>
-		    </widget>
-		  </child>
+                  <child>
+                    <widget class="GtkSeparatorMenuItem" id="separator115">
+                      <property name="visible">True</property>
+                    </widget>
+                  </child>
+
+                  <child>
+                    <widget class="GtkCheckMenuItem" id="last_import_roll">
+                      <property name="visible">True</property>
+                      <property name="label" translatable="yes">Last import roll</property>
+                      <property name="use_underline">True</property>
+                      <property name="active">False</property>
+                      <signal name="activate" handler="HandleSetLastImportRoll" last_modification_time="Mon, 29 May 2006 15:18:53 GMT"/>
+                    </widget>
+                  </child>
+
+                  <child>
+                    <widget class="GtkMenuItem" id="last_import_rolls">
+                      <property name="visible">True</property>
+                      <property name="label" translatable="yes">Last import rolls...</property>
+                      <property name="use_underline">True</property>
+                      <signal name="activate" handler="HandleSetLastImportRolls" last_modification_time="Mon, 29 May 2006 15:18:53 GMT"/>
+                    </widget>
+                  </child>
+
+                  <child>
+                    <widget class="GtkMenuItem" id="clear_last_import_filter">
+                      <property name="visible">True</property>
+                      <property name="label" translatable="yes">Clear Last import filter</property>
+                      <property name="use_underline">True</property>
+                      <signal name="activate" handler="HandleClearLastImportFilter" last_modification_time="Mon, 29 May 2006 15:24:10 GMT"/>
+                    </widget>
+                  </child>
+
+                  <child>
+                    <widget class="GtkSeparatorMenuItem" id="separator116">
+                      <property name="visible">True</property>
+                    </widget>
+                  </child>
 
 		  <child>
 		    <widget class="GtkMenuItem" id="find_tag">
@@ -13138,4 +13172,646 @@ Custom
   </child>
 </widget>
 
+<widget class="GtkDialog" id="last_roll_dialog">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Last Import Rolls Filter</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox16">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+	<widget class="GtkHButtonBox" id="dialog-action_area16">
+	  <property name="visible">True</property>
+	  <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+	  <child>
+	    <widget class="GtkButton" id="cancelbutton7">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-cancel</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-6</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="okbutton8">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-ok</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-5</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">False</property>
+	  <property name="fill">True</property>
+	  <property name="pack_type">GTK_PACK_END</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkFrame" id="frame47">
+	  <property name="visible">True</property>
+	  <property name="label_xalign">0</property>
+	  <property name="label_yalign">0.5</property>
+	  <property name="shadow_type">GTK_SHADOW_NONE</property>
+
+	  <child>
+	    <widget class="GtkAlignment" id="alignment63">
+	      <property name="visible">True</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xscale">1</property>
+	      <property name="yscale">1</property>
+	      <property name="top_padding">0</property>
+	      <property name="bottom_padding">0</property>
+	      <property name="left_padding">12</property>
+	      <property name="right_padding">0</property>
+
+	      <child>
+		<widget class="GtkLabel" id="label212">
+		  <property name="width_request">616</property>
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Select one or more import rolls you would like to work with below. 
+Observe that you will only see photos from these rolls, until you clear the Last Import Rolls filter.</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">True</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.439999997616</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
+		</widget>
+	      </child>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkLabel" id="label210">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">&lt;b&gt;&lt;/b&gt;</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">True</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="type">label_item</property>
+	    </packing>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">True</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkFrame" id="frame48">
+	  <property name="visible">True</property>
+	  <property name="label_xalign">0</property>
+	  <property name="label_yalign">0.5</property>
+	  <property name="shadow_type">GTK_SHADOW_NONE</property>
+
+	  <child>
+	    <widget class="GtkAlignment" id="alignment64">
+	      <property name="visible">True</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xscale">1</property>
+	      <property name="yscale">1</property>
+	      <property name="top_padding">0</property>
+	      <property name="bottom_padding">0</property>
+	      <property name="left_padding">12</property>
+	      <property name="right_padding">0</property>
+
+	      <child>
+		<widget class="GtkTable" id="table27">
+		  <property name="width_request">600</property>
+		  <property name="visible">True</property>
+		  <property name="n_rows">10</property>
+		  <property name="n_columns">2</property>
+		  <property name="homogeneous">False</property>
+		  <property name="row_spacing">0</property>
+		  <property name="column_spacing">10</property>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_2">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">2</property>
+		      <property name="bottom_attach">3</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_3">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">3</property>
+		      <property name="bottom_attach">4</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_4">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">4</property>
+		      <property name="bottom_attach">5</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_5">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">5</property>
+		      <property name="bottom_attach">6</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_6">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">6</property>
+		      <property name="bottom_attach">7</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_7">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">7</property>
+		      <property name="bottom_attach">8</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_8">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">8</property>
+		      <property name="bottom_attach">9</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_9">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">9</property>
+		      <property name="bottom_attach">10</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_10">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">0</property>
+		      <property name="bottom_attach">1</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_11">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">1</property>
+		      <property name="bottom_attach">2</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_12">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">2</property>
+		      <property name="bottom_attach">3</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_13">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">3</property>
+		      <property name="bottom_attach">4</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_14">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">4</property>
+		      <property name="bottom_attach">5</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_15">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">5</property>
+		      <property name="bottom_attach">6</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_16">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">6</property>
+		      <property name="bottom_attach">7</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_18">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">8</property>
+		      <property name="bottom_attach">9</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_19">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">9</property>
+		      <property name="bottom_attach">10</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_1">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">1</property>
+		      <property name="bottom_attach">2</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_0">
+		      <property name="width_request">300</property>
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">0</property>
+		      <property name="right_attach">1</property>
+		      <property name="top_attach">0</property>
+		      <property name="bottom_attach">1</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="roll_17">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes"></property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">7</property>
+		      <property name="bottom_attach">8</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
+		</widget>
+	      </child>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkLabel" id="label211">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">&lt;b&gt;&lt;/b&gt;</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">True</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="type">label_item</property>
+	    </packing>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">True</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
--- /dev/null	2006-05-23 00:25:23.000000000 +1000
+++ src/LastRollDialog.cs	2006-07-22 14:16:43.000000000 +1000
@@ -0,0 +1,186 @@
+////
+// Author Bengt Thuree <bengt@thuree.com>
+////
+
+using Gtk;
+using Gnome;
+
+public class LastRolls {
+	public class Set : FSpot.GladeDialog {
+		FSpot.PhotoQuery query;
+		ImportStore imports;
+		Gtk.Window parent_window;
+		uint [] ActiveRolls;
+
+		[Glade.Widget] private Button ok_button;
+		[Glade.Widget] private CheckButton roll_0;
+		[Glade.Widget] private CheckButton roll_1;
+		[Glade.Widget] private CheckButton roll_2;
+		[Glade.Widget] private CheckButton roll_3;
+		[Glade.Widget] private CheckButton roll_4;
+		[Glade.Widget] private CheckButton roll_5;
+		[Glade.Widget] private CheckButton roll_6;
+		[Glade.Widget] private CheckButton roll_7;
+		[Glade.Widget] private CheckButton roll_8;
+		[Glade.Widget] private CheckButton roll_9;
+		[Glade.Widget] private CheckButton roll_10;
+		[Glade.Widget] private CheckButton roll_11;
+		[Glade.Widget] private CheckButton roll_12;
+		[Glade.Widget] private CheckButton roll_13;
+		[Glade.Widget] private CheckButton roll_14;
+		[Glade.Widget] private CheckButton roll_15;
+		[Glade.Widget] private CheckButton roll_16;
+		[Glade.Widget] private CheckButton roll_17;
+		[Glade.Widget] private CheckButton roll_18;
+		[Glade.Widget] private CheckButton roll_19;
+
+		public Set (FSpot.PhotoQuery query, ImportStore imports, Gtk.Window parent_window)
+		{
+			this.query = query;
+			this.imports = imports;
+			this.parent_window = parent_window;
+			this.ActiveRolls = imports.GetActiveRolls();	
+		}
+		
+		private void SetRollStatus (uint rollnr, bool active, bool sensitive, string header)
+		{
+			switch (rollnr) {
+				case 0 : roll_0.Active = active;  roll_0.Sensitive = sensitive;  roll_0.Label = header;break;
+				case 1 : roll_1.Active = active;  roll_1.Sensitive = sensitive;  roll_1.Label = header;break;
+				case 2 : roll_2.Active = active;  roll_2.Sensitive = sensitive;  roll_2.Label = header;break;
+				case 3 : roll_3.Active = active;  roll_3.Sensitive = sensitive;  roll_3.Label = header;break;
+				case 4 : roll_4.Active = active;  roll_4.Sensitive = sensitive;  roll_4.Label = header;break;
+				case 5 : roll_5.Active = active;  roll_5.Sensitive = sensitive;  roll_5.Label = header;break;
+				case 6 : roll_6.Active = active;  roll_6.Sensitive = sensitive;  roll_6.Label = header;break;
+				case 7 : roll_7.Active = active;  roll_7.Sensitive = sensitive;  roll_7.Label = header;break;
+				case 8 : roll_8.Active = active;  roll_8.Sensitive = sensitive;  roll_8.Label = header;break;
+				case 9 : roll_9.Active = active;  roll_9.Sensitive = sensitive;  roll_9.Label = header;break;
+				case 10: roll_10.Active = active; roll_10.Sensitive = sensitive; roll_10.Label = header;break;
+				case 11: roll_11.Active = active; roll_11.Sensitive = sensitive; roll_11.Label = header;break;
+				case 12: roll_12.Active = active; roll_12.Sensitive = sensitive; roll_12.Label = header;break;
+				case 13: roll_13.Active = active; roll_13.Sensitive = sensitive; roll_13.Label = header;break;
+				case 14: roll_14.Active = active; roll_14.Sensitive = sensitive; roll_14.Label = header;break;
+				case 15: roll_15.Active = active; roll_15.Sensitive = sensitive; roll_15.Label = header;break;
+				case 16: roll_16.Active = active; roll_16.Sensitive = sensitive; roll_16.Label = header;break;
+				case 17: roll_17.Active = active; roll_17.Sensitive = sensitive; roll_17.Label = header;break;
+				case 18: roll_18.Active = active; roll_18.Sensitive = sensitive; roll_18.Label = header;break;
+				case 19: roll_19.Active = active; roll_19.Sensitive = sensitive; roll_19.Label = header;break;
+				default : break;
+			}			
+		}
+		
+		private bool GetRollStatus (uint rollnr)
+		{
+			bool result = false;
+			switch (rollnr) {
+				case 0 : result = roll_0.Active; break;
+				case 1 : result = roll_1.Active; break;				
+				case 2:  result = roll_2.Active; break;
+				case 3:  result = roll_3.Active; break;				
+				case 4:  result = roll_4.Active; break;
+				case 5:  result = roll_5.Active; break;				
+				case 6:  result = roll_6.Active; break;
+				case 7:  result = roll_7.Active; break;				
+				case 8:  result = roll_8.Active; break;
+				case 9:  result = roll_9.Active; break;				
+				case 10: result = roll_10.Active; break;
+				case 11: result = roll_11.Active; break;				
+				case 12: result = roll_12.Active; break;
+				case 13: result = roll_13.Active; break;				
+				case 14: result = roll_14.Active; break;
+				case 15: result = roll_15.Active; break;				
+				case 16: result = roll_16.Active; break;
+				case 17: result = roll_17.Active; break;				
+				case 18: result = roll_18.Active; break;
+				case 19: result = roll_19.Active; break;
+				default : break;
+			}
+			return result;				
+		}
+		
+		private void SetTicksToDialog()
+		{
+//ActiveRolls	= Last 20 Import ID sessions (3, 4, 5, 6, 7, 8, 9..., 22)
+//ImportIdRange	= Which import ID sessions should be filtered (3, 4, 5)	
+					
+			bool sensitive = false;
+			bool active = false;
+			string header;
+
+			for (uint k = 0; k < ImportStore.MaxNumberImports; k++)
+			{
+				sensitive = false;
+				active = false;
+				header = "";
+				if (k < ActiveRolls.Length) {
+					sensitive = (ActiveRolls[k] > 0);
+					if (sensitive) {
+						uint numphotos = imports.GetNumberOfPhotosInRoll(ActiveRolls[k]);
+						System.DateTime dateforroll = imports.GetDateForRoll((uint) ActiveRolls[k]);
+// FIXME - Do not know why the {1,5:#,###} format code do not work!!!
+						header = System.String.Format (
+							Mono.Posix.Catalog.GetPluralString ("{0} - Imported {1,5:#,###} photo", 
+										"{0} - Imported {1,5:#,###} photos", (int)numphotos),
+							dateforroll.ToString("%dd %MMM (%HH:%mm)"),
+							numphotos);		
+					}
+					// System.Console.WriteLine ("Header string >>{0}<<", header);
+					if ((query != null) && (query.ImportIdRange != null)) {
+						uint i = 0;
+						while ( (!active) && (i < ImportStore.MaxNumberImports) ) {
+							if (query.ImportIdRange.GetImportId(i) == ActiveRolls[k])
+								active = true;
+							i++;
+						} // while
+					} // if
+				} // if
+				SetRollStatus (k, active, sensitive, header);
+			} // for					
+		}
+		
+		private uint [] GetTicksFromDialog()
+		{
+			uint [] result = new uint[ImportStore.MaxNumberImports];
+			uint resnr = 0;
+			for (uint k = 0; k < ImportStore.MaxNumberImports; k++)
+			{
+				if (k < ActiveRolls.Length) 
+					if (GetRollStatus(k)) {
+						result[resnr] = ActiveRolls[k];
+						resnr++;
+					} // if
+			} //. for
+			return result;
+		}
+
+		public bool Execute ()
+		{
+			this.CreateDialog ("last_roll_dialog");
+			
+			// Init the dialog
+			SetTicksToDialog();
+			
+			this.Dialog.DefaultResponse = ResponseType.Ok;
+			ResponseType response = (ResponseType) this.Dialog.Run ();
+
+			bool success = false;
+
+			if (response == ResponseType.Ok) {
+				uint [] resultticks = GetTicksFromDialog();
+				bool any_ticks = false;
+				int k = 0;
+				while ((!any_ticks) && (k < ImportStore.MaxNumberImports)) {
+					any_ticks = (resultticks[k] > 0);
+					k++;
+				}
+				if (any_ticks) {
+					query.ImportIdRange = new PhotoStore.ImportIdRange (resultticks);
+					success = true;
+				};
+			}
+
+			this.Dialog.Destroy ();
+			return success;
+		}
+	}
+}
