refactor pixbuf getting thing out to a separate function
This commit is contained in:
parent
47b5aaed64
commit
14f6525195
|
@ -336,22 +336,27 @@ class TerminatorTerm (gtk.VBox):
|
||||||
def on_vte_size_allocate(self, widget, allocation):
|
def on_vte_size_allocate(self, widget, allocation):
|
||||||
self._titlebox.set_terminal_size (self._vte.get_column_count (), self._vte.get_row_count ())
|
self._titlebox.set_terminal_size (self._vte.get_column_count (), self._vte.get_row_count ())
|
||||||
|
|
||||||
def on_drag_begin(self, widget, drag_context, data):
|
def get_pixbuf(self, maxsize= None):
|
||||||
dbg ('Drag begins')
|
pixmap = self.get_snapshot()
|
||||||
pixmap = widget.get_parent().get_snapshot()
|
|
||||||
(width, height) = pixmap.get_size()
|
(width, height) = pixmap.get_size()
|
||||||
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
|
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)
|
pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, width, height)
|
||||||
|
|
||||||
longest = max(width, height)
|
longest = max(width, height)
|
||||||
factor = float(512) / float(longest)
|
|
||||||
|
|
||||||
if (width * factor) > width or (height * factor) > height:
|
if maxsize is not None:
|
||||||
|
factor = float(maxsize) / float(longest)
|
||||||
|
|
||||||
|
if not maxsize or (width * factor) > width or (height * factor) > height:
|
||||||
factor = 1
|
factor = 1
|
||||||
|
|
||||||
scaledpixbuf = pixbuf.scale_simple (int(width * factor), int(height * factor), gtk.gdk.INTERP_BILINEAR)
|
scaledpixbuf = pixbuf.scale_simple (int(width * factor), int(height * factor), gtk.gdk.INTERP_BILINEAR)
|
||||||
|
|
||||||
widget.drag_source_set_icon_pixbuf(scaledpixbuf)
|
return(scaledpixbuf)
|
||||||
|
|
||||||
|
def on_drag_begin(self, widget, drag_context, data):
|
||||||
|
dbg ('Drag begins')
|
||||||
|
widget.drag_source_set_icon_pixbuf(self.get_pixbuf (512))
|
||||||
|
|
||||||
def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data):
|
def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data):
|
||||||
dbg ("Drag data get")
|
dbg ("Drag data get")
|
||||||
|
|
Loading…
Reference in New Issue