diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py index 0adfed30f9602ce87da83175391b330139c47f4a..5887d648a1d7a3b46c99cb7973a06d0caa6c7c73 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.""" @@ -379,7 +383,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 @@ -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 @@ -431,7 +434,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) diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py index edced463222c4945cdc585b154434e70d271f77b..e2312a52d9ff75bf2da47ca919b3a8fde5af6ed4 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 b21ded429a95ac27cd6d396dd31e34c621513175..62cb2d08013f79c245bcc153f105ad92676c0397 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) @@ -161,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 46e8365517588c98e8c11ca8991ffe4d551ccc69..f98b3d2569d01ff0675b3af7b375ae1df86b3982 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): diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py index 4995fd6074aabc6215f9357e242349f0151a9dcc..3e9733cd282ce53e7350480d53fee214b6e40a8d 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):