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



Author: blewis
Date: Thu Jul 10 16:10:34 2008
New Revision: 1163
URL: http://svn.gnome.org/viewvc/pitivi?rev=1163&view=rev

Log:
* pitivi/ui/timeline.py:
fix bug created by previous commit in which files were added to old
timeline after new project has loaded.
* pitivi/ui/timelineobjects.py:
fixed exception being thrown on newProjectLoaded


Modified:
   branches/SOC_2008_BLEWIS/ChangeLog
   branches/SOC_2008_BLEWIS/pitivi/ui/timeline.py
   branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/timeline.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/timeline.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/timeline.py	Thu Jul 10 16:10:34 2008
@@ -54,8 +54,6 @@
         self.connect("drag-data-received", self._dragDataReceivedCb)
         self.connect("drag-leave", self._dragLeaveCb)
         self.connect("drag-motion", self._dragMotionCb)
-        self.project = instance.PiTiVi.current
-        self.timeline = instance.PiTiVi.current.timeline
 
     def _createUi(self):
         """ draw the GUI """
@@ -103,14 +101,15 @@
             audiobrother = TimelineBlankSource(factory=filefactory,
                 media_type=MEDIA_TYPE_AUDIO, name=filefactory.name)
             source.setBrother(audiobrother)
-
+        
+        timeline = instance.PiTiVi.current.timeline
         if pos_ == -1:
-            self.timeline.videocomp.appendSource(source)
+            timeline.videocomp.appendSource(source)
         elif pos_:
-            self.timeline.videocomp.insertSourceAfter(source,
+            timeline.videocomp.insertSourceAfter(source,
                 self.condensed[pos_ - 1])
         else:
-            self.timeline.videocomp.prependSource(source)
+            timeline.videocomp.prependSource(source)
 
     def _dragMotionCb(self, unused_layout, unused_context, x, y, timestamp):
         #TODO: temporarily add source to timeline, and put it in drag mode

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py	Thu Jul 10 16:10:34 2008
@@ -178,15 +178,17 @@
     def __init__(self, timeline, *args, **kwargs):
         HList.__init__(self, *args, **kwargs)
         self.sig_ids = None
+        self.timeline = None
         self.set_timeline(timeline)
         self.reorderable = True
         self.widgets = {}
         self.elements = {}
 
     def set_timeline(self, timeline):
-        if self.sig_ids:
+        if self.timeline:
             for sig in self.sig_ids:
                 self.timeline.videocomp.disconnect(sig)
+            self.sig_ids = None
         self.timeline = timeline
         if timeline:
             #TODO: connect transition callbacks here
@@ -197,6 +199,7 @@
             removed = timeline.videocomp.connect("source-removed",
                 self._sourceRemovedCb)
             self.sig_ids = (changed, added, removed)
+            self._condensedListChangedCb(None, timeline.videocomp.condensed)
 
     # overriding from parent
     def swap(self, a, b):
@@ -215,11 +218,13 @@
     def _condensedListChangedCb(self, unused_videocomp, clist):
         """ add/remove the widgets """
         gst.debug("condensed list changed in videocomp")
+        #print "condensed list changed"
         order = [self.index(self.widgets[e]) for e in clist]
         self.reorder(order)
 
     def _sourceAddedCb(self, timeline, element):
         gst.debug("Adding new element to the layout")
+        #print "source added"
         if isinstance(element, TimelineFileSource):
             widget = SimpleSourceWidget(element)
             widget.connect("delete-me", self._sourceDeleteMeCb, element)
@@ -240,10 +245,17 @@
         self.add_child(self.widgets[element])
 
     def _sourceRemovedCb(self, timeline, element):
+        gst.debug("Removing element")
+        #print "source removed"
         self.remove_child(self.widgets[element])
         del self.elements[self.widgets[element]]
         del self.widgets[element]
 
+    def remove_all(self):
+        HList.remove_all(self)
+        self.elements = {}
+        self.widgets = {}
+
 ## Child callbacks
 
     def _sourceDeleteMeCb(self, unused_widget, element):
@@ -322,17 +334,14 @@
 
 ## Project callbacks
 
-    def _newProjectLoadingCb(self, unused_inst, unused_project):
-        gst.log("...")
+    def _newProjectLoadingCb(self, unused_inst, project):
+        #now we connect to the new project, so we can receive any
+        self.items.set_timeline(project.timeline)
 
     def _newProjectLoadedCb(self, unused_inst, project):
-        gst.log("...")
         assert(instance.PiTiVi.current == project)
-        #now we connect to the new project, so we can receive any
+
         #signals that might be emitted while the project is loading
-        self._connectToTimeline(project.timeline)
-        self._condensedListChangedCb(None, 
-            self.timeline.videocomp.condensed)
 
     def _newProjectFailedCb(self, unused_inst, unused_reason, unused_uri):
         # oops the project failed to load



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