From a5cc0f049b24d99877ad6e997a02ad4c19520ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandru=20B=C4=83lu=C8=9B?= Date: Sun, 26 Aug 2018 23:08:35 +0200 Subject: [PATCH 1/3] clipproperties: Use the new API for setting effect index --- pitivi/clipproperties.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py index 0adfed30f..4d0af92d4 100644 --- a/pitivi/clipproperties.py +++ b/pitivi/clipproperties.py @@ -379,7 +379,7 @@ class EffectProperties(Gtk.Expander, Loggable): toplevel=True): effect = self.clip.ui.add_effect(effect_info) if effect: - self.clip.set_top_effect_priority(effect, drop_index) + self.clip.set_top_effect_index(effect, drop_index) elif drag_context.get_suggested_action() == Gdk.DragAction.MOVE: # An effect dragged from the same treeview to change its position. # Source @@ -431,7 +431,7 @@ class EffectProperties(Gtk.Expander, Loggable): with self.app.action_log.started("move effect", finalizing_action=CommitTimelineFinalizingAction(pipeline), toplevel=True): - clip.set_top_effect_priority(effect, drop_index) + clip.set_top_effect_index(effect, drop_index) new_path = Gtk.TreePath.new() new_path.append_index(drop_index) -- GitLab From fa2db6cf768303962c8d367112805ebbedf17466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandru=20B=C4=83lu=C8=9B?= Date: Sun, 26 Aug 2018 23:13:08 +0200 Subject: [PATCH 2/3] clipproperties: Effects priority monitoring Update the UI after setting the effect priority and after undo/redo of effects reordering. Fixes #2178 Fixes #2234 --- pitivi/clipproperties.py | 7 +++++-- pitivi/undo/timeline.py | 6 +++++- tests/test_undo_timeline.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py index 4d0af92d4..5887d648a 100644 --- a/pitivi/clipproperties.py +++ b/pitivi/clipproperties.py @@ -302,13 +302,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) @@ -338,7 +343,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.""" @@ -416,7 +420,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 diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py index b21ded429..390ddcde7 100644 --- a/pitivi/undo/timeline.py +++ b/pitivi/undo/timeline.py @@ -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) diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py index 4995fd607..3e9733cd2 100644 --- a/tests/test_undo_timeline.py +++ b/tests/test_undo_timeline.py @@ -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): -- GitLab From 723fd4c47818386f3445a9e9589296cd84897be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandru=20B=C4=83lu=C8=9B?= Date: Sun, 26 Aug 2018 23:36:03 +0200 Subject: [PATCH 3/3] Use GObject.ParamFlags instead of deprecated constants --- pitivi/timeline/previewers.py | 6 +++--- pitivi/undo/timeline.py | 2 +- pitivi/utils/widgets.py | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py index edced4632..e2312a52d 100644 --- a/pitivi/timeline/previewers.py +++ b/pitivi/timeline/previewers.py @@ -101,7 +101,7 @@ class ThumbnailBin(PreviewerBin): "uri of the media file", "A URI", "", - GObject.PARAM_READWRITE), + GObject.ParamFlags.READWRITE), } def __init__(self, bin_desc="videoconvert ! videorate ! " @@ -178,11 +178,11 @@ class WaveformPreviewer(PreviewerBin): "uri of the media file", "A URI", "", - GObject.PARAM_READWRITE), + GObject.ParamFlags.READWRITE), "duration": (GObject.TYPE_UINT64, "Duration", "Duration", - 0, GLib.MAXUINT64 - 1, 0, GObject.PARAM_READWRITE) + 0, GLib.MAXUINT64 - 1, 0, GObject.ParamFlags.READWRITE) } def __init__(self): diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py index 390ddcde7..62cb2d080 100644 --- a/pitivi/undo/timeline.py +++ b/pitivi/undo/timeline.py @@ -165,7 +165,7 @@ class TrackElementAction(UndoableAction): self.track_element = track_element self.track_element_props = [] for prop in self.track_element.list_children_properties(): - if not prop.flags & GObject.PARAM_WRITABLE or \ + if not prop.flags & GObject.ParamFlags.WRITABLE or \ prop.name in PROPS_TO_IGNORE: continue prop_name = child_property_name(prop) diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py index 46e836551..f98b3d256 100644 --- a/pitivi/utils/widgets.py +++ b/pitivi/utils/widgets.py @@ -755,7 +755,6 @@ class GstElementSettingsWidget(Gtk.Box, Loggable): if src_caps_fields: srccaps = self.element.get_static_pad('src').get_pad_template().caps - vals = {} for field, prefered_value in src_caps_fields.items(): gvalue = srccaps[0][field] if isinstance(gvalue, Gst.ValueList) and isinstance(prefered_value, Gst.ValueList): @@ -953,7 +952,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable): """Gets a name/value dict with the properties.""" values = {} for prop, widget in self.properties.items(): - if not prop.flags & GObject.PARAM_WRITABLE: + if not prop.flags & GObject.ParamFlags.WRITABLE: continue value = widget.getWidgetValue() if value is not None and (value != prop.default_value or with_default): -- GitLab