[pitivi] undo: Add LayerAdded and LayerRemoved actions.



commit d392f1c31ece62005c95c59b7c860f30d345144e
Author: Mathieu Duponchelle <mathieu duponchelle opencreed com>
Date:   Fri May 2 13:02:08 2014 +0200

    undo: Add LayerAdded and LayerRemoved actions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739251

 pitivi/undo/timeline.py |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index ad85ed0..173cd8b 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -147,6 +147,30 @@ class ClipRemoved(UndoableAction):
         self._undone()
 
 
+class LayerAdded(UndoableAction):
+    def __init__(self, timeline, layer):
+        self.timeline = timeline
+        self.layer = layer
+
+    def do(self):
+        self.timeline.add_layer(self.layer)
+
+    def undo(self):
+        self.timeline.remove_layer(self.layer)
+
+
+class LayerRemoved(UndoableAction):
+    def __init__(self, timeline, layer):
+        self.timeline = timeline
+        self.layer = layer
+
+    def do(self):
+        self.timeline.remove_layer(self.layer)
+
+    def undo(self):
+        self.timeline.add_layer(self.layer)
+
+
 class InterpolatorKeyframeAdded(UndoableAction):
 
     def __init__(self, track_element, keyframe):
@@ -379,7 +403,11 @@ class TimelineLogObserver(object):
     def _layerAddedCb(self, timeline, layer):
         layer.connect("clip-added", self._clipAddedCb)
         layer.connect("clip-removed", self._clipRemovedCb)
+        action = LayerAdded(timeline, layer)
+        self.log.push(action)
 
     def _layerRemovedCb(self, timeline, layer):
         layer.disconnect_by_func(self._clipAddedCb)
         layer.disconnect_by_func(self._clipRemovedCb)
+        action = LayerRemoved(timeline, layer)
+        self.log.push(action)


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