[pitivi] utils/timeline: Adds a "ClipEdited" undoable action.
- From: Jean-François Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] utils/timeline: Adds a "ClipEdited" undoable action.
- Date: Tue, 6 Aug 2013 10:14:11 +0000 (UTC)
commit eff672c1c4b6c07dfce8c667eb5060add7bbfa10
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date: Mon Jul 15 03:41:43 2013 +0200
utils/timeline: Adds a "ClipEdited" undoable action.
+ And use it in EditingContext
pitivi/timeline/elements.py | 7 +++++--
pitivi/utils/timeline.py | 41 +++++++++++++++++++++++++++++++++++++++--
2 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 220d96a..70ea894 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -300,7 +300,8 @@ class TrimHandle(Clutter.Texture):
self.timelineElement.timeline.bTimeline,
GES.EditMode.EDIT_TRIM,
edge,
- None)
+ None,
+ self.timelineElement.timeline._container.app.action_log)
self._context.connect("clip-trim", self.clipTrimCb)
self._context.connect("clip-trim-finished", self.clipTrimFinishedCb)
@@ -1064,7 +1065,9 @@ class URISourceElement(TimelineElement):
self.timeline.bTimeline,
mode,
GES.Edge.EDGE_NONE,
- None)
+ None,
+ self.timeline._container.app.action_log)
+
# This can't change during a drag, so we can safely compute it now for drag events.
nbrLayers = len(self.timeline.bTimeline.get_layers())
self.brother = self.timeline.findBrother(self.bElement)
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index 72cdb56..f8b9115 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -29,6 +29,8 @@ from pitivi.utils.signal import Signallable
from pitivi.utils.receiver import receiver, handler
from pitivi.utils.ui import Point
+from pitivi.undo.undo import UndoableAction
+
#from pitivi.utils.align import AutoAligner
# Selection modes
@@ -49,6 +51,23 @@ class TimelineError(Exception):
pass
+class ClipEdited(UndoableAction):
+ def __init__(self, focus, old_priority, new_priority, mode, edge, old_position, new_position):
+ self.focus = focus
+ self.old_priority = old_priority
+ self.old_position = old_position
+ self.new_priority = new_priority
+ self.new_position = new_position
+ self.mode = mode
+ self.edge = edge
+
+ def do(self):
+ self.focus.edit([], self.new_priority, self.mode, self.edge, long(self.new_position))
+
+ def undo(self):
+ self.focus.edit([], self.old_priority, self.mode, self.edge, long(self.old_position))
+
+
class Selected(Signallable):
"""
A simple class that let us emit a selected-changed signal
@@ -213,7 +232,7 @@ class EditingContext(Signallable):
"clip-trim-finished": [],
}
- def __init__(self, focus, timeline, mode, edge, settings):
+ def __init__(self, focus, timeline, mode, edge, settings, action_log):
"""
@param focus: the Clip or TrackElement which is to be the
main target of interactive editing, such as the object directly under the
@@ -242,14 +261,29 @@ class EditingContext(Signallable):
self.focus = focus.get_parent()
else:
self.focus = focus
+
+ self.old_position = self.focus.get_start()
+ if edge == GES.Edge.EDGE_END and mode == GES.EditMode.EDIT_TRIM:
+ self.old_position += self.focus.get_duration()
+
+ self.old_priority = self.focus.get_priority()
+
self.timeline = timeline
+ self.action_log = action_log
self.edge = edge
self.mode = mode
+ self.action_log.begin("move-clip")
+
def finish(self):
"""Clean up timeline for normal editing"""
- # TODO: post undo / redo action here
+
+ action = ClipEdited(self.focus, self.old_priority, self.new_priority, self.mode, self.edge,
+ self.old_position, self.new_position)
+
+ self.action_log.push(action)
+ self.action_log.commit()
self.timeline.commit()
self.emit("clip-trim-finished")
@@ -266,6 +300,9 @@ class EditingContext(Signallable):
else:
priority = max(0, priority)
+ self.new_position = position
+ self.new_priority = priority
+
res = self.focus.edit([], priority, self.mode, self.edge, long(position))
if res and self.mode == GES.EditMode.EDIT_TRIM:
if self.edge == GES.Edge.EDGE_START:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]