[pitivi] elements: Cache the pixbuf used for drawing the TrimHandles



commit 5443f35cc240cf72571522f6d76b3c8c2baa1394
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Thu Oct 22 16:20:54 2015 +0200

    elements: Cache the pixbuf used for drawing the TrimHandles
    
    Differential Revision: https://phabricator.freedesktop.org/D433

 pitivi/timeline/elements.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 00a5be6..8799f61 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -573,6 +573,7 @@ class TrimHandle(Gtk.EventBox, Loggable):
 
     SELECTED_WIDTH = 5
     DEFAULT_WIDTH = 1
+    PIXBUF = None
 
     def __init__(self, clip, edge):
         Gtk.EventBox.__init__(self)
@@ -596,8 +597,10 @@ class TrimHandle(Gtk.EventBox, Loggable):
 
     def do_draw(self, cr):
         Gtk.EventBox.do_draw(self, cr)
-        Gdk.cairo_set_source_pixbuf(cr, GdkPixbuf.Pixbuf.new_from_file(os.path.join(
-                                    configure.get_pixmap_dir(), "trimbar-focused.png")), 10, 10)
+        if TrimHandle.PIXBUF is None:
+            TrimHandle.PIXBUF = GdkPixbuf.Pixbuf.new_from_file(
+                os.path.join(configure.get_pixmap_dir(), "trimbar-focused.png"))
+        Gdk.cairo_set_source_pixbuf(cr, TrimHandle.PIXBUF, 10, 10)
 
 
 class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]