[pitivi: 7/18] Added back the option to start the application without the UI



commit 16ccafadccbeee1978be709d092877709d235bd5
Author: Alex BÄ?luÈ? <alexandru balut gmail com>
Date:   Thu Dec 16 11:29:59 2010 +0100

    Added back the option to start the application without the UI

 bin/pitivi.in         |    5 +++++
 pitivi/application.py |   40 +++++++++++++++++++++++-----------------
 2 files changed, 28 insertions(+), 17 deletions(-)
---
diff --git a/bin/pitivi.in b/bin/pitivi.in
index 5d86a2b..bce256b 100644
--- a/bin/pitivi.in
+++ b/bin/pitivi.in
@@ -130,6 +130,11 @@ def _init_gobject_gtk_gst():
 def _run_pitivi():
     import pitivi.application as ptv
 
+    # Make it easy for developers to debug the application startup.
+    if os.environ.get('PITIVI_DEBUG_NO_UI') == '1':
+        print 'Starting Pitivi with no GUI.'
+        ptv.GuiPitivi._showGui = lambda *args, **kargs : None
+
     sys.exit(ptv.main(sys.argv))
 
 try:
diff --git a/pitivi/application.py b/pitivi/application.py
index 0de5260..7580752 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -270,6 +270,7 @@ class GuiPitivi(InteractivePitivi):
 
     def __init__(self, debug=False):
         InteractivePitivi.__init__(self, debug)
+        self._showGui()
 
     def _showStartupError(self, message, detail):
         dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
@@ -282,8 +283,13 @@ class GuiPitivi(InteractivePitivi):
     def _eosCb(self, unused_obj):
         self.shutdown()
 
-    def _setGui(self, gui):
-        self.gui = gui
+    def _createGui(self):
+        """Returns a gtk.Widget which represents the UI."""
+        raise NotImplementedError()
+
+    def _showGui(self):
+        """Creates and shows the UI."""
+        self.gui = self._createGui()
         self.gui.show()
 
     def shutdown(self):
@@ -293,11 +299,15 @@ class GuiPitivi(InteractivePitivi):
             return True
         return False
 
-class ProjectCreatorGuiPitivi(GuiPitivi):
+class FullGuiPitivi(GuiPitivi):
+
+    def _createGui(self):
+        return PitiviMainWindow(self)
+
+class ProjectCreatorGuiPitivi(FullGuiPitivi):
 
     def __init__(self, media_filenames, add_to_timeline=False, debug=False):
-        GuiPitivi.__init__(self, debug)
-        self._setGui(PitiviMainWindow(self))
+        FullGuiPitivi.__init__(self, debug)
         # load the passed filenames, optionally adding them to the timeline
         # (useful during development)
         self.projectManager.newBlankProject()
@@ -335,18 +345,17 @@ class ProjectCreatorGuiPitivi(GuiPitivi):
 
         return True
 
-class ProjectLoaderGuiPitivi(GuiPitivi):
+class ProjectLoaderGuiPitivi(FullGuiPitivi):
 
     def __init__(self, project_filename, debug=False):
-        GuiPitivi.__init__(self, debug)
+        FullGuiPitivi.__init__(self, debug)
+
         self._loadProject(project_filename)
-        self._setGui(PitiviMainWindow(self))
 
-class StartupWizardGuiPitivi(GuiPitivi):
+class StartupWizardGuiPitivi(FullGuiPitivi):
 
     def __init__(self, debug=False):
-        GuiPitivi.__init__(self, debug)
-        self._setGui(PitiviMainWindow(self))
+        FullGuiPitivi.__init__(self, debug)
 
         self.projectManager.newBlankProject()
 
@@ -362,16 +371,13 @@ class PreviewGuiPitivi(GuiPitivi):
     def __init__(self, project_filename, debug=False):
         GuiPitivi.__init__(self, debug)
 
-        # init ui for previewing
-        self.viewer = PitiviViewer(self.settings)
-        self._setGui(self._createWindow(self.viewer))
-
         self._loadProject(project_filename)
 
-    def _createWindow(self, viewer):
+    def _createGui(self):
+        self.viewer = PitiviViewer(self.settings)
         window = gtk.Window()
         window.connect("delete-event", self._deleteCb)
-        window.add(viewer)
+        window.add(self.viewer)
         return window
 
     def _deleteCb(self, unused_widget, unused_data):



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