[f-spot/rubenv-gsoc-2009: 57/86] Kill CompletePixbuf and expose Loader in PhotoImageView.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/rubenv-gsoc-2009: 57/86] Kill CompletePixbuf and expose Loader in PhotoImageView.
- Date: Sun, 23 May 2010 12:36:44 +0000 (UTC)
commit 1da1a54a2d39b0415b80f22d0b8831bf6ee049af
Author: Ruben Vermeersch <ruben savanne be>
Date: Sat Aug 8 02:50:52 2009 +0200
Kill CompletePixbuf and expose Loader in PhotoImageView.
src/Editors/CropEditor.cs | 7 ++++-
src/Editors/Editor.cs | 4 ++-
src/Loaders/IImageLoader.cs | 2 -
src/PhotoImageView.cs | 46 +++++++++++++++++-------------------------
4 files changed, 27 insertions(+), 32 deletions(-)
---
diff --git a/src/Editors/CropEditor.cs b/src/Editors/CropEditor.cs
index 6d4c265..03d26d1 100644
--- a/src/Editors/CropEditor.cs
+++ b/src/Editors/CropEditor.cs
@@ -10,6 +10,7 @@
using FSpot;
using FSpot.UI.Dialog;
using FSpot.Utils;
+using FSpot.Loaders;
using Gdk;
using Gtk;
using Mono.Unix;
@@ -140,8 +141,10 @@ namespace FSpot.Editors {
break;
case ConstraintType.SameAsPhoto:
try {
- Pixbuf pb = State.PhotoImageView.CompletePixbuf ();
- State.PhotoImageView.SelectionXyRatio = (double)pb.Width / (double)pb.Height;
+ IImageLoader loader = State.PhotoImageView.Loader;
+ loader.Load (ImageLoaderItem.Large);
+ using (Pixbuf large = loader.Large)
+ State.PhotoImageView.SelectionXyRatio = (double)large.Width / (double)large.Height;
} catch (System.Exception ex) {
Log.Warning ("Exception in selection ratio's: {0}", ex);
State.PhotoImageView.SelectionXyRatio = 0;
diff --git a/src/Editors/Editor.cs b/src/Editors/Editor.cs
index 517e8d6..2eda078 100644
--- a/src/Editors/Editor.cs
+++ b/src/Editors/Editor.cs
@@ -64,7 +64,9 @@ namespace FSpot.Editors {
// FIXME: We might get this value from the PhotoImageView.
using (ImageFile img = ImageFile.Create (photo.DefaultVersion.Uri)) {
if (State.PhotoImageView != null) {
- photo_pixbuf = State.PhotoImageView.CompletePixbuf ().ShallowCopy ();
+ IImageLoader loader = State.PhotoImageView.Loader;
+ loader.Load (ImageLoaderItem.Full);
+ photo_pixbuf = loader.Full;
} else {
using (IImageLoader loader = ImageLoader.Create (photo.DefaultVersionUri)) {
loader.Load (ImageLoaderItem.Full);
diff --git a/src/Loaders/IImageLoader.cs b/src/Loaders/IImageLoader.cs
index 55993f3..d18be79 100644
--- a/src/Loaders/IImageLoader.cs
+++ b/src/Loaders/IImageLoader.cs
@@ -15,8 +15,6 @@ using Gdk;
namespace FSpot.Loaders {
public interface IImageLoader : IDisposable {
- bool Loading { get; }
-
event EventHandler<AreaPreparedEventArgs> AreaPrepared;
event EventHandler<AreaUpdatedEventArgs> AreaUpdated;
event EventHandler<ItemsCompletedEventArgs> Completed;
diff --git a/src/PhotoImageView.cs b/src/PhotoImageView.cs
index 729e7d4..f3fa4c6 100644
--- a/src/PhotoImageView.cs
+++ b/src/PhotoImageView.cs
@@ -52,15 +52,6 @@ namespace FSpot.Widgets {
get { return loupe; }
}
- public Gdk.Pixbuf CompletePixbuf ()
- {
- //FIXME: this should be an async call
- if (loader != null)
- while (loader.Loading)
- Gtk.Application.RunIteration (true);
- return this.Pixbuf;
- }
-
public void Reload ()
{
if (Item == null || !Item.IsValid)
@@ -160,10 +151,10 @@ namespace FSpot.Widgets {
protected override void OnDestroyed ()
{
- if (loader != null) {
- loader.AreaUpdated -= HandlePixbufAreaUpdated;
- loader.AreaPrepared -= HandlePixbufPrepared;
- loader.Dispose ();
+ if (Loader != null) {
+ Loader.AreaUpdated -= HandlePixbufAreaUpdated;
+ Loader.AreaPrepared -= HandlePixbufPrepared;
+ Loader.Dispose ();
}
base.OnDestroyed ();
}
@@ -219,32 +210,33 @@ namespace FSpot.Widgets {
#endregion
#region loader
+ public IImageLoader Loader { get; private set; }
+
uint timer;
- IImageLoader loader;
bool prepared_is_new;
ImageLoaderItem current_item;
void Load (Uri uri)
{
timer = Log.DebugTimerStart ();
- if (loader != null)
- loader.Dispose ();
+ if (Loader != null)
+ Loader.Dispose ();
HideStatus ();
current_item = ImageLoaderItem.None;
prepared_is_new = true;
- loader = ImageLoader.Create (uri);
- loader.AreaPrepared += HandlePixbufPrepared;
- loader.AreaUpdated += HandlePixbufAreaUpdated;
- loader.ProgressHint += HandleProgressHint;
- loader.Load (ImageLoaderItem.Thumbnail | ImageLoaderItem.Large | ImageLoaderItem.Full, HandleCompleted);
+ Loader = ImageLoader.Create (uri);
+ Loader.AreaPrepared += HandlePixbufPrepared;
+ Loader.AreaUpdated += HandlePixbufAreaUpdated;
+ Loader.ProgressHint += HandleProgressHint;
+ Loader.Load (ImageLoaderItem.Thumbnail | ImageLoaderItem.Large | ImageLoaderItem.Full, HandleCompleted);
}
void HandlePixbufPrepared (object sender, AreaPreparedEventArgs args)
{
IImageLoader loader = sender as IImageLoader;
- if (loader != this.loader)
+ if (loader != Loader)
return;
if (!ShowProgress)
@@ -258,8 +250,8 @@ namespace FSpot.Widgets {
Log.Debug ("Prepared is new: {0}", prepared_is_new);
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);
+ PixbufOrientation orientation = Accelerometer.GetViewOrientation (Loader.PixbufOrientation (current_item));
+ ChangeImage (Loader.Pixbuf (current_item), orientation, prepared_is_new, current_item != ImageLoaderItem.Full);
prepared_is_new = false;
if (prev != null)
@@ -271,7 +263,7 @@ namespace FSpot.Widgets {
void HandlePixbufAreaUpdated (object sender, AreaUpdatedEventArgs args)
{
IImageLoader loader = sender as IImageLoader;
- if (loader != this.loader)
+ if (loader != Loader)
return;
if (!ShowProgress)
@@ -286,13 +278,13 @@ namespace FSpot.Widgets {
Log.DebugTimerPrint (timer, "Loading image took {0} (" + args.Items.ToString () + ")");
HideStatus ();
IImageLoader loader = sender as IImageLoader;
- if (loader != this.loader)
+ if (loader != Loader)
return;
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);
+ ChangeImage (Loader.Pixbuf (current_item), Accelerometer.GetViewOrientation (Loader.PixbufOrientation (current_item)), false, false);
}
if (Pixbuf == null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]