[pitivi] undo: Squash undo and redo signals into one



commit b36bc1b42defd1626b3e3f6bd1b927d4272210e8
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Tue Apr 26 15:55:06 2016 +0200

    undo: Squash undo and redo signals into one
    
    Both signals tell more or less the same thing, that the undo log
    changed. We don't care whether something has been added or removed, so
    they can be merged.
    
    Differential Revision: https://phabricator.freedesktop.org/D965

 pitivi/application.py |    8 ++------
 pitivi/undo/undo.py   |    7 +++----
 tests/test_undo.py    |    7 +++----
 3 files changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 5d27292..4d63403 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -267,8 +267,7 @@ class Pitivi(Gtk.Application, Loggable):
         self.action_log = UndoableActionLog()
         self.action_log.connect("pre-push", self._action_log_pre_push_cb)
         self.action_log.connect("commit", self._actionLogCommit)
-        self.action_log.connect("undo", self._actionLogUndo)
-        self.action_log.connect("redo", self._actionLogRedo)
+        self.action_log.connect("move", self._action_log_move_cb)
 
         timeline_observer = TimelineObserver(self.action_log, app=self)
         timeline_observer.startObserving(project.timeline)
@@ -368,10 +367,7 @@ class Pitivi(Gtk.Application, Loggable):
             return
         self._syncDoUndo()
 
-    def _actionLogUndo(self, action_log, unused_stack):
-        self._syncDoUndo()
-
-    def _actionLogRedo(self, action_log, unused_stack):
+    def _action_log_move_cb(self, action_log, unused_stack):
         self._syncDoUndo()
 
     def _syncDoUndo(self):
diff --git a/pitivi/undo/undo.py b/pitivi/undo/undo.py
index f8cb150..6e300ed 100644
--- a/pitivi/undo/undo.py
+++ b/pitivi/undo/undo.py
@@ -137,8 +137,7 @@ class UndoableActionLog(GObject.Object, Loggable):
         "push": (GObject.SIGNAL_RUN_LAST, None, (object, object)),
         "rollback": (GObject.SIGNAL_RUN_LAST, None, (object,)),
         "commit": (GObject.SIGNAL_RUN_LAST, None, (object,)),
-        "undo": (GObject.SIGNAL_RUN_LAST, None, (object,)),
-        "redo": (GObject.SIGNAL_RUN_LAST, None, (object,)),
+        "move": (GObject.SIGNAL_RUN_LAST, None, (object,)),
     }
 
     def __init__(self):
@@ -245,7 +244,7 @@ class UndoableActionLog(GObject.Object, Loggable):
         stack = self.undo_stacks.pop(-1)
         self._run(stack.undo)
         self.redo_stacks.append(stack)
-        self.emit("undo", stack)
+        self.emit("move", stack)
 
     def redo(self):
         """
@@ -259,7 +258,7 @@ class UndoableActionLog(GObject.Object, Loggable):
         stack = self.redo_stacks.pop(-1)
         self._run(stack.do)
         self.undo_stacks.append(stack)
-        self.emit("redo", stack)
+        self.emit("move", stack)
 
     def _takeSnapshot(self):
         return list(self.undo_stacks)
diff --git a/tests/test_undo.py b/tests/test_undo.py
index cbfc351..19ce2d9 100644
--- a/tests/test_undo.py
+++ b/tests/test_undo.py
@@ -173,8 +173,7 @@ class TestUndoableActionLog(TestCase):
         self.signals.append((signalName, args))
 
     def _connectToUndoableActionLog(self, log):
-        for signalName in ("begin", "push", "rollback", "commit",
-                           "undo", "redo"):
+        for signalName in ("begin", "push", "rollback", "commit", "move"):
             log.connect(signalName, self._undoActionLogSignalCb, signalName)
 
     def _disconnectFromUndoableActionLog(self, log):
@@ -380,7 +379,7 @@ class TestUndoableActionLog(TestCase):
         self.log.undo()
         self.assertEqual(len(self.signals), 5)
         name, stack = self.signals[4]
-        self.assertEqual(name, "undo")
+        self.assertEqual(name, "move")
         self.assertEqual(len(self.log.undo_stacks), 0)
         self.assertEqual(len(self.log.redo_stacks), 1)
 
@@ -391,7 +390,7 @@ class TestUndoableActionLog(TestCase):
         self.log.redo()
         self.assertEqual(len(self.signals), 6)
         name, stack = self.signals[5]
-        self.assertEqual(name, "redo")
+        self.assertEqual(name, "move")
         self.assertEqual(len(self.log.undo_stacks), 1)
         self.assertEqual(len(self.log.redo_stacks), 0)
 


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