[pitivi] undo: Rename log fields to action_log



commit 38201b2fea242efa500565bd42dffad8cc05fae7
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Wed Apr 6 14:47:50 2016 +0200

    undo: Rename log fields to action_log
    
    log conflicts with Loggable.log and might be confusing.
    Also, it's not just a log, it can go back and forth.
    
    Differential Revision: https://phabricator.freedesktop.org/D894

 pitivi/application.py       |    2 +-
 pitivi/undo/project.py      |   10 +++++-----
 pitivi/undo/timeline.py     |   36 ++++++++++++++++++------------------
 tests/test_undo_timeline.py |    5 +++--
 4 files changed, 27 insertions(+), 26 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 285ca5e..207e1ae 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -268,7 +268,7 @@ class Pitivi(Gtk.Application, Loggable):
         self.action_log.connect("undo", self._actionLogUndo)
         self.action_log.connect("redo", self._actionLogRedo)
 
-        timeline_observer = TimelineObserver(self.action_log)
+        timeline_observer = TimelineObserver(self.action_log, app=self)
         timeline_observer.startObserving(project.timeline)
 
         project_observer = ProjectObserver(self.action_log)
diff --git a/pitivi/undo/project.py b/pitivi/undo/project.py
index 06f7805..8ef08ec 100644
--- a/pitivi/undo/project.py
+++ b/pitivi/undo/project.py
@@ -87,11 +87,11 @@ class ProjectObserver():
     """Monitors a project instance and reports UndoableActions.
 
     Attributes:
-        log (UndoableActionLog): The action log where to report actions.
+        action_log (UndoableActionLog): The action log where to report actions.
     """
 
-    def __init__(self, log):
-        self.log = log
+    def __init__(self, action_log):
+        self.action_log = action_log
 
     def startObserving(self, project):
         """Starts monitoring the specified Project.
@@ -115,8 +115,8 @@ class ProjectObserver():
 
     def _assetAddedCb(self, project, asset):
         action = AssetAddedAction(project, asset)
-        self.log.push(action)
+        self.action_log.push(action)
 
     def _assetRemovedCb(self, project, asset):
         action = AssetRemovedAction(project, asset)
-        self.log.push(action)
+        self.action_log.push(action)
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 3606a6b..d8c24ec 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -525,16 +525,16 @@ class TimelineObserver(Loggable):
     timelinePropertyChangedAction = ClipPropertyChanged
     activePropertyChangedAction = ActivePropertyChanged
 
-    def __init__(self, log):
+    def __init__(self, action_log, app):
         Loggable.__init__(self)
-
-        self.log = log
+        self.action_log = action_log
+        self.app = app
         self.clip_property_trackers = {}
         self.control_source_keyframe_trackers = {}
-        self.children_props_tracker = TrackElementChildPropertyTracker(log)
+        self.children_props_tracker = TrackElementChildPropertyTracker(self.action_log)
 
     def startObserving(self, timeline):
-        """Starts monitoring the specified Timeline.
+        """Starts monitoring the specified timeline.
 
         Args:
             timeline (GES.Timeline): The timeline to be monitored.
@@ -625,8 +625,8 @@ class TimelineObserver(Loggable):
         tracker.connect("keyframe-moved", self._controlSourceKeyFrameMovedCb)
         self.control_source_keyframe_trackers[control_source] = tracker
 
-        if self.log.app and not existed:
-            self.log.app.write_action("set-control-source",
+        if not existed:
+            self.app.write_action("set-control-source",
                                       {"element-name": track_element.get_name(),
                                        "property-name": binding.props.name,
                                        "binding-type": "direct",
@@ -656,14 +656,14 @@ class TimelineObserver(Loggable):
             return
         self._connectToClip(clip)
         action = ClipAdded(layer, clip)
-        self.log.push(action)
+        self.action_log.push(action)
 
     def _clipRemovedCb(self, layer, clip):
         if isinstance(clip, GES.TransitionClip):
             return
         self._disconnectFromClip(clip)
         action = ClipRemoved(layer, clip)
-        self.log.push(action)
+        self.action_log.push(action)
 
     def _clipPropertyChangedCb(self, tracker, clip,
                                property_name, old_value, new_value):
@@ -673,14 +673,14 @@ class TimelineObserver(Loggable):
         action = self.timelinePropertyChangedAction(clip, property_name,
                                                     old_value, new_value)
         setattr(tracker, attr_name, new_value)
-        self.log.push(action)
+        self.action_log.push(action)
 
     def _clipTrackElementAddedCb(self, clip, track_element):
         self._connectToTrackElement(track_element)
         if isinstance(track_element, GES.BaseEffect):
             action = TrackElementAdded(clip, track_element,
                                        self.children_props_tracker)
-            self.log.push(action)
+            self.action_log.push(action)
 
     def _clipTrackElementRemovedCb(self, clip, track_element):
         self.debug("%s REMOVED from (%s)" % (track_element, clip))
@@ -688,41 +688,41 @@ class TimelineObserver(Loggable):
         if isinstance(track_element, GES.BaseEffect):
             action = TrackElementRemoved(clip, track_element,
                                          self.children_props_tracker)
-            self.log.push(action)
+            self.action_log.push(action)
 
     def _controlSourceKeyFrameAddedCb(self, source, keyframe, track_element,
                                       property_name):
         action = ControlSourceValueAdded(track_element,
                                          source, keyframe, property_name)
-        self.log.push(action)
+        self.action_log.push(action)
 
     def _controlSourceKeyFrameRemovedCb(self, source, keyframe, track_element,
                                         property_name):
         action = ControlSourceValueRemoved(track_element,
                                            source, keyframe, property_name)
-        self.log.push(action)
+        self.action_log.push(action)
 
     def _trackElementActiveChangedCb(self, track_element, active, add_effect_action):
         """
         This happens when an effect is (de)activated on a clip in the timeline.
         """
         action = self.activePropertyChangedAction(add_effect_action, active)
-        self.log.push(action)
+        self.action_log.push(action)
 
     def _controlSourceKeyFrameMovedCb(self, tracker, track_element,
                                       keyframe, old_snapshot, new_snapshot):
         action = ControlSourceKeyframeChanged(track_element, keyframe,
                                               old_snapshot, new_snapshot)
-        self.log.push(action)
+        self.action_log.push(action)
 
     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)
+        self.action_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)
+        self.action_log.push(action)
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 12a6a4c..0260dbd 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -19,6 +19,7 @@
 # License along with this program; if not, write to the
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
+from unittest import mock
 from unittest import TestCase
 
 from gi.repository import GES
@@ -66,7 +67,7 @@ class TestTimelineLogObserver(TestCase):
 
     def setUp(self):
         self.action_log = UndoableActionLog()
-        self.observer = TimelineObserverSpy(self.action_log)
+        self.observer = TimelineObserverSpy(self.action_log, app=mock.Mock())
 
     def testConnectionAndDisconnection(self):
         timeline = GES.Timeline.new_audio_video()
@@ -106,7 +107,7 @@ class TestTimelineUndo(TestCase):
         self.timeline = app.project_manager.current_project.timeline
         self.layer = self.timeline.append_layer()
         self.action_log = UndoableActionLog()
-        self.observer = TimelineObserverSpy(self.action_log)
+        self.observer = TimelineObserverSpy(self.action_log, app=mock.Mock())
         self.observer.startObserving(self.timeline)
 
     def getTimelineClips(self):


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