[pitivi] clipproperties: Fix text transferring when switching selection
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] clipproperties: Fix text transferring when switching selection
- Date: Mon, 8 Mar 2021 21:43:56 +0000 (UTC)
commit e0dfc124873eb911d83d61f091c8684bd70babfd
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Sun Mar 7 23:38:30 2021 +0100
clipproperties: Fix text transferring when switching selection
When the title UI was being updated, the previous title clip was being
changed to contain the text of the newly selected title clip.
Fixes #2545
pitivi/clip_properties/title.py | 5 +--
tests/test_clipproperties.py | 76 +++++++++++++++++++++++++++++++----------
2 files changed, 61 insertions(+), 20 deletions(-)
---
diff --git a/pitivi/clip_properties/title.py b/pitivi/clip_properties/title.py
index a1a61b62b..fdd906196 100644
--- a/pitivi/clip_properties/title.py
+++ b/pitivi/clip_properties/title.py
@@ -221,13 +221,14 @@ class TitleProperties(Gtk.Expander, Loggable):
self.source.disconnect(self._children_props_handler)
self._children_props_handler = None
+ self.source = None
+
if source:
assert isinstance(source, (GES.TextOverlay, GES.TitleSource))
self._update_from_source(source)
self._children_props_handler = source.connect("deep-notify",
self._source_deep_notify_cb)
-
- self.source = source
+ self.source = source
self.set_visible(bool(self.source))
diff --git a/tests/test_clipproperties.py b/tests/test_clipproperties.py
index af5cc89ae..efc237457 100644
--- a/tests/test_clipproperties.py
+++ b/tests/test_clipproperties.py
@@ -274,7 +274,7 @@ class TransformationPropertiesTest(common.TestCase):
self.assertEqual(value, source.ui.default_position[prop])
-class ClipPropertiesTest(common.TestCase):
+class TitlePropertiesTest(common.TestCase):
"""Tests for the TitleProperties class."""
def _get_title_source_child_props(self):
@@ -321,7 +321,6 @@ class ClipPropertiesTest(common.TestCase):
# Modify the title.
mod_title = "Modifed Title"
self.clipproperties.title_expander.textbuffer.props.text = mod_title
- self.clipproperties.title_expander.textbuffer.props.text = mod_title
ps2 = self._get_title_source_child_props()
self.assertEqual(ps2["text"][1], mod_title)
self.assertNotEqual(ps1["text"], ps2["text"])
@@ -336,6 +335,63 @@ class ClipPropertiesTest(common.TestCase):
ps4 = self._get_title_source_child_props()
self.assertDictEqual(ps2, ps4)
+ @common.setup_timeline
+ @common.setup_clipproperties
+ def test_selection_does_nothing(self):
+ """Checks de/selection do not create undoable operations."""
+ self.project.pipeline.get_position = mock.Mock(return_value=0)
+ self.clipproperties.create_title_clip_cb(None)
+ self.assertEqual(len(self.action_log.undo_stacks), 1)
+ clips = self.layer.get_clips()
+ self.assertEqual(len(clips), 1, clips)
+
+ self.timeline_container.timeline.selection.unselect(clips)
+ self.assertEqual(len(self.action_log.undo_stacks), 1)
+
+ self.timeline_container.timeline.selection.select(clips)
+ self.assertEqual(len(self.action_log.undo_stacks), 1)
+
+ @common.setup_timeline
+ @common.setup_clipproperties
+ def test_xxx(self):
+ """Exercise creating a title clip."""
+ self.project.pipeline.get_position = mock.Mock(return_value=0)
+
+ # Create the first clip.
+ self.clipproperties.create_title_clip_cb(None)
+ clip1, = self.layer.get_clips()
+ source1, = clip1.get_children(False)
+ self.clipproperties.title_expander.textbuffer.props.text = "TC1"
+ self.assertEqual(source1.get_child_property("text"), (True, "TC1"))
+
+ # Make place for the second clip at the beginning of the layer.
+ clip1.props.start = clip1.props.duration
+
+ # Create the second clip.
+ self.clipproperties.create_title_clip_cb(None)
+ clip2, clip1_ = self.layer.get_clips()
+ self.assertIs(clip1_, clip1)
+ source2, = clip2.get_children(False)
+ self.clipproperties.title_expander.textbuffer.props.text = "TC2"
+ self.assertEqual(source2.get_child_property("text"), (True, "TC2"))
+
+ self.assertEqual(source2.get_child_property("text"), (True, "TC2"))
+ self.assertEqual(source1.get_child_property("text"), (True, "TC1"))
+
+ # Switch back to clip1.
+ self.timeline_container.timeline.selection.select([clip1])
+ self.assertEqual(source1.get_child_property("text"), (True, "TC1"))
+ self.assertEqual(source2.get_child_property("text"), (True, "TC2"))
+
+ # Switch back to clip2.
+ self.timeline_container.timeline.selection.select([clip2])
+ self.assertEqual(source1.get_child_property("text"), (True, "TC1"))
+ self.assertEqual(source2.get_child_property("text"), (True, "TC2"))
+
+
+class ClipPropertiesTest(common.TestCase):
+ """Tests for the ClipProperties class."""
+
@common.setup_timeline
@common.setup_clipproperties
def test_alignment_editor(self):
@@ -374,22 +430,6 @@ class ClipPropertiesTest(common.TestCase):
self.assertEqual(source.get_child_property("posx").value, -width)
self.assertEqual(source.get_child_property("posy").value, -height)
- @common.setup_timeline
- @common.setup_clipproperties
- def test_selection_does_nothing(self):
- """Checks de/selection do not create undoable operations."""
- self.project.pipeline.get_position = mock.Mock(return_value=0)
- self.clipproperties.create_title_clip_cb(None)
- self.assertEqual(len(self.action_log.undo_stacks), 1)
- clips = self.layer.get_clips()
- self.assertEqual(len(clips), 1, clips)
-
- self.timeline_container.timeline.selection.unselect(clips)
- self.assertEqual(len(self.action_log.undo_stacks), 1)
-
- self.timeline_container.timeline.selection.select(clips)
- self.assertEqual(len(self.action_log.undo_stacks), 1)
-
class SpeedPropertiesTest(common.TestCase):
"""Tests for the TransformationProperties widget."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]