[pitivi] undo: Rename effect related tracker to TrackElement
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] undo: Rename effect related tracker to TrackElement
- Date: Sat, 15 Nov 2014 10:33:14 +0000 (UTC)
commit b1bda280fc0b4634b9a49e81b388a3e3da2e77c6
Author: Thibault Saunier <tsaunier gnome org>
Date: Sat Sep 27 10:15:11 2014 +0200
undo: Rename effect related tracker to TrackElement
Because we can track children properties of any TrackElement in there.
https://bugzilla.gnome.org/show_bug.cgi?id=739251
pitivi/undo/effect.py | 112 +++++++++++++++++++++++-----------------------
pitivi/undo/timeline.py | 23 ++++-----
2 files changed, 66 insertions(+), 69 deletions(-)
---
diff --git a/pitivi/undo/effect.py b/pitivi/undo/effect.py
index 5471bf4..917655e 100644
--- a/pitivi/undo/effect.py
+++ b/pitivi/undo/effect.py
@@ -28,26 +28,26 @@ from pitivi.undo.undo import UndoableAction
from pitivi.effects import PROPS_TO_IGNORE
-class EffectPropertyChanged(UndoableAction):
+class TrackElementPropertyChanged(UndoableAction):
- def __init__(self, effect, property_name, old_value, new_value):
+ def __init__(self, track_element, property_name, old_value, new_value):
UndoableAction.__init__(self)
- self.effect = effect
+ self.track_element = track_element
self.property_name = property_name
self.old_value = old_value
self.new_value = new_value
def do(self):
- self.effect.set_child_property(self.property_name, self.new_value)
+ self.track_element.set_child_property(self.property_name, self.new_value)
self._done()
def undo(self):
- self.effect.set_child_property(self.property_name, self.old_value)
+ self.track_element.set_child_property(self.property_name, self.old_value)
self._undone()
def serializeLastAction(self):
st = Gst.Structure.new_empty("set-child-property")
- st['element-name'] = self.effect.get_name()
+ st['element-name'] = self.track_element.get_name()
st['property'] = self.property_name
st['value'] = self.new_value
@@ -56,122 +56,122 @@ class EffectPropertyChanged(UndoableAction):
# FIXME We should refactor pitivi.undo.PropertyChangeTracker so we can use it as
# a baseclass here!
-class EffectGstElementPropertyChangeTracker:
+class TrackElementChildPropertyTracker:
"""
- Track effect configuration changes in its list of control effects
+ Track track_element configuration changes in its list of control track_elements
"""
def __init__(self, action_log):
- self._tracked_effects = {}
+ self._tracked_track_elements = {}
self.action_log = action_log
self.pipeline = None
- def addEffectElement(self, effect):
- if effect in self._tracked_effects:
+ def addTrackElement(self, track_element):
+ if track_element in self._tracked_track_elements:
return
properties = {}
- effect.connect('deep-notify', self._propertyChangedCb)
+ track_element.connect('deep-notify', self._propertyChangedCb)
- for prop in effect.list_children_properties():
- properties[prop.name] = effect.get_child_property(prop.name)[1]
+ for prop in track_element.list_children_properties():
+ properties[prop.name] = track_element.get_child_property(prop.name)[1]
- self._tracked_effects[effect] = properties
+ self._tracked_track_elements[track_element] = properties
- def getPropChangedFromEffect(self, effect):
- return self._tracked_effects[effect]
+ def getPropChangedFromTrackElement(self, track_element):
+ return self._tracked_track_elements[track_element]
- def _propertyChangedCb(self, effect, unused_gstelement, pspec):
- old_value = self._tracked_effects[effect][pspec.name]
- new_value = effect.get_child_property(pspec.name)[1]
- action = EffectPropertyChanged(
- effect, pspec.name, old_value, new_value)
- self._tracked_effects[effect][pspec.name] = new_value
+ def _propertyChangedCb(self, track_element, unused_gstelement, pspec):
+ old_value = self._tracked_track_elements[track_element][pspec.name]
+ new_value = track_element.get_child_property(pspec.name)[1]
+ action = TrackElementPropertyChanged(
+ track_element, pspec.name, old_value, new_value)
+ self._tracked_track_elements[track_element][pspec.name] = new_value
self.action_log.push(action)
-class EffectAdded(UndoableAction):
+class TrackElementAdded(UndoableAction):
# Note: We have a bug if we just remove the Effect from the timeline
# and keep it saved here and then readd it to corresponding timeline (it
# freezes everything). So what we are doing is to free the Effect,
# keep its settings here when undoing, and instanciate a new one when
- # doing again. We have to keep all EffectPropertyChanged object that refers
- # to the Effect when undoing so we reset theirs effect when
+ # doing again. We have to keep all TrackElementPropertyChanged object that refers
+ # to the Effect when undoing so we reset theirs track_element when
# doing it again. The way of doing it is the same with EffectRemoved
- def __init__(self, clip, effect, properties_watcher):
+ def __init__(self, clip, track_element, properties_watcher):
UndoableAction.__init__(self)
self.clip = clip
- self.effect = effect
- self.asset = effect.get_asset()
- self.effect_props = []
+ self.track_element = track_element
+ self.asset = track_element.get_asset()
+ self.track_element_props = []
self.gnl_obj_props = []
self._properties_watcher = properties_watcher
self._props_changed = []
def do(self):
- self.effect = self.clip.add_asset(self.asset)
- for prop_name, prop_value in self.effect_props:
- self.effect.set_child_property(prop_name, prop_value)
+ self.track_element = self.clip.add_asset(self.asset)
+ for prop_name, prop_value in self.track_element_props:
+ self.track_element.set_child_property(prop_name, prop_value)
self.clip.get_layer().get_timeline().commit()
self._props_changed = []
self._done()
def undo(self):
- props = self.effect.list_children_properties()
- self.effect_props = [(prop.name, self.effect.get_child_property(prop.name)[1])
+ props = self.track_element.list_children_properties()
+ self.track_element_props = [(prop.name, self.track_element.get_child_property(prop.name)[1])
for prop in props
if prop.flags & GObject.PARAM_WRITABLE
and prop.name not in PROPS_TO_IGNORE]
- self.clip.remove(self.effect)
+ self.clip.remove(self.track_element)
self._props_changed =\
- self._properties_watcher.getPropChangedFromEffect(self.effect)
- del self.effect
- self.effect = None
+ self._properties_watcher.getPropChangedFromTrackElement(self.track_element)
+ del self.track_element
+ self.track_element = None
self._undone()
def serializeLastAction(self):
st = Gst.Structure.new_empty("container-add-child")
st["container-name"] = self.clip.get_name()
- st["asset-id"] = self.effect.get_id()
- st["child-type"] = GObject.type_name(self.effect.get_asset().get_extractable_type())
+ st["asset-id"] = self.track_element.get_id()
+ st["child-type"] = GObject.type_name(self.track_element.get_asset().get_extractable_type())
return st
-class EffectRemoved(UndoableAction):
+class TrackElementRemoved(UndoableAction):
- def __init__(self, clip, effect, properties_watcher):
+ def __init__(self, clip, track_element, properties_watcher):
UndoableAction.__init__(self)
- self.effect = effect
+ self.track_element = track_element
self.clip = clip
- self.asset = effect.get_asset()
- self.effect_props = []
+ self.asset = track_element.get_asset()
+ self.track_element_props = []
self.gnl_obj_props = []
self._properties_watcher = properties_watcher
self._props_changed = []
def do(self):
- props = self.effect.list_children_properties()
- self.effect_props = [(prop.name, self.effect.get_child_property(prop.name)[1])
+ props = self.track_element.list_children_properties()
+ self.track_element_props = [(prop.name, self.track_element.get_child_property(prop.name)[1])
for prop in props
if prop.flags & GObject.PARAM_WRITABLE
and prop.name not in PROPS_TO_IGNORE]
- self.clip.remove(self.effect)
+ self.clip.remove(self.track_element)
self._props_changed =\
- self._properties_watcher.getPropChangedFromEffect(self.effect)
- del self.effect
- self.effect = None
+ self._properties_watcher.getPropChangedFromTrackElement(self.track_element)
+ del self.track_element
+ self.track_element = None
self._done()
def undo(self):
- self.effect = self.clip.add_asset(self.asset)
- for prop_name, prop_value in self.effect_props:
- self.effect.set_child_property(prop_name, prop_value)
+ self.track_element = self.clip.add_asset(self.asset)
+ for prop_name, prop_value in self.track_element_props:
+ self.track_element.set_child_property(prop_name, prop_value)
self.clip.get_layer().get_timeline().commit()
self._props_changed = []
self._undone()
@@ -179,6 +179,6 @@ class EffectRemoved(UndoableAction):
def serializeLastAction(self):
st = Gst.Structure.new_empty("container-remove-child")
st["container-name"] = self.clip.get_name()
- st["child-name"] = self.effect.get_name()
+ st["child-name"] = self.track_element.get_name()
return st
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 5ad41e1..c12d988 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -24,8 +24,8 @@ from gi.repository import GES
from gi.repository import GObject
from pitivi.undo.undo import PropertyChangeTracker, UndoableAction
-from pitivi.undo.effect import EffectAdded, EffectRemoved
-from pitivi.undo.effect import EffectGstElementPropertyChangeTracker
+from pitivi.undo.effect import TrackElementAdded, TrackElementRemoved
+from pitivi.undo.effect import TrackElementChildPropertyTracker
class ClipPropertyChangeTracker(PropertyChangeTracker):
@@ -294,13 +294,12 @@ class TimelineLogObserver(object):
self.log = log
self.clip_property_trackers = {}
self.interpolator_keyframe_trackers = {}
- self.effect_properties_tracker = EffectGstElementPropertyChangeTracker(
- log)
+ self.children_props_tracker = TrackElementChildPropertyTracker(log)
self._pipeline = None
def setPipeline(self, pipeline):
self._pipeline = pipeline
- self.effect_properties_tracker.pipeline = pipeline
+ self.children_props_tracker.pipeline = pipeline
def getPipeline(self):
return self._pipeline
@@ -366,7 +365,7 @@ class TimelineLogObserver(object):
# for prop, interpolator in track_element.getInterpolators().itervalues():
# self._connectToInterpolator(interpolator)
if isinstance(track_element, GES.BaseEffect):
- self.effect_properties_tracker.addEffectElement(track_element)
+ self.children_props_tracker.addTrackElement(track_element)
def _disconnectFromTrackElement(self, track_element):
pass
@@ -415,16 +414,15 @@ class TimelineLogObserver(object):
def _clipTrackElementAddedCb(self, clip, track_element):
self._connectToTrackElement(track_element)
if isinstance(track_element, GES.BaseEffect):
- action = EffectAdded(clip, track_element,
- self.effect_properties_tracker)
+ action = TrackElementAdded(clip, track_element,
+ self.children_props_tracker)
self.log.push(action)
def _clipTrackElementRemovedCb(self, clip, track_element):
self._disconnectFromTrackElement(track_element)
if isinstance(track_element, GES.BaseEffect):
- action = EffectRemoved(clip,
- track_element,
- self.effect_properties_tracker)
+ action = TrackElementRemoved(clip, track_element,
+ self.children_props_tracker)
self.log.push(action)
def _interpolatorKeyframeAddedCb(self, track_element, keyframe):
@@ -432,8 +430,7 @@ class TimelineLogObserver(object):
self.log.push(action)
def _interpolatorKeyframeRemovedCb(self, track_element, keyframe, old_value=None):
- action = self.interpolatorKeyframeRemovedAction(
- track_element, keyframe)
+ action = self.interpolatorKeyframeRemovedAction(track_element, keyframe)
self.log.push(action)
def _trackElementActiveChangedCb(self, track_element, active, add_effect_action):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]