[f-spot/icon-view-cleanup: 8/24] More naming cleanusp: IPhotoVersion, IPhotoComparer, IPhotoVersionable.



commit 25b1927b0962e4920175fb418a19204ad1c39d7f
Author: Ruben Vermeersch <ruben savanne be>
Date:   Fri Aug 13 18:19:55 2010 +0200

    More naming cleanusp: IPhotoVersion, IPhotoComparer, IPhotoVersionable.

 src/Clients/MainApp/FSpot.Widgets/InfoBox.cs       |    8 +-
 src/Clients/MainApp/FSpot/App.cs                   |    2 +-
 src/Clients/MainApp/FSpot/InfoOverlay.cs           |    4 +-
 src/Clients/MainApp/FSpot/MainWindow.cs            |    8 +-
 src/Clients/MainApp/FSpot/Photo.cs                 |    8 +-
 src/Clients/MainApp/FSpot/PhotoVersion.cs          |    2 +-
 src/Clients/MainApp/PhotoVersionMenu.cs            |    8 +-
 src/Clients/MainApp/ThumbnailCommand.cs            |    2 +-
 src/Core/FSpot.Core/FSpot.Core.csproj              |    6 +-
 .../FSpot.Core/FSpot.Core/FileBrowsableItem.cs     |    6 +-
 .../FSpot.Core/IBrowsableItemComparer.cs           |   44 --------------
 .../FSpot.Core/FSpot.Core/IBrowsableItemVersion.cs |   62 --------------------
 .../FSpot.Core/IBrowsableItemVersionable.cs        |   30 ----------
 src/Core/FSpot.Core/FSpot.Core/IPhoto.cs           |    4 +-
 src/Core/FSpot.Core/FSpot.Core/IPhotoComparer.cs   |   45 ++++++++++++++
 src/Core/FSpot.Core/FSpot.Core/IPhotoVersion.cs    |   62 ++++++++++++++++++++
 .../FSpot.Core/FSpot.Core/IPhotoVersionable.cs     |   30 ++++++++++
 src/Core/FSpot.Core/Makefile.am                    |    6 +-
 .../FSpot.Exporters.Gallery/GalleryExport.cs       |    2 +-
 .../FSpot.Tools.RawPlusJpeg/RawPlusJpeg.cs         |    2 +-
 20 files changed, 171 insertions(+), 170 deletions(-)
---
diff --git a/src/Clients/MainApp/FSpot.Widgets/InfoBox.cs b/src/Clients/MainApp/FSpot.Widgets/InfoBox.cs
index 25b85a6..451d59f 100644
--- a/src/Clients/MainApp/FSpot.Widgets/InfoBox.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/InfoBox.cs
@@ -77,7 +77,7 @@ namespace FSpot.Widgets
 			}
 		}
 
-		public delegate void VersionChangedHandler (InfoBox info_box, IBrowsableItemVersion version);
+		public delegate void VersionChangedHandler (InfoBox info_box, IPhotoVersion version);
 		public event VersionChangedHandler VersionChanged;
 
 		private Expander info_expander;
@@ -252,7 +252,7 @@ namespace FSpot.Widgets
 			size_value_label = AttachLabel (info_table, 3, name_value_label);
 			exposure_value_label = AttachLabel (info_table, 4, name_value_label);
 
-			version_list = new ListStore (typeof (IBrowsableItemVersion), typeof (string), typeof (bool));
+			version_list = new ListStore (typeof (IPhotoVersion), typeof (string), typeof (bool));
 			version_combo = new ComboBox ();
 			CellRendererText version_name_cell = new CellRendererText ();
 			version_name_cell.Ellipsize = Pango.EllipsizeMode.End;
@@ -459,7 +459,7 @@ namespace FSpot.Widgets
 			version_combo.Changed -= OnVersionComboChanged;
 
 			int count = 0;
-			foreach (IBrowsableItemVersion version in photo.Versions) {
+			foreach (IPhotoVersion version in photo.Versions) {
 				version_list.AppendValues (version, version.Name, true);
 				if (version == photo.DefaultVersion)
 					version_combo.Active = count;
@@ -519,7 +519,7 @@ namespace FSpot.Widgets
 			TreeIter iter;
 
 			if (combo.GetActiveIter (out iter))
-				VersionChanged (this, (IBrowsableItemVersion)version_list.GetValue (iter, 0));
+				VersionChanged (this, (IPhotoVersion)version_list.GetValue (iter, 0));
 		}
 
 		private void UpdateMultiple ()
diff --git a/src/Clients/MainApp/FSpot/App.cs b/src/Clients/MainApp/FSpot/App.cs
index 17115cb..b5b86ce 100644
--- a/src/Clients/MainApp/FSpot/App.cs
+++ b/src/Clients/MainApp/FSpot/App.cs
@@ -269,7 +269,7 @@ namespace FSpot
 			window.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (0, 0, 0));
 
 			if (photos.Length > 0) {
-				Array.Sort (photos, new IBrowsableItemComparer.RandomSort ());
+				Array.Sort (photos, new IPhotoComparer.RandomSort ());
 				slideshow = new FSpot.Widgets.SlideShow (new BrowsablePointer (new PhotoList (photos), 0), (uint)(delay * 1000), true);
 				slideshow.Transition = new FSpot.Transitions.DissolveTransition ();
 				window.Add (slideshow);
diff --git a/src/Clients/MainApp/FSpot/InfoOverlay.cs b/src/Clients/MainApp/FSpot/InfoOverlay.cs
index e902085..d923c0f 100644
--- a/src/Clients/MainApp/FSpot/InfoOverlay.cs
+++ b/src/Clients/MainApp/FSpot/InfoOverlay.cs
@@ -31,9 +31,9 @@ namespace FSpot {
 			Photo = item.Current;
 		}
 
-		private void HandleVersionChanged (InfoBox box, IBrowsableItemVersion version)
+		private void HandleVersionChanged (InfoBox box, IPhotoVersion version)
 		{
-			IBrowsableItemVersionable versionable = item.Current as IBrowsableItemVersionable;
+			IPhotoVersionable versionable = item.Current as IPhotoVersionable;
 			PhotoQuery q = item.Collection as PhotoQuery;
 
 			if (versionable != null && q != null) {
diff --git a/src/Clients/MainApp/FSpot/MainWindow.cs b/src/Clients/MainApp/FSpot/MainWindow.cs
index 560f10c..bf3c66f 100644
--- a/src/Clients/MainApp/FSpot/MainWindow.cs
+++ b/src/Clients/MainApp/FSpot/MainWindow.cs
@@ -360,7 +360,7 @@ namespace FSpot
 
 			InfoBox = new InfoBox ();
 			ViewModeChanged += InfoBox.HandleMainWindowViewModeChanged;
-			InfoBox.VersionChanged += delegate (InfoBox box, IBrowsableItemVersion version) { UpdateForVersionChange (version);};
+			InfoBox.VersionChanged += delegate (InfoBox box, IPhotoVersion version) { UpdateForVersionChange (version);};
 			sidebar_vbox.PackEnd (InfoBox, false, false, 0);
 
 			InfoBox.Context = ViewContext.Library;
@@ -1783,7 +1783,7 @@ namespace FSpot
 		void HandleAdjustTime (object sender, EventArgs args)
 		{
 			PhotoList list = new PhotoList (Selection.Items);
-			list.Sort (new IBrowsableItemComparer.CompareDateName ());
+			list.Sort (new IPhotoComparer.CompareDateName ());
 			(new AdjustTimeDialog (Database, list)).Run ();
 		}
 
@@ -2485,9 +2485,9 @@ namespace FSpot
 
 		// Version Id updates.
 
-		void UpdateForVersionChange (IBrowsableItemVersion version)
+		void UpdateForVersionChange (IPhotoVersion version)
 		{
-			IBrowsableItemVersionable versionable = CurrentPhoto as IBrowsableItemVersionable;
+			IPhotoVersionable versionable = CurrentPhoto as IPhotoVersionable;
 
 			if (versionable != null) {
 				versionable.SetDefaultVersion (version);
diff --git a/src/Clients/MainApp/FSpot/Photo.cs b/src/Clients/MainApp/FSpot/Photo.cs
index 3b39279..c17fcd1 100644
--- a/src/Clients/MainApp/FSpot/Photo.cs
+++ b/src/Clients/MainApp/FSpot/Photo.cs
@@ -26,7 +26,7 @@ using FSpot.Imaging;
 
 namespace FSpot
 {
-	public class Photo : DbItem, IComparable, IPhoto, IBrowsableItemVersionable {
+	public class Photo : DbItem, IComparable, IPhoto, IPhotoVersionable {
 
 		PhotoChanges changes = new PhotoChanges ();
 		public PhotoChanges Changes {
@@ -114,7 +114,7 @@ namespace FSpot
 		private uint highest_version_id;
 
 		private Dictionary<uint, PhotoVersion> versions = new Dictionary<uint, PhotoVersion> ();
-		public IEnumerable<IBrowsableItemVersion> Versions {
+		public IEnumerable<IPhotoVersion> Versions {
 			get {
 				foreach (var version in versions.Values)
 					yield return version;
@@ -207,7 +207,7 @@ namespace FSpot
 			return null;
 		}
 
-		public IBrowsableItemVersion DefaultVersion {
+		public IPhotoVersion DefaultVersion {
 			get {
 				if (!versions.ContainsKey (DefaultVersionId))
 					throw new Exception ("Something is horribly wrong, this should never happen: no default version!");
@@ -215,7 +215,7 @@ namespace FSpot
 			}
 		}
 
-		public void SetDefaultVersion (IBrowsableItemVersion version)
+		public void SetDefaultVersion (IPhotoVersion version)
 		{
 			PhotoVersion photo_version = version as PhotoVersion;
 			if (photo_version == null)
diff --git a/src/Clients/MainApp/FSpot/PhotoVersion.cs b/src/Clients/MainApp/FSpot/PhotoVersion.cs
index 21d6d4a..d3a1fef 100644
--- a/src/Clients/MainApp/FSpot/PhotoVersion.cs
+++ b/src/Clients/MainApp/FSpot/PhotoVersion.cs
@@ -15,7 +15,7 @@ using FSpot.Core;
 
 namespace FSpot
 {
-    public class PhotoVersion : IBrowsableItemVersion
+    public class PhotoVersion : IPhotoVersion
     {
         public string Name { get; set; }
         public IPhoto Photo { get; private set; }
diff --git a/src/Clients/MainApp/PhotoVersionMenu.cs b/src/Clients/MainApp/PhotoVersionMenu.cs
index 44b10c7..136a23a 100644
--- a/src/Clients/MainApp/PhotoVersionMenu.cs
+++ b/src/Clients/MainApp/PhotoVersionMenu.cs
@@ -10,14 +10,14 @@ using FSpot.Core;
 
 public class PhotoVersionMenu : Menu {
 
-	public IBrowsableItemVersion Version {
+	public IPhotoVersion Version {
 		get; private set;
 	}
 
 	public delegate void VersionChangedHandler (PhotoVersionMenu menu);
 	public event VersionChangedHandler VersionChanged;
 
-	private Dictionary <MenuItem, IBrowsableItemVersion> version_mapping;
+	private Dictionary <MenuItem, IPhotoVersion> version_mapping;
 
 	private void HandleMenuItemActivated (object sender, EventArgs args)
 	{
@@ -33,9 +33,9 @@ public class PhotoVersionMenu : Menu {
 	{
 		Version = photo.DefaultVersion;
 
-		version_mapping = new Dictionary<MenuItem, IBrowsableItemVersion> ();
+		version_mapping = new Dictionary<MenuItem, IPhotoVersion> ();
 
-		foreach (IBrowsableItemVersion version in photo.Versions) {
+		foreach (IPhotoVersion version in photo.Versions) {
 			MenuItem menu_item = new MenuItem (version.Name);
 			menu_item.Show ();
 			menu_item.Sensitive = true;
diff --git a/src/Clients/MainApp/ThumbnailCommand.cs b/src/Clients/MainApp/ThumbnailCommand.cs
index f3cf4cc..f75f59c 100644
--- a/src/Clients/MainApp/ThumbnailCommand.cs
+++ b/src/Clients/MainApp/ThumbnailCommand.cs
@@ -30,7 +30,7 @@ public class ThumbnailCommand {
 			    && progress_dialog.Update (String.Format (Mono.Unix.Catalog.GetString ("Updating picture \"{0}\""), photo.Name)))
 				break;
 
-			foreach (IBrowsableItemVersion version in photo.Versions) {
+			foreach (IPhotoVersion version in photo.Versions) {
 				loader.Request (version.Uri, ThumbnailSize.Large, 10);
 			}
 
diff --git a/src/Core/FSpot.Core/FSpot.Core.csproj b/src/Core/FSpot.Core/FSpot.Core.csproj
index f7c385a..b2c33f0 100644
--- a/src/Core/FSpot.Core/FSpot.Core.csproj
+++ b/src/Core/FSpot.Core/FSpot.Core.csproj
@@ -32,9 +32,6 @@
     <Compile Include="FSpot.Core\Global.cs" />
     <Compile Include="FSpot.Core\FileBrowsableItem.cs" />
     <Compile Include="FSpot.Core\IBrowsableItemChanges.cs" />
-    <Compile Include="FSpot.Core\IBrowsableItemComparer.cs" />
-    <Compile Include="FSpot.Core\IBrowsableItemVersion.cs" />
-    <Compile Include="FSpot.Core\IBrowsableItemVersionable.cs" />
     <Compile Include="FSpot.Core\IBrowsableCollection.cs" />
     <Compile Include="FSpot.Core\ILoadable.cs" />
     <Compile Include="FSpot.Core\PhotoChanges.cs" />
@@ -43,6 +40,9 @@
     <Compile Include="FSpot.Core\Defines.cs" />
     <Compile Include="FSpot.Core\IPhoto.cs" />
     <Compile Include="FSpot.Core\IPhotoExtensions.cs" />
+    <Compile Include="FSpot.Core\IPhotoComparer.cs" />
+    <Compile Include="FSpot.Core\IPhotoVersion.cs" />
+    <Compile Include="FSpot.Core\IPhotoVersionable.cs" />
   </ItemGroup>
   <ProjectExtensions>
     <MonoDevelop>
diff --git a/src/Core/FSpot.Core/FSpot.Core/FileBrowsableItem.cs b/src/Core/FSpot.Core/FSpot.Core/FileBrowsableItem.cs
index d0acfb0..a162a99 100644
--- a/src/Core/FSpot.Core/FSpot.Core/FileBrowsableItem.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/FileBrowsableItem.cs
@@ -66,9 +66,9 @@ namespace FSpot.Core {
             }
         }
 
-        public IBrowsableItemVersion DefaultVersion { get; private set; }
+        public IPhotoVersion DefaultVersion { get; private set; }
 
-		public IEnumerable<IBrowsableItemVersion> Versions {
+		public IEnumerable<IPhotoVersion> Versions {
 			get { yield return DefaultVersion; }
 		}
 
@@ -92,7 +92,7 @@ namespace FSpot.Core {
             }
         }
 
-        private class FileBrowsableItemVersion : IBrowsableItemVersion {
+        private class FileBrowsableItemVersion : IPhotoVersion {
             public string Name { get { return String.Empty; } }
             public bool IsProtected { get { return true; } }
 
diff --git a/src/Core/FSpot.Core/FSpot.Core/IPhoto.cs b/src/Core/FSpot.Core/FSpot.Core/IPhoto.cs
index 47f4ee8..ae88678 100644
--- a/src/Core/FSpot.Core/FSpot.Core/IPhoto.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/IPhoto.cs
@@ -55,13 +55,13 @@ namespace FSpot.Core
         ///    The default version of this item. Every item must have at least one version and this must not be
         ///    <see langref="null"/>
         /// </summary>
-        IBrowsableItemVersion DefaultVersion { get; }
+        IPhotoVersion DefaultVersion { get; }
 
         /// <summary>
         ///    All versions of this item. Since every item must have at least the default version, this enumeration
         ///    must not be empty.
         /// </summary>
-        IEnumerable<IBrowsableItemVersion> Versions { get; }
+        IEnumerable<IPhotoVersion> Versions { get; }
         
         #endregion
         
diff --git a/src/Core/FSpot.Core/FSpot.Core/IPhotoComparer.cs b/src/Core/FSpot.Core/FSpot.Core/IPhotoComparer.cs
new file mode 100644
index 0000000..a550024
--- /dev/null
+++ b/src/Core/FSpot.Core/FSpot.Core/IPhotoComparer.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace FSpot.Core
+{
+    public static class IPhotoComparer
+    {
+        public class CompareDateName : IComparer<IPhoto>
+        {
+            public int Compare (IPhoto p1, IPhoto p2)
+            {
+                int result = p1.CompareDate (p2);
+                
+                if (result == 0)
+                    result = p1.CompareName (p2);
+                
+                return result;
+            }
+        }
+
+        public class RandomSort : IComparer
+        {
+            Random random = new Random ();
+
+            public int Compare (object obj1, object obj2)
+            {
+                return random.Next (-5, 5);
+            }
+        }
+
+        public class CompareDirectory : IComparer<IPhoto>
+        {
+            public int Compare (IPhoto p1, IPhoto p2)
+            {
+                int result = p1.CompareDefaultVersionUri (p2);
+                
+                if (result == 0)
+                    result = p1.CompareName (p2);
+                
+                return result;
+            }
+        }
+    }
+}
diff --git a/src/Core/FSpot.Core/FSpot.Core/IPhotoVersion.cs b/src/Core/FSpot.Core/FSpot.Core/IPhotoVersion.cs
new file mode 100644
index 0000000..6ce0c89
--- /dev/null
+++ b/src/Core/FSpot.Core/FSpot.Core/IPhotoVersion.cs
@@ -0,0 +1,62 @@
+/*
+ * IBrowsableItemVersion.cs
+ *
+ * Author(s):
+ *  Ruben Vermeersch <ruben savanne be>
+ *  Mike Gemuende <mike gemuende de>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using Hyena;
+
+
+namespace FSpot.Core
+{
+
+    public interface IPhotoVersion : ILoadable
+    {
+
+        #region Metadata
+
+        /// <summary>
+        ///   The name of the version. e.g. "Convert to Black and White"
+        /// </summary>
+        /// <remarks>
+        ///   This is not the name of the file.
+        /// </remarks>
+        string Name { get; }
+
+        // TODO: add Comment
+        bool IsProtected { get; }
+
+        // TODO: add more metadata
+
+        #endregion
+
+
+        #region File Information
+
+        // TODO: BaseUri and Filename are just in the database scheme. Does it make sense to provide them
+        //       to the outside?
+
+        /// <summary>
+        ///   The base uri of the directory of this version. That is the whole uri without the
+        ///   filename.
+        /// </summary>
+        SafeUri BaseUri { get; }
+
+        /// <summary>
+        ///    The filename of this version.
+        /// </summary>
+        string Filename { get; }
+
+        // TODO: add Comment
+        // TODO: not every item is also imported. So does it make sense to have that checksum here?
+        //       (If a comment is added, include the easons for having this here!)
+        string ImportMD5 { get; }
+        
+        #endregion
+        
+    }
+}
diff --git a/src/Core/FSpot.Core/FSpot.Core/IPhotoVersionable.cs b/src/Core/FSpot.Core/FSpot.Core/IPhotoVersionable.cs
new file mode 100644
index 0000000..a0dd1b3
--- /dev/null
+++ b/src/Core/FSpot.Core/FSpot.Core/IPhotoVersionable.cs
@@ -0,0 +1,30 @@
+/*
+ * IBrowsableItemVersion.cs
+ *
+ * Author(s):
+ *  Ruben Vermeersch <ruben savanne be>
+ *  Mike Gemuende <mike gemuende de>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System.Collections.Generic;
+
+namespace FSpot.Core
+{
+    /// <summary>
+    ///    The interface adds functionality which is related to items where
+    ///    versions can be added or removed.
+    /// </summary>
+    public interface IPhotoVersionable : IPhoto
+    {
+        /// <summary>
+        ///    Sets the default version of a the item.
+        /// </summary>
+        /// <param name="version">
+        ///    A <see cref="IBrowsableItemVersion"/> which will be the new
+        ///    default version.
+        /// </param>
+        void SetDefaultVersion (IPhotoVersion version);
+    }
+}
diff --git a/src/Core/FSpot.Core/Makefile.am b/src/Core/FSpot.Core/Makefile.am
index 5cd5cf0..6d58fc7 100644
--- a/src/Core/FSpot.Core/Makefile.am
+++ b/src/Core/FSpot.Core/Makefile.am
@@ -14,12 +14,12 @@ SOURCES =  \
 	FSpot.Core/Global.cs \
 	FSpot.Core/IBrowsableCollection.cs \
 	FSpot.Core/IBrowsableItemChanges.cs \
-	FSpot.Core/IBrowsableItemComparer.cs \
-	FSpot.Core/IBrowsableItemVersion.cs \
-	FSpot.Core/IBrowsableItemVersionable.cs \
 	FSpot.Core/ILoadable.cs \
 	FSpot.Core/IPhoto.cs \
+	FSpot.Core/IPhotoComparer.cs \
 	FSpot.Core/IPhotoExtensions.cs \
+	FSpot.Core/IPhotoVersion.cs \
+	FSpot.Core/IPhotoVersionable.cs \
 	FSpot.Core/PhotoChanges.cs \
 	FSpot.Core/PhotosChanges.cs \
 	FSpot.Core/Roll.cs \
diff --git a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryExport.cs b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryExport.cs
index dc9f035..06cd07a 100644
--- a/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryExport.cs
+++ b/src/Extensions/Exporters/FSpot.Exporters.Gallery/FSpot.Exporters.Gallery/GalleryExport.cs
@@ -619,7 +619,7 @@ namespace FSpot.Exporters.Gallery {
 			export_dialog = (Gtk.Dialog) xml.GetWidget ("gallery_export_dialog");
 
 			this.items = selection.Items;
-			Array.Sort<IPhoto> (this.items, new IBrowsableItemComparer.CompareDateName());
+			Array.Sort<IPhoto> (this.items, new IPhotoComparer.CompareDateName());
 			album_button.Sensitive = false;
 			IconView view = new IconView (selection);
 			view.DisplayDates = false;
diff --git a/src/Extensions/Tools/FSpot.Tools.RawPlusJpeg/FSpot.Tools.RawPlusJpeg/RawPlusJpeg.cs b/src/Extensions/Tools/FSpot.Tools.RawPlusJpeg/FSpot.Tools.RawPlusJpeg/RawPlusJpeg.cs
index fd4253c..a4860c6 100644
--- a/src/Extensions/Tools/FSpot.Tools.RawPlusJpeg/FSpot.Tools.RawPlusJpeg/RawPlusJpeg.cs
+++ b/src/Extensions/Tools/FSpot.Tools.RawPlusJpeg/FSpot.Tools.RawPlusJpeg/RawPlusJpeg.cs
@@ -39,7 +39,7 @@ namespace FSpot.Tools.RawPlusJpeg
 				return;
 
 			Photo [] photos = App.Instance.Database.Photos.Query ((Tag [])null, null, null, null);
-			Array.Sort (photos, new IBrowsableItemComparer.CompareDirectory ());
+			Array.Sort (photos, new IPhotoComparer.CompareDirectory ());
 
 			Photo raw = null;
 			Photo jpeg = null;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]