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

« back to all changes in this revision

Viewing changes to pitivi/ui/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 , Non-linear video editor
3
 
#
4
 
#       pitivi/ui/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
 
import gtk
24
 
import os
25
 
from gettext import gettext as _
26
 
 
27
 
from pitivi.configure import get_ui_dir
28
 
from pitivi.check import soft_deps
29
 
 
30
 
 
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()
34
 
    """
35
 
 
36
 
    def __init__(self, app):
37
 
        self.app = 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")
42
 
 
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()
46
 
        self.show()
47
 
 
48
 
    def _onCloseButtonClickedCb(self, unused_button):
49
 
        self.hide()
50
 
 
51
 
    def _onInstallButtonClickedCb(self, unused_button):
52
 
        self.hide()
53
 
        """
54
 
        # FIXME: this is not implemented properly. Here is some partially working code:
55
 
        
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)
62
 
 
63
 
        soft_deps_list = []
64
 
        for dep in soft_deps:
65
 
            soft_deps_list.append(dep)
66
 
 
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")
69
 
 
70
 
        # Instead, we should be using InstallResources(xid, type, resources)
71
 
        self.iface.InstallResources(self.window.window_xid, None, soft_deps_list)
72
 
        """
73
 
        # TODO: catch exceptions/create callbacks to _installFailedCb
74
 
 
75
 
    def _setDepsLabel(self):
76
 
        """Set the contents of the label containing the list of missing dependencies"""
77
 
        label_contents = ""
78
 
        for dep in soft_deps:
79
 
            label_contents += u"• " + dep + " (" + soft_deps[dep] + ")\n"
80
 
        self.builder.get_object("pkg_list").set_text(label_contents)
81
 
 
82
 
    def show(self):
83
 
        self.window.set_transient_for(self.app.gui)
84
 
        self.window.set_modal(True)
85
 
        self._setDepsLabel()
86
 
        self.window.show()
87
 
        self.window.grab_focus()
88
 
 
89
 
    def hide(self):
90
 
        self.window.hide()
91
 
 
92
 
    def _installFailedCb(self, unused_exception):
93
 
        """Handle the failure of installing packages."""
94
 
        self.show()