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
|
#
# bootlocwidget.py: widget for setting the location of the boot loader
#
# Copyright (C) 2001, 2002 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): Jeremy Katz <katzj@redhat.com>
#
import gtk
import gobject
import iutil
import gui
from rhpl.translate import _, N_
from driveorderwidget import DriveOrderWidget
class BootloaderLocationWidget:
"""Widget to set where to install the boot loader to"""
def __init__(self, anaconda, parent):
self.bl = anaconda.id.bootloader
self.fsset = anaconda.id.fsset
self.diskset = anaconda.id.diskset
self.parent = parent
self.intf = anaconda.intf
self.driveOrder = self.bl.drivelist
self.usingGrub = self.bl.useGrub()
locationBox = gtk.VBox (False, 2)
locationBox.set_border_width(5)
label = gtk.Label(_("Install Boot Loader record on:"))
label.set_alignment(0.0, 0.5)
locationBox.pack_start(label)
spacer = gtk.Label("")
spacer.set_size_request(10, 1)
locationBox.pack_start(spacer, False)
choices = self.fsset.bootloaderChoices(self.diskset, self.bl)
self.bootDevices = {}
if choices:
radio = None
keys = choices.keys()
keys.reverse()
for key in keys:
(device, desc) = choices[key]
radio = gtk.RadioButton(radio,
("/dev/%s %s" % (device, _(desc))))
locationBox.pack_start(radio, False)
self.bootDevices[key] = (radio, device, desc)
if self.bl.getDevice() == device:
radio.set_active(True)
else:
radio.set_active(False)
if not radio is None:
radio.set_use_underline(False)
spacer = gtk.Label("")
spacer.set_size_request(25, 1)
locationBox.pack_start(spacer, False)
orderButton = gtk.Button(_("_Change Drive Order"))
locationBox.pack_start(orderButton, False)
orderButton.connect("clicked", self.editDriveOrder)
self.setMbrLabel(self.driveOrder[0])
alignment = gtk.Alignment()
alignment.set(0.0, 0, 0, 0)
alignment.add(locationBox)
self.widget = alignment
def editDriveOrder(self, *args):
dialog = gtk.Dialog(_("Edit Drive Order"), flags = gtk.DIALOG_MODAL)
gui.addFrame(dialog)
dialog.set_modal(True)
dialog.set_position(gtk.WIN_POS_CENTER)
label = gui.WrappingLabel(_("Arrange the drives to be in the same "
"order as used by the BIOS. Changing "
"the drive order may be useful if you "
"have multiple SCSI adapters or both SCSI "
"and IDE adapters and want to boot from "
"the SCSI device.\n\n"
"Changing the drive order will change "
"where the installation program "
"locates the Master Boot Record (MBR)."))
label.set_alignment(0.0, 0.0)
dialog.vbox.pack_start(label, padding = 25)
orderWidget = DriveOrderWidget(self.driveOrder, self.diskset)
alignment = gtk.Alignment()
alignment.set(0.5, 0, 0, 0)
alignment.add(orderWidget.getWidget())
dialog.vbox.pack_start(alignment)
dialog.add_button('gtk-cancel', 1)
dialog.add_button('gtk-ok', 0)
dialog.show_all()
while 1:
rc = dialog.run()
if rc == 1:
break
self.driveOrder = orderWidget.getOrder()
self.setMbrLabel(self.driveOrder[0])
break
dialog.destroy()
return rc
# set the label on the mbr radio button to show the right device.
# kind of a hack
def setMbrLabel(self, firstDrive):
if not self.bootDevices.has_key("mbr"):
return
(radio, olddev, desc) = self.bootDevices["mbr"]
radio.set_label("/dev/%s %s" % (firstDrive, _(desc)))
radio.set_use_underline(False)
self.bootDevices["mbr"] = (radio, firstDrive, desc)
def getWidget(self):
return self.widget
def getBootDevice(self):
for key in self.bootDevices.keys():
if self.bootDevices[key][0].get_active():
return self.bootDevices[key][1]
def getDriveOrder(self):
return self.driveOrder
def setUsingGrub(self, val):
self.usingGrub = val
|