1
# -*- coding: utf-8 -*-
4
# pitivi/dialogs/depsmanager.py
6
# Copyright (c) 2011 Jean-François Fortin Tam <nekohayo@gmail.com>
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU Lesser General Public
10
# License as published by the Free Software Foundation; either
11
# version 2.1 of the License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
# Lesser General Public License for more details.
18
# You should have received a copy of the GNU Lesser General Public
19
# License along with this program; if not, write to the
20
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21
# Boston, MA 02110-1301, USA.
23
""" This module implements the notions of missing dependencies """
25
from gi.repository import Gtk
28
from pitivi.configure import get_ui_dir
29
from pitivi.check import missing_soft_deps
32
class DepsManager(object):
33
"""Display a dialog listing missing soft dependencies.
34
The sane way to query and install is by using PackageKit's InstallResource()
37
def __init__(self, app, parent_window=None):
39
self.builder = Gtk.Builder()
40
self.builder.add_from_file(os.path.join(get_ui_dir(), "depsmanager.ui"))
41
self.builder.connect_signals(self)
42
self.window = self.builder.get_object("window1")
43
self.window.set_modal(True)
45
self.window.set_transient_for(parent_window)
47
self.window.set_transient_for(self.app.gui)
48
# Same hack as in the rendering progress dialog,
49
# to prevent GTK3 from eating a crazy amount of vertical space:
50
self.window.set_resizable(False)
52
# FIXME: autodetect if we can actually use PackageKit's
53
# "InstallResource" dbus method, and if yes, show this button.
54
self.builder.get_object("install_btn").hide()
58
def _onCloseButtonClickedCb(self, unused_button):
62
def _onInstallButtonClickedCb(self, unused_button):
63
""" Hide on install and try to install dependencies """
65
# FIXME: this is not implemented properly.
66
# Here is some partially working code:
68
# self.session_bus = dbus.SessionBus()
69
# self.dbus_path = "/org/freedesktop/PackageKit"
70
# self.dbus_name = "org.freedesktop.PackageKit"
71
# self.dbus_interface = "org.freedesktop.PackageKit.Modify"
72
# self.obj = self.session_bus.get_object(self.dbus_name, self.dbus_path)
73
# self.iface = dbus.Interface(self.obj, self.dbus_interface)
75
# soft_deps_list = missing_soft_deps.keys()
77
# This line works for testing, but InstallProvideFiles
78
# is not really what we want:
79
# self.iface.InstallProvideFiles(self.window.window_xid,
80
# soft_deps_list, "show-progress,show-finished")
82
# Instead, we should be using InstallResources(xid, type, resources)
83
# self.iface.InstallResources(self.window.window_xid,
84
# None, soft_deps_list)
86
# TODO: catch exceptions/create callbacks to _installFailedCb
88
def _setDepsLabel(self):
90
Set the contents of the label containing the list of
94
for depname, dep in missing_soft_deps.iteritems():
95
label_contents += "• %s (%s)\n" % (dep.modulename, dep.additional_message)
96
self.builder.get_object("pkg_list").set_text(label_contents)
99
"""Show internal window"""
103
"""Hide internal window"""
106
def _installFailedCb(self, unused_exception):
107
"""Handle the failure of installing packages."""