[f-spot/rubenv-gsoc-2009: 86/86] Make it build and somewhat work: tons of breakage.



commit 05c9bb9f4e5e261c938583b6edb22c810aa9061d
Author: Ruben Vermeersch <ruben savanne be>
Date:   Sun May 23 14:30:27 2010 +0200

    Make it build and somewhat work: tons of breakage.
    
    But it's a base we can work upon.

 Makefile.addins                                  |    3 +++
 extensions/Exporters/PicasaWebExport/Makefile.am |    1 +
 extensions/Exporters/ZipExport/ZipExport.cs      |    2 +-
 extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs      |    2 +-
 src/Core/App.cs                                  |   14 ++++++++++----
 src/Core/Photo.cs                                |    6 +++---
 src/Core/PhotoVersion.cs                         |    2 +-
 src/Editors/Editor.cs                            |   16 +++++++++-------
 src/Editors/Processing/Pipeline.cs               |    4 ++--
 src/Editors/RepeatableEditor.cs                  |   15 ++++++++-------
 src/Imaging/ImageFile.cs                         |    2 +-
 src/Jobs/CleanHiddenVersionsJob.cs               |    2 +-
 src/MainWindow.cs                                |    2 +-
 src/PhotoImageView.cs                            |   17 ++++++++++-------
 src/PhotoStore.cs                                |    6 +++---
 src/PrintOperation.cs                            |    2 +-
 src/Widgets/PreviewPopup.cs                      |    2 +-
 src/Widgets/SlideShow.cs                         |    6 +++---
 18 files changed, 60 insertions(+), 44 deletions(-)
---
diff --git a/Makefile.addins b/Makefile.addins
index 09700f2..2faf9fb 100644
--- a/Makefile.addins
+++ b/Makefile.addins
@@ -14,12 +14,15 @@ build_references =					\
 	-r:$(top_builddir)/src/f-spot.exe		\
 	-r:$(top_builddir)/src/Cms.dll			\
 	-r:$(top_builddir)/src/FSpot.Core.dll		\
+	-r:$(top_builddir)/src/FSpot.Loaders.dll		\
+	-r:$(top_builddir)/src/FSpot.Imaging.dll		\
 	-r:$(top_builddir)/src/FSpot.Platform.dll	\
 	-r:$(top_builddir)/src/FSpot.Query.dll		\
 	-r:$(top_builddir)/src/FSpot.Utils.dll		\
 	-r:$(top_builddir)/src/FSpot.Widgets.dll	\
 	$(LINK_SEMWEB)					\
 	$(LINK_GPHOTO2)					\
+	$(LINK_KEYRING)					\
 	$(LINK_GIOSHARP)				\
 	$(LINK_UNIQUESHARP)				\
 	$(LINK_GTKSHARPBEANS)			\
diff --git a/extensions/Exporters/PicasaWebExport/Makefile.am b/extensions/Exporters/PicasaWebExport/Makefile.am
index aad1668..ee2e5a7 100644
--- a/extensions/Exporters/PicasaWebExport/Makefile.am
+++ b/extensions/Exporters/PicasaWebExport/Makefile.am
@@ -17,6 +17,7 @@ REFS =						\
 	-r:$(top_builddir)/src/FSpot.Imaging.dll	\
 	$(LINK_SEMWEB)				\
 	-r:google-sharp/Mono.Google.dll		\
+	$(LINK_KEYRING)			\
 	$(LINK_GIOSHARP)			\
 	$(LINK_GPHOTO2)				\
 	$(LINK_UNIQUESHARP)			\
diff --git a/extensions/Exporters/ZipExport/ZipExport.cs b/extensions/Exporters/ZipExport/ZipExport.cs
index ce386ca..78d2416 100644
--- a/extensions/Exporters/ZipExport/ZipExport.cs
+++ b/extensions/Exporters/ZipExport/ZipExport.cs
@@ -114,7 +114,7 @@ namespace ZipExport {
 				if (scale_check.Active) {
 					FilterSet filters = new FilterSet ();
 					filters.Add (new JpegFilter ());
-					filters.Add (new ResizeFilter ((uint) scale_size.ValueAsInt));
+					filters.Add (new ResizeFilter (scale_size.ValueAsInt));
 					FilterRequest freq = new FilterRequest (photos [i].DefaultVersion.Uri);
 					filters.Convert (freq);
 					f = freq.Current.LocalPath;
diff --git a/extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs b/extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs
index 4461d7f..17c2512 100644
--- a/extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs
+++ b/extensions/Tools/RawPlusJpeg/RawPlusJpeg.cs
@@ -44,7 +44,7 @@ namespace RawPlusJpegExtension
 			for (int i = 0; i < photos.Length; i++) {
 				Photo p = photos [i];
 
-				ImageFile img = ImageFile.Create (p.DefaultVersionUri);
+				ImageFile img = ImageFile.Create (p.DefaultVersion.Uri);
 				if (!ImageFile.IsRaw (img) && !ImageFile.IsJpeg (img))
 					continue;
 
diff --git a/src/Core/App.cs b/src/Core/App.cs
index bfac4c3..0ec98fb 100644
--- a/src/Core/App.cs
+++ b/src/Core/App.cs
@@ -33,13 +33,19 @@ namespace FSpot
 				return app;
 			}
 		}
+        
+        public bool HasOrganizer {
+            get {
+                return organizer != null;
+            }
+        }
 
 		public MainWindow Organizer {
 			get {
-				if (organizer == null) {
-					organizer = new MainWindow (Database);
-					Register (organizer.Window);
-				}
+                if (organizer == null) {
+                    organizer = new MainWindow (Database);
+                    Register (organizer.Window);
+                }
 				return organizer;
 			}
 		}
diff --git a/src/Core/Photo.cs b/src/Core/Photo.cs
index 53e19d4..3ce348c 100644
--- a/src/Core/Photo.cs
+++ b/src/Core/Photo.cs
@@ -141,7 +141,7 @@ namespace FSpot
 				uint highest = 0;
 				foreach (uint key in HiddenVersions.Keys)
 					highest = Math.Max (highest, key);
-				foreach (uint key in Versions.Keys)
+				foreach (uint key in versions.Keys)
 					highest = Math.Max (highest, key);
 				return highest;
 			}
@@ -328,14 +328,14 @@ namespace FSpot
 				throw new Exception ("Cannot delete original version");
 	
 			changes.HideVersion (version_id);
-			Versions.Remove (version_id);
+			versions.Remove (version_id);
 			ResetDefaultVersion (version_id);
 
 			if (clean_hidden_versions_timeout == 0) {
 				clean_hidden_versions_timeout = GLib.Timeout.Add (5000, delegate () {
 					clean_hidden_versions_timeout = 0;
 
-					Core.Database.Jobs.Create (typeof (CleanHiddenVersionsJob), "");
+					App.Instance.Database.Jobs.Create (typeof (CleanHiddenVersionsJob), "");
 					return true;
 				});
 			}
diff --git a/src/Core/PhotoVersion.cs b/src/Core/PhotoVersion.cs
index 3f7014d..e61c21a 100644
--- a/src/Core/PhotoVersion.cs
+++ b/src/Core/PhotoVersion.cs
@@ -36,7 +36,7 @@ namespace FSpot
 
 		public uint RefCount {
 			get {
-				return Core.Database.Photos.VersionRefCount (this);
+				return App.Instance.Database.Photos.VersionRefCount (this);
 			}
 		}
 	
diff --git a/src/Editors/Editor.cs b/src/Editors/Editor.cs
index bac7c4f..4f7288d 100644
--- a/src/Editors/Editor.cs
+++ b/src/Editors/Editor.cs
@@ -69,7 +69,7 @@ namespace FSpot.Editors {
 					loader.Load (ImageLoaderItem.Full);
 					photo_pixbuf = loader.Full;
 				} else {
-					using (IImageLoader loader = ImageLoader.Create (photo.DefaultVersionUri)) {
+					using (IImageLoader loader = ImageLoader.Create (photo.DefaultVersion.Uri)) {
 						loader.Load (ImageLoaderItem.Full);
 						photo_pixbuf = loader.Full;
 					}
@@ -152,15 +152,15 @@ namespace FSpot.Editors {
 			bool create_version = photo.DefaultVersion.IsProtected;
 
 			// Or if there's another version based on it...
-			create_version |= photo.DefaultVersion.RefCount != 0;
+			create_version |= (photo.DefaultVersion as PhotoVersion).RefCount != 0;
 
 			// Or if it's based on a processable version.
-			create_version |= photo.DefaultVersion.Type == PhotoVersionType.Processable;
+			create_version |= (photo.DefaultVersion as PhotoVersion).Type == PhotoVersionType.Processable;
 
 			photo.SaveVersion (pixbuf, create_version);
 			photo.Changes.DataChanged = true;
-			Core.Database.Photos.Commit (photo);
-			ThumbnailFactory.DeleteThumbnail (photo.DefaultVersionUri);
+			App.Instance.Database.Photos.Commit (photo);
+			ThumbnailFactory.DeleteThumbnail (photo.DefaultVersion.Uri);
 		}
 
 		protected abstract Pixbuf Process (Pixbuf input, Cms.Profile input_profile);
@@ -230,7 +230,8 @@ namespace FSpot.Editors {
 					if (!StateInitialized)
 						return;
 
-					State.PhotoImageView.ChangeImage (previewed, State.PhotoImageView.PixbufOrientation, false, false);
+					// FIXME State.PhotoImageView.ChangeImage (previewed, State.PhotoImageView.PixbufOrientation, false, false);
+                    State.PhotoImageView.Pixbuf = previewed;
                     App.Instance.Organizer.InfoBox.UpdateHistogram (previewed);
 
 					if (old_preview != null) {
@@ -274,7 +275,8 @@ namespace FSpot.Editors {
 
 		public void Restore () {
 			if (Original != null && State.PhotoImageView != null) {
-				State.PhotoImageView.ChangeImage (Original, state.PhotoImageView.PixbufOrientation, false, false);
+				// FIXME State.PhotoImageView.ChangeImage (Original, state.PhotoImageView.PixbufOrientation, false, false);
+                State.PhotoImageView.Pixbuf = Original;
 
 				App.Instance.Organizer.InfoBox.UpdateHistogram (null);
 			}
diff --git a/src/Editors/Processing/Pipeline.cs b/src/Editors/Processing/Pipeline.cs
index a18afc8..62652ba 100644
--- a/src/Editors/Processing/Pipeline.cs
+++ b/src/Editors/Processing/Pipeline.cs
@@ -37,7 +37,7 @@ namespace FSpot.Editors.Processing {
 			Photo = photo;
 			Settings = new Dictionary<string, Setting> ();
 
-			SettingStore store = Core.Database.ProcessingSettings;
+			SettingStore store = App.Instance.Database.ProcessingSettings;
 			foreach (Setting setting in store.GetAll (Photo.Id, Photo.DefaultVersionId)) {
 				Settings.Add (setting.Key, setting);
 			}
@@ -129,7 +129,7 @@ namespace FSpot.Editors.Processing {
 		{
 			foreach (Setting setting in Settings.Values) {
 				setting.VersionId = version;
-				Core.Database.ProcessingSettings.Commit (setting);
+				App.Instance.Database.ProcessingSettings.Commit (setting);
 			}
 		}
 #endregion
diff --git a/src/Editors/RepeatableEditor.cs b/src/Editors/RepeatableEditor.cs
index fcdb469..1c6b0d0 100644
--- a/src/Editors/RepeatableEditor.cs
+++ b/src/Editors/RepeatableEditor.cs
@@ -43,7 +43,7 @@ namespace FSpot.Editors {
 		sealed protected override void LoadPhoto (Photo photo, out Pixbuf photo_pixbuf, out Cms.Profile photo_profile)
 		{
 			// Figure out the original version to process
-			PhotoVersion version = photo.DefaultVersion;
+			PhotoVersion version = photo.DefaultVersion as PhotoVersion;
 			uint parent_version = version.Type == PhotoVersionType.Processable ? version.ParentVersionId : version.VersionId;
 			Uri uri = photo.VersionUri (parent_version);
 
@@ -73,20 +73,21 @@ namespace FSpot.Editors {
 			bool create_version = photo.DefaultVersion.IsProtected;
 
 			// Or if it's not a Processable version.
-			create_version |= photo.DefaultVersion.Type != PhotoVersionType.Processable;
+			create_version |= (photo.DefaultVersion as PhotoVersion).Type != PhotoVersionType.Processable;
 
 			uint parent_version_id = photo.DefaultVersionId;
 			uint saved_version = photo.SaveVersion (pixbuf, create_version);
 			if (create_version) {
-				photo.DefaultVersion.Type = PhotoVersionType.Processable;
-				photo.DefaultVersion.ParentVersionId = parent_version_id;
+                PhotoVersion version = photo.DefaultVersion as PhotoVersion;
+				version.Type = PhotoVersionType.Processable;
+				version.ParentVersionId = parent_version_id;
 				photo.Changes.ChangeVersion (photo.DefaultVersionId);
 			}
 			Pipeline.Save (saved_version);
 
 			photo.Changes.DataChanged = true;
-			Core.Database.Photos.Commit (photo);
-			ThumbnailFactory.DeleteThumbnail (photo.DefaultVersionUri);
+			App.Instance.Database.Photos.Commit (photo);
+			ThumbnailFactory.DeleteThumbnail (photo.DefaultVersion.Uri);
 		}
 
 		public override EditorState CreateState ()
@@ -101,7 +102,7 @@ namespace FSpot.Editors {
 
 			// Figure out the original version to process
 			Photo photo = State.Items [0] as Photo;
-			PhotoVersion version = photo.DefaultVersion;
+			PhotoVersion version = photo.DefaultVersion as PhotoVersion;
 			uint parent_version = version.Type == PhotoVersionType.Processable ? version.ParentVersionId : version.VersionId;
 			Uri uri = photo.VersionUri (parent_version);
 
diff --git a/src/Imaging/ImageFile.cs b/src/Imaging/ImageFile.cs
index 3ca7a34..109ea7b 100644
--- a/src/Imaging/ImageFile.cs
+++ b/src/Imaging/ImageFile.cs
@@ -68,7 +68,7 @@ namespace FSpot {
 			name_table [".raw"] = typeof (FSpot.Tiff.NefFile);
 			name_table [".kdc"] = typeof (FSpot.Tiff.NefFile);
 			name_table [".arw"] = typeof (FSpot.Tiff.NefFile);
-			name_table [".rw2"] = typeof (FSpot.DCRawFile);
+			name_table [".rw2"] = typeof (FSpot.Tiff.NefFile);
 			name_table [".tiff"] = typeof (FSpot.Tiff.TiffFile);
 			name_table [".tif"] = typeof (FSpot.Tiff.TiffFile);
 			name_table [".orf"] =  typeof (FSpot.Tiff.NefFile);
diff --git a/src/Jobs/CleanHiddenVersionsJob.cs b/src/Jobs/CleanHiddenVersionsJob.cs
index f594765..25aefe1 100644
--- a/src/Jobs/CleanHiddenVersionsJob.cs
+++ b/src/Jobs/CleanHiddenVersionsJob.cs
@@ -24,7 +24,7 @@ namespace FSpot.Jobs {
 
 		protected override bool Execute ()
 		{
-			Core.Database.Photos.CleanHiddenVersions ();
+			App.Instance.Database.Photos.CleanHiddenVersions ();
 			return true;
 		}
 	}
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index 8b0dfa7..9ef7bf8 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -2213,8 +2213,8 @@ namespace FSpot
 							DeleteException (e, photo.VersionUri (id).ToString ());
 						}
 					}
+					photo.DeleteHiddenVersions ();
 				}
-				photo.DeleteHiddenVersions ();
 				Database.Photos.Remove (photos);
 				
 				UpdateQuery ();
diff --git a/src/PhotoImageView.cs b/src/PhotoImageView.cs
index af8dcfe..b0c8904 100644
--- a/src/PhotoImageView.cs
+++ b/src/PhotoImageView.cs
@@ -184,14 +184,14 @@ namespace FSpot.Widgets {
 
 			// I do not like the trip through MainWindow here, can this be
 			// done better?
-			if (MainWindow.Toplevel == null) {
+			if (!App.Instance.HasOrganizer) {
 				progress_bar_present = false;
 				return false;
 			}
 
 			progress_bar = new ProgressBar ();
 			progress_bar.Visible = false;
-			progress_bar_container = MainWindow.Toplevel.StatusContainer;
+			progress_bar_container = App.Instance.Organizer.StatusContainer;
 			progress_bar_container.Add (progress_bar);
 			progress_bar_present = true;
 
@@ -264,13 +264,12 @@ namespace FSpot.Widgets {
 
 			Gdk.Pixbuf prev = Pixbuf;
 			PixbufOrientation orientation = Accelerometer.GetViewOrientation (Loader.PixbufOrientation (current_item));
-			ChangeImage (Loader.Pixbuf (current_item), orientation, prepared_is_new, current_item != ImageLoaderItem.Full);
+            Pixbuf = Loader.Pixbuf (current_item);
+            this.ZoomFit (current_item != ImageLoaderItem.Full);
 			prepared_is_new = false;
 
 			if (prev != null)
 				prev.Dispose ();
-
-			this.ZoomFit (args.ReducedResolution);
 		}
 
 		void HandlePixbufAreaUpdated (object sender, AreaUpdatedEventArgs args)
@@ -298,7 +297,9 @@ namespace FSpot.Widgets {
 			Pixbuf prev = this.Pixbuf;
 			if (current_item != args.Items.Largest ()) {
 				current_item = args.Items.Largest ();
-				ChangeImage (Loader.Pixbuf (current_item), Accelerometer.GetViewOrientation (Loader.PixbufOrientation (current_item)), false, false);
+                Pixbuf = Loader.Pixbuf (current_item);
+                PixbufOrientation = Accelerometer.GetViewOrientation (Loader.PixbufOrientation (current_item));
+                ZoomFit (false);
 			}
 
 			if (Pixbuf == null)
@@ -334,7 +335,9 @@ namespace FSpot.Widgets {
 			Pixbuf err = new Pixbuf (FSpotPixbufUtils.ErrorPixbuf, 0, 0,
 									 FSpotPixbufUtils.ErrorPixbuf.Width,
 									 FSpotPixbufUtils.ErrorPixbuf.Height);
-			ChangeImage (err, PixbufOrientation.TopLeft, true, false);
+            Pixbuf = err;
+            PixbufOrientation = PixbufOrientation.TopLeft;
+            ZoomFit (false);
 			if (old != null)
 				old.Dispose ();
 
diff --git a/src/PhotoStore.cs b/src/PhotoStore.cs
index 07b6aa1..7ad6bb8 100644
--- a/src/PhotoStore.cs
+++ b/src/PhotoStore.cs
@@ -212,7 +212,7 @@ public class PhotoStore : DbStore<Photo> {
 	}		
 	
 	private void GetAllVersions  (string ids) {
-		SqliteDataReader reader = Database.Query("SELECT photo_id, version_id, name, base_uri, filename, md5_sum, protected, type, parent_version_id FROM photo_versions WHERE photo_id IN " + ids");
+		SqliteDataReader reader = Database.Query("SELECT photo_id, version_id, name, base_uri, filename, md5_sum, protected, type, parent_version_id FROM photo_versions WHERE photo_id IN " + ids);
 		
 		while (reader.Read ()) {
 			uint id = Convert.ToUInt32 (reader ["photo_id"]);
@@ -281,7 +281,7 @@ public class PhotoStore : DbStore<Photo> {
 
 	public uint VersionRefCount (PhotoVersion version)
 	{
-		string query = String.Format ("SELECT COUNT(*) AS ref_count FROM photo_versions WHERE photo_id = {0} AND parent_version_id = {1}", version.Photo.Id, version.VersionId);
+		string query = String.Format ("SELECT COUNT(*) AS ref_count FROM photo_versions WHERE photo_id = {0} AND parent_version_id = {1}", (version.Photo as Photo).Id, version.VersionId);
 		uint ref_count = Convert.ToUInt32 (Database.QuerySingle (query));
 		return ref_count;
 	}
@@ -557,7 +557,7 @@ public class PhotoStore : DbStore<Photo> {
 					"DELETE FROM photo_versions WHERE photo_id = :photo_id AND version_id = :version_id",
 					"photo_id", photo.Id,
 					"version_id", version_id));
-				Core.Database.ProcessingSettings.RemoveAll (photo.Id, version_id);
+				App.Instance.Database.ProcessingSettings.RemoveAll (photo.Id, version_id);
 			}
 		if (changes.VersionsAdded != null)
 			foreach (uint version_id in changes.VersionsAdded) {
diff --git a/src/PrintOperation.cs b/src/PrintOperation.cs
index 1aefe29..e7638e7 100644
--- a/src/PrintOperation.cs
+++ b/src/PrintOperation.cs
@@ -115,7 +115,7 @@ namespace FSpot
 					{
 						Gdk.Pixbuf pixbuf;
 						try {
-							using (IImageLoader loader = ImageLoader.Create (selected_photos[p_index].DefaultVersionUri)) {
+							using (IImageLoader loader = ImageLoader.Create (selected_photos[p_index].DefaultVersion.Uri)) {
 								loader.Load (ImageLoaderItem.Full);
 								using (Gdk.Pixbuf full = loader.Full)
 									pixbuf = PixbufUtils.ScaleToMaxSize (full, (int) mx, (int) my);
diff --git a/src/Widgets/PreviewPopup.cs b/src/Widgets/PreviewPopup.cs
index 720f916..756cc40 100644
--- a/src/Widgets/PreviewPopup.cs
+++ b/src/Widgets/PreviewPopup.cs
@@ -116,7 +116,7 @@ namespace FSpot {
 				// A bizarre pixbuf = hack to try to deal with cinematic displays, etc.
 				int preview_size = ((this.Screen.Width + this.Screen.Height)/2)/3;
 				try {
-					using (IImageLoader loader = ImageLoader.Create (item.DefaultVersionUri)) {
+					using (IImageLoader loader = ImageLoader.Create (item.DefaultVersion.Uri)) {
 						loader.Load (ImageLoaderItem.Large);
 						using (Pixbuf large = loader.Large) {
 							if (large != null)
diff --git a/src/Widgets/SlideShow.cs b/src/Widgets/SlideShow.cs
index 2154c6d..3171c42 100644
--- a/src/Widgets/SlideShow.cs
+++ b/src/Widgets/SlideShow.cs
@@ -92,7 +92,7 @@ namespace FSpot.Widgets
 			if (running)
 				flip.Start ();
 			lock (sync_handle) {
-				if (prev != null && prev != PixbufUtils.ErrorPixbuf)
+				if (prev != null && prev != FSpotPixbufUtils.ErrorPixbuf)
 					prev.Dispose ();
 				prev = next;
 
@@ -160,9 +160,9 @@ namespace FSpot.Widgets
 		}
 		protected override void OnDestroyed ()
 		{
-			if (prev != null && prev != PixbufUtils.ErrorPixbuf)
+			if (prev != null && prev != FSpotPixbufUtils.ErrorPixbuf)
 				prev.Dispose ();
-			if (next != null && next != PixbufUtils.ErrorPixbuf)
+			if (next != null && next != FSpotPixbufUtils.ErrorPixbuf)
 				next.Dispose ();
 
 			base.OnDestroyed ();



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