public void HandleIconViewDragBegin (object sender, DragBeginArgs args)
{
Photo[] photos = SelectedPhotos ();
if (photos.Length > 0) {
int len = Math.Min (photos.Length, 4);
int size = 48;
int border = 2;
int csize = size / 2 + len * size / 2 + 2 * border;
Pixbuf container = new Pixbuf (Gdk.Colorspace.Rgb, true, 8, csize, csize);
container.Fill (0x00000000);
bool use_icon = false;
;
while (len-- > 0) {
FSpot.PixbufCache.CacheEntry entry = icon_view.Cache.Lookup (photos [len].DefaultVersion.Uri);
Pixbuf thumbnail = null;
if (entry != null) {
Cms.Profile screen_profile;
if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile)) {
thumbnail = entry.Pixbuf.Copy ();
FSpot.ColorManagement.ApplyProfile (thumbnail, screen_profile);
} else
thumbnail = entry.ShallowCopyPixbuf ();
}
if (thumbnail != null) {
Pixbuf small = thumbnail.ScaleToMaxSize (size, size);
int x = border + len * (size / 2) + (size - small.Width) / 2;
int y = border + len * (size / 2) + (size - small.Height) / 2;
Pixbuf box = new Pixbuf (container, x - border, y - border,
small.Width + 2 * border, small.Height + 2 * border);
box.Fill (0x000000ff);
small.CopyArea (0, 0, small.Width, small.Height, container, x, y);
thumbnail.Dispose ();
small.Dispose ();
use_icon = true;
}
}
if (use_icon)
Gtk.Drag.SetIconPixbuf (args.Context, container, 0, 0);
container.Dispose ();
}
}