[pitivi: 2/4] SourceList: Add gstSources() method to get a sorted list of sources.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi: 2/4] SourceList: Add gstSources() method to get a sorted list of sources.
- Date: Mon, 20 Apr 2009 10:23:45 -0400 (EDT)
commit 013d1dfc9ed6fcee06cdf3496a5c1bb45ab1d4ac
Author: Edward Hervey <bilboed bilboed com>
Date: Mon Apr 20 12:36:41 2009 +0200
SourceList: Add gstSources() method to get a sorted list of sources.
The order is the order in which the sources were added to the SourceList
---
pitivi/sourcelist.py | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/pitivi/sourcelist.py b/pitivi/sourcelist.py
index 4b5eed0..6f5f36e 100644
--- a/pitivi/sourcelist.py
+++ b/pitivi/sourcelist.py
@@ -36,6 +36,8 @@ class SourceList(object, Signallable, Loggable):
@type project: L{Project}
@ivar discoverer: The discoverer used
@type discoverer: L{Discoverer}
+ @ivar sources: The sources
+ @type sources: Dictionnary of uri => factory
Signals:
- C{file_added} : A file has been completely discovered and is valid.
@@ -61,6 +63,7 @@ class SourceList(object, Signallable, Loggable):
self.log("new sourcelist for project %s", project)
self.project = project
self.sources = {}
+ self._sourceindex = []
self.tempsources = {}
self.discoverer = Discoverer()
self.discoverer.connect("not_media_file", self._notMediaFileCb)
@@ -77,6 +80,7 @@ class SourceList(object, Signallable, Loggable):
def __delitem__(self, uri):
try:
self.sources.__delitem__(uri)
+ self._sourceindex.__delitem__(uri)
except KeyError:
pass
else:
@@ -149,8 +153,19 @@ class SourceList(object, Signallable, Loggable):
if uri in self and self[uri]:
raise Exception("We already have an objectfactory for uri %s", uri)
self.sources[uri] = factory
+ self._sourceindex.append(uri)
self.emit("file_added", factory)
+ def getSources(self):
+ """ Returns the list of sources used.
+
+ The list will be ordered by the order in which they were added
+ """
+ res = []
+ for i in self._sourceindex:
+ res.append(self[i])
+ return res
+
def _finishedAnalyzingCb(self, unused_discoverer, factory):
# callback from finishing analyzing factory
if factory.name in self.tempsources:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]