From 47b5aaed64649e1f9a087d02b1367d0b0d44971d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 16 May 2009 22:17:04 +0100 Subject: [PATCH] take a snapshot of the terminal, scale it if necessary and use that for the drag icon --- terminatorlib/terminatorterm.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index d193c2fc..02d26776 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -338,7 +338,20 @@ class TerminatorTerm (gtk.VBox): def on_drag_begin(self, widget, drag_context, data): dbg ('Drag begins') - widget.drag_source_set_icon_pixbuf(self.terminator.icon_theme.load_icon (APP_NAME, 48, 0)) + pixmap = widget.get_parent().get_snapshot() + (width, height) = pixmap.get_size() + pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) + pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, width, height) + + longest = max(width, height) + factor = float(512) / float(longest) + + if (width * factor) > width or (height * factor) > height: + factor = 1 + + scaledpixbuf = pixbuf.scale_simple (int(width * factor), int(height * factor), gtk.gdk.INTERP_BILINEAR) + + widget.drag_source_set_icon_pixbuf(scaledpixbuf) def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data): dbg ("Drag data get")