[pitivi/ges] When trimming image clips, don't try to preview them in viewer



commit 59c6e7c55151fc4387b79662e02a2d53ebe2d9de
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Mon Apr 30 23:19:12 2012 -0400

    When trimming image clips, don't try to preview them in viewer

 pitivi/timeline/track.py |    8 ++++----
 pitivi/utils/timeline.py |    5 ++---
 pitivi/viewer.py         |   16 ++++++++++++----
 3 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index 45dab3d..409d21f 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -274,9 +274,9 @@ class StartHandle(TrimHandle):
 
             self._view.app.action_log.begin("trim object")
 
-        def clipTrimCb(self, unused_TrimStartContext, clip_uri, position):
+        def clipTrimCb(self, unused_TrimStartContext, tl_obj, position):
             # While a clip is being trimmed, ask the viewer to preview it
-            self._view.app.gui.viewer.clipTrimPreview(clip_uri, position)
+            self._view.app.gui.viewer.clipTrimPreview(tl_obj, position)
 
         def clipTrimFinishedCb(self, unused_TrimStartContext):
             # When a clip has finished trimming, tell the viewer to reset itself
@@ -306,9 +306,9 @@ class EndHandle(TrimHandle):
             self._context.connect("clip-trim-finished", self.clipTrimFinishedCb)
             self._view.app.action_log.begin("trim object")
 
-        def clipTrimCb(self, unused_TrimStartContext, clip_uri, position):
+        def clipTrimCb(self, unused_TrimStartContext, tl_obj, position):
             # While a clip is being trimmed, ask the viewer to preview it
-            self._view.app.gui.viewer.clipTrimPreview(clip_uri, position)
+            self._view.app.gui.viewer.clipTrimPreview(tl_obj, position)
 
         def clipTrimFinishedCb(self, unused_TrimStartContext):
             # When a clip has finished trimming, tell the viewer to reset itself
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index ad4a66a..7a5075f 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -242,11 +242,10 @@ class EditingContext(Signallable):
 
         res = self.focus.edit([], priority, self.mode, self.edge, long(position))
         if res and self.mode == ges.EDIT_MODE_TRIM:
-            uri = self.focus.props.uri
             if self.edge == ges.EDGE_START:
-                self.emit("clip-trim", uri, self.focus.props.in_point)
+                self.emit("clip-trim", self.focus, self.focus.props.in_point)
             elif self.edge == ges.EDGE_END:
-                self.emit("clip-trim", uri, self.focus.props.duration)
+                self.emit("clip-trim", self.focus, self.focus.props.duration)
 
 
 #-------------------------- Interfaces ----------------------------------------#
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index 8f7453f..987e61f 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -496,10 +496,17 @@ class PitiviViewer(gtk.VBox, Loggable):
         self.positionCheck()
         return self.currentState != gst.STATE_PAUSED
 
-    def clipTrimPreview(self, clip_uri, position):
+    def clipTrimPreview(self, tl_obj, position):
         """
         While a clip is being trimmed, show a live preview of it.
         """
+        self._clipTrimPreviewed = True
+        if tl_obj.props.is_image or not hasattr(tl_obj, "get_uri"):
+            self.log("%s is an image or has no URI, so not previewing trim" % tl_obj)
+            self._clipTrimPreviewed = False
+            return False
+
+        clip_uri = tl_obj.props.uri
         cur_time = time()
         if not self._tmp_pipeline:
             self.debug("Creating temporary pipeline for clip %s, position %s",
@@ -519,9 +526,10 @@ class PitiviViewer(gtk.VBox, Loggable):
         """
         After trimming a clip, reset the project pipeline into the viewer.
         """
-        self._tmp_pipeline = None  # Free the memory
-        self.setPipeline(self.app.current.pipeline, self._oldTimelinePos)
-        self.debug("Back to old pipeline")
+        if self._clipTrimPreviewed:
+            self._tmp_pipeline = None  # Free the memory
+            self.setPipeline(self.app.current.pipeline, self._oldTimelinePos)
+            self.debug("Back to old pipeline")
 
     def pipelineStateChanged(self, state):
         """



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