[pitivi] application: Use **kwargs to write GstValidate action types



commit 6f7081f4ecb9591a8a933b9b8488a55fd6a9c0f3
Author: Thibault Saunier <tsaunier gnome org>
Date:   Fri Nov 11 10:34:09 2016 -0300

    application: Use **kwargs to write GstValidate action types
    
    Reviewed-by: Alex Băluț <alexandru balut gmail com>
    Differential Revision: https://phabricator.freedesktop.org/D1471

 pitivi/application.py       |    7 ++++---
 pitivi/project.py           |    7 ++++---
 pitivi/timeline/timeline.py |    8 ++++----
 pitivi/transitions.py       |    6 +++---
 pitivi/utils/timeline.py    |   18 ++++++++----------
 pitivi/utils/widgets.py     |    4 ++--
 6 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 11874f3..6ffe44a 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -93,7 +93,7 @@ class Pitivi(Gtk.Application, Loggable):
         Zoomable.app = self
         self.shortcuts = ShortcutsManager(self)
 
-    def write_action(self, action, properties={}):
+    def write_action(self, action, **kwargs):
         if self._scenario_file is None:
             return
 
@@ -113,7 +113,8 @@ class Pitivi(Gtk.Application, Loggable):
         if not isinstance(action, Gst.Structure):
             structure = Gst.Structure.new_empty(action)
 
-            for key, value in properties.items():
+            for key, value in kwargs.items():
+                key = key.replace("_", "-")
                 structure[key] = value
 
             action = structure
@@ -266,7 +267,7 @@ class Pitivi(Gtk.Application, Loggable):
             with open(project_path) as project:
                 content = project.read().replace("\n", "")
                 self.write_action("load-project",
-                                  {"serialized-content": content})
+                                  serialized_content=content)
 
     def _newProjectLoadingCb(self, unused_project_manager, project):
         self._setScenarioFile(project.get_uri())
diff --git a/pitivi/project.py b/pitivi/project.py
index 04f17d1..7e1f0dc 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -1258,9 +1258,10 @@ class Project(Loggable, GES.Project):
                 track.set_restriction_caps(caps)
 
         if self.app:
-            self.app.write_action("set-track-restriction-caps", {
-                "caps": caps.to_string(),
-                "track-type": GES.TrackType.VIDEO.value_nicks[0]})
+            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 be63d34..1956ac9 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1701,9 +1701,9 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
             if start < position and end > position:
                 clip.get_layer().splitting_object = True
 
-                self.app.write_action("split-clip", {
-                    "clip-name": clip.get_name(),
-                    "position": float(position / Gst.SECOND)})
+                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
@@ -1823,7 +1823,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
         Zoomable.zoomOut()
 
     def _zoomFitCb(self, unused_action, unused_parameter):
-        self.app.write_action("zoom-fit", {"optional-action-type": True})
+        self.app.write_action("zoom-fit", optional_action_type=True)
 
         self.timeline.set_best_zoom_ratio(allow_zoom_in=True)
 
diff --git a/pitivi/transitions.py b/pitivi/transitions.py
index 235ee1d..7eba7b4 100644
--- a/pitivi/transitions.py
+++ b/pitivi/transitions.py
@@ -204,9 +204,9 @@ class TransitionsListWidget(Gtk.Box, Loggable):
             self.props_widgets.set_sensitive(True)
 
         self.element.get_parent().set_asset(transition_asset)
-        self.app.write_action("element-set-asset", {
-            "asset-id": transition_asset.get_id(),
-            "element-name": self.element.get_name()})
+        self.app.write_action("element-set-asset",
+            asset_id=transition_asset.get_id(),
+            element_name=self.element.get_name())
         self.app.project_manager.current_project.pipeline.flushSeek()
 
         return True
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index 236c3ee..a2092b7 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -284,12 +284,12 @@ class EditingContext(GObject.Object, Loggable):
         self.new_priority = priority
 
         res = self.focus.edit([], priority, self.mode, self.edge, int(position))
-        self.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)})
+        self.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:
@@ -374,14 +374,12 @@ class Zoomable(object):
     @classmethod
     def zoomIn(cls):
         cls.setZoomLevel(cls._cur_zoom + 1)
-        cls.app.write_action("zoom-in",
-                             {"optional-action-type": True})
+        cls.app.write_action("zoom-in", optional_action_type=True)
 
     @classmethod
     def zoomOut(cls):
         cls.setZoomLevel(cls._cur_zoom - 1)
-        cls.app.write_action("zoom-out",
-                             {"optional-action-type": True})
+        cls.app.write_action("zoom-out", optional_action_type=True)
 
     @classmethod
     def computeZoomRatio(cls, x):
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 55bf453..1c3df19 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -1068,8 +1068,8 @@ class ZoomBox(Gtk.Grid, Zoomable):
     def _zoomAdjustmentChangedCb(self, adjustment):
         Zoomable.setZoomLevel(adjustment.get_value())
         self.timeline.app.write_action("set-zoom-level",
-                                       {"level": adjustment.get_value(),
-                                        "optional-action-type": True})
+                                       level=adjustment.get_value(),
+                                       optional_action_type=True)
 
         if self._manual_set is False:
             self.timeline.timeline.scrollToPlayhead()


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