[pitivi: 59/65] Methods to determine what sources are not used in the timeline



commit ddd7ad4381d97d55af9369e2b5dd625f90f77ff3
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Thu Jun 30 18:50:48 2011 -0400

    Methods to determine what sources are not used in the timeline

 pitivi/timeline/timeline.py |   12 ++++++++++++
 pitivi/ui/sourcelist.py     |   11 ++++++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 0c26ec4..5974150 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1642,6 +1642,18 @@ class Timeline(Signallable, Loggable):
         for obj in objs:
             self.removeTimelineObject(obj, deep=True)
 
+    def usesFactory(self, factory):
+        """
+        Return whether the specified factory is present in the timeline.
+        @param the factory you are looking for
+        @type factory
+        @returns True if found, or False if not in the timeline.
+        """
+        for obj in self.timeline_objects:
+            if obj.factory is factory:
+                return True
+        return False
+
     def _timelineObjectStartChangedCb(self, timeline_object, start):
         self.timeline_objects.remove(timeline_object)
         start_insort_right(self.timeline_objects, timeline_object)
diff --git a/pitivi/ui/sourcelist.py b/pitivi/ui/sourcelist.py
index 8ebf643..e069093 100644
--- a/pitivi/ui/sourcelist.py
+++ b/pitivi/ui/sourcelist.py
@@ -389,7 +389,7 @@ class SourceList(gtk.VBox, Loggable):
         self._removeSources()
 
     def _selectUnusedSourcesCb(self, widget):
-        pass
+        self._selectUnusedSources()
 
     def _insertEndCb(self, unused_action):
         self.app.action_log.begin("add clip")
@@ -709,6 +709,15 @@ class SourceList(gtk.VBox, Loggable):
             self.app.current.sources.removeUri(uri)
         self.app.action_log.commit()
 
+    def _selectUnusedSources(self):
+        """
+        Select, in the media library, unused sources in the project.
+        """
+        sources = self.app.current.sources.getSources()
+        for source in sources:
+            if not self.app.current.timeline.usesFactory(source):
+                print "Unused source:", source.name
+
     ## UI Button callbacks
 
     def _importButtonClickedCb(self, unused_widget=None):



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