[pitivi] clipproperties: Update widgets when switching clips
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] clipproperties: Update widgets when switching clips
- Date: Wed, 17 Feb 2021 08:10:54 +0000 (UTC)
commit 187ecc8bec4abb3f7b6bee0c86ed933c1b0be897
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Mon Feb 15 22:11:19 2021 +0100
clipproperties: Update widgets when switching clips
The speed widgets were not being updated when selecting a different
clip.
pitivi/clipproperties.py | 13 +++++++++++++
tests/test_clipproperties.py | 21 +++++++++++++++++++++
2 files changed, 34 insertions(+)
---
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index 8660ba76c..ead9e5cd2 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -362,6 +362,10 @@ class TimeProperties(Gtk.Expander, Loggable):
@rate.setter # type: ignore
def rate(self, value: float) -> None:
self._set_rate(value)
+ # We assume the "rate" has been set as an effect of the binding between
+ # the self._speed_adjustment and the "rate" property.
+ # Signal the "rate_linear" property is updated so
+ # self._speed_scale_adjustment is also updated.
self.notify("rate_linear")
@GObject.Property(type=float)
@@ -373,6 +377,10 @@ class TimeProperties(Gtk.Expander, Loggable):
def rate_linear(self, linear: float) -> None:
value = self._linear_to_rate(linear)
self._set_rate(value)
+ # We assume the "rate_linear" has been set as an effect of the binding
+ # between the self._speed_scale_adjustment and the "rate" property.
+ # Signal the "rate" property is updated so the self._speed_adjustment
+ # is also updated.
self.notify("rate")
def _set_rate(self, value: float):
@@ -475,6 +483,11 @@ class TimeProperties(Gtk.Expander, Loggable):
self._time_effects = self.__get_time_effects(self._clip)
if self._clip:
+ # Signal the properties changed so the Adjustments bound to them
+ # and the widgets using these are updated.
+ self.notify("rate")
+ self.notify("rate_linear")
+
self._clip.connect("deep-notify", self.__child_property_changed_cb)
self.show_all()
else:
diff --git a/tests/test_clipproperties.py b/tests/test_clipproperties.py
index e01734a34..af5cc89ae 100644
--- a/tests/test_clipproperties.py
+++ b/tests/test_clipproperties.py
@@ -522,6 +522,27 @@ class SpeedPropertiesTest(common.TestCase):
def test_clip_speed_v(self):
self._check_clip_speed(video=True)
+ @common.setup_project_with_clips(assets_names=["mp3_sample.mp3", "30fps_numeroted_frames_blue.webm"])
+ @common.setup_clipproperties
+ def test_widgets_updated_when_switching_clips(self):
+ clip1, clip2 = self.layer.get_clips()
+ clip1_duration = clip1.props.duration
+ clip2_duration = clip2.props.duration
+
+ self.timeline_container.timeline.selection.select([clip1])
+ self.assertIs(self.speed_box._clip, clip1)
+ self.assert_applied_rate(0, 1.0, clip1_duration)
+
+ self.speed_box._speed_adjustment.props.value = 2.0
+ self.assert_applied_rate(1, 2.0, clip1_duration / 2)
+
+ self.timeline_container.timeline.selection.select([clip2])
+ self.assertIs(self.speed_box._clip, clip2)
+ self.assert_applied_rate(0, 1.0, clip2_duration)
+
+ self.timeline_container.timeline.selection.select([clip1])
+ self.assert_applied_rate(1, 2.0, clip1_duration / 2)
+
@common.setup_project_with_clips
@common.setup_clipproperties
def test_load_project_clip_speed(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]