Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/actions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius/actions.py')
-rw-r--r--tutorius/actions.py46
1 files changed, 30 insertions, 16 deletions
diff --git a/tutorius/actions.py b/tutorius/actions.py
index fe64c95..f6f3338 100644
--- a/tutorius/actions.py
+++ b/tutorius/actions.py
@@ -17,6 +17,7 @@
This module defines Actions that can be done and undone on a state
"""
import gtk
+import cairo
import logging
from gettext import gettext as _
@@ -70,22 +71,35 @@ class DragWrapper(object):
y = self._widget.allocation.y
depth = 24 # Should be set dynamically
- pxbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height)
- pxbuf.fill(0xFFFFFFFF)
-
- px = gtk.gdk.Pixmap(None, width, height, depth) # source, size, colors
- px.set_colormap(gtk.gdk.colormap_get_system())
- ctxt = px.cairo_create()
- ctxt.set_source_pixbuf(pxbuf,0,0)
- ctxt.paint()
-
- # Compensate when drawing the icon for the context
- # translation done to the position occupied by the widget
- ctxt.translate(-x, -y)
- self._widget.draw_with_context(ctxt)
-
- pxbuf.get_from_drawable(px,gtk.gdk.colormap_get_system(), 0, 0, 0, 0, -1, -1)
- drag_context.set_icon_pixbuf(pxbuf,0,0)
+ if hasattr(self._widget, 'draw_with_context'):
+ px = gtk.gdk.Pixmap(None, width, height, depth) # source, size, colors
+ ctxt = px.cairo_create()
+ # Compensate when drawing the icon for the context
+ # translation done to the position occupied by the widget
+ ctxt.translate(-x, -y)
+ self._widget.draw_with_context(ctxt)
+
+ # Do the same for the icon shape mask
+ mask = gtk.gdk.Pixmap(None, width, height, 1)
+ ctxt = mask.cairo_create()
+ ctxt.set_operator(cairo.OPERATOR_CLEAR)
+ ctxt.paint()
+ ctxt.set_operator(cairo.OPERATOR_SOURCE)
+ ctxt.translate(-x, -y)
+ self._widget.draw_with_context(ctxt)
+
+ drag_context.set_icon_pixmap(gtk.gdk.colormap_get_system(),
+ px, mask, 0, 0)
+ else:
+ pxbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
+ width, height)
+ pxbuf.get_from_drawable(self._widget.window,
+ gtk.gdk.colormap_get_system(),
+ src_x=0, src_y=0, # has it's own window
+ dest_x=0, dest_y=0,
+ width=width, height=height)
+ drag_context.set_icon_pixbuf(pxbuf, 0, 0)
+
def _drag_fail(self, *args):
"""