[pitivi] timeline: Allow undoing a paste operation
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Allow undoing a paste operation
- Date: Wed, 22 Feb 2017 21:20:37 +0000 (UTC)
commit 16927e165f1cf3f1645b3ccba2f18b48e2fbcd4b
Author: Stefan Popa <stefanpopa2209 gmail com>
Date: Wed Feb 22 21:53:54 2017 +0100
timeline: Allow undoing a paste operation
When pasting a copied clip, the undo button behaves as if the paste
operation didn't take place (i.e. it undoes the operation previous to
the paste operation).
To fix this, I logged the paste operation in the action_log.
Fixes https://phabricator.freedesktop.org/T7688
Differential Revision: https://phabricator.freedesktop.org/D1678
pitivi/timeline/timeline.py | 8 ++++++--
tests/test_undo_timeline.py | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 7c5613e..77abb51 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1656,12 +1656,16 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.updateActions()
def __pasteClipsCb(self, unused_action, unused_parameter):
- if self.__copiedGroup:
+ if not self.__copiedGroup:
+ self.info("Nothing to paste.")
+ return
+
+ with self.app.action_log.started("paste",
+ CommitTimelineFinalizingAction(self._project.pipeline)):
save = self.__copiedGroup.copy(True)
position = self._project.pipeline.getPosition()
self.__copiedGroup.paste(position)
self.__copiedGroup = save
- self._project.pipeline.commit_timeline()
def _alignSelectedCb(self, unused_action, unused_parameter):
if not self.ges_timeline:
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 50654f9..de7e184 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -585,6 +585,40 @@ class TestLayerObserver(BaseTestUndoTimeline):
self.action_log.redo()
self.assertIsNotNone(self.get_transition_element(self.layer))
+ def test_paste_undo(self):
+ """Checks a paste operation can be undone."""
+ self.setup_timeline_container()
+ timeline = self.timeline_container.timeline
+ project = timeline.ges_timeline.get_asset()
+
+ # Create test clip
+ clip = common.create_test_clip(GES.TitleClip)
+ clip.props.start = 0
+ clip.props.duration = 10
+ self.layer.add_clip(clip)
+ self.assertEqual(len(self.layer.get_clips()), 1)
+
+ # Select the test clip
+ event = mock.Mock()
+ event.get_button.return_value = (True, 1)
+ with mock.patch.object(Gtk, "get_event_widget") as get_event_widget:
+ get_event_widget.return_value = clip.ui
+ clip.ui.timeline._button_press_event_cb(None, event)
+ clip.ui._button_release_event_cb(None, event)
+
+ self.timeline_container.copy_action.emit("activate", None)
+
+ position = 10
+ project.pipeline.getPosition = mock.Mock(return_value=position)
+ self.timeline_container.paste_action.emit("activate", None)
+ self.assertEqual(len(self.layer.get_clips()), 2)
+
+ self.action_log.undo()
+ self.assertEqual(len(self.layer.get_clips()), 1)
+
+ self.action_log.redo()
+ self.assertEqual(len(self.layer.get_clips()), 2)
+
class TestControlSourceObserver(BaseTestUndoTimeline):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]