[pitivi] pitivi: Add a method to get selected elements at a position



commit f04cdaf204ea664933ea524057158fae291c66f6
Author: Thibault Saunier <tsaunier gnome org>
Date:   Mon Jul 6 12:48:27 2015 +0200

    pitivi: Add a method to get selected elements at a position
    
    Summary:
    Factoring out some code and making the code simpler to follow.
    
    Depends on D269
    
    Reviewers: Mathieu_Du, aleb
    
    Differential Revision: https://phabricator.freedesktop.org/D270

 pitivi/utils/pipeline.py |    2 ++
 pitivi/utils/timeline.py |   11 +++++++++++
 pitivi/viewer.py         |   17 ++++++-----------
 3 files changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index 19d06fc..c74f4cf 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -700,6 +700,8 @@ class Pipeline(GES.Pipeline, SimplePipeline):
         SimplePipeline.simple_seek(self, position)
 
     def _busMessageCb(self, bus, message):
+        if message.type == Gst.MessageType.ASYNC_DONE:
+            self.commiting = False
         if message.type == Gst.MessageType.ASYNC_DONE and\
                 self._commit_wanted:
             self.debug("Commiting now that ASYNC is DONE")
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index 4bc98f9..ec24d71 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -172,6 +172,17 @@ class Selection(GObject.Object, Loggable):
 
         return set(objects)
 
+    def getSelectedTrackElementsAtPosition(self, position, element_type=GObject.Object,
+                                           track_type=GES.TrackType.UNKNOWN):
+        selected = []
+        for clip in self.selected:
+            if clip.props.start <= position and position <= clip.props.start + clip.props.duration:
+                elements = clip.find_track_elements(None, track_type, element_type)
+                if elements:
+                    selected.extend(elements)
+
+        return selected
+
     def getSelectedEffects(self):
         """
         Returns the list of L{GES.BaseEffect} contained in this selection.
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index a41c86c..3c5a542 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -503,17 +503,12 @@ class TransformationBox(Gtk.EventBox, Loggable):
             return False
 
         self.__editSource = None
-        for clip in self.app.project_manager.current_project.timeline.ui.selection.selected:
-            if clip.props.start <= position and position <= clip.props.start + clip.props.duration:
-                video_source = clip.find_track_elements(None, GES.TrackType.VIDEO, GES.VideoSource)
-                if video_source and self.__editSource:
-                    video_source = None
-                    break
-
-                try:
-                    self.__editSource = video_source[0]
-                except IndexError:
-                    continue
+        selection = self.app.project_manager.current_project.timeline.ui.selection
+        selected_videoelements = selection.getSelectedTrackElementsAtPosition(position,
+                                                                              GES.VideoSource,
+                                                                              GES.TrackType.VIDEO)
+        if len(selected_videoelements) == 1:
+            self.__editSource = selected_videoelements[0]
 
     def do_event(self, event):
         if event.type == Gdk.EventType.ENTER_NOTIFY and event.mode == Gdk.CrossingMode.NORMAL:


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