Commit 7045e321 authored by Alexandru Băluț's avatar Alexandru Băluț

clipproperties: Effects priority monitoring

Update the UI after setting the effect priority and after undo/redo of
effects reordering.

Fixes #2178
Fixes #2234
parent 6ba117ca
......@@ -307,13 +307,18 @@ class EffectProperties(Gtk.Expander, Loggable):
def _connect_to_track_element(self, track_element):
track_element.connect("notify::active", self._notify_active_cb)
track_element.connect("notify::priority", self._notify_priority_cb)
def _disconnect_from_track_element(self, track_element):
track_element.disconnect_by_func(self._notify_active_cb)
track_element.disconnect_by_func(self._notify_priority_cb)
def _notify_active_cb(self, unused_track_element, unused_param_spec):
self._updateTreeview()
def _notify_priority_cb(self, unused_track_element, unused_param_spec):
self._updateTreeview()
def _trackElementRemovedCb(self, unused_clip, track_element):
if isinstance(track_element, GES.BaseEffect):
self._disconnect_from_track_element(track_element)
......@@ -343,7 +348,6 @@ class EffectProperties(Gtk.Expander, Loggable):
self.__remove_configuration_widget()
self.effects_properties_manager.cleanCache(effect)
effect.get_parent().remove(effect)
self._updateTreeview()
def _drag_motion_cb(self, unused_widget, unused_drag_context, unused_x, unused_y, unused_timestamp):
"""Highlights some widgets to indicate it can receive drag&drop."""
......@@ -421,7 +425,6 @@ class EffectProperties(Gtk.Expander, Loggable):
else:
# This should happen when dragging after the last row.
drop_index = len(model) - 1
drop_pos = Gtk.TreeViewDropPosition.INTO_OR_BEFORE
return source_index, drop_index
......
......@@ -146,7 +146,11 @@ class TrackElementObserver(TimelineElementObserver):
def __init__(self, ges_track_element, action_log):
TimelineElementObserver.__init__(self, ges_track_element, action_log)
self.gobject_observer = GObjectObserver(ges_track_element, ("active",), action_log)
if isinstance(ges_track_element, GES.BaseEffect):
property_names = ("active", "priority",)
else:
property_names = ("active",)
self.gobject_observer = GObjectObserver(ges_track_element, property_names, action_log)
def release(self):
TimelineElementObserver.release(self)
......
......@@ -733,6 +733,39 @@ class TestControlSourceObserver(BaseTestUndoTimeline):
self.assertEqual(0.9, control_source.get_all()[0].value)
class TestTrackElementObserver(BaseTestUndoTimeline):
def test_effects_index(self):
stacks = []
self.action_log.connect("commit", BaseTestUndoTimeline.commit_cb, stacks)
clip1 = GES.TitleClip()
self.layer.add_clip(clip1)
effect1 = GES.Effect.new("agingtv")
effect2 = GES.Effect.new("edgetv")
clip1.add(effect1)
clip1.add(effect2)
self.assertEqual(clip1.get_top_effect_index(effect1), 0)
self.assertEqual(clip1.get_top_effect_index(effect2), 1)
with self.action_log.started("move effect"):
assert clip1.set_top_effect_index(effect2, 0)
self.assertEqual(len(stacks), 1)
self.assertEqual(clip1.get_top_effect_index(effect1), 1)
self.assertEqual(clip1.get_top_effect_index(effect2), 0)
self.action_log.undo()
self.assertEqual(clip1.get_top_effect_index(effect1), 0)
self.assertEqual(clip1.get_top_effect_index(effect2), 1)
self.action_log.redo()
self.assertEqual(clip1.get_top_effect_index(effect1), 1)
self.assertEqual(clip1.get_top_effect_index(effect2), 0)
class TestTimelineElementObserver(BaseTestUndoTimeline):
def testTrackElementPropertyChanged(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment