summaryrefslogtreecommitdiffstats
path: root/iw/dependencies_gui.py
blob: 7388b092a468bdd027b6f2d1e7ac1b80e8b79c0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#
# dependencies_gui.py: screen to allow resolution of unresolved dependencies.
#
# Copyright 2000-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import gobject
import gtk
from iw_gui import *
from rhpl.translate import _, N_

class UnresolvedDependenciesWindow (InstallWindow):

    windowTitle = N_("Unresolved Dependencies")
    htmlTag = "depend"

    def __init__ (self, ics):
	InstallWindow.__init__ (self, ics)
        self.dependRB = None
        self.causeRB = None
        self.ics = ics

    def getPrev (self):
	self.comps.setSelectionState(self.origSelection)
    
    def updateSize (self, *args):
        self.sizelabel.set_text (_("Total install size: %s") % self.comps.sizeStr())

    def installToggled (self, widget, *args):
        self.comps.selectDepCause (self.deps)
        if widget.get_active ():
            self.comps.selectDeps (self.deps)
        else:
            self.comps.unselectDeps (self.deps)
        self.updateSize ()

    def causeToggled (self, widget, *args):
        if widget.get_active ():
            self.comps.unselectDepCause (self.deps)
        else:
            self.comps.selectDepCause (self.deps)            
        self.updateSize ()

    def ignoreToggled (self, widget, *args):
        if widget.get_active ():
            self.comps.selectDepCause (self.deps)
            self.comps.unselectDeps (self.deps)            
        self.updateSize ()

    #UnresolvedDependenciesWindow tag="depend"
    def getScreen (self, comps, deps):
        self.ics.setHelpEnabled(gtk.TRUE)
	self.deps = deps
	self.comps = comps

        sw = gtk.ScrolledWindow ()
        sw.set_border_width (5)
        sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

	store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        for (name, suggest) in self.deps:
	    iter = store.append()
	    store.set_value(iter, 0, name)
	    store.set_value(iter, 1, suggest)

	view = gtk.TreeView(store)
	col = gtk.TreeViewColumn(_("Package"), gtk.CellRendererText(), text=0)
	view.append_column(col)
	col = gtk.TreeViewColumn(_("Requirement"), gtk.CellRendererText(),
				 text=1)
	view.append_column(col)
        sw.add (view)

	# assume things will be selected -- that matches our default
	self.origSelection = self.comps.getSelectionState()
        self.comps.selectDeps (self.deps)

        self.sizelabel = gtk.Label("")
        self.sizelabel.set_alignment (1, .5)
        self.updateSize()

        rb = gtk.VBox (gtk.FALSE)
        self.dependRB = gtk.RadioButton (None, _("Install packages to "
                                                "satisfy dependencies"))
        
        self.causeRB  = gtk.RadioButton (self.dependRB, _("Do not install "
                                                         "packages that "
                                                         "have dependencies"))
        
        self.ignoreRB = gtk.RadioButton (self.dependRB, _("Ignore package "
                                                         "dependencies"))

        rb.pack_start (self.dependRB)
        rb.pack_start (self.causeRB)
        rb.pack_start (self.ignoreRB)
        rb.pack_start (self.sizelabel)

        self.dependRB.set_active (1)
        self.dependRB.connect('toggled', self.installToggled)
        self.causeRB.connect('toggled', self.causeToggled)
        self.ignoreRB.connect('toggled', self.ignoreToggled)

        box = gtk.VBox (gtk.FALSE, 5)
        box.pack_start (sw, gtk.TRUE)
        box.pack_start (rb, gtk.FALSE)

        return box