Index: src/ImportCommand.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/ImportCommand.cs,v
retrieving revision 1.44.2.2
diff -u -r1.44.2.2 ImportCommand.cs
--- src/ImportCommand.cs	1 Aug 2006 17:00:56 -0000	1.44.2.2
+++ src/ImportCommand.cs	28 Aug 2006 21:22:27 -0000
@@ -298,6 +298,7 @@
 	[Glade.Widget] Gtk.CheckButton attach_check;
 	[Glade.Widget] Gtk.CheckButton recurse_check;
 	[Glade.Widget] Gtk.CheckButton copy_check;
+	[Glade.Widget] Gtk.CheckButton duplicate_check;
 	[Glade.Widget] Gtk.Button ok_button;
 	[Glade.Widget] Gtk.Image tag_image;
 	[Glade.Widget] Gtk.Label tag_label;
@@ -309,9 +310,13 @@
 	Gtk.Window main_window;
 	FSpot.PhotoList collection;
 	bool copy;
+	bool include_duplicates;
 	SourceMenu menu;
 
 	int total;
+    
+	private int duplicates;
+
 	PhotoStore store;
 	FSpot.Delay step;
 	
@@ -321,7 +326,8 @@
 
 	FSpot.Delay idle_start; 
 
-	string loading_string;
+	string default_loading = Mono.Posix.Catalog.GetString ("Loading {0} of {1}");
+	string duplicate_loading = Mono.Posix.Catalog.GetString ("Importing {0} of {1}, {2} duplicate(s)");
 
 	string import_path;
 	public string ImportPath {
@@ -374,7 +380,6 @@
 		main_window = mw;
 		step = new FSpot.Delay (new GLib.IdleHandler (Step));
 		idle_start = new FSpot.Delay (new IdleHandler (Start));
-		loading_string = Catalog.GetString ("Loading {0} of {1}");
 	}
 
 	private void HandleDialogResponse (object obj, ResponseArgs args)
@@ -386,12 +391,16 @@
 		}
 	}
 
-	private void UpdateProgressBar (int count, int total)
+	private void UpdateProgressBar (int count, int total, int duplicates)
 	{
 		if (progress_bar == null)
 			return;
 
-		progress_bar.Text = String.Format (loading_string, count, total);
+		if (duplicates > 0)
+			progress_bar.Text = String.Format (duplicate_loading, count, total, duplicates);
+		else 
+			progress_bar.Text = String.Format (default_loading,   count, total);
+
 		progress_bar.Fraction = (double) count / System.Math.Max (total, 1);
 	}
 
@@ -423,16 +432,22 @@
 
 		if (photo == null || thumbnail == null) {
 			Console.WriteLine ("Could not import file");
-		} else {
-			//icon_scrolled.Visible = true;
-			collection.Add (photo);
-		
-			//grid.AddThumbnail (thumbnail);
+		} 
+	        else {
+			if (store.IsDuplicate (photo)) {
+				duplicates++;
+				if (include_duplicates)
+					collection.Add (photo);
+				else
+					store.Remove (photo);
+			}
+			else {
+				collection.Add (photo);
+			}
 
+			UpdateProgressBar (count, total, include_duplicates ? duplicates : 0);
 			thumbnail.Dispose ();
 		}
-		if (count < total)
-			UpdateProgressBar (count + 1, total);
 
 		if (ongoing && total > 0)
 			return true;
@@ -462,10 +477,11 @@
 		this.importer = imp;
 		AllowFinish = false;
 		
+		duplicates = 0;
 		total = importer.Prepare ();
 
 		if (total > 0)
-			UpdateProgressBar (1, total);
+			UpdateProgressBar (1, total, 0);
 		
 		collection.Clear ();
 		collection.Capacity = total;
@@ -554,6 +570,14 @@
 		idle_start.Start ();
 	}
 
+	private void HandleDuplicateToggled (object sender, System.EventArgs args)
+	{
+		this.Cancel ();
+		this.Dialog.Sensitive = false;
+	       
+		idle_start.Start ();
+	}
+
 	public int ImportFromFile (PhotoStore store, string path)
 	{
 		this.store = store;
@@ -572,6 +596,7 @@
 		//import_folder_entry.Activated += HandleEntryActivate;
 		recurse_check.Toggled += HandleRecurseToggled;
 		copy_check.Toggled += HandleRecurseToggled;
+		duplicate_check.Toggled += HandleDuplicateToggled;
 
 		menu = new SourceMenu (this);
 		source_option_menu.Menu = menu;
@@ -727,6 +752,9 @@
 		
 		if (copy_check != null)
 			copy = copy_check.Active;
+
+		if (duplicate_check != null)
+		 	include_duplicates = duplicate_check.Active;
 		
 		bool recurse = true;
 		if (recurse_check != null)
@@ -738,7 +766,7 @@
 		total = importer.Prepare ();
 		
 		if (total > 0)
-			UpdateProgressBar (1, total);
+			UpdateProgressBar (1, total, duplicates);
 		
 		collection.Clear ();
 		collection.Capacity = total;
@@ -778,7 +806,7 @@
 	{
 		Db db = new Db (db_path, true);
 
-		ImportCommand command = new ImportCommand ();
+		ImportCommand command = new ImportCommand (main_window);
 
 		command.ImportFromPath (db.Photos, directory_path, true);
 
Index: src/MainWindow.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/MainWindow.cs,v
retrieving revision 1.265.2.15
diff -u -r1.265.2.15 MainWindow.cs
--- src/MainWindow.cs	19 Aug 2006 19:51:47 -0000	1.265.2.15
+++ src/MainWindow.cs	28 Aug 2006 21:22:41 -0000
@@ -87,6 +87,7 @@
 	[Glade.Widget] MenuItem clear_date_range;
 
 	[Glade.Widget] CheckMenuItem find_untagged;
+	[Glade.Widget] CheckMenuItem find_duplicate;
 	
 	// Tags
 	[Glade.Widget] MenuItem edit_selected_tag;
@@ -1534,6 +1535,7 @@
 			"Grahm Orr",
 			"Ewen Cheslack-Postava",
 			"Gabriel Burt",
+			"Thomas Van Machelen",
 			"Patanjali Somayaji",
 			"Matt Jones",
 			"Martin Willemoes Hansen",
@@ -2076,6 +2078,10 @@
 		if (find_untagged.Active != query.Untagged)
 			find_untagged.Active = query.Untagged;
 
+		// Duplicates
+		if (find_duplicate.Active != query.Duplicate)
+		 	find_duplicate.Active = query.Duplicate;
+
 		clear_date_range.Sensitive = (query.Range != null);
 	}
 	
@@ -2427,6 +2433,22 @@
 			tag_selection_widget.SelectionChanged += OnTagSelectionChanged;
 
 			query.Untagged = true;
+		}
+	}
+
+	void HandleFindDuplicates (object sender, EventArgs args) {
+		if (query.Duplicate == find_duplicate.Active)
+			return;
+
+		if (query.Duplicate)
+			query.Duplicate = false;
+		else {
+			// Having tags selected wouldn't make sense
+			tag_selection_widget.SelectionChanged -= OnTagSelectionChanged;
+			tag_selection_widget.TagSelection = new Tag [] {};
+			tag_selection_widget.SelectionChanged += OnTagSelectionChanged;
+
+			query.Duplicate = true;
 		}
 	}
 	
Index: src/PhotoQuery.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/PhotoQuery.cs,v
retrieving revision 1.20.2.6
diff -u -r1.20.2.6 PhotoQuery.cs
--- src/PhotoQuery.cs	15 Aug 2006 01:02:56 -0000	1.20.2.6
+++ src/PhotoQuery.cs	28 Aug 2006 21:22:47 -0000
@@ -63,6 +63,7 @@
 			set {
 				tags = value;
 				photos = store.Query (tags, extra_condition, range);
+				duplicate = false;
 				RequestReload ();
 			}
 		}
@@ -95,6 +96,8 @@
 
 				if (untagged)
 					photos = store.QueryUntagged (range);
+				else if (duplicate)
+				 	photos = store.QueryDuplicate (range);
 				else
 					photos = store.Query (tags, extra_condition, range);
 
@@ -108,18 +111,41 @@
 				return untagged;
 			}
 			set {
-				if (untagged != value) {
-					untagged = value;
-
-					if (untagged) {
-						tags = null;
-						extra_condition = null;
-						photos = store.QueryUntagged (range);
-					} else
-						photos = store.Query (tags, extra_condition, range);
-					
-					RequestReload ();
-				}
+				if (untagged == value)
+					return;
+				
+				untagged = value;
+ 
+				if (untagged) {
+				 	duplicate = false;
+					tags = null;
+					photos = store.QueryUntagged (range);
+				} else
+					photos = store.Query (tags, null, range);
+				
+				RequestReload ();
+			}
+		}
+ 
+ 		private bool duplicate = false;
+ 		public bool Duplicate {
+ 			get {
+ 				return duplicate;
+ 			}
+ 			set {
+ 				if (duplicate == value)
+ 					return;
+ 
+ 				duplicate = value;
+ 
+ 				if (duplicate) {
+ 				 	untagged = false;
+ 					tags = null;
+ 					photos = store.QueryDuplicate (range);
+ 				} else
+ 					photos = store.Query (tags, null, range);
+ 
+ 				RequestReload ();
 			}
 		}
 
Index: src/PhotoStore.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/PhotoStore.cs,v
retrieving revision 1.81.2.6
diff -u -r1.81.2.6 PhotoStore.cs
--- src/PhotoStore.cs	15 Aug 2006 01:02:56 -0000	1.81.2.6
+++ src/PhotoStore.cs	28 Aug 2006 21:22:50 -0000
@@ -154,7 +154,7 @@
 	private string directory_path;
 	private string name;
 
-	private string Path {
+	public string Path {
 		get {
 			return directory_path + "/" + name;
 		}
@@ -202,6 +202,16 @@
 		}
 	}
 
+	private byte[] md5sum;
+	public byte[] MD5Sum {
+		get {
+			return md5sum;
+		}
+		set {
+			md5sum = value;
+		}
+	}
+
 	// Version management
 	public const int OriginalVersionId = 1;
 	private uint highest_version_id;
@@ -554,7 +564,26 @@
 		return version;
 	}
 
+	public static byte[] GetMD5Sum (string filename)
+	{
+		if (!File.Exists(filename))
+		 	return new byte[0];
+	 
+		FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
+		System.Security.Cryptography.MD5 md5ServiceProvider = new System.Security.Cryptography.MD5CryptoServiceProvider();
+
+		return md5ServiceProvider.ComputeHash(fs);
+	}
+
 	// Constructor
+	public Photo (uint id, long unix_time, string directory_path, string name, string description, uint default_version_id, byte[] md5sum) 
+		: this (id, unix_time, directory_path, name)
+	{
+		this.description = description;
+		this.default_version_id = default_version_id;
+		this.md5sum = md5sum;  
+	}
+     
 	public Photo (uint id, long unix_time, string directory_path, string name)
 		: base (id)
 	{
@@ -564,6 +593,7 @@
 		this.name = name;
 
 		description = "";
+		md5sum = new byte[0]; 
 
 		// Note that the original version is never stored in the photo_versions table in the
 		// database.
@@ -571,10 +601,7 @@
 	}
 
 	public Photo (uint id, long unix_time, string path)
-		: this (id, unix_time,
-
-			System.IO.Path.GetDirectoryName (path),
-			System.IO.Path.GetFileName (path))
+		: this (id, unix_time, System.IO.Path.GetDirectoryName (path), System.IO.Path.GetFileName (path))
 	{
 	}
 
@@ -582,6 +609,12 @@
 
 public class PhotoStore : DbStore {
 	TagStore tag_store;
+
+	private Hashtable md5_cache;
+	public Hashtable MD5Cache {
+		get { return md5_cache;}
+	}
+	
 	
 	public static ThumbnailFactory ThumbnailFactory = new ThumbnailFactory (ThumbnailSize.Large);
 
@@ -648,6 +681,7 @@
 		: base (connection, false)
 	{
 		this.tag_store = tag_store;
+		this.md5_cache = new Hashtable ();
 		EnsureThumbnailDirectory ();
 
 		if (! is_new)
@@ -663,7 +697,8 @@
 			"       directory_path     STRING NOT NULL,		   " +
 			"       name               STRING NOT NULL,		   " +
 			"       description        TEXT NOT NULL,	           " +
-			"       default_version_id INTEGER NOT NULL		   " +
+			"	default_version_id INTEGER NOT NULL,		   " +
+			"	md5sum             STRING NOT NULL		   " +
 			")";
 
 		command.ExecuteNonQuery ();
@@ -710,24 +745,30 @@
 		FSpot.ImageFile img = FSpot.ImageFile.Create (origPath);
 		long unix_time = DbUtils.UnixTimeFromDateTime (img.Date);
 		string description = img.Description != null  ? img.Description.Split ('\0') [0] : "";
+		string directory = System.IO.Path.GetDirectoryName (newPath);
+		string name = System.IO.Path.GetFileName (newPath);
+		byte[] md5sum = Photo.GetMD5Sum(newPath);
+        
 		SqliteCommand command = new SqliteCommand ();
 		command.Connection = Connection;
 
 		command.CommandText = String.Format ("INSERT INTO photos (time, " +
-						     "directory_path, name, description, default_version_id) " +
-						     "       VALUES ({0}, '{1}', '{2}', '{3}', {4})",
+						     "directory_path, name, description, default_version_id, md5sum) " +
+						     "       VALUES ({0}, '{1}', '{2}', '{3}', {4}, '{5}')",
 						     unix_time,
-						     SqlString (System.IO.Path.GetDirectoryName (newPath)),
-						     SqlString (System.IO.Path.GetFileName (newPath)),
+						     SqlString (directory),
+						     SqlString (name),
 						     SqlString (description),
-						     Photo.OriginalVersionId);
+						     Photo.OriginalVersionId,
+						     SqlString (Convert.ToBase64String (md5sum)));
 
 		command.ExecuteScalar ();
 		command.Dispose ();
 
 		uint id = (uint) Connection.LastInsertRowId;
-		Photo photo = new Photo (id, unix_time, newPath);
+		Photo photo = new Photo (id, unix_time, directory, name, description, Photo.OriginalVersionId, md5sum);
 		AddToCache (photo);
+		AddToMD5Cache (photo);
 		photo.Loaded = true;
 
 		thumbnail = GenerateThumbnail (UriList.PathToFileUri (newPath));		
@@ -797,20 +838,12 @@
 				
 				photo.AddVersionUnsafely (version_id, name);
 			}
-
-			/*
-			string directory_path = null;
-			if (reader [3] != null)
-				directory_path = reader [3].ToString ();
-			System.Console.WriteLine ("directory_path = {0}", directory_path);
-			*/
-
-
 		}
 	}
 
-	private void GetAllTags () {
-			SqliteCommand command = new SqliteCommand ();
+	private void GetAllTags () 
+	{
+		SqliteCommand command = new SqliteCommand ();
 		command.Connection = Connection;
 		command.CommandText = String.Format ("SELECT photo_id, tag_id " +
 						     "FROM photo_tags ");
@@ -914,7 +947,8 @@
 						     "       directory_path,                       " +
 						     "       name,                                 " +
 						     "       description,                          " +
-						     "       default_version_id                    " +
+						     "       default_version_id,                   " +
+						     "       md5sum                                " +
 						     "     FROM photos                             " +
 						     "     WHERE id = {0}                          ",
 						     id);
@@ -924,11 +958,13 @@
 			photo = new Photo (id,
 					   Convert.ToInt64 (reader [0]),
 					   reader [1].ToString (),
-					   reader [2].ToString ());
+					   reader [2].ToString (),
+					   reader[3].ToString (),
+					   Convert.ToUInt32 (reader[4]),
+					   Convert.FromBase64String (reader[5].ToString ()));
 
-			photo.Description = reader[3].ToString ();
-			photo.DefaultVersionId = Convert.ToUInt32 (reader[4]);
 			AddToCache (photo);
+			AddToMD5Cache (photo);
 		}
 
 		command.Dispose ();
@@ -957,7 +993,8 @@
 		command.CommandText = String.Format ("SELECT id,                                   " +
 				                     "       time,                                 " +
 						     "       description,                          " +
-						     "       default_version_id                    " +
+						     "       default_version_id,                   " +
+						     "       md5sum                                " +
 						     "  FROM photos                                " +
 						     " WHERE directory_path = \"{0}\"              " +
 						     "   AND name = \"{1}\"                        ",
@@ -970,11 +1007,13 @@
 			photo = new Photo (Convert.ToUInt32 (reader [0]),
 					   Convert.ToInt64 (reader [1]),
 					   directory_path,
-					   filename);
+					   filename,
+					   reader[2].ToString(),
+					   Convert.ToUInt32 (reader[3]),
+					   Convert.FromBase64String (reader[5].ToString ()));
 
-			photo.Description = reader[2].ToString ();
-			photo.DefaultVersionId = Convert.ToUInt32 (reader[3]);
 			AddToCache (photo);
+			AddToMD5Cache (photo);
 		}
 
 		command.Dispose ();
@@ -1016,6 +1055,7 @@
 
 			query_builder.Append (String.Format ("id = {0}", items[i].Id));
 			tv_query_builder.Append (String.Format ("photo_id = {0}", items[i].Id));
+			RemoveFromMD5Cache (items[i]);
 			RemoveFromCache (items[i]);
 		}
 
@@ -1049,6 +1089,8 @@
 		Remove (new Photo [] { (Photo)item });
 	}
 
+	
+
 	public override void Commit (DbItem item)
 	{
 		DbItemEventArgs args = new DbItemEventArgs (item);
@@ -1074,14 +1116,18 @@
 
 		SqliteCommand command = new SqliteCommand ();
 		command.Connection = Connection;
-		command.CommandText = String.Format ("UPDATE photos SET description = '{0}',     " +
-						     "                  default_version_id = {1}, " +
-						     "                  time = {2} " +
-						     "              WHERE id = {3}",
-						     SqlString (photo.Description),
-						     photo.DefaultVersionId,
-						     DbUtils.UnixTimeFromDateTime (photo.Time),
-						     photo.Id);
+		command.CommandText = String.Format (
+						"UPDATE photos " + 
+						" SET description = '{0}',     " +
+						"     default_version_id = {1}, " +
+						"     time = {2}, " +
+						"     md5sum = '{3}' " +
+						" WHERE id = {4}",
+						SqlString (photo.Description),
+						photo.DefaultVersionId,
+						DbUtils.UnixTimeFromDateTime (photo.Time),
+						SqlString (Convert.ToBase64String (photo.MD5Sum)),
+						photo.Id);
 		command.ExecuteNonQuery ();
 		command.Dispose ();
 
@@ -1094,6 +1140,7 @@
 		command.Dispose ();
 
 		foreach (Tag tag in photo.Tags) {
+            
 			command = new SqliteCommand ();
 			command.Connection = Connection;
 			command.CommandText = String.Format ("INSERT INTO photo_tags (photo_id, tag_id) " +
@@ -1126,6 +1173,49 @@
 			command.Dispose ();
 		}
 	}
+
+	public bool IsDuplicate (Photo photo)
+	{
+		string md5 = Convert.ToBase64String(photo.MD5Sum);
+	 
+	 	if (!md5_cache.ContainsKey(md5))
+			return false;	
+	 
+	 	if (photo.Id == (uint)md5_cache[md5])
+		 	return false;
+
+		return true;
+	}
+
+	protected void AddToMD5Cache (Photo photo)
+	{
+		if (photo.MD5Sum.Length == 0)
+		 	return;
+	 
+		if (md5_cache[Convert.ToBase64String(photo.MD5Sum)] == null)
+			md5_cache.Add(Convert.ToBase64String(photo.MD5Sum), photo.Id);
+	}
+
+	protected void RemoveFromMD5Cache (Photo photo)
+	{
+		if (photo.MD5Sum.Length == 0)
+		 	return;
+	 
+		object id = md5_cache[Convert.ToBase64String(photo.MD5Sum)];
+		
+		if (id == null)
+			return;
+	 
+		if ((uint)id != photo.Id)
+			return;
+
+		Photo[] photos = QueryMD5Sum (photo);		
+
+		if (photos.Length == 0)
+			md5_cache.Remove (Convert.ToBase64String(photo.MD5Sum));
+		else
+			md5_cache[Convert.ToBase64String(photo.MD5Sum)] = photos[0].Id;
+	}
 	
 	public class DateRange 
 	{
@@ -1177,10 +1267,10 @@
 				photo = new Photo (id,
 						   Convert.ToInt64 (reader [1]),
 						   reader [2].ToString (),
-						   reader [3].ToString ());
-				
-				photo.Description = reader[4].ToString ();
-				photo.DefaultVersionId = Convert.ToUInt32 (reader[5]);		 
+						   reader [3].ToString (),
+						   reader [4].ToString (),
+						   Convert.ToUInt32 (reader[5]),
+						   Convert.FromBase64String (reader [6].ToString ()));
 				
 				version_list.Add (photo);
 			}
@@ -1191,6 +1281,7 @@
 		bool need_load = false;
 		foreach (Photo photo in version_list) {
 			AddToCache (photo);
+			AddToMD5Cache (photo);
 			need_load |= !photo.Loaded;
 		}
 		
@@ -1216,7 +1307,8 @@
 						     "       photos.directory_path,              " +
 						     "       photos.name,                        " +
 						     "       photos.description,                 " +
-						     "       photos.default_version_id           " +
+						     "       photos.default_version_id,          " +
+						     "       photos.md5sum                       " +
 						     "     FROM photos                           " +
 						     "     WHERE directory_path = \"{0}\"", dir.FullName);
 
@@ -1241,6 +1333,30 @@
 		return Query (query_builder.ToString ());
 	}
 
+	public Photo[] QueryDuplicate (DateRange range)
+	{
+		Photo[] photos = Query (null, null, range);
+
+		ArrayList duplicates = new ArrayList ();
+ 
+		foreach (Photo photo in photos) {
+			if (IsDuplicate (photo))
+				duplicates.Add (photo);
+		}
+ 
+		return duplicates.ToArray (typeof (Photo)) as Photo[];
+	}
+ 
+	private Photo[] QueryMD5Sum (Photo original)
+	{
+		string query = String.Format("SELECT * FROM photos WHERE md5sum = '{0}' AND id <> {1}",
+ 					     Convert.ToBase64String(original.MD5Sum),
+ 					     original.Id);
+ 
+ 		return Query (query);
+ 	}
+ 
+
 	public Photo [] Query (Tag [] tags, string extra_condition, DateRange range)
 	{
 		string query;
@@ -1276,7 +1392,8 @@
 				      "       photos.directory_path,              " +
 				      "       photos.name,                        " +
 				      "       photos.description,                 " +
-				      "       photos.default_version_id           " +
+				      "       photos.default_version_id,          " +
+				      "       photos.md5sum                       " +
 				      "     FROM photos                      ");
 		
 		if (range != null) {
Index: src/QueryDisplay.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/QueryDisplay.cs,v
retrieving revision 1.7.2.1
diff -u -r1.7.2.1 QueryDisplay.cs
--- src/QueryDisplay.cs	1 Aug 2006 17:00:57 -0000	1.7.2.1
+++ src/QueryDisplay.cs	28 Aug 2006 21:23:01 -0000
@@ -9,6 +9,7 @@
 	Gtk.EventBox tag_view_box;
 	Gtk.Label label;
 	Gtk.Label untagged;
+	Gtk.Label duplicate;
 	Gtk.HBox warning_box;
 	Gtk.Button clear_button;
 	TagSelectionWidget selector;
@@ -40,6 +41,10 @@
 		untagged.Visible = false;
 		hbox.PackStart (untagged, false, false, 0);
 
+		duplicate = new Gtk.Label (Catalog.GetString ("Duplicate photos"));
+		duplicate.Visible = false;
+		hbox.PackStart (duplicate, false, false, 0);
+
 		tag_view_box = new EventBox ();
 		tag_view = new TagView (tag_view_box);
 		tag_view.Show ();
@@ -76,11 +81,12 @@
 		
 		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.Duplicate)
 			active_search = true;
 		
 		this.Visible = active_search;
 		untagged.Visible = query.Untagged;
+		duplicate.Visible = query.Duplicate;
 		warning_box.Visible = (query.Count < 1);
 	}
 }
Index: src/Updater.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/Updater.cs,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 Updater.cs
--- src/Updater.cs	14 Aug 2006 21:11:46 -0000	1.5.2.1
+++ src/Updater.cs	28 Aug 2006 21:23:27 -0000
@@ -66,7 +66,54 @@
 			AddUpdate (delegate (SqliteConnection connection) {
 				ExecuteNonQuery ("UPDATE tags SET is_category = 1 WHERE name != 'Hidden'");
 			});
-			
+
+			// Update from version 3 to 4: add md5sum column to photos table
+			AddUpdate (delegate (SqliteConnection connection) {
+				System.Console.WriteLine("Adding MD5 field to photos");
+
+				string temp_table = MoveTableToTemp ("photos");
+
+				ExecuteNonQuery ("CREATE TABLE photos ( " +
+						"  id                 INTEGER PRIMARY KEY NOT NULL, " +
+						"  time               INTEGER NOT NULL,	" +
+						"  directory_path     STRING NOT NULL,		" +
+						"  name               STRING NOT NULL,		" +
+						"  description        TEXT NOT NULL,	    " +
+						"  default_version_id INTEGER NOT NULL,	" +
+						"  md5sum             STRING NOT NULL		" +
+						")");
+
+				ExecuteScalar (String.Format (  "INSERT INTO photos (id, time, directory_path, " + 
+								"                    name, description, default_version_id, md5sum)" + 
+								"SELECT id, time, directory_path, " +
+								"       name, description, default_version_id, '' " +
+								"FROM   {0} ", 
+								temp_table));
+
+				SqliteCommand command = new SqliteCommand ();
+				command.Connection = db.Connection;
+				command.CommandText = "SELECT id, directory_path, name FROM photos";
+				SqliteDataReader reader = command.ExecuteReader ();
+    
+				while (reader.Read ()) {
+					uint photo_id = Convert.ToUInt32 (reader [0]);
+					string full_path = System.IO.Path.Combine(reader[1].ToString(), reader[2].ToString());
+
+					byte[] md5sum = Photo.GetMD5Sum(full_path);
+
+					if (md5sum == null)
+					 	continue;
+
+					ExecuteScalar (String.Format (  "UPDATE photos " + 
+									"SET md5sum = '{0}' " +
+									"WHERE id = {1}",
+									Convert.ToBase64String(md5sum),
+									photo_id));
+					}
+
+					command.Dispose ();
+			}, true);
+					
 			// Update from version 3 to 4
 			//AddUpdate (delegate (SqliteConnection connection) {
 			//	do update here
Index: src/f-spot.glade
===================================================================
RCS file: /cvs/gnome/f-spot/src/f-spot.glade,v
retrieving revision 1.142.2.10
diff -u -r1.142.2.10 f-spot.glade
--- src/f-spot.glade	28 Aug 2006 05:20:27 -0000	1.142.2.10
+++ src/f-spot.glade	28 Aug 2006 22:21:15 -0000
@@ -7272,7 +7272,7 @@
 		      <signal name="activate" handler="HandleSendMailCommand" last_modification_time="Mon, 07 Jun 2004 22:31:01 GMT"/>
 
 		      <child internal-child="image">
-			<widget class="GtkImage" id="image40">
+			<widget class="GtkImage" id="image43">
 			  <property name="visible">True</property>
 			  <property name="stock">gnome-stock-mail-fwd</property>
 			  <property name="icon_size">1</property>
@@ -7625,7 +7625,7 @@
 			      <property name="visible">True</property>
 			      <property name="label" translatable="yes">_Month</property>
 			      <property name="use_underline">True</property>
-			      <property name="active">True</property>
+			      <property name="active">False</property>
 			      <signal name="activate" handler="HandleArrangeByTime" last_modification_time="Fri, 20 Aug 2004 22:26:32 GMT"/>
 			    </widget>
 			  </child>
@@ -7635,7 +7635,7 @@
 			      <property name="visible">True</property>
 			      <property name="label" translatable="yes">_Folder</property>
 			      <property name="use_underline">True</property>
-			      <property name="active">False</property>
+			      <property name="active">True</property>
 			      <property name="group">month</property>
 			      <signal name="activate" handler="HandleArrangeByDirectory" last_modification_time="Fri, 20 Aug 2004 22:26:32 GMT"/>
 			    </widget>
@@ -7671,9 +7671,8 @@
 		  <child>
 		    <widget class="GtkImageMenuItem" id="find_by_tag">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">By _Tag</property>
+		      <property name="label" translatable="yes">By _Tag...</property>
 		      <property name="use_underline">True</property>
-		      <signal name="activate" handler="HandleFindByTag" last_modification_time="Tue, 10 Aug 2004 07:08:24 GMT"/>
 		      <child internal-child="image">
 			<widget class="GtkImage" id="image35">
 			  <property name="visible">True</property>
@@ -7730,6 +7729,16 @@
 		  </child>
 
 		  <child>
+		    <widget class="GtkCheckMenuItem" id="find_duplicate">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">_Find Duplicates</property>
+		      <property name="use_underline">True</property>
+		      <property name="active">False</property>
+		      <signal name="activate" handler="HandleFindDuplicates" last_modification_time="Tue, 10 Aug 2004 07:08:24 GMT"/>
+		    </widget>
+		  </child>
+
+		  <child>
 		    <widget class="GtkCheckMenuItem" id="find_untagged">
 		      <property name="visible">True</property>
 		      <property name="label" translatable="yes">_Untagged Photos</property>
@@ -9377,26 +9386,6 @@
 	  <property name="spacing">6</property>
 
 	  <child>
-	    <widget class="GtkCheckButton" id="recurse_check">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label" translatable="yes">Include subdirectories</property>
-	      <property name="use_underline">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="active">True</property>
-	      <property name="inconsistent">False</property>
-	      <property name="draw_indicator">True</property>
-	    </widget>
-	    <packing>
-	      <property name="padding">0</property>
-	      <property name="expand">False</property>
-	      <property name="fill">False</property>
-	      <property name="pack_type">GTK_PACK_END</property>
-	    </packing>
-	  </child>
-
-	  <child>
 	    <widget class="GtkVBox" id="vbox65">
 	      <property name="visible">True</property>
 	      <property name="homogeneous">False</property>
@@ -9663,6 +9652,44 @@
 	      <property name="relief">GTK_RELIEF_NORMAL</property>
 	      <property name="focus_on_click">True</property>
 	      <property name="active">True</property>
+	      <property name="inconsistent">False</property>
+	      <property name="draw_indicator">True</property>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">False</property>
+	      <property name="fill">False</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkCheckButton" id="recurse_check">
+	      <property name="visible">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label" translatable="yes">Include subdirectories</property>
+	      <property name="use_underline">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="active">True</property>
+	      <property name="inconsistent">False</property>
+	      <property name="draw_indicator">True</property>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">False</property>
+	      <property name="fill">False</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkCheckButton" id="duplicate_check">
+	      <property name="visible">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label" translatable="yes">Include duplicates.</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>
Index: po/it.po
===================================================================
RCS file: /cvs/gnome/f-spot/po/it.po,v
retrieving revision 1.3
diff -u -r1.3 it.po
--- po/it.po	19 Mar 2005 12:46:49 -0000	1.3
+++ po/it.po	28 Aug 2006 23:09:46 -0000
@@ -2,13 +2,14 @@
 # Copyright (C) 2005 Free Software Foundation, Inc.
 # This file is distributed under the same license as the f-spot package.
 # Marco Colombo <m.colombo@ed.ac.uk>, 2005.
+# Marco Aicardi <marco -at- aicardi -dot- eu>, 2006.
 #
 msgid ""
 msgstr ""
 "Project-Id-Version: F-Spot 0.0.11\n"
 "POT-Creation-Date: 2005-03-14 04:53-0600\n"
-"PO-Revision-Date: 2005-03-17 15:32+0000\n"
-"Last-Translator: Marco Colombo <m.colombo@ed.ac.uk>\n"
+"PO-Revision-Date: 2006-08-29 00:44+0100\n"
+"Last-Translator: Marco Aicardi <marco -at- aicardi -dot- eu>\n"
 "Language-Team: Italian <tp@lists.linux.it>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
@@ -18,11 +19,11 @@
 
 #: f-spot.desktop.in.in.h:1
 msgid "F-Spot Photo Album"
-msgstr "Album di foto di F-Spot"
+msgstr "Album Fotografico F-Spot"
 
 #: f-spot.desktop.in.in.h:2
 msgid "Photo Album"
-msgstr "Album di foto"
+msgstr "Album Fotografico"
 
 #: libeog/eog-file-selection.c:29 libeog/eog-file-selection.c:46
 msgid "By Extension"
@@ -78,7 +79,7 @@
 
 #: libeog/eog-file-selection.c:207
 msgid "Unsupported file format."
-msgstr "Formato di file non gestito."
+msgstr "Formato di file non supportato."
 
 #: libeog/eog-file-selection.c:225
 msgid "Determine File Type:"
@@ -102,11 +103,11 @@
 
 #: libeog/eog-image.c:803
 msgid "Unsupported image type for saving."
-msgstr "Tipo di immagine non gestito al salvataggio."
+msgstr "Tipo di immagine non supportato per il salvataggio."
 
 #: libeog/image-view.c:2082
 msgid "interpolation type"
-msgstr "tipo interpolazione"
+msgstr "tipo di interpolazione"
 
 #: libeog/image-view.c:2083
 msgid "the type of interpolation to use"
@@ -126,11 +127,11 @@
 
 #: libeog/image-view.c:2103
 msgid "dither"
-msgstr ""
+msgstr "retinatura"
 
 #: libeog/image-view.c:2104
 msgid "dither type"
-msgstr ""
+msgstr "tipo di retinatura"
 
 #: libfspot/f-jpeg-utils.c:422
 msgid "File not found"
@@ -163,7 +164,7 @@
 
 #: src/CameraFileSelectionDialog.cs:87
 msgid "Downloading Previews"
-msgstr "Saricamento anteprime"
+msgstr "Scaricamento anteprime"
 
 #: src/CameraFileSelectionDialog.cs:95
 msgid "Downloading Preview of {0}"
@@ -183,14 +184,14 @@
 
 #: src/CameraFileSelectionDialog.cs:164
 msgid "Unable to create directory."
-msgstr "Impossibile creare la directory."
+msgstr "Impossibile creare la cartella."
 
 #: src/CameraFileSelectionDialog.cs:165
 msgid ""
 "Error \"{0}\" while creating directory \"{0}\".  Check that the path and "
 "permissions are correct and try again"
 msgstr ""
-"Errore \"{0}\" durante la creazione della directory \"{0}\". Controllare che "
+"Errore \"{0}\" durante la creazione della cartella \"{0}\". Controllare che "
 "il percorso e i permessi siano corretti e riprovare."
 
 #: src/CameraFileSelectionDialog.cs:186 src/CDExport.cs:139
@@ -269,19 +270,19 @@
 
 #: src/Exif.cs:226
 msgid "Image Directory"
-msgstr "Director immagini"
+msgstr "Cartella immagini"
 
 #: src/Exif.cs:228
 msgid "Thumbnail Directory"
-msgstr "Directory miniature"
+msgstr "Cartella miniature"
 
 #: src/Exif.cs:230
 msgid "Exif Directory"
-msgstr "Directory Exif"
+msgstr "Cartella Exif"
 
 #: src/Exif.cs:232
 msgid "GPS Directory"
-msgstr "Directory GPS"
+msgstr "Cartella GPS"
 
 #: src/Exif.cs:234
 msgid "InterOperability Directory"
@@ -289,19 +290,19 @@
 
 #: src/Exif.cs:236
 msgid "Unknown Directory"
-msgstr "Directory sconosciuta"
+msgstr "Cartella sconosciuta"
 
 #: src/FlickrExport.cs:49
 msgid "Enter Password"
-msgstr "Inserire password"
+msgstr "Inserire Password"
 
 #: src/FlickrExport.cs:57
 msgid "Enter Password for "
-msgstr "Inserire password per "
+msgstr "Inserire Password per "
 
 #: src/FlickrExport.cs:88 src/GalleryExport.cs:417
 msgid "Uploading picture \"{0}\""
-msgstr "Caricamento immagine \"{0}\""
+msgstr "Invio immagine \"{0}\""
 
 #: src/FlickrExport.cs:100 src/GalleryExport.cs:438
 msgid "Upload Complete"
@@ -309,11 +310,11 @@
 
 #: src/FlickrExport.cs:105
 msgid "Error Uploading To Flickr"
-msgstr "Errore durante il caricamento su Flickr"
+msgstr "Errore durante il l'invio a Flickr"
 
 #: src/FlickrExport.cs:135 src/GalleryExport.cs:387
 msgid "Uploading Pictures"
-msgstr "Caricamento immagini"
+msgstr "Invio immagini"
 
 #: src/FlickrExport.cs:145
 msgid "Unable to log on."
@@ -341,16 +342,16 @@
 
 #: src/FolderExport.cs:245 src/OriginalExport.cs:225
 msgid "Transfering Pictures"
-msgstr "Trasferimento immagini"
+msgstr "Trasferimento immagini in corso"
 
 #: src/FolderExport.cs:629
 msgid "Prev"
-msgstr "Precedente"
+msgstr "Prec"
 
 # FIXME: femminile?
 #: src/FolderExport.cs:634 src/f-spot.glade.h:90
 msgid "Next"
-msgstr "Successivo"
+msgstr "Succ"
 
 #: src/FolderExport.cs:697
 msgid "Gallery generated by "
@@ -378,7 +379,7 @@
 
 #: src/f-spot.glade.h:6
 msgid "<b>Account</b>"
-msgstr ""
+msgstr "<b>Account</b>"
 
 #: src/f-spot.glade.h:7
 msgid "<b>Album</b>"
@@ -418,11 +419,11 @@
 
 #: src/f-spot.glade.h:16
 msgid "<b>Items to Burn</b>"
-msgstr ""
+msgstr "<b>Oggetti da masterizzare</b>"
 
 #: src/f-spot.glade.h:17
 msgid "<b>Photograph Layout</b>"
-msgstr ""
+msgstr "<b>Disposizione foto</b>"
 
 #: src/f-spot.glade.h:18
 msgid "<b>Photos</b>"
@@ -462,11 +463,11 @@
 
 #: src/f-spot.glade.h:28
 msgid "Ad_just Color..."
-msgstr "A_ggiusta colore..."
+msgstr "Regola_ colore..."
 
 #: src/f-spot.glade.h:29
 msgid "Adjust Color"
-msgstr "Aggiusta colore"
+msgstr "Regola colore"
 
 #: src/f-spot.glade.h:30
 msgid "Arranged _By"
@@ -536,7 +537,7 @@
 
 #: src/f-spot.glade.h:46
 msgid "Crop Photo to Fit"
-msgstr ""
+msgstr "Taglia ed adatta la foto"
 
 #: src/f-spot.glade.h:47
 msgid "Description:"
@@ -560,7 +561,7 @@
 
 #: src/f-spot.glade.h:52
 msgid "Display _Timeline"
-msgstr ""
+msgstr "Mostra la barra temporale"
 
 #: src/f-spot.glade.h:53
 msgid "E-Mail:"
@@ -643,7 +644,7 @@
 "Full Page\n"
 "Standard - 4x6"
 msgstr ""
-"Pagina piena\n"
+"Pagina intera\n"
 "Standard - 4x6"
 
 #: src/f-spot.glade.h:75
@@ -694,7 +695,7 @@
 
 #: src/f-spot.glade.h:89
 msgid "Include subdirectories."
-msgstr "Includi le sottodirectory."
+msgstr "Includi le sottocartelle."
 
 #: src/f-spot.glade.h:91
 msgid ""
@@ -761,7 +762,7 @@
 
 #: src/f-spot.glade.h:108
 msgid "Print Crop Marks"
-msgstr ""
+msgstr "Stampa punti di taglio"
 
 #: src/f-spot.glade.h:109
 msgid "Rem_ove Tag"
@@ -773,11 +774,11 @@
 
 #: src/f-spot.glade.h:111 src/StockIcons.cs:35
 msgid "Rotate _Left"
-msgstr "Ruota _sinistra"
+msgstr "Ruota a _sinistra"
 
 #: src/f-spot.glade.h:112 src/StockIcons.cs:36
 msgid "Rotate _Right"
-msgstr "Ruota _destra"
+msgstr "Ruota a _destra"
 
 #: src/f-spot.glade.h:113
 msgid "Saturation:"
@@ -785,7 +786,7 @@
 
 #: src/f-spot.glade.h:114
 msgid "Scale images to no larger than: "
-msgstr ""
+msgstr "Ridimensiona le immagini a non più di: "
 
 #: src/f-spot.glade.h:115
 msgid "Select Files To Copy From Camera..."
@@ -801,7 +802,7 @@
 
 #: src/f-spot.glade.h:118
 msgid "Select _None"
-msgstr ""
+msgstr "Seleziona _nessuno"
 
 #: src/f-spot.glade.h:119
 msgid "Select a tag..."
@@ -840,7 +841,7 @@
 
 #: src/f-spot.glade.h:129
 msgid "Strip Image Metadata"
-msgstr "Togli i metadati dell'immagine"
+msgstr "Togli i Metadati dall'immagine"
 
 #: src/f-spot.glade.h:130
 msgid "Strip metadata"
@@ -884,11 +885,11 @@
 
 #: src/f-spot.glade.h:140
 msgid "Will print Using: US Letter size on Generic Postscript"
-msgstr ""
+msgstr "Formato stampa: Lettera US su Postscript Generica"
 
 #: src/f-spot.glade.h:141
 msgid "Write only these Items to CD"
-msgstr ""
+msgstr "Masterizza su CD solo questi oggetti"
 
 #: src/f-spot.glade.h:142
 msgid "Zoom _In"
@@ -908,7 +909,7 @@
 
 #: src/f-spot.glade.h:146
 msgid "_Clear Date Range"
-msgstr "_Pulisci intervallo date"
+msgstr "_Annulla intervallo date"
 
 #: src/f-spot.glade.h:147
 msgid "_Close"
@@ -980,7 +981,7 @@
 
 #: src/f-spot.glade.h:164
 msgid "_Sharpen..."
-msgstr ""
+msgstr "Affilatura..."
 
 #: src/f-spot.glade.h:165
 msgid "_Size"
@@ -1026,7 +1027,7 @@
 # FIXME
 #: src/GalleryExport.cs:442
 msgid "Error Uploading To Gallery"
-msgstr "Errore durante il caricamento sulla galleria"
+msgstr "Errore durante l'invio alla galleria"
 
 #: src/GalleryExport.cs:474
 msgid "(No Gallery)"
@@ -1047,14 +1048,14 @@
 
 #: src/ImportCommand.cs:349
 msgid "Directory does not exist."
-msgstr "La directory non esiste."
+msgstr "La cartella non esiste."
 
 #: src/ImportCommand.cs:350
 msgid ""
 "The directory you selected \"{0}\" does not exist.  Please choose a "
 "different directory"
 msgstr ""
-"La directory selezionata \"{0}\" non esiste. Scegliere un'altra directory"
+"La cartella selezionata \"{0}\" non esiste. Scegliere un'altra cartella"
 
 #: src/InfoBox.cs:70 src/PhotoVersionCommands.cs:55
 msgid "Name:"
@@ -1089,6 +1090,8 @@
 "F-Spot was unable to find any cameras attached to this system.  Double check "
 "that the camera is connected and has power"
 msgstr ""
+"F-Spot non ha trovato alcuna macchina fotografica collegata al sistema"
+"Ricontrolla che la macchina fotografica sia collegata ed accesa"
 
 #: src/MainWindow.cs:865
 msgid "Error connecting to camera"
@@ -1096,14 +1099,14 @@
 
 #: src/MainWindow.cs:866
 msgid "Received error \"{0}\" while connecting to camera"
-msgstr "Ricevuto errore \"{0}\" durante la connessione alla fotocamera"
+msgstr "Ricevuto l'errore \"{0}\" durante la connessione alla fotocamera"
 
 #. Translators should localize the following string
 #. * which will give them credit in the About box.
 #. * E.g. "Martin Willemoes Hansen"
 #: src/MainWindow.cs:994
 msgid "translator-credits"
-msgstr "Marco Colombo <m.colombo@ed.ac.uk>"
+msgstr "Marco Colombo <m.colombo@ed.ac.uk> - Marco Aicardi <marco -at- aicardi -dot- eu>"
 
 #: src/MainWindow.cs:1125
 msgid "Unsharp Mask"
@@ -1179,7 +1182,7 @@
 
 #: src/PhotoPopup.cs:26
 msgid "Copy Image Location"
-msgstr ""
+msgstr "C"
 
 #: src/PhotoPopup.cs:38
 msgid "Remove From Catalog"
@@ -1269,7 +1272,7 @@
 
 #: src/StockIcons.cs:28
 msgid "Crop"
-msgstr ""
+msgstr "Ritaglia"
 
 #: src/StockIcons.cs:29
 msgid "Edit Image"
@@ -1317,7 +1320,7 @@
 
 #: src/TagCommands.cs:133 src/TagPopup.cs:22
 msgid "Create New Category"
-msgstr "Crea nuova categoria"
+msgstr "Crea una nuova categoria"
 
 #: src/TagCommands.cs:134
 msgid "Name of new category:"
