~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to pitivi/dialogs/depsmanager.py

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-04-05 15:28:16 UTC
  • mfrom: (6.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20140405152816-6lijoax4cngiz5j5
Tags: 0.93-3
* debian/control:
  + Depend on python-gi (>= 3.10), older versions do not work
    with pitivi (Closes: #732813).
  + Add missing dependency on gir1.2-clutter-gst-2.0 (Closes: #743692).
  + Add suggests on gir1.2-notify-0.7 and gir1.2-gnomedesktop-3.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# Pitivi video editor
 
3
#
 
4
#       pitivi/dialogs/depsmanager.py
 
5
#
 
6
# Copyright (c) 2011 Jean-François Fortin Tam <nekohayo@gmail.com>
 
7
#
 
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.
 
12
#
 
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.
 
17
#
 
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.
 
22
 
 
23
""" This module implements the notions of missing dependencies """
 
24
 
 
25
from gi.repository import Gtk
 
26
import os
 
27
 
 
28
from pitivi.configure import get_ui_dir
 
29
from pitivi.check import missing_soft_deps
 
30
 
 
31
 
 
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()
 
35
    """
 
36
 
 
37
    def __init__(self, app, parent_window=None):
 
38
        self.app = app
 
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)
 
44
        if parent_window:
 
45
            self.window.set_transient_for(parent_window)
 
46
        else:
 
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)
 
51
 
 
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()
 
55
        self._setDepsLabel()
 
56
        self.show()
 
57
 
 
58
    def _onCloseButtonClickedCb(self, unused_button):
 
59
        """ Hide on close """
 
60
        self.hide()
 
61
 
 
62
    def _onInstallButtonClickedCb(self, unused_button):
 
63
        """ Hide on install and try to install dependencies """
 
64
        self.hide()
 
65
        # FIXME: this is not implemented properly.
 
66
        # Here is some partially working code:
 
67
 
 
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)
 
74
 
 
75
        # soft_deps_list = missing_soft_deps.keys()
 
76
 
 
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")
 
81
 
 
82
        # Instead, we should be using InstallResources(xid, type, resources)
 
83
        # self.iface.InstallResources(self.window.window_xid,
 
84
        # None, soft_deps_list)
 
85
 
 
86
        # TODO: catch exceptions/create callbacks to _installFailedCb
 
87
 
 
88
    def _setDepsLabel(self):
 
89
        """
 
90
        Set the contents of the label containing the list of
 
91
        missing dependencies
 
92
        """
 
93
        label_contents = ""
 
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)
 
97
 
 
98
    def show(self):
 
99
        """Show internal window"""
 
100
        self.window.show()
 
101
 
 
102
    def hide(self):
 
103
        """Hide internal window"""
 
104
        self.window.hide()
 
105
 
 
106
    def _installFailedCb(self, unused_exception):
 
107
        """Handle the failure of installing packages."""
 
108
        self.show()