[pitivi] Serialize the setting of asset on transition



commit 91cb72706e1883cd77d9a217b0da499b9992748f
Author: Thibault Saunier <tsaunier gnome org>
Date:   Thu Sep 25 19:00:23 2014 +0200

    Serialize the setting of asset on transition
    
    And simplify the way we write action in the file
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739251

 pitivi/application.py       |   12 ++++++++++--
 pitivi/project.py           |    9 ++++-----
 pitivi/timeline/timeline.py |    7 +++----
 pitivi/transitions.py       |    7 ++++++-
 pitivi/utils/timeline.py    |   14 +++++++-------
 5 files changed, 30 insertions(+), 19 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index c7144b8..19ce795 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -98,13 +98,21 @@ class Pitivi(Gtk.Application, Loggable):
         self.connect("activate", self._activateCb)
         self.connect("open", self.openCb)
 
-    def write_action(self, structure):
+    def write_action(self, action, properties={}):
         if self._first_action:
             self.log_file.write(
                 "description, seek=true, handles-states=true\n")
             self._first_action = False
 
-        self.log_file.write(structure.to_string() + "\n")
+        if not isinstance(action, Gst.Structure):
+            structure = Gst.Structure.new_empty(action)
+
+            for key, value in properties.items():
+                structure[key] = value
+
+            action = structure
+
+        self.log_file.write(action.to_string() + "\n")
         self.log_file.flush()
 
     def _startupCb(self, unused_app):
diff --git a/pitivi/project.py b/pitivi/project.py
index 80726bc..966615a 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -963,7 +963,7 @@ class Project(Loggable, GES.Project):
         Our override of the GES.Timeline.commit method, letting us
         scenarialize the action in the scenarios.
         """
-        self.app.write_action(Gst.Structure.new_empty("commit"))
+        self.app.write_action("commit")
         GES.Timeline.commit(self.timeline)
 
     def createTimeline(self):
@@ -997,10 +997,9 @@ class Project(Loggable, GES.Project):
         for track in self.timeline.get_tracks():
             if isinstance(track, GES.VideoTrack):
                 track.set_restriction_caps(caps)
-        st = Gst.Structure.new_empty("set-track-restriction-caps")
-        st["caps"] = caps.to_string()
-        st["track-type"] = GES.TrackType.VIDEO.value_nicks[0]
-        self.app.write_action(st)
+        self.app.write_action("set-track-restriction-caps", {
+            "caps": caps.to_string(),
+            "track-type": GES.TrackType.VIDEO.value_nicks[0]})
 
         self.pipeline.flushSeek()
 
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 472b1d0..59b9bfe 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1264,10 +1264,9 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
                 clip = element.get_parent()
                 clip.get_layer().splitting_object = True
 
-                st = Gst.Structure.new_empty("split-clip")
-                st["clip-name"] = clip.get_name()
-                st["position"] = float(position / Gst.SECOND)
-                self.app.write_action(st)
+                self.app.write_action("split-clip", {
+                    "clip-name": clip.get_name(),
+                    "position": float(position / Gst.SECOND)})
 
                 clip.split(position)
                 clip.get_layer().splitting_object = False
diff --git a/pitivi/transitions.py b/pitivi/transitions.py
index 9c4b162..280892c 100644
--- a/pitivi/transitions.py
+++ b/pitivi/transitions.py
@@ -22,6 +22,7 @@
 
 import os
 
+from gi.repository import Gst
 from gi.repository import GES
 from gi.repository import GLib
 from gi.repository import GObject
@@ -171,7 +172,11 @@ class TransitionsListWidget(Gtk.VBox, Loggable):
         else:
             self.props_widgets.set_sensitive(True)
 
-        self.element.get_parent().set_asset(transition_asset)
+        clip_asset = self.element.get_parent()
+        clip_asset.set_asset(transition_asset)
+        self.app.write_action("element-set-asset", {
+            "asset-id": transition_asset.get_id(),
+            "element-name": clip_asset.get_name()})
         self.app.project_manager.current_project.seeker.flush(True)
 
         return True
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index 8334a6c..b77f606 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -273,13 +273,13 @@ class EditingContext(GObject.Object):
 
         res = self.focus.edit(
             [], priority, self.mode, self.edge, int(position))
-        st = Gst.Structure.new_empty("edit-container")
-        st["container-name"] = self.focus.get_name()
-        st["position"] = float(position / Gst.SECOND)
-        st["edit-mode"] = self.mode.value_nick
-        st["edge"] = self.edge.value_nick
-        st["new-layer-priority"] = int(priority)
-        self.action_log.app.write_action(st)
+        self.action_log.app.write_action("edit-container", {
+            "container-name": self.focus.get_name(),
+            "position": float(position / Gst.SECOND),
+            "edit-mode": self.mode.value_nick,
+            "edge": self.edge.value_nick,
+            "new-layer-priority": int(priority)})
+
         if res and self.mode == GES.EditMode.EDIT_TRIM:
             if self.edge == GES.Edge.EDGE_START:
                 self.emit("clip-trim", self.focus, self.focus.props.in_point)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]