[f-spot/rubenv-gsoc-2009: 43/86] Switch PreviewPopup from PhotoLoader to ImageLoader.



commit 0a4f61de1428bfa1e69791f4f5a4c42d4464699a
Author: Ruben Vermeersch <ruben savanne be>
Date:   Thu Jul 30 13:36:04 2009 +0200

    Switch PreviewPopup from PhotoLoader to ImageLoader.

 src/Loaders/LibrawImageLoader.cs |    3 ++-
 src/Widgets/PreviewPopup.cs      |   16 +++++++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/Loaders/LibrawImageLoader.cs b/src/Loaders/LibrawImageLoader.cs
index 99d2fdd..23cbdc9 100644
--- a/src/Loaders/LibrawImageLoader.cs
+++ b/src/Loaders/LibrawImageLoader.cs
@@ -183,7 +183,8 @@ namespace FSpot.Loaders {
 			if (large == null) {
 				// Fallback for files without an embedded preview (yuck!)
 				LoadFull ();
-				large = full.ShallowCopy ();
+				if (full != null)
+					large = full.ShallowCopy ();
 			}
 
 			switch (orientation) {
diff --git a/src/Widgets/PreviewPopup.cs b/src/Widgets/PreviewPopup.cs
index 1d4467e..720f916 100644
--- a/src/Widgets/PreviewPopup.cs
+++ b/src/Widgets/PreviewPopup.cs
@@ -13,6 +13,7 @@ using Cairo;
 using Gdk;
 using FSpot.Widgets;
 using FSpot.Utils;
+using FSpot.Loaders;
 
 namespace FSpot {
 	public class PreviewPopup : Gtk.Window {
@@ -108,15 +109,20 @@ namespace FSpot {
 			
 			string orig_path = item.DefaultVersion.Uri.LocalPath;
 
-			Gdk.Pixbuf pixbuf = preview_cache.Get (orig_path + show_histogram.ToString ()).ShallowCopy ();
+			Gdk.Pixbuf pixbuf = preview_cache.Get (orig_path + show_histogram.ToString ());
+			if (pixbuf != null)
+				pixbuf = pixbuf.ShallowCopy ();
 			if (pixbuf == null) {
 				// A bizarre pixbuf = hack to try to deal with cinematic displays, etc.
 				int preview_size = ((this.Screen.Width + this.Screen.Height)/2)/3;
 				try {
-					if (item is Photo)
-						pixbuf = FSpot.PhotoLoader.LoadAtMaxSize ((Photo)item, preview_size, preview_size);
-					else
-						pixbuf = PixbufUtils.LoadAtMaxSize (orig_path, preview_size, preview_size);
+					using (IImageLoader loader = ImageLoader.Create (item.DefaultVersionUri)) {
+						loader.Load (ImageLoaderItem.Large);
+						using (Pixbuf large = loader.Large) {
+							if (large != null)
+								pixbuf = PixbufUtils.ScaleToMaxSize (large, preview_size, preview_size, false);
+						}
+					}
 				} catch (Exception) {
 					pixbuf = null;
 				}



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