pitivi r1202 - in branches/SOC_2008_BLEWIS: . pitivi/ui



Author: blewis
Date: Sun Jul 20 20:32:43 2008
New Revision: 1202
URL: http://svn.gnome.org/viewvc/pitivi?rev=1202&view=rev

Log:
* pitivi/ui/complexlayer.py:
layerinfolist directly connects to composition start/duration-changed
signals and emits its own signal, for the sake of convenience in the
ui.
automatically disconnects signal handlers
* pitivi/ui/complextimeline.py:
ComplexTimelineWidget no longer uses toplayer, but TimelineToolbar and
Ruler directly, as the layout has changed. The ruler is on top,
directly above the timeline, and the toolbar is on the bottom.
* pitivi/ui/layerwidgets.py:
TimelineToolBar packing rules changed so that buttons appear the right
size at the bottom of the screen. Also added getZoomRatio() and
setZoomRatio() methods to prevent pitivi from crashing. Haven't tested
whether zooming still works, but I intend to overhaul the mechanism
for handling zooming anyways.
* pitivi/ui/ruler.py:
wrapped a long line to 80 columns


Modified:
   branches/SOC_2008_BLEWIS/ChangeLog
   branches/SOC_2008_BLEWIS/pitivi/ui/complexlayer.py
   branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
   branches/SOC_2008_BLEWIS/pitivi/ui/layerwidgets.py
   branches/SOC_2008_BLEWIS/pitivi/ui/ruler.py

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/complexlayer.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/complexlayer.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/complexlayer.py	Sun Jul 20 20:32:43 2008
@@ -57,24 +57,34 @@
 class LayerInfo:
     """ Information on a layer for the complex timeline widgets """
 
-    def __init__(self, composition, expanded=True):
+    def __init__(self, composition, sigid, expanded=True):
         """
         If currentHeight is None, it will be set to the given minimumHeight.
         """
         self.composition = composition
         self.expanded = expanded
+        self.sigid = sigid
 
 class LayerInfoList(gobject.GObject):
     """ List, on steroids, of the LayerInfo"""
 
     __gsignals__ = {
-        'layer-added' : ( gobject.SIGNAL_RUN_LAST,
-                          gobject.TYPE_NONE,
-                          ( gobject.TYPE_PYOBJECT, gobject.TYPE_INT, ) ),
-        'layer-removed' : ( gobject.SIGNAL_RUN_LAST,
-                          gobject.TYPE_NONE,
-                          ( gobject.TYPE_INT, ) ),
-        }
+        'layer-added' : (
+            gobject.SIGNAL_RUN_LAST,
+            gobject.TYPE_NONE,
+            (gobject.TYPE_PYOBJECT, gobject.TYPE_INT, )
+        ),
+        'layer-removed' : (
+            gobject.SIGNAL_RUN_LAST,
+            gobject.TYPE_NONE,
+            (gobject.TYPE_INT, )
+        ),
+        'start-duration-changed' : (
+            gobject.SIGNAL_RUN_LAST,
+            gobject.TYPE_NONE,
+            ()
+        )
+    }
 
     def __init__(self):
         gobject.GObject.__init__(self)
@@ -92,6 +102,9 @@
         self.addComposition(self.timeline.audiocomp)
         self.addComposition(self.timeline.videocomp)
 
+    def _start_duration_changed_cb(self, timeline, start, duration):
+        self.emit("start-duration-changed")
+
     def addComposition(self, composition, pos=-1):
         """
         Insert the composition at the given position (default end)
@@ -105,7 +118,9 @@
             expanded = False
         else:
             expanded = True
-        layer = LayerInfo(composition, expanded)
+        sigid = composition.connect("start-duration-changed",
+            self._start_duration_changed_cb)
+        layer = LayerInfo(composition, sigid, expanded)
         if pos == -1:
             self._list.append(layer)
         else:
@@ -124,6 +139,7 @@
             return False
         position = self._list.index(layer)
         self._list.remove(layer)
+        layer.composition.disconnect(layer.sigid)
         self.emit('layer-removed', position)
 
     def _clear(self):

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py	Sun Jul 20 20:32:43 2008
@@ -30,7 +30,8 @@
 
 from pitivi.bin import SmartTimelineBin
 from complexlayer import LayerInfoList
-from layerwidgets import TopLayer, CompositionLayer
+from layerwidgets import TimelineToolBar
+import ruler
 from complexinterface import ZoomableWidgetInterface
 import goocanvas
 from util import *
@@ -363,6 +364,7 @@
         self.layers = VList(canvas=self)
         self.layers.connect("notify::width", self._request_size)
         self.layers.connect("notify::height", self._request_size)
+        set_pos(self.layers, (3.5, 0))
         self.get_root_item().add_child(self.layers)
         self._marquee = make_item(MARQUEE)
         manage_selection(self, self._marquee, True, self._selection_changed_cb)
@@ -431,21 +433,17 @@
 # ComplexTimelineWidget(gtk.VBox)
 # |  Top container
 # |
-# +--TopLayer (TimelineLayer (gtk.HBox))
-# |   |
-# |   +--TopLeftTimelineWidget(?)
-# |   |
-# |   +--ScaleRuler(gtk.Layout)
+# +--ScaleRuler(gtk.Layout)
 # |
 # +--gtk.ScrolledWindow
-#    |
-#    +--CompositionsLayer(gtk.VBox)
-#       |
-#       +--CompositionLayer(TimelineLayer(gtk.HBox))
-#          |
-#          +--InfoLayer(gtk.Expander)
-#          |
-#          +--TrackLayer(gtk.Layout)
+# |  |
+# |  +--CompositionLayers(goocanas.Canvas)
+# |  |  |
+# |  |  +--ComplexTrack(SmartGroup)
+# |  |
+# |  +--Status Bar ??
+# | 
+# +--ToolBar / (Status Bar??)
 
 class ComplexTimelineWidget(gtk.VBox, ZoomableWidgetInterface):
 
@@ -469,31 +467,35 @@
 
         # force update of UI
         self.layerInfoList.setTimeline(instance.PiTiVi.current.timeline)
+        self.layerInfoList.connect("start-duration-changed",
+            self._layerStartDurationChanged)
 
     def _createUI(self):
         self.set_border_width(4)
         self.leftSizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
 
         self.hadj = gtk.Adjustment()
-
-        # top layer (TopLayer)
-        self.topLayer = TopLayer(self.leftSizeGroup, self.hadj)
-        # overriding topLayer's ZoomableWidgetInterface methods
-        self.topLayer.getDuration = self.getDuration
-        self.topLayer.getStartTime = self.getStartTime
-        self.topLayer.overrideZoomableWidgetInterfaceMethods()
-        self.pack_start(self.topLayer, expand=False)
+        self.ruler = ruler.ScaleRuler(self.hadj)
+        #FIXME: this is crack
+        self.ruler.getDuration = self.getDuration
+        self.ruler.getStartTime = self.getStartTime
+        self.ruler.zoomChanged = self.zoomChanged
+        self.ruler.set_size_request(0, 35)
+        self.ruler.set_border_width(0)
+        self.pack_start(self.ruler, expand=False, fill=True)
 
         # List of CompositionLayers
         self.compositionLayers = CompositionLayers(self.leftSizeGroup,
            self.layerInfoList)
-
-        # ... in a scrolled window
         self.scrolledWindow = gtk.ScrolledWindow(self.hadj)
         self.scrolledWindow.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_AUTOMATIC)
         self.scrolledWindow.add(self.compositionLayers)
         self.pack_start(self.scrolledWindow, expand=True)
 
+        #toolbar
+        self.tb = TimelineToolBar()
+        self.pack_start(self.tb, expand=False, fill=False)
+
 ## Project callbacks
 
     def _newProjectLoadingCb(self, unused_inst, project):
@@ -502,6 +504,11 @@
     def _newProjectFailedCb(self, unused_inst, unused_reason, unused_uri):
         self.layerInfoList.setTimeline(None)
 
+## layer callbacks
+
+    def _layerStartDurationChanged(self, layer):
+        self.ruler.startDurationChanged()
+
 ## ZoomableWidgetInterface overrides
 ## * we send everything to self.compositionLayers
 ## * topLayer's function calls will also go there
@@ -513,8 +520,8 @@
         return self.compositionLayers.getStartTime()
 
     def zoomChanged(self):
-        self.topLayer.rightWidget.zoomChanged()
         self.compositionLayers.zoomChanged()
+        self.ruler.zoomChanged()
 
 ## ToolBar callbacks
 
@@ -526,5 +533,5 @@
     def _playgroundPositionCb(self, unused_playground, smartbin, value):
         if isinstance(smartbin, SmartTimelineBin):
             # for the time being we only inform the ruler
-            self.topLayer.timelinePositionChanged(value, 0)
+            self.ruler.timelinePositionChanged(value, 0)
             self.compositionLayers.timelinePositionChanged(value, 0)

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/layerwidgets.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/layerwidgets.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/layerwidgets.py	Sun Jul 20 20:32:43 2008
@@ -33,7 +33,7 @@
 class TimelineToolBar(gtk.HBox):
 
     def __init__(self):
-        gtk.HBox.__init__(self, homogeneous=True)
+        gtk.HBox.__init__(self, homogeneous=False)
         self._addButtons()
 
     def _addButtons(self):
@@ -42,14 +42,15 @@
         image = gtk.image_new_from_stock(gtk.STOCK_ZOOM_IN,
                                          gtk.ICON_SIZE_SMALL_TOOLBAR)
         self.zoomInButton.set_image(image)
-        self.pack_start(self.zoomInButton, expand=False)
+        self.pack_start(self.zoomInButton, expand=False, fill=False)
         self.zoomInButton.connect('clicked', self._zoomClickedCb)
 
         self.zoomOutButton = gtk.Button(label="")
         self.zoomOutButton.set_image(gtk.image_new_from_stock(gtk.STOCK_ZOOM_OUT,
                                                               gtk.ICON_SIZE_SMALL_TOOLBAR))
-        self.pack_start(self.zoomOutButton, expand=False)
+        self.pack_start(self.zoomOutButton, expand=False, fill=False)
         self.zoomOutButton.connect('clicked', self._zoomClickedCb)
+        self._ratio = None
 
     def _zoomClickedCb(self, button):
         if button == self.zoomInButton:
@@ -62,6 +63,12 @@
             return
         self.setZoomRatio(ratio)
 
+    def getZoomRatio(self):
+        return self._ratio
+
+    def setZoomRatio(self, ratio):
+        self._ratio = ratio
+
 class TimelineLayer(gtk.HBox):
 
     leftWidgetClass = None

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/ruler.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/ruler.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/ruler.py	Sun Jul 20 20:32:43 2008
@@ -45,7 +45,8 @@
     def __init__(self, hadj):
         gst.log("Creating new ScaleRule")
         gtk.Layout.__init__(self)
-        self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
+        self.add_events(gtk.gdk.POINTER_MOTION_MASK |
+            gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
         self.set_hadjustment(hadj)
         self.pixmap = None
         # position is in nanoseconds
@@ -65,7 +66,6 @@
     def getPixelWidth(self):
         return ZoomableWidgetInterface.getPixelWidth(self) + 2 * self.border
 
-
     ## timeline position changed method
 
     def timelinePositionChanged(self, value, unused_frame):



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