[pitivi] Cleanup commit_timeline calls



commit 967d73139cf445d44c4b4f14445eab38e06b1f80
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sat Sep 3 19:51:01 2016 +0200

    Cleanup commit_timeline calls
    
    Remove some which were not needed because CommitTimelineFinalizingAction
    was being used already.
    Replaced some with CommitTimelineFinalizingAction.
    
    Also moved the selection reset out of the action log transaction in
    TimelineContainer._ungroupSelected.
    
    Differential Revision: https://phabricator.freedesktop.org/D1296

 pitivi/clipproperties.py    |   14 ++++++--------
 pitivi/effects.py           |    1 -
 pitivi/timeline/layer.py    |    1 -
 pitivi/timeline/timeline.py |   24 ++++++++++--------------
 4 files changed, 16 insertions(+), 24 deletions(-)
---
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index 57ac1e9..4895c65 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -299,12 +299,12 @@ class EffectProperties(Gtk.Expander, Loggable):
         self._removeEffect(effect)
 
     def _removeEffect(self, effect):
-        pipeline = self._project.ges_timeline.get_parent()
-        with self.app.action_log.started("remove effect", CommitTimelineFinalizingAction(pipeline)):
+        pipeline = self._project.pipeline
+        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)
-            pipeline.commit_timeline()
         self._updateTreeview()
 
     def addEffectToClip(self, clip, factory_name, priority=None):
@@ -327,14 +327,13 @@ 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
-                pipeline = self._project.ges_timeline.get_parent()
+                pipeline = self._project.pipeline
                 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)
-                pipeline.commit_timeline()
                 break
         return None
 
@@ -428,7 +427,6 @@ class EffectProperties(Gtk.Expander, Loggable):
                                          CommitTimelineFinalizingAction(pipeline)):
             clip.set_top_effect_priority(effect, drop_index)
 
-        pipeline.commit_timeline()
         new_path = Gtk.TreePath.new()
         new_path.append_index(drop_index)
         self.__updateAll(path=new_path)
@@ -623,9 +621,9 @@ class TransformationProperties(Gtk.Expander, Loggable):
         res, cvalue = self.source.get_child_property(prop)
         assert res
         if value != cvalue:
-            with self.app.action_log.started("Transformation property change"):
+            with self.app.action_log.started("Transformation property change",
+                                             CommitTimelineFinalizingAction(self._project.pipeline)):
                 self.source.set_child_property(prop, value)
-            self._project.pipeline.commit_timeline()
             self.app.gui.viewer.overlay_stack.update(self.source)
 
     def __setSource(self, source):
diff --git a/pitivi/effects.py b/pitivi/effects.py
index 46bf5fa..8654891 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -590,5 +590,4 @@ class EffectsPropertiesManager:
             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 7738c65..ed9929e 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -232,7 +232,6 @@ class LayerControls(Gtk.EventBox, Loggable):
         with self.app.action_log.started("delete layer",
                                          CommitTimelineFinalizingAction(pipeline)):
             self.ges_timeline.remove_layer(self.ges_layer)
-        pipeline.commit_timeline()
 
     def __move_layer_cb(self, unused_simple_action, unused_parameter, step):
         index = self.ges_layer.get_priority()
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 1281f1a..59c9689 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1146,7 +1146,6 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
 
     def __endMovingLayer(self):
         self.app.action_log.commit("move layer")
-        self._project.pipeline.commit_timeline()
         self.__moving_layer = None
 
 
@@ -1231,7 +1230,8 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
         initial_position = self.__getInsertPosition(position)
         clip_position = initial_position
 
-        with self.app.action_log.started("add asset"):
+        with self.app.action_log.started("add asset",
+                                         CommitTimelineFinalizingAction(self._project.pipeline)):
             for obj in objs:
                 if isinstance(obj, GES.Clip):
                     obj.set_start(clip_position)
@@ -1252,7 +1252,6 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
                 else:
                     raise TimelineError("Cannot insert: %s" % type(obj))
                 clip_position += duration
-        self._project.pipeline.commit_timeline()
 
         if zoom_was_fitted:
             self._setBestZoomRatio()
@@ -1568,15 +1567,14 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
 
     def _deleteSelected(self, unused_action, unused_parameter):
         if self.ges_timeline:
-            with self.app.action_log.started("delete clip"):
+            with self.app.action_log.started("delete clip",
+                                             CommitTimelineFinalizingAction(self._project.pipeline)):
                 for clip in self.timeline.selection:
                     layer = clip.get_layer()
                     if isinstance(clip, GES.TransitionClip):
                         continue
                     layer.remove_clip(clip)
 
-                self._project.pipeline.commit_timeline()
-
             self.timeline.selection.setSelection([], SELECT)
 
     def _ungroupSelected(self, unused_action, unused_parameter):
@@ -1584,24 +1582,24 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
             self.info("No ges_timeline set yet!")
             return
 
-        with self.app.action_log.started("ungroup"):
+        with self.app.action_log.started("ungroup",
+                                         CommitTimelineFinalizingAction(self._project.pipeline)):
             for obj in self.timeline.selection:
                 toplevel = obj.get_toplevel_parent()
                 if toplevel == self.timeline.current_group:
                     for child in toplevel.get_children(False):
                         child.ungroup(False)
 
-            self.timeline.resetSelectionGroup()
-            self.timeline.selection.setSelection([], SELECT)
-
-        self._project.pipeline.commit_timeline()
+        self.timeline.resetSelectionGroup()
+        self.timeline.selection.setSelection([], SELECT)
 
     def _groupSelected(self, unused_action, unused_parameter):
         if not self.ges_timeline:
             self.info("No timeline set yet?")
             return
 
-        with self.app.action_log.started("group"):
+        with self.app.action_log.started("group",
+                                         CommitTimelineFinalizingAction(self._project.pipeline)):
             containers = set()
             new_group = None
             for obj in self.timeline.selection:
@@ -1621,8 +1619,6 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
             if new_group:
                 self.timeline.current_group.add(new_group)
 
-            self._project.pipeline.commit_timeline()
-
     def __copyClipsCb(self, unused_action, unused_parameter):
         if self.timeline.current_group:
             self.__copiedGroup = self.timeline.current_group.copy(True)


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