private void HandlePixbufLoaded(FSpot.PixbufCache Cache, FSpot.PixbufCache.CacheEntry entry)
        {
            Gdk.Pixbuf result = entry.ShallowCopyPixbuf ();
            int order = (int) entry.Data;

            if (result == null)
                return;

            // We have to do the scaling here rather than on load because we need to preserve the
            // Pixbuf option iformation to verify the thumbnail validity later
            int width, height;
            PixbufUtils.Fit (result, ThumbnailWidth, ThumbnailHeight, false, out width, out height);
            if (result.Width > width && result.Height > height) {
                //  Log.Debug ("scaling");
                Gdk.Pixbuf temp = PixbufUtils.ScaleDown (result, width, height);
                result.Dispose ();
                result = temp;
            } else if (result.Width < ThumbnailWidth && result.Height < ThumbnailHeight) {
                // FIXME this is a workaround to handle images whose actual size is smaller than
                // the thumbnail size, it needs to be fixed at a different level.
                Gdk.Pixbuf temp = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, ThumbnailWidth, ThumbnailHeight);
                temp.Fill (0x00000000);
                result.CopyArea (0, 0,
                        result.Width, result.Height,
                        temp,
                        (temp.Width - result.Width)/ 2,
                        temp.Height - result.Height);

                result.Dispose ();
                result = temp;
            }

            Cache.Update (entry, result);
            InvalidateCell (order);
        }
	private void HandlePixbufLoaded (FSpot.PixbufCache cache, FSpot.PixbufCache.CacheEntry entry)
	{
		Gdk.Pixbuf result = entry.ShallowCopyPixbuf ();
		int order = (int) entry.Data;

		if (order >= 0 && order < collection.Count) {
			System.Uri uri = collection [order].DefaultVersionUri;

			if (result == null && !System.IO.File.Exists (FSpot.ThumbnailGenerator.ThumbnailPath (uri)))
				FSpot.ThumbnailGenerator.Default.Request (uri, 0, 256, 256);
			
			if (result == null)
				return;
			
			if (!FSpot.PhotoLoader.ThumbnailIsValid (uri, result))
				FSpot.ThumbnailGenerator.Default.Request (uri, 0, 256, 256);
		}
			
		if (result == null)
			return;

		// We have to do the scaling here rather than on load because we need to preserve the 
		// Pixbuf option iformation to verify the thumbnail validity later
		int width, height;
		PixbufUtils.Fit (result, ThumbnailWidth, ThumbnailHeight, false, out width, out height);
		if (result.Width > width && result.Height > height) {
			//  System.Console.WriteLine ("scaling");
			Gdk.Pixbuf temp = PixbufUtils.ScaleDown (result, width, height);
			result.Dispose ();
			result = temp;
		} else if (result.Width < ThumbnailWidth && result.Height < ThumbnailHeight) {
			// FIXME this is a workaround to handle images whose actual size is smaller than 
			// the thumbnail size, it needs to be fixed at a different level.
			Gdk.Pixbuf temp = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, ThumbnailWidth, ThumbnailHeight);
			temp.Fill (0x00000000);
			result.CopyArea (0, 0, 
					 result.Width, result.Height, 
					 temp, 
					 (temp.Width - result.Width)/ 2,
					 temp.Height - result.Height);

			result.Dispose ();
			result = temp;
		}

		cache.Update (entry, result);
		InvalidateCell (order);
	}