1
# -*- coding: utf-8 -*-
2
# PiTiVi , Non-linear video editor
4
# pitivi/ui/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.
25
from gettext import gettext as _
27
from pitivi.configure import get_ui_dir
28
from pitivi.check import soft_deps
31
class DepsManager(object):
32
"""Display a dialog listing missing soft dependencies.
33
The sane way to query and install is by using PackageKit's InstallResource()
36
def __init__(self, app):
38
self.builder = gtk.Builder()
39
self.builder.add_from_file(os.path.join(get_ui_dir(), "depsmanager.ui"))
40
self.builder.connect_signals(self)
41
self.window = self.builder.get_object("window1")
43
# FIXME: autodetect if we can actually use PackageKit's "InstallResource" dbus
44
# method, and if yes, show this button.
45
self.builder.get_object("install_btn").hide()
48
def _onCloseButtonClickedCb(self, unused_button):
51
def _onInstallButtonClickedCb(self, unused_button):
54
# FIXME: this is not implemented properly. Here is some partially working code:
56
self.session_bus = dbus.SessionBus()
57
self.dbus_path = "/org/freedesktop/PackageKit"
58
self.dbus_name = "org.freedesktop.PackageKit"
59
self.dbus_interface = "org.freedesktop.PackageKit.Modify"
60
self.obj = self.session_bus.get_object(self.dbus_name, self.dbus_path)
61
self.iface = dbus.Interface(self.obj, self.dbus_interface)
65
soft_deps_list.append(dep)
67
# This line works for testing, but InstallProvideFiles is not really what we want:
68
#self.iface.InstallProvideFiles(self.window.window_xid, soft_deps_list, "show-progress,show-finished")
70
# Instead, we should be using InstallResources(xid, type, resources)
71
self.iface.InstallResources(self.window.window_xid, None, soft_deps_list)
73
# TODO: catch exceptions/create callbacks to _installFailedCb
75
def _setDepsLabel(self):
76
"""Set the contents of the label containing the list of missing dependencies"""
79
label_contents += u"• " + dep + " (" + soft_deps[dep] + ")\n"
80
self.builder.get_object("pkg_list").set_text(label_contents)
83
self.window.set_transient_for(self.app.gui)
84
self.window.set_modal(True)
87
self.window.grab_focus()
92
def _installFailedCb(self, unused_exception):
93
"""Handle the failure of installing packages."""