summaryrefslogtreecommitdiffstats
path: root/iw/installpath_gui.py
blob: a65e6513ef4d2fce1f17d5ed4382b24707562d54 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
from gtk import *
from iw_gui import *
from language_gui import *
from language_support_gui import *
from welcome_gui import *
from progress_gui import *
from package_gui import *
from network_gui import *
from account_gui import *
from auth_gui import *
from mouse_gui import *
from keyboard_gui import *
from format_gui import *
from congrats_gui import *
from dependencies_gui import *
from lilo_gui import *
from silo_gui import *
from examine_gui import *
from bootdisk_gui import *
from firewall_gui import *
from timezone_gui import *
from xconfig_gui import *
from fdisk_gui import *
from rootpartition_gui import *
from confirm_gui import *
import iutil
from translate import _
from upgrade_swap_gui import *
import installclass

UPGRADE = 0
INSTALL = 1

CUSTOM = 2
WORKSTATION_GNOME = 3
WORKSTATION_KDE = 4
SERVER = 5

def D_(x):
    return x

class InstallPathWindow (InstallWindow):		

    installTypes = installclass.availableClasses()

    def __init__ (self, ics):
	if iutil.getArch() == 'sparc':
	    BootloaderWindow = SiloWindow
            BootloaderSkipname = "silo"
	else:
	    BootloaderWindow = LiloWindow
            BootloaderSkipname = "lilo"            

	self.installSteps = [
		     ( AutoPartitionWindow, "partition" ),
                     FDiskWindow,
		     ( PartitionWindow, "partition" ),
		     ( FormatWindow, "format" ),
		     ( BootloaderWindow, BootloaderSkipname ),
		     ( NetworkWindow, "network" ),
                     ( FirewallWindow, "firewall" ),
                     ( LanguageSupportWindow, "languagesupport" ),
		     ( TimezoneWindow, "timezone" ),
		     ( AccountWindow, "accounts" ),
		     ( AuthWindow, "authentication" ),
		     ( PackageSelectionWindow, "package-selection" ), 
		     ( UnresolvedDependenciesWindow, "dependencies" ),
                     ( XConfigWindow, "xconfig" ),
                     ( MonitorWindow, "monitor" ),
                     ( ConfirmWindow, "confirm" ),
		     InstallProgressWindow,
		     ( BootdiskWindow, "bootdisk" ),
		     ( CongratulationWindow, "complete" )
		   ]

	self.upgradeSteps = [
		     ( UpgradeExamineWindow, "custom-upgrade"),
                     ( UpgradeSwapWindow, "System Swap Space"),
		     ( BootloaderWindow, BootloaderSkipname ),
		     UnresolvedDependenciesWindow,
                     ( ConfirmWindow, "confirm" ),
		     InstallProgressWindow,
		     ( BootdiskWindow, "bootdisk" ),
		     CongratulationWindow
		   ]

	InstallWindow.__init__ (self, ics)

        ics.readHTML ("instpath")

	self.commonSteps = [ ( LanguageWindow, "language" ), 
			     ( KeyboardWindow, "keyboard" ),
			     ( MouseWindow, "mouse" ),
			     ( WelcomeWindow, "welcome" ),
			     ( InstallPathWindow, "installtype" ),
			   ]

        ics.setTitle (_("Install Type"))
        ics.setNextEnabled (1)
        self.ics = ics

    def getNext(self):
	from fstab import GuiFstab

	if not self.__dict__.has_key("upgradeButton"):
	    return

	# Hack to let backing out of upgrades work properly
	if self.todo.setupFilesystems and self.todo.fstab:
	    self.todo.fstab.turnOffSwap()

	needNewDruid = 0
	icw = self.ics.getICW ()
	if self.upgradeButton.get_active():
	    self.todo.upgrade = 1
            icw.setStateList (self.commonSteps + 
                              self.upgradeSteps, len (self.commonSteps)-1)
	else:
            icw.setStateList (self.commonSteps + 
                              self.installSteps, len (self.commonSteps)-1)
	    self.todo.upgrade = 0

	    for (button, object) in self.installClasses:
		if button.get_active():
		    break
	    if not isinstance (self.orig, object):
                self.todo.setClass (object(self.todo.expert))
		needNewDruid = 1

	# This makes the error message delivery come at a sane place
	if needNewDruid or not self.todo.fstab:
	    self.todo.fstab = GuiFstab(self.todo.setupFilesystems, 
				       self.todo.serial, 0, 0,
				       self.todo.intf.waitWindow,
				       self.todo.intf.messageWindow,
				       self.todo.intf.progressWindow,
                                       not self.todo.expert,
                                       self.todo.method.protectedPartitions(),
                                       self.todo.expert,
                                       self.todo.upgrade)

    def toggled (self, widget, type):
        if not widget.get_active (): return
        if type == INSTALL:
	    self.installBox.set_sensitive(1)
        elif type == UPGRADE:
	    self.installBox.set_sensitive(0)

    def pixRadioButton (self, group, label, pixmap):
        im = self.ics.readPixmap (pixmap)
        if im:
            im.render ()
            pix = im.make_pixmap ()
            hbox = GtkHBox (FALSE, 5)
            hbox.pack_start (pix, FALSE, FALSE, 0)
            label = GtkLabel (label)
            label.set_alignment (0.0, 0.5)
            hbox.pack_start (label, TRUE, TRUE, 15)
            button = GtkRadioButton (group)
            button.add (hbox)
        else:
            button = GtkRadioButton (group, label)
        return button

    # InstallPathWindow tag="instpath"
    def getScreen (self):
	if (self.todo.instClass.installType == "install"):
            self.ics.getICW ().setStateList (self.commonSteps + 
				self.installSteps, len (self.commonSteps)-1)
            self.todo.upgrade = 0
	    return None
	elif (self.todo.instClass.installType == "upgrade"):
            self.ics.getICW ().setStateList (self.commonSteps + 
				self.upgradeSteps, len (self.commonSteps)-1)
            self.todo.upgrade = 1
	    return None

	box = GtkVBox (FALSE, 5)

	installButton = self.pixRadioButton (None, _("Install"), "install.png")
        installButton.connect ("toggled", self.toggled, INSTALL)
	self.upgradeButton = self.pixRadioButton (installButton, _("Upgrade"), "upgrade.png")
        self.upgradeButton.connect ("toggled", self.toggled, UPGRADE)

	if (self.todo.upgrade):
	    self.upgradeButton.set_active(1)
            self.toggled (self.upgradeButton, UPGRADE)
	else:
	    instClass = self.todo.getClass()
	    installButton.set_active(1)

        self.installBox = GtkVBox (FALSE, 0)

        group = None
	self.installClasses = []
        
        self.orig = self.todo.getClass()
	haveSetDefault = 0
	defaultGroup = None

	for (name, object, pixmap) in self.installTypes:
            group = self.pixRadioButton (group, _(name), pixmap)
            self.installBox.pack_start (group, FALSE)
	    self.installClasses.append ((group, object))
            if isinstance(self.orig, object):
		group.set_active (1)
		haveSetDefault = 1
	    if object.default:
		defaultGroup = group

	if not haveSetDefault and defaultGroup:
	    defaultGroup.set_active(1)

	spacer = GtkLabel("")
	spacer.set_usize(60, 1)

	align = GtkAlignment ()
	align.set (0.0, 0.0, 0.0, 0.0)

	table = GtkTable(2, 4)
        table.attach(installButton, 0, 2, 0, 1, xoptions = FILL | EXPAND)
	table.attach(align, 2, 3, 0, 1, xoptions = FALSE)
	self.installBox.set_usize(300, -1)
        table.attach(self.installBox, 1, 3, 1, 2)
        table.attach(self.upgradeButton, 0, 3, 2, 3)

	box.pack_start(table, FALSE)

	hbox = GtkHBox (FALSE)

        self.toggled (installButton, INSTALL)
        self.toggled (self.upgradeButton, UPGRADE)
        box.set_border_width (5)
        return box