[pitivi: 28/41] Add a check for soft dependencies on startup



commit 1c4d249e837f7883b8a57a478c8e0d0ad2b6bf88
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Wed Aug 10 17:08:49 2011 +0200

    Add a check for soft dependencies on startup

 data/ui/startupwizard.ui   |   56 +++++++++++++++++++++++++++++++++----------
 pitivi/check.py            |   20 +++++++++++++++
 pitivi/ui/startupwizard.py |    9 +++++++
 3 files changed, 72 insertions(+), 13 deletions(-)
---
diff --git a/data/ui/startupwizard.ui b/data/ui/startupwizard.ui
index 63e00f6..3a654f0 100644
--- a/data/ui/startupwizard.ui
+++ b/data/ui/startupwizard.ui
@@ -1,34 +1,42 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy project-wide -->
+  <object class="GtkImage" id="image2">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="stock">gtk-open</property>
+  </object>
   <object class="GtkWindow" id="window1">
-    <property name="visible">False</property>
+    <property name="can_focus">False</property>
     <property name="border_width">10</property>
     <property name="title" translatable="yes">Welcome</property>
     <property name="resizable">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
-    <property name="type_hint">normal</property>
     <property name="skip_taskbar_hint">True</property>
-    <signal name="delete_event" handler="_deleteCb"/>
-    <signal name="key_press_event" handler="_keyPressCb"/>
+    <signal name="key-press-event" handler="_keyPressCb" swapped="no"/>
+    <signal name="delete-event" handler="_deleteCb" swapped="no"/>
     <child>
       <object class="GtkHBox" id="hbox2">
         <property name="visible">True</property>
+        <property name="can_focus">False</property>
         <property name="spacing">12</property>
         <child>
           <object class="GtkVBox" id="vbox1">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="spacing">6</property>
             <child>
               <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">Double-click a project below to load it:</property>
               </object>
               <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -37,24 +45,30 @@
                 <property name="width_request">300</property>
                 <property name="height_request">215</property>
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="limit">7</property>
                 <property name="show_not_found">False</property>
                 <property name="show_tips">True</property>
                 <property name="sort_type">mru</property>
-                <signal name="item_activated" handler="_loadCb"/>
+                <signal name="item-activated" handler="_loadCb" swapped="no"/>
               </object>
               <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
                 <property name="position">1</property>
               </packing>
             </child>
           </object>
           <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">0</property>
           </packing>
         </child>
         <child>
           <object class="GtkVButtonBox" id="vbuttonbox2">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="spacing">6</property>
             <property name="layout_style">start</property>
             <child>
@@ -63,8 +77,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
-                <signal name="clicked" handler="_newProjectCb"/>
+                <signal name="clicked" handler="_newProjectCb" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -78,8 +93,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
-                <signal name="clicked" handler="_userManualCb"/>
+                <signal name="clicked" handler="_userManualCb" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -93,8 +109,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
                 <property name="image">image2</property>
-                <signal name="clicked" handler="_onBrowseButtonClickedCb"/>
+                <signal name="clicked" handler="_onBrowseButtonClickedCb" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -102,16 +119,29 @@
                 <property name="position">2</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="missing_deps_button">
+                <property name="label" translatable="yes">Missing dependencies...</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <signal name="clicked" handler="_onMissingDepsButtonClickedCb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
           </object>
           <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
       </object>
     </child>
   </object>
-  <object class="GtkImage" id="image2">
-    <property name="visible">True</property>
-    <property name="stock">gtk-open</property>
-  </object>
 </interface>
diff --git a/pitivi/check.py b/pitivi/check.py
index 84a980f..59b748a 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -105,6 +105,8 @@ def check_required_version(modulename):
 
 def initial_checks():
     reg = gst.registry_get_default()
+    global soft_deps
+    soft_deps = {}
     if PiTiVi:
         return (_("%s is already running") % APPNAME,
                 _("An instance of %s is already running in this script.") % APPNAME)
@@ -158,4 +160,22 @@ def initial_checks():
     if not __try_import__("pkg_resources"):
         return (_("Could not import the distutils modules"),
                 _("Make sure you have the distutils Python module installed."))
+
+    # The following are soft dependencies
+    # Note that instead of checking for plugins using gst.registry_get_default().find_plugin("foo"),
+    # we could check for elements using gst.element_factory.make("foo")
+    if not __try_import__("numpy"):
+        soft_deps["NumPy"] = _("Enables the autoalign feature")
+    if not gst.registry_get_default().find_plugin("frei0r"):
+        soft_deps["Frei0r"] = _("Additional video effects")
+    if not gst.registry_get_default().find_plugin("ffmpeg"):
+        soft_deps["GStreamer FFmpeg plugin"] = _('Additional multimedia codecs through the FFmpeg library')
+    # Test for gst bad
+    # This is disabled because, by definition, gst bad is a set of plugins that can
+    # move to gst good or ugly, and we don't really have something to rely upon.
+    #if not gst.registry_get_default().find_plugin("swfdec"): # FIXME: find a more representative plugin
+    #    soft_deps["GStreamer bad plugins"] = _('Additional GStreamer plugins whose code is not of good enough quality, or are not considered tested well enough. The licensing may or may not be LGPL')
+    # Test for gst ugly
+    #if not gst.registry_get_default().find_plugin("x264"):
+    #    soft_deps["GStreamer ugly plugins"] = _('Additional good quality GStreamer plugins whose license is not LGPL or with licensing issues')
     return None
diff --git a/pitivi/ui/startupwizard.py b/pitivi/ui/startupwizard.py
index 3f2c64d..1e2ddcc 100644
--- a/pitivi/ui/startupwizard.py
+++ b/pitivi/ui/startupwizard.py
@@ -27,6 +27,8 @@ from gettext import gettext as _
 
 from pitivi.configure import get_ui_dir
 from pitivi.configure import APPMANUALURL
+from pitivi.ui.depsmanager import DepsManager
+from pitivi.check import soft_deps
 
 from urllib import unquote
 
@@ -58,6 +60,9 @@ class StartUpWizard(object):
         filter.add_pattern("*.xptv")
         self.recent_chooser.add_filter(filter)
 
+        if not soft_deps:
+            self.builder.get_object("missing_deps_button").hide()
+
         self.app.projectManager.connect("new-project-failed",
                 self._projectFailedCb)
         self.app.projectManager.connect("new-project-loaded",
@@ -89,6 +94,10 @@ class StartUpWizard(object):
         """Handle a click on the Browse button."""
         self.app.gui.openProject()
 
+    def _onMissingDepsButtonClickedCb(self, unused_button):
+        self.hide()
+        self.dep_manager = DepsManager()
+
     def _userManualCb(self, unused_button):
         """Handle a click on the Help button."""
         webbrowser.open(APPMANUALURL)



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