[pitivi] Add a validate utility and override the stop; action type in there



commit 6e8551921a00bce94e0e7da58a7023599a8f80bd
Author: Thibault Saunier <tsaunier gnome org>
Date:   Wed Dec 10 19:59:28 2014 +0100

    Add a validate utility and override the stop; action type in there
    
    In the future we can override more action types

 pitivi/check.py          |    3 +++
 pitivi/project.py        |   10 +++-------
 pitivi/utils/Makefile.am |    1 +
 pitivi/utils/validate.py |   44 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 51 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/check.py b/pitivi/check.py
index 5c0305a..3cea5ec 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -267,6 +267,9 @@ def initialize_modules():
     from gi.repository import GES
     GES.init()
 
+    from pitivi.utils import validate
+    validate.init()
+
 
 """
 --------------------------------------------------------------------------------
diff --git a/pitivi/project.py b/pitivi/project.py
index f0213e1..ca19128 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -40,6 +40,7 @@ from pwd import getpwuid
 from pitivi.undo.undo import UndoableAction
 from pitivi.configure import get_ui_dir
 
+from pitivi.utils.validate import has_validate
 from pitivi.utils.misc import quote_uri, path_from_uri, isWritable, unicode_error_dialog
 from pitivi.utils.pipeline import PipelineError, Seeker
 from pitivi.utils.loggable import Loggable
@@ -53,13 +54,6 @@ from pitivi.preset import AudioPresetManager, DuplicatePresetNameException,\
     VideoPresetManager
 from pitivi.render import CachedEncoderList
 
-try:
-    from gi.repository import GstValidate
-    GstValidate.init()
-    has_validate = GES.validate_register_action_types()
-except ImportError:
-    has_validate = False
-
 
 DEFAULT_MUXER = "oggmux"
 DEFAULT_VIDEO_ENCODER = "theoraenc"
@@ -788,6 +782,8 @@ class Project(Loggable, GES.Project):
         self._has_rendering_values = False
 
     def setupValidateScenario(self):
+        from gi.repository import GstValidate
+
         self.info("Setting up validate scenario")
         self.runner = GstValidate.Runner.new()
         self.monitor = GstValidate.Monitor.factory_create(
diff --git a/pitivi/utils/Makefile.am b/pitivi/utils/Makefile.am
index f7b9a31..15a82e2 100644
--- a/pitivi/utils/Makefile.am
+++ b/pitivi/utils/Makefile.am
@@ -11,6 +11,7 @@ utils_PYTHON =        \
        threads.py      \
        ripple_update_group.py  \
        misc.py         \
+       validate.py     \
        widgets.py
 
 clean-local:
diff --git a/pitivi/utils/validate.py b/pitivi/utils/validate.py
new file mode 100644
index 0000000..7b8575e
--- /dev/null
+++ b/pitivi/utils/validate.py
@@ -0,0 +1,44 @@
+# Pitivi video editor
+#
+#       pitivi/utils/validate.py
+#
+# Copyright (c) 2014, Thibault Saunier <thibault saunier collabora com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+import sys
+from gi.repository import GES
+
+has_validate = False
+
+
+def stop(scenario, action):
+    sys.stdout.write("STOP action, not doing anything in pitivi")
+    sys.stdout.flush()
+    return 1
+
+
+def init():
+    global has_validate
+    try:
+        from gi.repository import GstValidate
+        GstValidate.init()
+        has_validate = GES.validate_register_action_types()
+        GstValidate.register_action_type("stop", "pitivi",
+                                         stop, None,
+                                         "Pitivi override for the stop action",
+                                         GstValidate.ActionTypeFlags.NONE)
+    except ImportError:
+        has_validate = False


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