Hi,

any simpler and/or more efficient way to do this is very welcome.

Thanks,

Tomeu
From 8a719943c0c77b1217246169587ae2b948c7114c Mon Sep 17 00:00:00 2001
From: Tomeu Vizoso <[EMAIL PROTECTED]>
Date: Mon, 23 Jun 2008 13:34:43 +0200
Subject: [PATCH] Show the actual icon when dragging activities in the favorites view.

---
 src/view/home/favoritesview.py |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/view/home/favoritesview.py b/src/view/home/favoritesview.py
index 1c948e8..217e909 100644
--- a/src/view/home/favoritesview.py
+++ b/src/view/home/favoritesview.py
@@ -204,10 +204,21 @@ class FavoritesView(hippo.Canvas):
         return False
 
     def __drag_begin_cb(self, widget, context):
-        icon_file_name = self._last_clicked_icon.props.file_name
-        # TODO: we should get the pixbuf from the widget, so it has colors, etc
-        pixbuf = gtk.gdk.pixbuf_new_from_file(icon_file_name)
-        
+        if self._last_clicked_icon is None:
+            return
+
+        width, height = self._last_clicked_icon.get_allocation()
+        pixmap = gtk.gdk.Pixmap(self.window, width, height)
+        cr = pixmap.cairo_create()
+
+        cr.set_source_surface(self._last_clicked_icon.surface, 0, 0)
+        cr.paint()
+
+        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, has_alpha=True,
+                                bits_per_sample=8, width=width, height=height)
+        pixbuf = pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
+                                          0, 0, 0, 0, -1, -1)
+
         hot_spot = style.zoom(10)
         context.set_icon_pixbuf(pixbuf, hot_spot, hot_spot)
 
-- 
1.5.4.3

_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar

Reply via email to