[pitivi: 10/18] ui/timeline.py: add a gtk.HScale to upper left corner of timeline for zooming



commit fe933cb37e13f0cf14470df1583d916bcf429892
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date:   Tue Dec 8 13:49:26 2009 -0800

    ui/timeline.py: add a gtk.HScale to upper left corner of timeline for zooming
    closes bug 586025

 pitivi/ui/timeline.py |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 57701b2..e27a1d7 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -191,6 +191,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
         Zoomable.__init__(self)
         self.log("Creating Timeline")
 
+        self._updateZoom = True
         self.project = None
         self.ui_manager = ui_manager
         self.app = instance
@@ -213,6 +214,17 @@ class Timeline(gtk.Table, Loggable, Zoomable):
         self.hadj = gtk.Adjustment()
         self.vadj = gtk.Adjustment()
 
+        # zooming slider
+        self._zoomAdjustment = gtk.Adjustment()
+        self._zoomAdjustment.set_value(Zoomable.getCurrentZoomLevel())
+        self._zoomAdjustment.connect("value-changed",
+            self._zoomAdjustmentChangedCb)
+        self._zoomAdjustment.props.lower = 0
+        self._zoomAdjustment.props.upper = Zoomable.zoom_steps
+        zoomslider = gtk.HScale(self._zoomAdjustment)
+        zoomslider.props.draw_value = False
+        self.attach(zoomslider, 0, 1, 0, 1, yoptions=0, xoptions=gtk.FILL)
+
         # controls for tracks and layers
         self._controls = TimelineControls()
         controlwindow = gtk.Viewport(None, self.vadj)
@@ -438,8 +450,16 @@ class Timeline(gtk.Table, Loggable, Zoomable):
 
 ## Zooming and Scrolling
 
+    def _zoomAdjustmentChangedCb(self, adjustment):
+        # GTK crack
+        self._updateZoom = False
+        Zoomable.setZoomLevel(int(adjustment.get_value()))
+        self._updateZoom = True
+
     def zoomChanged(self):
         self._canvas.props.redraw_when_scrolled = True
+        if self._updateZoom:
+            self._zoomAdjustment.set_value(self.getCurrentZoomLevel())
         self.ruler.queue_resize()
         self.ruler.queue_draw()
 



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