[pitivi: 29/41] Create a missing dependencies dialog



commit f6bc3cf2d293570412f689dd6a2f025249a42b63
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Wed Aug 10 19:05:02 2011 +0200

    Create a missing dependencies dialog

 data/ui/Makefile.am      |    1 +
 data/ui/depsmanager.ui   |  111 ++++++++++++++++++++++++++++++++++++++++++++++
 pitivi/check.py          |   17 +++++--
 pitivi/ui/Makefile.am    |    1 +
 pitivi/ui/depsmanager.py |   64 ++++++++++++++++++++++++++
 5 files changed, 190 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
index 6cb0307..2cd10c9 100644
--- a/data/ui/Makefile.am
+++ b/data/ui/Makefile.am
@@ -7,6 +7,7 @@ ui_DATA = \
 	mainwindow.xml		 \
 	preferences.ui		 \
 	projectsettings.ui	 \
+	depsmanager.ui	\
 	startupwizard.ui
 
 EXTRA_DIST = \
diff --git a/data/ui/depsmanager.ui b/data/ui/depsmanager.ui
new file mode 100644
index 0000000..19d4d89
--- /dev/null
+++ b/data/ui/depsmanager.ui
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkDialog" id="window1">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Missing Dependencies</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="close_btn">
+                <property name="label">gtk-close</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>
+                <property name="use_stock">True</property>
+                <signal name="clicked" handler="_onCloseButtonClickedCb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="install_btn">
+                <property name="label" translatable="yes">Install</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="_onInstallButtonClickedCb" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="box1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">12</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">To enable additional features, please install the following packages and restart PiTiVi:</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkAlignment" id="alignment1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="left_padding">24</property>
+                <child>
+                  <object class="GtkLabel" id="pkg_list">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">label</property>
+                    <property name="wrap">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">close_btn</action-widget>
+      <action-widget response="0">install_btn</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/pitivi/check.py b/pitivi/check.py
index 59b748a..c129fe7 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -31,6 +31,9 @@ from gettext import gettext as _
 from pitivi.instance import PiTiVi
 from pitivi.configure import APPNAME, PYGTK_REQ, PYGST_REQ, GST_REQ, GNONLIN_REQ, PYCAIRO_REQ
 
+global soft_deps
+soft_deps = {}
+
 
 def initiate_videosinks():
     """
@@ -105,8 +108,6 @@ 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)
@@ -163,10 +164,13 @@ def initial_checks():
 
     # 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")
+    # 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"):
+    try:
+        #if not gst.registry_get_default().find_plugin("frei0r"):
+        gst.element_factory_make("frei0r-filter-scale0tilt")
+    except gst.ElementNotFoundError:
         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')
@@ -179,3 +183,8 @@ def initial_checks():
     #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
+
+
+def get_softdeps():
+    """Returns the soft_deps dictionary."""
+    return soft_deps
diff --git a/pitivi/ui/Makefile.am b/pitivi/ui/Makefile.am
index 4cf007b..c4559a6 100644
--- a/pitivi/ui/Makefile.am
+++ b/pitivi/ui/Makefile.am
@@ -7,6 +7,7 @@ ui_PYTHON =			\
 	controller.py		\
 	curve.py		\
 	dnd.py			\
+	depsmanager.py	\
 	dynamic.py		\
 	encodingdialog.py	\
 	encodingprogress.py	\
diff --git a/pitivi/ui/depsmanager.py b/pitivi/ui/depsmanager.py
new file mode 100644
index 0000000..652d929
--- /dev/null
+++ b/pitivi/ui/depsmanager.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+# PiTiVi , Non-linear video editor
+#
+#       pitivi/ui/depsmanager.py
+#
+# Copyright (c) 2011 Jean-FranÃois Fortin Tam <nekohayo gmail 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 gtk
+import os
+from gettext import gettext as _
+
+from pitivi.configure import get_ui_dir
+from pitivi.check import get_softdeps
+
+class DepsManager(object):
+    """Display a dialog listing missing soft dependencies.
+    The sane way to query packages (like frei0r), is by using PackageKit's GetRequires()
+    """
+
+    def __init__(self):#, app):
+        #self.app = app
+        self.builder = gtk.Builder()
+        self.builder.add_from_file(os.path.join(get_ui_dir(), "depsmanager.ui"))
+        self.builder.connect_signals(self)
+
+        self.window = self.builder.get_object("window1")
+        self.show()
+
+    def _onCloseButtonClickedCb(self, unused_button):
+        self.hide()
+
+    def _onInstallButtonClickedCb(self, unused_button): # TODO: do stuff here
+        self.hide()
+        soft_deps = get_softdeps()
+        for foo in soft_deps:
+            print foo
+            print "\t", soft_deps[foo], "\n"
+
+    def show(self):
+#        self.window.set_transient_for(self.app.gui)
+        self.window.show()
+        self.window.grab_focus()
+
+    def hide(self):
+        self.window.hide()
+
+    def _installFailedCb(self, unused_exception):
+        """Handle the failure of installing packages."""
+        self.show()



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