[pitivi] timeline: Select newly pasted clips
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Select newly pasted clips
- Date: Thu, 8 Apr 2021 15:15:52 +0000 (UTC)
commit dbc5328d9ce61d9b1aaad1c1a6c3759da0bf602f
Author: Piotrek Brzeziński <thewildtree outlook com>
Date: Tue Apr 6 13:03:00 2021 +0200
timeline: Select newly pasted clips
Automatically selects clip(s) after they're pasted on the timeline.
Fixes #2529.
pitivi/timeline/timeline.py | 11 ++++++-----
tests/test_timeline_timeline.py | 28 ++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index e30c2f383..68632c794 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -2000,16 +2000,17 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
with self.app.action_log.started("paste",
finalizing_action=CommitTimelineFinalizingAction(self._project.pipeline),
toplevel=True):
- copied_group_shallow_copy = self.__copied_group.paste(position)
- if not copied_group_shallow_copy:
+ pasted_group = self.__copied_group.paste(position)
+ if not pasted_group:
self.info("The paste is not possible at position: %s", position)
return
-
+ self.timeline.selection.select(pasted_group.children)
try:
- self.__copied_group = copied_group_shallow_copy.copy(True)
+ # We need to recreate the copied group as pasting destroys it.
+ self.__copied_group = pasted_group.copy(True)
self.__copied_group.props.serialize = False
finally:
- copied_group_shallow_copy.ungroup(recursive=False)
+ pasted_group.ungroup(recursive=False)
def __add_layer_cb(self, unused_action, unused_parameter):
with self.app.action_log.started("add layer",
diff --git a/tests/test_timeline_timeline.py b/tests/test_timeline_timeline.py
index 0bb993cf7..e5f323b69 100644
--- a/tests/test_timeline_timeline.py
+++ b/tests/test_timeline_timeline.py
@@ -559,6 +559,34 @@ class TestCopyPaste(common.TestCase):
timeline_container.paste_action.emit("activate", None)
self.assertEqual(len(layer.get_clips()), 1)
+ def test_paste_selection(self):
+ timeline_container = self.copy_clips(1)
+ timeline = timeline_container.timeline
+ layer = timeline.ges_timeline.get_layers()[0]
+ project = timeline.ges_timeline.get_asset()
+
+ # Paste a single clip.
+ clips = layer.get_clips()
+ self.assertEqual(len(clips), 1)
+ position = 10
+ project.pipeline.get_position = mock.Mock(return_value=position)
+ timeline_container.paste_action.emit("activate", None)
+
+ clips = layer.get_clips()
+ self.assertListEqual([bool(clip.selected) for clip in clips], [False, True])
+
+ # The copy_clips() above simulates CTRL button press, so this will add 1st clip to the selection.
+ self.toggle_clip_selection(clips[0], True)
+ timeline_container.copy_action.emit("activate", None)
+
+ # Paste two clips.
+ position = 20
+ project.pipeline.get_position = mock.Mock(return_value=position)
+ timeline_container.paste_action.emit("activate", None)
+
+ clips = layer.get_clips()
+ self.assertListEqual([bool(clip.selected) for clip in clips], [False, False, True, True])
+
class TestEditing(common.TestCase):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]