[pitivi/ges: 200/287] undo: Move effect related classes to effect.py
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 200/287] undo: Move effect related classes to effect.py
- Date: Thu, 15 Mar 2012 16:42:39 +0000 (UTC)
commit b4a0fff7de88a857169ed513f178ef0ac69c2833
Author: Thibault Saunier <thibault saunier collabora com>
Date: Wed Jan 11 10:32:32 2012 -0300
undo: Move effect related classes to effect.py
pitivi/undo/effect.py | 109 ++++++++++++++++++++++++++++++++++++++++++++
pitivi/undo/timeline.py | 115 +----------------------------------------------
2 files changed, 111 insertions(+), 113 deletions(-)
---
diff --git a/pitivi/undo/effect.py b/pitivi/undo/effect.py
index b585eb1..79808ff 100644
--- a/pitivi/undo/effect.py
+++ b/pitivi/undo/effect.py
@@ -26,6 +26,7 @@
import gobject
from pitivi.undo.undo import UndoableAction
+from pitivi.effects import PROPS_TO_IGNORE
class EffectPropertyChanged(UndoableAction):
@@ -95,3 +96,111 @@ class EffectGstElementPropertyChangeTracker:
new_value)
self._tracked_effects[gst_element][pspec.name] = new_value
self.action_log.push(action)
+
+
+class TrackEffectAdded(UndoableAction):
+ # Note: We have a bug if we just remove the TrackEffect 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 TrackEffect,
+ # 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 TrackEffect when undoing so we reset theirs gst_element when
+ # doing it again. The way of doing it is the same with TrackEffectRemoved
+ 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):
+ timeline = self.timeline_object.timeline
+ tl_obj_track_obj = timeline.addEffectFactoryOnObject(self.factory,
+ timeline_objects=[self.timeline_object])
+
+ self.track_object = tl_obj_track_obj[0][1]
+ element = self.track_object.getElement()
+ for prop_name, prop_value in self.effect_props:
+ element.set_property(prop_name, prop_value)
+ for prop_name, prop_value in self.gnl_obj_props:
+ self.track_object.gnl_object.set_property(prop_name, prop_value)
+ for prop_changed in self._props_changed:
+ prop_changed.gst_element = self.track_object.getElement()
+ self._props_changed = []
+
+ 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
+ self.gnl_obj_props = [(prop.name, gnl_obj.get_property(prop.name))
+ for prop in gnl_props
+ if prop.flags & gobject.PARAM_WRITABLE]
+
+ self.timeline_object.removeTrackObject(self.track_object)
+ self.track_object.track.removeTrackObject(self.track_object)
+ self._props_changed =\
+ self._properties_watcher.getPropChangedFromTrackObj(self.track_object)
+ del self.track_object
+ self.track_object = None
+
+ self._undone()
+
+
+class TrackEffectRemoved(UndoableAction):
+ def __init__(self, timeline_object, track_object, properties_watcher):
+ self.track_object = track_object
+ self.timeline_object = timeline_object
+ self.factory = track_object.factory
+ self.effect_props = []
+ self.gnl_obj_props = []
+ self._properties_watcher = properties_watcher
+ self._props_changed = []
+
+ def do(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
+ self.gnl_obj_props = [(prop.name, gnl_obj.get_property(prop.name))
+ for prop in gnl_props
+ if prop.flags & gobject.PARAM_WRITABLE]
+
+ self.timeline_object.removeTrackObject(self.track_object)
+ self.track_object.track.removeTrackObject(self.track_object)
+ self._props_changed =\
+ self._properties_watcher.getPropChangedFromTrackObj(self.track_object)
+ del self.track_object
+ self.track_object = None
+
+ self._done()
+
+ def undo(self):
+ timeline = self.timeline_object.timeline
+ tl_obj_track_obj = timeline.addEffectFactoryOnObject(self.factory,
+ timeline_objects=[self.timeline_object])
+
+ self.track_object = tl_obj_track_obj[0][1]
+ element = self.track_object.getElement()
+ for prop_name, prop_value in self.effect_props:
+ element.set_property(prop_name, prop_value)
+ for prop_name, prop_value in self.gnl_obj_props:
+ self.track_object.gnl_object.set_property(prop_name, prop_value)
+ for prop_changed in self._props_changed:
+ prop_changed.gst_element = self.track_object.getElement()
+ self._props_changed = []
+
+ self._undone()
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 84a179e..d47540a 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -19,13 +19,10 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
-import gobject
-
from pitivi.utils.signal import Signallable
-from pitivi.undo.undo import PropertyChangeTracker
-from pitivi.undo.undo import UndoableAction
+from pitivi.undo.undo import PropertyChangeTracker, UndoableAction
+from pitivi.undo.effect import TrackEffectAdded, TrackEffectRemoved
-from pitivi.effects import PROPS_TO_IGNORE
from pitivi.undo.effects import EffectGstElementPropertyChangeTracker
@@ -165,114 +162,6 @@ class TimelineObjectRemoved(UndoableAction):
self._undone()
-class TrackEffectAdded(UndoableAction):
- # Note: We have a bug if we just remove the TrackEffect 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 TrackEffect,
- # 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 TrackEffect when undoing so we reset theirs gst_element when
- # doing it again. The way of doing it is the same with TrackEffectRemoved
- 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):
- timeline = self.timeline_object.timeline
- tl_obj_track_obj = timeline.addEffectFactoryOnObject(self.factory,
- timeline_objects=[self.timeline_object])
-
- self.track_object = tl_obj_track_obj[0][1]
- element = self.track_object.getElement()
- for prop_name, prop_value in self.effect_props:
- element.set_property(prop_name, prop_value)
- for prop_name, prop_value in self.gnl_obj_props:
- self.track_object.gnl_object.set_property(prop_name, prop_value)
- for prop_changed in self._props_changed:
- prop_changed.gst_element = self.track_object.getElement()
- self._props_changed = []
-
- 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
- self.gnl_obj_props = [(prop.name, gnl_obj.get_property(prop.name))
- for prop in gnl_props
- if prop.flags & gobject.PARAM_WRITABLE]
-
- self.timeline_object.removeTrackObject(self.track_object)
- self.track_object.track.removeTrackObject(self.track_object)
- self._props_changed =\
- self._properties_watcher.getPropChangedFromTrackObj(self.track_object)
- del self.track_object
- self.track_object = None
-
- self._undone()
-
-
-class TrackEffectRemoved(UndoableAction):
- def __init__(self, timeline_object, track_object, properties_watcher):
- self.track_object = track_object
- self.timeline_object = timeline_object
- self.factory = track_object.factory
- self.effect_props = []
- self.gnl_obj_props = []
- self._properties_watcher = properties_watcher
- self._props_changed = []
-
- def do(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
- self.gnl_obj_props = [(prop.name, gnl_obj.get_property(prop.name))
- for prop in gnl_props
- if prop.flags & gobject.PARAM_WRITABLE]
-
- self.timeline_object.removeTrackObject(self.track_object)
- self.track_object.track.removeTrackObject(self.track_object)
- self._props_changed =\
- self._properties_watcher.getPropChangedFromTrackObj(self.track_object)
- del self.track_object
- self.track_object = None
-
- self._done()
-
- def undo(self):
- timeline = self.timeline_object.timeline
- tl_obj_track_obj = timeline.addEffectFactoryOnObject(self.factory,
- timeline_objects=[self.timeline_object])
-
- self.track_object = tl_obj_track_obj[0][1]
- element = self.track_object.getElement()
- for prop_name, prop_value in self.effect_props:
- element.set_property(prop_name, prop_value)
- for prop_name, prop_value in self.gnl_obj_props:
- self.track_object.gnl_object.set_property(prop_name, prop_value)
- for prop_changed in self._props_changed:
- prop_changed.gst_element = self.track_object.getElement()
- self._props_changed = []
-
- self._undone()
-
-
class InterpolatorKeyframeAdded(UndoableAction):
def __init__(self, track_object, keyframe):
self.track_object = track_object
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]