[f-spot/rubenv-gsoc-2009: 12/86] Load the full size RAW in the background.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/rubenv-gsoc-2009: 12/86] Load the full size RAW in the background.
- Date: Sun, 23 May 2010 12:32:57 +0000 (UTC)
commit 87aa8ca10310911725623b0934f5d90e243d0f2c
Author: Ruben Vermeersch <ruben savanne be>
Date: Sat Jul 18 20:08:01 2009 +0200
Load the full size RAW in the background.
src/Loaders/LibrawImageLoader.cs | 57 ++++++++++++++++++++++++++++++--------
1 files changed, 45 insertions(+), 12 deletions(-)
---
diff --git a/src/Loaders/LibrawImageLoader.cs b/src/Loaders/LibrawImageLoader.cs
index d554321..7ecf04b 100644
--- a/src/Loaders/LibrawImageLoader.cs
+++ b/src/Loaders/LibrawImageLoader.cs
@@ -9,10 +9,11 @@
// This is free software. See COPYING for details
//
+using FSpot.Loaders.Native;
+using FSpot.Utils;
using Gdk;
using System;
-using FSpot.Utils;
-using FSpot.Loaders.Native;
+using System.Threading;
namespace FSpot.Loaders {
public class LibrawImageLoader : IImageLoader {
@@ -21,6 +22,8 @@ namespace FSpot.Loaders {
bool is_disposed = false;
bool is_loading = false;
+ Pixbuf thumb, full;
+
public void Load (Uri uri)
{
if (this.uri != null)
@@ -31,17 +34,41 @@ namespace FSpot.Loaders {
return;
loader = new NativeLibrawLoader (uri.AbsolutePath);
+ LoadThumbnail ();
+ ThreadPool.QueueUserWorkItem (delegate { LoadFull (); });
+ }
- Pixbuf thumb = loader.LoadThumbnail ();
+ void LoadThumbnail ()
+ {
+ thumb = loader.LoadThumbnail ();
PixbufOrientation = PixbufOrientation.TopLeft;
- Pixbuf = thumb;
- EventHandler<AreaPreparedEventArgs> prep = AreaPrepared;
- if (prep != null)
- prep (this, new AreaPreparedEventArgs (true));
- EventHandler<AreaUpdatedEventArgs> upd = AreaUpdated;
- if (upd != null)
- upd (this, new AreaUpdatedEventArgs (new Rectangle (0, 0, thumb.Width, thumb.Height)));
+ GLib.Idle.Add (delegate {
+ EventHandler<AreaPreparedEventArgs> prep = AreaPrepared;
+ if (prep != null)
+ prep (this, new AreaPreparedEventArgs (true));
+ EventHandler<AreaUpdatedEventArgs> upd = AreaUpdated;
+ if (upd != null)
+ upd (this, new AreaUpdatedEventArgs (new Rectangle (0, 0, thumb.Width, thumb.Height)));
+ return false;
+ });
+ }
+ void LoadFull ()
+ {
+ full = loader.LoadFull ();
+ PixbufOrientation = PixbufOrientation.TopLeft;
+ GLib.Idle.Add (delegate {
+ EventHandler<AreaPreparedEventArgs> prep = AreaPrepared;
+ if (prep != null)
+ prep (this, new AreaPreparedEventArgs (false));
+ EventHandler<AreaUpdatedEventArgs> upd = AreaUpdated;
+ if (upd != null)
+ upd (this, new AreaUpdatedEventArgs (new Rectangle (0, 0, full.Width, full.Height)));
+ EventHandler eh = Completed;
+ if (eh != null)
+ eh (this, EventArgs.Empty);
+ return false;
+ });
}
public event EventHandler<AreaPreparedEventArgs> AreaPrepared;
@@ -54,10 +81,16 @@ namespace FSpot.Loaders {
public void Dispose ()
{
-
+ // TODO: Abort the NativeLibrawLoader
+ thumb.Dispose ();
+ full.Dispose ();
}
- public Pixbuf Pixbuf { get; private set; }
+ public Pixbuf Pixbuf {
+ get {
+ return full == null ? thumb : full;
+ }
+ }
public PixbufOrientation PixbufOrientation { get; private set; }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]