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



Author: blewis
Date: Fri Jul 11 13:47:48 2008
New Revision: 1165
URL: http://svn.gnome.org/viewvc/pitivi?rev=1165&view=rev

Log:
File load works in advanced UI now! \0/
* pitivi/ui/complexlayer.py:
added setTimeline() method, which removes all current layers and then adds
a new layer for each composition in the new timeline.
* pitivi/ui/complextimeline.py:
added signal handlers for clearing and loading new projects
UI now proerly handles layer-added, layer-removed signals
some UI bug fixes to make sure new layers are properly displayed
temporarily broke code for ruler resizing, but this will get fixed later
when the timeline layout is changed.


Modified:
   branches/SOC_2008_BLEWIS/ChangeLog
   branches/SOC_2008_BLEWIS/pitivi/ui/complexlayer.py
   branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.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	Fri Jul 11 13:47:48 2008
@@ -70,17 +70,22 @@
     __gsignals__ = {
         'layer-added' : ( gobject.SIGNAL_RUN_LAST,
                           gobject.TYPE_NONE,
-                          ( gobject.TYPE_INT, ) ),
+                          ( gobject.TYPE_PYOBJECT, gobject.TYPE_INT, ) ),
         'layer-removed' : ( gobject.SIGNAL_RUN_LAST,
                           gobject.TYPE_NONE,
                           ( gobject.TYPE_INT, ) ),
         }
 
-    def __init__(self, timeline):
+    def __init__(self):
         gobject.GObject.__init__(self)
-        self.timeline = timeline
+        self.timeline = None
         self._list = []
-        self._fillList()
+
+    def setTimeline(self, timeline):
+        self._clear()
+        self.timeline = timeline
+        if self.timeline:
+            self._fillList()
 
     def _fillList(self):
         gst.debug("filling up LayerInfoList")
@@ -105,7 +110,7 @@
             self._list.append(layer)
         else:
             self._list.insert(pos, layer)
-        self.emit('layer-added', pos)
+        self.emit('layer-added', layer, pos)
         return layer
 
     def removeComposition(self, composition):
@@ -121,6 +126,11 @@
         self._list.remove(layer)
         self.emit('layer-removed', position)
 
+    def _clear(self):
+        while len(self._list):
+            layer = self._list[0]
+            self.removeComposition(layer.composition)
+
     def findCompositionLayerInfo(self, composition):
         """ Returns the LayerInfo corresponding to the given composition """
         for layer in self._list:

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	Fri Jul 11 13:47:48 2008
@@ -226,12 +226,10 @@
         self.layers.connect("notify::width", self._request_size)
         self.layers.connect("notify::height", self._request_size)
         self.get_root_item().add_child(self.layers)
-        for layerinfo in self.layerInfoList:
-            self._layerAddedCb(layerinfo)
         self._marquee = make_item(MARQUEE)
         manage_selection(self, self._marquee, True, self._selection_changed_cb)
 
-    ## ZoomableWidgetInterface overrides
+## ZoomableWidgetInterface overrides
 
     def _selection_changed_cb(self, selected, deselected):
         for item in selected:
@@ -255,17 +253,20 @@
     def timelinePositionChanged(self, value, frame):
         pass
 
-    ## LayerInfoList callbacks
+## LayerInfoList callbacks
 
-    def _layerAddedCb(self, layer, position=-1):
+    def _layerAddedCb(self, unused_infolist, layer, position):
         track = ComplexTrack()
         track.set_composition(layer.composition)
         track.set_canvas(self)
-        self.layers.add_child(track)
+        self.layers.insert_child(track, position)
+        self.set_bounds(0, 0, self.layers.width, self.layers.height)
+        self.set_size_request(int(self.layers.width), int(self.layers.height))
 
     def _layerRemovedCb(self, unused_layerInfoList, position):
         #TODO handle this, and test it somehow
-        pass
+        child = self.layers.item_at(position)
+        self.layers.remove_child(child)
 #
 # Complex Timeline Design v2 (08 Feb 2006)
 #
@@ -301,14 +302,18 @@
         self.zoomratio = 10.0
 
         # common LayerInfoList
-        self.layerInfoList = LayerInfoList(instance.PiTiVi.current.timeline)
-        instance.PiTiVi.playground.connect('position', self._playgroundPositionCb)
-        for layer in self.layerInfoList:
-            layer.composition.connect('start-duration-changed',
-                                      self._layerStartDurationChangedCb)
-
+        self.layerInfoList = LayerInfoList()
+        
+        # project signals
+        instance.PiTiVi.connect("new-project-loading",
+            self._newProjectLoadingCb)
+        instance.PiTiVi.connect("new-project-failed",
+            self._newProjectFailedCb)
         self._createUI()
 
+        # force update of UI
+        self.layerInfoList.setTimeline(instance.PiTiVi.current.timeline)
+
     def _createUI(self):
         self.set_border_width(4)
         self.leftSizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
@@ -333,14 +338,17 @@
         self.scrolledWindow.add(self.compositionLayers)
         self.pack_start(self.scrolledWindow, expand=True)
 
-    def _layerStartDurationChangedCb(self, unused_composition, unused_start,
-                                     unused_duration):
-        # Force resize of ruler
-        self.topLayer.startDurationChanged()
-
-    ## ZoomableWidgetInterface overrides
-    ## * we send everything to self.compositionLayers
-    ## * topLayer's function calls will also go there
+## Project callbacks
+
+    def _newProjectLoadingCb(self, unused_inst, project):
+        self.layerInfoList.setTimeline(project.timeline)
+
+    def _newProjectFailedCb(self, unused_inst, unused_reason, unused_uri):
+        self.layerInfoList.setTimeline(None)
+
+## ZoomableWidgetInterface overrides
+## * we send everything to self.compositionLayers
+## * topLayer's function calls will also go there
 
     def getDuration(self):
         return self.compositionLayers.getDuration()
@@ -352,12 +360,12 @@
         self.topLayer.rightWidget.zoomChanged()
         self.compositionLayers.zoomChanged()
 
-    ## ToolBar callbacks
+## ToolBar callbacks
 
     def toolBarZoomChangedCb(self, unused_toolbar, zoomratio):
         self.setZoomRatio(zoomratio)
 
-    ## PlayGround timeline position callback
+## PlayGround timeline position callback
 
     def _playgroundPositionCb(self, unused_playground, smartbin, value):
         if isinstance(smartbin, SmartTimelineBin):



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