[pitivi: 11/14] git add pitivi/sourcelist_undo.py
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi: 11/14] git add pitivi/sourcelist_undo.py
- Date: Wed, 24 Jun 2009 13:11:10 +0000 (UTC)
commit f9059dae6153f94baf7ab91b5255c4a58a89e165
Author: Alessandro Decina <alessandro d gmail com>
Date: Wed Jun 24 11:21:47 2009 +0200
git add pitivi/sourcelist_undo.py
pitivi/sourcelist_undo.py | 79 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/sourcelist_undo.py b/pitivi/sourcelist_undo.py
new file mode 100644
index 0000000..b1ada4c
--- /dev/null
+++ b/pitivi/sourcelist_undo.py
@@ -0,0 +1,79 @@
+# PiTiVi , Non-linear video editor
+#
+# pitivi/sourcelist_undo.py
+#
+# Copyright (c) 2009, Alessandro Decina <alessandro d gmail com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+from pitivi.undo import UndoableAction
+
+class SourceListSourceAddedAction(UndoableAction):
+ def __init__(self, sourcelist, source):
+ self.sourcelist = sourcelist
+ self.source = source
+
+ def undo(self):
+ self.sourcelist.removeUri(self.source.uri)
+ self._undone()
+
+ def do(self):
+ self.sourcelist.addFactory(self.source)
+ self._done()
+
+class SourceListSourceRemovedAction(UndoableAction):
+ def __init__(self, sourcelist, uri, source):
+ self.sourcelist = sourcelist
+ self.uri = uri
+ self.source = source
+
+ def undo(self):
+ self.sourcelist.addFactory(self.source.uri, self.source)
+ self._undone()
+
+ def do(self):
+ del self.sourcelist[self.source.uri]
+ self._done()
+
+class SourceListLogObserver(object):
+ def __init__(self, log):
+ self.log = log
+
+ def startObserving(self, sourcelist):
+ self._connectToSourcelist(sourcelist)
+
+ def stopObserving(self, sourcelist):
+ self._disconnectFromSourcelist(sourcelist)
+
+ def _connectToSourcelist(self, sourcelist):
+ sourcelist.connect("source-added", self._sourceAddedCb)
+ sourcelist.connect("source-removed", self._sourceRemovedCb)
+
+ def _disconnectFromSourcelist(self, sourcelist):
+ sourcelist.disconnect_by_func(self._sourceAddedCb)
+ sourcelist.disconnect_by_func(self._sourceRemovedCb)
+
+ def _sourceAddedCb(self, sourcelist, factory):
+ self.log.begin("add source")
+ action = SourceListSourceAddedAction(sourcelist, factory)
+ self.log.push(action)
+ self.log.commit()
+
+ def _sourceRemovedCb(self, sourcelist, uri, factory):
+ self.log.begin("remove source")
+ action = SourceListSourceRemovedAction(sourcelist, uri, factory)
+ self.log.push(action)
+ self.log.commit()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]