Skip to content
Browse files

undo: Start handling effects

  • Loading branch information...
1 parent 6097c7e commit 5147fb31a951b0583695d1bcb87f002cb961af8b Thibault Saunier committed with Jan 26, 2012
Showing with 99 additions and 114 deletions.
  1. +4 −16 pitivi/clipproperties.py
  2. +7 −22 pitivi/timeline/timeline.py
  3. +20 −29 pitivi/undo/effect.py
  4. +47 −46 pitivi/undo/timeline.py
  5. +21 −1 pitivi/utils/timeline.py
View
20 pitivi/clipproperties.py
@@ -39,6 +39,7 @@
from pitivi.utils.loggable import Loggable
from pitivi.utils.ui import PADDING, SPACING
from pitivi.utils.widgets import GstElementSettingsWidget
+from pitivi.utils.timeline import add_effect
from pitivi.effects import AUDIO_EFFECT, VIDEO_EFFECT, HIDDEN_EFFECTS, \
EffectsPropertiesManager
@@ -340,22 +341,9 @@ def addEffectToCurrentSelection(self, bin_desc):
# Checking that this effect can be applied on this track object
# Which means, it has the corresponding media_type
- for tckobj in tlobj.get_track_objects():
- track = tckobj.get_track()
- if track.props.track_type == ges.TRACK_TYPE_AUDIO and \
- media_type == AUDIO_EFFECT or \
- track.props.track_type == ges.TRACK_TYPE_VIDEO and \
- media_type == VIDEO_EFFECT:
- #Actually add the effect
- self.app.action_log.begin("add effect")
- effect = ges.TrackParseLaunchEffect(bin_desc)
- tlobj.add_track_object(effect)
- track.add_object(effect)
- self._updateAll()
- self.app.action_log.commit()
- self._seeker.flush()
-
- break
+ add_effect(tlobj, bin_desc, self.app)
+ self._updateAll()
+ self._seeker.flush()
def _dragDataReceivedCb(self, unused_layout, context, unused_x, unused_y,
selection, unused_targetType, unused_timestamp):
View
29 pitivi/timeline/timeline.py
@@ -42,7 +42,7 @@
from curve import KW_LABEL_Y_OVERFLOW
from track import TrackControls, TRACK_CONTROL_WIDTH, Track, TrackObject
-from pitivi.utils.timeline import Controller, MoveContext, SELECT, Zoomable
+from pitivi.utils.timeline import Controller, MoveContext, SELECT, Zoomable, add_effect
from pitivi.dialogs.depsmanager import DepsManager
from pitivi.dialogs.filelisterrordialog import FileListErrorDialog
@@ -830,29 +830,14 @@ def _dragDropCb(self, widget, context, x, y, timestamp):
# Trying to apply effect only on the first object of the selection
tlobj = timeline_objs[0]
+ add_effect(tlobj, bin_desc, app)
+ self._factories = None
+ self.seeker.seek(self._position)
- # Checking that this effect can be applied on this track object
- # Which means, it has the corresponding media_type
- for tckobj in tlobj.get_track_objects():
- track = tckobj.get_track()
- if track.props.track_type == ges.TRACK_TYPE_AUDIO and \
- media_type == AUDIO_EFFECT or \
- track.props.track_objects == ges.TRACK_TYPE_VIDEO and \
- media_type == VIDEO_EFFECT:
- #Actually add the effect
- self.app.action_log.begin("add effect")
- effect = ges.TrackParseLaunchEffect(bin_desc)
- tlobj.add_track_object(effect)
- track.add_object(effect)
- self.app.action_log.commit()
- self._factories = None
- self.seeker.seek(self._position)
- context.drop_finish(True, timestamp)
-
- self.timeline.selection.setSelection(timeline_objs, SELECT)
- break
+ context.drop_finish(True, timestamp)
+ self.timeline.selection.setSelection(timeline_objs, SELECT)
- return True
+ return True
return False
View
49 pitivi/undo/effect.py
@@ -27,6 +27,7 @@
from pitivi.undo.undo import UndoableAction
from pitivi.effects import PROPS_TO_IGNORE
+from pitivi.utils.timeline import add_effect
class EffectPropertyChanged(UndoableAction):
@@ -56,19 +57,10 @@ def __init__(self, action_log):
self.action_log = action_log
self.pipeline = None
- def addEffectElement(self, gst_element):
- properties = {}
-
- if gst_element in self._tracked_effects:
- return
-
- for prop in gobject.list_properties(gst_element):
- gst_element.connect('notify::' + prop.name,
- self._propertyChangedCb,
- gst_element)
- if prop.flags & gobject.PARAM_READABLE:
- properties[prop.name] = gst_element.get_property(prop.name)
- self._tracked_effects[gst_element] = properties
+ def addEffect(self, tckobj):
+ tckobj.connect('deep-notify', self._propertyChangedCb)
+ self._tracked_effects[tckobj] = [prop.name for prop in \
+ tckobj.list_children_properties()]
def getPropChangedFromTrackObj(self, track_effect):
prop_changed = []
@@ -89,12 +81,12 @@ def getPropChangedFromTrackObj(self, track_effect):
return prop_changed
- def _propertyChangedCb(self, gst_element, pspec, unused):
- old_value = self._tracked_effects[gst_element][pspec.name]
+ def _propertyChangedCb(self, tckobj, gst_element, pspec, unused):
+ old_value = self._tracked_effects[tckobj][pspec.name]
new_value = gst_element.get_property(pspec.name)
- action = EffectPropertyChanged(gst_element, pspec.name, old_value,
+ action = EffectPropertyChanged(tckobj, pspec.name, old_value,
new_value)
- self._tracked_effects[gst_element][pspec.name] = new_value
+ self._tracked_effects[tckobj][pspec.name] = new_value
self.action_log.push(action)
@@ -109,13 +101,13 @@ class TrackEffectAdded(UndoableAction):
def __init__(self, timeline_object, track_object, properties_watcher):
self.timeline_object = timeline_object
self.track_object = track_object
- self.factory = track_object.factory
self.effect_props = []
self.gnl_obj_props = []
self._properties_watcher = properties_watcher
self._props_changed = []
def do(self):
+ add_effect(self.timeline_object, bin_desc, app)
timeline = self.timeline_object.timeline
tl_obj_track_obj = timeline.addEffectFactoryOnObject(self.factory,
timeline_objects=[self.timeline_object])
@@ -133,20 +125,19 @@ def do(self):
self._done()
def undo(self):
- element = self.track_object.getElement()
- props = gobject.list_properties(element)
- self.effect_props = [(prop.name, element.get_property(prop.name))
- for prop in props
- if prop.flags & gobject.PARAM_WRITABLE
- and prop.name not in PROPS_TO_IGNORE]
- gnl_props = gobject.list_properties(self.track_object.gnl_object)
- gnl_obj = self.track_object.gnl_object
+ element = self.track_object.get_element()
+ props = self.track_object.list_children_properties()
+ self_props = [(prop.name, self.track_object.get_child_property(prop.name))
+ for prop in props]
+ gnl_props = gobject.list_properties(self.track_object.get_gnlobject())
+ gnl_obj = self.track_object.get_gnlobject()
self.gnl_obj_props = [(prop.name, gnl_obj.get_property(prop.name))
for prop in gnl_props
- if prop.flags & gobject.PARAM_WRITABLE]
+ if prop.flags & gobject.PARAM_WRITABLE
+ and prop.name not in PROPS_TO_IGNORE]
- self.timeline_object.removeTrackObject(self.track_object)
- self.track_object.track.removeTrackObject(self.track_object)
+ self.timeline_object.release_track_object(self.track_object)
+ self.track_object.get_track().remove_object(self.track_object)
self._props_changed =\
self._properties_watcher.getPropChangedFromTrackObj(self.track_object)
del self.track_object
View
93 pitivi/undo/timeline.py
@@ -233,6 +233,8 @@ def __init__(self, log):
def startObserving(self, timeline):
self._connectToTimeline(timeline)
+ timeline.connect("layer-added", self._layerAddedCb)
+ timeline.connect("layer-removed", self._layerRemovedCb)
for layer in timeline.get_layers():
for timeline_object in layer.get_objects():
self._connectToTimelineObject(timeline_object)
@@ -257,15 +259,16 @@ def _disconnectFromTimeline(self, timeline):
def _connectToTimelineObject(self, timeline_object):
tracker = TimelineObjectPropertyChangeTracker()
+ tracker.connectToObject(timeline_object)
for property_name in tracker.property_names:
tracker.connect("notify::" + property_name,
self._timelineObjectPropertyChangedCb, property_name)
self.timeline_object_property_trackers[timeline_object] = tracker
timeline_object.connect("track-object-added", self._timelineObjectTrackObjectAddedCb)
timeline_object.connect("track-object-removed", self._timelineObjectTrackObjectRemovedCb)
- track_object.connect("effect-added", self._effectAddedCb)
- track_object.connect("effect-removed", self._effectRemovedCb)
+ timeline_object.connect("effect-added", self._effectAddedCb)
+ timeline_object.connect("effect-removed", self._effectRemovedCb)
for obj in timeline_object.get_track_objects():
self._connectToTrackObject(obj)
@@ -278,38 +281,36 @@ def _connectToTrackObject(self, track_object):
#for prop, interpolator in track_object.getInterpolators().itervalues():
#self._connectToInterpolator(interpolator)
if isinstance(track_object, ges.TrackEffect):
- self.effect_properties_tracker.addEffectElement(track_object.getElement())
+ self.effect_properties_tracker.addEffect(track_object)
- def _disconnectFromTrackObject(self, track_object):
- for prop, interpolator in track_object.getInterpolators().itervalues():
- self._disconnectFromInterpolator(interpolator)
-
- def _connectToInterpolator(self, interpolator):
- interpolator.connect("keyframe-added", self._interpolatorKeyframeAddedCb)
- interpolator.connect("keyframe-removed",
- self._interpolatorKeyframeRemovedCb)
-
- tracker = KeyframeChangeTracker()
- tracker.connectToObject(interpolator)
- tracker.connect("keyframe-moved", self._interpolatorKeyframeMovedCb)
- self.interpolator_keyframe_trackers[interpolator] = tracker
-
- def _disconnectFromInterpolator(self, interpolator):
- tracker = self.interpolator_keyframe_trackers.pop(interpolator)
- tracker.disconnectFromObject(interpolator)
- tracker.disconnect_by_func(self._interpolatorKeyframeMovedCb)
-
- def _effectAddedCb(self, timeline, track_object):
- action = self.trackEffectAddAction(timeline_object, track_object,
- self.effect_properties_tracker)
+ #def _disconnectFromTrackObject(self, track_object):
+ #for prop, interpolator in track_object.getInterpolators().itervalues():
+ #self._disconnectFromInterpolator(interpolator)
+
+ #def _connectToInterpolator(self, interpolator):
+ #interpolator.connect("keyframe-added", self._interpolatorKeyframeAddedCb)
+ #interpolator.connect("keyframe-removed",
+ #self._interpolatorKeyframeRemovedCb)
+
+ #tracker = KeyframeChangeTracker()
+ #tracker.connectToObject(interpolator)
+ #tracker.connect("keyframe-moved", self._interpolatorKeyframeMovedCb)
+ #self.interpolator_keyframe_trackers[interpolator] = tracker
+
+ #def _disconnectFromInterpolator(self, interpolator):
+ #tracker = self.interpolator_keyframe_trackers.pop(interpolator)
+ #tracker.disconnectFromObject(interpolator)
+ #tracker.disconnect_by_func(self._interpolatorKeyframeMovedCb)
+
+ def _effectAddedCb(self, tlobj, track_object):
+ action = self.trackEffectAddAction(tlobj, track_object,
+ self.effect_properties_tracker)
#We use the action instead of the track object
#because the track_object changes when redoing
- track_object.connect("effect-added",
+ track_object.connect("notify::active",
self._trackObjectActiveChangedCb, action)
self.log.push(action)
- element = track_object.getElement()
- if element:
- self.effect_properties_tracker.addEffectElement(element)
+ self.effect_properties_tracker.addEffect(track_object)
def _effectRemovedCb(self, timeline, track_object):
track_object.disconnect_by_func(self._effectAddedCb)
@@ -321,6 +322,8 @@ def _layerAddedCb(self, timeline="her", layer="What"):
self._timelineObjectTrackObjectAddedCb)
tlobj.connect("track-object-removed",
self._timelineObjectTrackObjectRemovedCb)
+ tlobj.connect("effect-added", self._effectAddedCb)
+ tlobj.connect("effect-removed", self._effectRemovedCb)
layer.connect("object-added", self._timelineObjectAddedCb)
layer.connect("object-removed", self._timelineObjectRemovedCb)
@@ -354,9 +357,7 @@ def _timelineObjectTrackObjectAddedCb(self, timeline_object, track_object):
track_object.connect("active-changed",
self._trackObjectActiveChangedCb, action)
self.log.push(action)
- element = track_object.getElement()
- if element:
- self.effect_properties_tracker.addEffectElement(element)
+ self.effect_properties_tracker.addEffect(track_object)
else:
self._connectToTrackObject(track_object)
@@ -367,24 +368,24 @@ def _timelineObjectTrackObjectRemovedCb(self, timeline_object,
track_object,
self.effect_properties_tracker)
self.log.push(action)
- else:
- self._disconnectFromTrackObject(track_object)
+ #else:
+ #self._disconnectFromTrackObject(track_object)
- def _interpolatorKeyframeAddedCb(self, track_object, keyframe):
- action = self.interpolatorKeyframeAddedAction(track_object, keyframe)
- self.log.push(action)
+ #def _interpolatorKeyframeAddedCb(self, track_object, keyframe):
+ #action = self.interpolatorKeyframeAddedAction(track_object, keyframe)
+ #self.log.push(action)
- def _interpolatorKeyframeRemovedCb(self, track_object, keyframe,
- old_value=None):
- action = self.interpolatorKeyframeRemovedAction(track_object, keyframe)
- self.log.push(action)
+ #def _interpolatorKeyframeRemovedCb(self, track_object, keyframe,
+ #old_value=None):
+ #action = self.interpolatorKeyframeRemovedAction(track_object, keyframe)
+ #self.log.push(action)
def _trackObjectActiveChangedCb(self, track_object, active, add_effect_action):
action = self.activePropertyChangedAction(add_effect_action, active)
self.log.push(action)
- def _interpolatorKeyframeMovedCb(self, tracker, track_object,
- keyframe, old_snapshot, new_snapshot):
- action = self.interpolatorKeyframeChangedAction(track_object,
- keyframe, old_snapshot, new_snapshot)
- self.log.push(action)
+ #def _interpolatorKeyframeMovedCb(self, tracker, track_object,
+ #keyframe, old_snapshot, new_snapshot):
+ #action = self.interpolatorKeyframeChangedAction(track_object,
+ #keyframe, old_snapshot, new_snapshot)
+ #self.log.push(action)
View
22 pitivi/utils/timeline.py
@@ -29,6 +29,7 @@
from pitivi.utils.signal import Signallable
from pitivi.utils.receiver import receiver, handler
from pitivi.utils.ui import Point
+from pitivi.effects import AUDIO_EFFECT, VIDEO_EFFECT
#from pitivi.utils.align import AutoAligner
@@ -251,7 +252,6 @@ def addTimelineObject(self, timeline_object):
Add the given timeline_object to the selection.
@param timeline_object: The object to add
- @type timeline_object: L{ges.TimelineObject}
@raises TimelineError: If the object is already controlled by this
Selection.
"""
@@ -1163,6 +1163,26 @@ def hover(self, item, target, event):
pass
+def add_effect(tlobj, bin_desc, app):
+ media_type = app.effects.getFactoryFromName(bin_desc).media_type
+
+ # Checking that this effect can be applied on this track object
+ # Which means, it has the corresponding media_type
+ for tckobj in tlobj.get_track_objects():
+ track = tckobj.get_track()
+ if track.props.track_type == ges.TRACK_TYPE_AUDIO and \
+ media_type == AUDIO_EFFECT or \
+ track.props.track_type == ges.TRACK_TYPE_VIDEO and \
+ media_type == VIDEO_EFFECT:
+ #Actually add the effect
+ app.action_log.begin("add effect")
+ effect = ges.TrackParseLaunchEffect(bin_desc)
+ track.add_object(effect)
+ tlobj.add_track_object(effect)
+ app.action_log.commit()
+ break
+
+
class View(object):
Controller = Controller

0 comments on commit 5147fb3

Please sign in to comment.
Something went wrong with that request. Please try again.