[pitivi] undo: Make use of CommitTimelineFinalizingAction all around



commit 920d44a0a434040be8806c0ab39660d9442e954d
Author: Thibault Saunier <tsaunier gnome org>
Date:   Tue Apr 26 17:38:21 2016 -0400

    undo: Make use of CommitTimelineFinalizingAction all around
    
    Reviewed-by: Alex Băluț <alexandru balut gmail com>
    Differential Revision: https://phabricator.freedesktop.org/D977

 pitivi/clipproperties.py |   20 +++++++++++++-------
 pitivi/effects.py        |    9 ++++++---
 pitivi/timeline/layer.py |    7 +++++--
 pitivi/undo/timeline.py  |    4 ----
 4 files changed, 24 insertions(+), 16 deletions(-)
---
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index 3457ac0..6c88191 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -35,6 +35,7 @@ from pitivi.effects import AUDIO_EFFECT
 from pitivi.effects import EffectsPropertiesManager
 from pitivi.effects import HIDDEN_EFFECTS
 from pitivi.effects import VIDEO_EFFECT
+from pitivi.undo.timeline import CommitTimelineFinalizingAction
 from pitivi.utils.loggable import Loggable
 from pitivi.utils.ui import disable_scroll
 from pitivi.utils.ui import EFFECT_TARGET_ENTRY
@@ -303,11 +304,12 @@ class EffectProperties(Gtk.Expander, Loggable):
         self._removeEffect(effect)
 
     def _removeEffect(self, effect):
-        with self.app.action_log.started("remove effect"):
+        pipeline = self._project.timeline.get_parent()
+        with self.app.action_log.started("remove effect", CommitTimelineFinalizingAction(pipeline)):
             self.__remove_configuration_widget()
             self.effects_properties_manager.cleanCache(effect)
             effect.get_parent().remove(effect)
-            self._project.timeline.commit()
+            pipeline.commit_timeline()
         self._updateTreeview()
 
     def addEffectToClip(self, clip, factory_name, priority=None):
@@ -320,12 +322,14 @@ class EffectProperties(Gtk.Expander, Loggable):
             if track_type == GES.TrackType.AUDIO and media_type == AUDIO_EFFECT or \
                     track_type == GES.TrackType.VIDEO and media_type == VIDEO_EFFECT:
                 # Actually add the effect
-                with self.app.action_log.started("add effect"):
+                pipeline = self._project.timeline.get_parent()
+                with self.app.action_log.started("add effect",
+                                                 CommitTimelineFinalizingAction(pipeline)):
                     effect = GES.Effect.new(bin_description=factory_name)
                     clip.add(effect)
                     if priority is not None and priority < len(model):
                         clip.set_top_effect_priority(effect, priority)
-                    self._project.timeline.commit()
+                pipeline.commit_timeline()
                 break
 
     def addEffectToCurrentSelection(self, factory_name):
@@ -414,10 +418,12 @@ class EffectProperties(Gtk.Expander, Loggable):
         # The paths are different.
         effects = clip.get_top_effects()
         effect = effects[source_index]
-        with self.app.action_log.started("move effect"):
+        pipeline = self._project.timeline.get_parent()
+        with self.app.action_log.started("move effect",
+                                         CommitTimelineFinalizingAction(pipeline)):
             clip.set_top_effect_priority(effect, drop_index)
-            self._project.timeline.commit()
-        self._project.pipeline.flushSeek()
+
+        pipeline.commit_timeline()
         new_path = Gtk.TreePath.new()
         new_path.append_index(drop_index)
         self.__updateAll(path=new_path)
diff --git a/pitivi/effects.py b/pitivi/effects.py
index cd84209..f22ffe3 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -591,8 +591,11 @@ class EffectsPropertiesManager:
             value = Gst.Fraction(int(value.num), int(value.denom))
 
         if value != self._current_element_values.get(prop.name):
-            with self.app.action_log.started("Effect property change"):
-                effect.set_child_property(prop.name, value)
+            from pitivi.undo.timeline import CommitTimelineFinalizingAction
 
-            self.app.project_manager.current_project.pipeline.flushSeek()
+            pipeline = self.app.project_manager.current_project.pipeline
+            with self.app.action_log.started("Effect property change",
+                                             CommitTimelineFinalizingAction(pipeline)):
+                effect.set_child_property(prop.name, value)
+            pipeline.commit_timeline()
             self._current_element_values[prop.name] = value
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index 0fed9d1..65b0703 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -29,6 +29,7 @@ from gi.repository import GObject
 from gi.repository import Gtk
 
 from pitivi.timeline import elements
+from pitivi.undo.timeline import CommitTimelineFinalizingAction
 from pitivi.utils import ui
 from pitivi.utils.loggable import Loggable
 from pitivi.utils.timeline import Zoomable
@@ -253,9 +254,11 @@ class LayerControls(Gtk.EventBox, Loggable):
         return menu_model, action_group
 
     def _deleteLayerCb(self, unused_action, unused_parametter):
-        with self.app.action_log.started("delete layer"):
+        pipeline = self.ges_timeline.get_asset().pipeline
+        with self.app.action_log.started("delete layer",
+                                         CommitTimelineFinalizingAction(pipeline)):
             self.ges_timeline.remove_layer(self.ges_layer)
-            self.ges_timeline.get_asset().pipeline.commit_timeline()
+        pipeline.commit_timeline()
 
     def _moveLayerCb(self, unused_simple_action, unused_parametter, step):
         index = self.ges_layer.get_priority()
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 18e93ec..e7f168a 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -148,7 +148,6 @@ class TrackElementAdded(UndoableAction):
         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().get_asset().pipeline.commit_timeline()
         self._props_changed = []
         self._done()
 
@@ -206,7 +205,6 @@ class TrackElementRemoved(UndoableAction):
         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().get_asset().pipeline.commit_timeline()
         self._props_changed = []
         self._undone()
 
@@ -302,13 +300,11 @@ class ClipPropertyChanged(UndoableAction):
     def do(self):
         self.clip.set_property(
             self.property_name.replace("-", "_"), self.new_value)
-        self.clip.get_layer().get_timeline().get_asset().pipeline.commit_timeline()
         self._done()
 
     def undo(self):
         self.clip.set_property(
             self.property_name.replace("-", "_"), self.old_value)
-        self.clip.get_layer().get_timeline().get_asset().pipeline.commit_timeline()
         self._undone()
 
 


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