[pitivi] titleeditor: Include the source child-props initialization in the undoable transaction



commit 3cbe5f52b25b185255a736747e198c62b84ae298
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Oct 7 00:31:12 2019 +0200

    titleeditor: Include the source child-props initialization in the undoable transaction
    
    Fixes #2293

 pitivi/titleeditor.py     | 27 ++++++++++++++-------------
 tests/test_titleeditor.py | 20 +++++++++++++++-----
 2 files changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index dfcd2394..871de9e0 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -247,19 +247,20 @@ class TitleEditor(Loggable):
         title_clip = GES.TitleClip()
         duration = self.app.settings.titleClipLength * Gst.MSECOND
         title_clip.set_duration(duration)
-        self.app.gui.editor.timeline_ui.insert_clips_on_first_layer([title_clip])
-        # Now that the clip is inserted in the timeline, it has a source which
-        # can be used to set its properties.
-        source = title_clip.get_children(False)[0]
-        properties = {"text": "",
-                      "foreground-color": BACKGROUND_DEFAULT_COLOR,
-                      "color": FOREGROUND_DEFAULT_COLOR,
-                      "font-desc": DEFAULT_FONT_DESCRIPTION,
-                      "valignment": DEFAULT_VALIGNMENT,
-                      "halignment": DEFAULT_HALIGNMENT}
-        for prop, value in properties.items():
-            res = source.set_child_property(prop, value)
-            assert res, prop
+        with self.app.action_log.started("add title clip", toplevel=True):
+            self.app.gui.editor.timeline_ui.insert_clips_on_first_layer([title_clip])
+            # Now that the clip is inserted in the timeline, it has a source which
+            # can be used to set its properties.
+            source = title_clip.get_children(False)[0]
+            properties = {"text": "",
+                          "foreground-color": BACKGROUND_DEFAULT_COLOR,
+                          "color": FOREGROUND_DEFAULT_COLOR,
+                          "font-desc": DEFAULT_FONT_DESCRIPTION,
+                          "valignment": DEFAULT_VALIGNMENT,
+                          "halignment": DEFAULT_HALIGNMENT}
+            for prop, value in properties.items():
+                res = source.set_child_property(prop, value)
+                assert res, prop
         self._selection.setSelection([title_clip], SELECT)
 
     def _source_deep_notify_cb(self, source, unused_gstelement, pspec):
diff --git a/tests/test_titleeditor.py b/tests/test_titleeditor.py
index 6c07fae8..7c101153 100644
--- a/tests/test_titleeditor.py
+++ b/tests/test_titleeditor.py
@@ -30,6 +30,18 @@ from tests.test_undo_timeline import BaseTestUndoTimeline
 class TitleEditorTest(BaseTestUndoTimeline):
     """Tests for the TitleEditor class."""
 
+    def _get_title_source_child_props(self):
+        clips = self.layer.get_clips()
+        self.assertEqual(len(clips), 1, clips)
+        self.assertIsInstance(clips[0], GES.TitleClip)
+        source, = clips[0].get_children(False)
+        return [source.get_child_property(p) for p in ("text",
+                                                       "x-absolute", "y-absolute",
+                                                       "valignment", "halignment",
+                                                       "font-desc",
+                                                       "color",
+                                                       "foreground-color")]
+
     def test_create(self):
         """Exercise creating a title clip."""
         # Wait until the project creates a layer in the timeline.
@@ -46,14 +58,12 @@ class TitleEditorTest(BaseTestUndoTimeline):
         self.project.pipeline.getPosition = mock.Mock(return_value=0)
 
         title_editor._createCb(None)
-        clips = self.layer.get_clips()
-        self.assertEqual(len(clips), 1, clips)
-        self.assertIsInstance(clips[0], GES.TitleClip)
+        ps1 = self._get_title_source_child_props()
 
         self.action_log.undo()
         clips = self.layer.get_clips()
         self.assertEqual(len(clips), 0, clips)
 
         self.action_log.redo()
-        clips = self.layer.get_clips()
-        self.assertEqual(len(clips), 1, clips)
+        ps2 = self._get_title_source_child_props()
+        self.assertListEqual(ps1, ps2)


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