1
## Kickstart Configurator - A graphical kickstart file generator
2
## Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.
3
## Copyright (C) 2000, 2001, 2002, 2003 Brent Fox <bfox@redhat.com>
4
## Tammy Fox <tfox@redhat.com>
6
## This program is free software; you can redistribute it and/or modify
7
## it under the terms of the GNU General Public License as published by
8
## the Free Software Foundation; either version 2 of the License, or
9
## (at your option) any later version.
11
## This program is distributed in the hope that it will be useful,
12
## but WITHOUT ANY WARRANTY; without even the implied warranty of
13
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
## GNU General Public License for more details.
16
## You should have received a copy of the GNU General Public License
17
## along with this program; if not, write to the Free Software
18
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
#Kickstart Configurator X Configuration
27
from rhpl.xhwstate import *
31
def __init__(self, xml, kickstartData):
32
self.kickstartData = kickstartData
33
self.xconfig_vbox = xml.get_widget("xconfig_vbox")
34
self.xconfig_label_box = xml.get_widget("xconfig_label_box")
35
self.config_x_button = xml.get_widget("config_x_button")
36
self.card_view = xml.get_widget("card_view")
37
self.monitor_view = xml.get_widget("monitor_view")
38
self.sync_button = xml.get_widget("sync_button")
39
self.sync_table = xml.get_widget("sync_table")
40
self.xconfig_notebook = xml.get_widget("xconfig_notebook")
41
self.hsync_entry = xml.get_widget("hsync_entry")
42
self.vsync_entry = xml.get_widget("vsync_entry")
43
self.color_depth_combo = xml.get_widget("color_depth_combo")
44
self.resolution_combo = xml.get_widget("resolution_combo")
45
self.videoram_combo = xml.get_widget("videoram_combo")
46
self.gnome_radiobutton = xml.get_widget("gnome_radiobutton")
47
self.kde_radiobutton = xml.get_widget("kde_radiobutton")
48
self.startxonboot_checkbutton = xml.get_widget("startxonboot_checkbutton")
49
self.firstboot_optionmenu = xml.get_widget("firstboot_optionmenu")
50
self.card_vbox = xml.get_widget("card_vbox")
51
self.monitor_vbox = xml.get_widget("monitor_vbox")
52
self.card_probe_check = xml.get_widget("card_probe_check")
53
self.monitor_probe_check = xml.get_widget("monitor_probe_check")
55
self.card_store = gtk.ListStore(gobject.TYPE_STRING)
56
self.card_view.set_model(self.card_store)
57
self.card_col = gtk.TreeViewColumn("", gtk.CellRendererText(), text = 0)
58
self.card_view.append_column(self.card_col)
60
self.monitor_store = gtk.ListStore(gobject.TYPE_STRING)
61
self.monitor_view.set_model(self.monitor_store)
62
self.monitor_col = gtk.TreeViewColumn("", gtk.CellRendererText(), text = 0)
63
self.monitor_view.append_column(self.monitor_col)
64
self.upgrade_flag = gtk.FALSE
66
self.config_x_button.connect("toggled", self.toggleXconfig)
67
self.monitor_probe_check.connect("toggled", self.on_monitor_probe_check_toggled)
68
self.card_probe_check.connect("toggled", self.on_card_probe_check_toggled)
69
self.sync_button.connect("toggled", self.toggle_sync)
72
self.fill_monitor_list()
75
color_depths = ["8", "16", "24", "32"]
76
self.color_depth_combo.set_popdown_strings(color_depths)
77
self.color_depth_combo.entry.set_editable(gtk.FALSE)
80
resolutions = ["640x480", "800x600", "1024x768", "1152x864", "1280x1024", "1400x1050",
81
"1600x1200", "1920x1440", "2048x1536"]
82
self.resolution_combo.set_popdown_strings(resolutions)
83
self.resolution_combo.entry.set_editable(gtk.FALSE)
85
#add video card RAM sizes to option menu
86
vram_list = ["256 KB", "512 KB", "1 MB", "2 MB", "4 MB", "8 MB", "16 MB", "32 MB", "64 MB"]
87
self.videoram_combo.set_popdown_strings(vram_list)
88
self.videoram_combo.entry.set_editable(gtk.FALSE)
90
self.ramsize_dict = {"256 KB" : "256",
101
def fill_card_list(self):
102
#add video cards to list
104
cardsFile = open("/usr/share/hwdata/Cards", "r")
106
raise RuntimeError, (_("Could not read video card database"))
108
lines = cardsFile.readlines ()
112
line = string.strip (line)
114
if len (line) > 4 and line[0:4] == 'NAME':
116
iter = self.card_store.append()
117
self.card_store.set_value(iter, 0, name)
119
def fill_monitor_list(self):
121
hardware_state = XF86HardwareState(None)
122
db = hardware_state.monitor.readMonitorsDB()
127
#put Generic LCD and Generic CRT at the front of the list
128
tmp = l[l.index("Generic LCD Display")]
129
l.remove(l[l.index("Generic LCD Display")])
132
tmp = l[l.index("Generic CRT Display")]
133
l.remove(l[l.index("Generic CRT Display")])
137
for manufacturer in l:
138
for mon in db[manufacturer]:
143
if model not in mon_list:
144
mon_list.append(model)
145
iter = self.monitor_store.append()
146
self.monitor_store.set_value(iter, 0, model)
148
def on_card_probe_check_toggled(self, *args):
149
self.card_vbox.set_sensitive(not self.card_probe_check.get_active())
151
def on_monitor_probe_check_toggled(self, *args):
152
self.monitor_vbox.set_sensitive(not self.monitor_probe_check.get_active())
154
def toggleXconfig (self, args):
155
config = self.config_x_button.get_active()
156
#disable xconfig notebook
157
self.xconfig_notebook.set_sensitive(config)
159
def toggle_sync (self, args):
160
sync_instead = self.sync_button.get_active()
161
self.sync_table.set_sensitive(sync_instead)
162
self.monitor_view.set_sensitive(not sync_instead)
164
def setSensitive(self, boolean):
165
if boolean == gtk.FALSE:
166
self.xconfig_vbox.hide()
167
self.xconfig_label_box.show()
168
self.upgrade_flag = gtk.TRUE
170
self.xconfig_vbox.show()
171
self.xconfig_label_box.hide()
172
self.upgrade_flag = gtk.FALSE
175
if self.upgrade_flag == gtk.TRUE:
176
self.kickstartData.setXconfig(None)
177
self.kickstartData.setFirstboot(None)
180
if self.config_x_button.get_active():
181
if self.firstboot_optionmenu.get_history() == 0:
182
self.kickstartData.setFirstboot(None)
183
elif self.firstboot_optionmenu.get_history() == 1:
184
self.kickstartData.setFirstboot(["--enable"])
185
elif self.firstboot_optionmenu.get_history() == 2:
186
self.kickstartData.setFirstboot(["--reconfig"])
188
self.kickstartData.setSkipX(None)
190
#color depth - translate
191
buf = "--depth=" + self.color_depth_combo.entry.get_text()
193
buf = buf + " --resolution=" + self.resolution_combo.entry.get_text()
195
if self.gnome_radiobutton.get_active():
196
buf = buf + " --defaultdesktop=GNOME"
197
elif self.kde_radiobutton.get_active():
198
buf = buf + " --defaultdesktop=KDE"
200
if self.startxonboot_checkbutton.get_active():
201
buf = buf + " --startxonboot"
203
if not self.card_probe_check.get_active():
204
#video card and monitor
205
temp, iter = self.card_view.get_selection().get_selected()
206
card = self.card_store.get_value(iter, 0)
207
buf = buf + " --card=\"" + card + "\""
210
buf = buf + " --videoram=" + self.ramsize_dict [self.videoram_combo.entry.get_text()]
212
if not self.monitor_probe_check.get_active():
213
if self.sync_button.get_active():
214
buf = buf + " --hsync=" + self.hsync_entry.get_text()
215
buf = buf + " --vsync=" + self.vsync_entry.get_text()
217
temp, iter = self.monitor_view.get_selection().get_selected()
218
name = self.monitor_store.get_value(iter, 0)
219
buf = buf + " --monitor=\"" + name + "\""
221
self.kickstartData.setXconfig([buf])
223
self.kickstartData.setSkipX(["skipx"])
224
self.kickstartData.setXconfig(None)
227
if self.kickstartData.getSkipX():
228
self.config_x_button.set_active(gtk.FALSE)
229
elif self.kickstartData.getXconfig():
230
self.config_x_button.set_active(gtk.TRUE)
232
if self.kickstartData.getFirstboot() == "--enable":
233
self.firstboot_optionmenu.set_history(1)
234
elif self.kickstartData.getFirstboot() == "--reconfig":
235
self.firstboot_optionmenu.set_history(2)
237
xLine = self.kickstartData.getXconfig()
238
xLine = string.join (xLine, " ")
239
xList = string.split(xLine, " --")
243
xList[xList.index(item)] = ("--" + item)
246
opt = string.replace(opt, "=", " ")
248
if opt == "--startxonboot":
249
self.startxonboot_checkbutton.set_active(gtk.TRUE)
251
if opt[:16] == "--defaultdesktop":
253
if string.lower(value) == "gnome":
254
self.gnome_radiobutton.set_active(gtk.TRUE)
255
if string.lower(value) == "kde":
256
self.kde_radiobutton.set_active(gtk.TRUE)
258
if opt[:7] == "--depth":
260
self.color_depth_combo.entry.set_text(string.strip(value))
262
if opt[:12] == "--resolution":
264
self.resolution_combo.entry.set_text(string.strip(value))
266
if opt[:6] == "--card":
267
value = string.strip(opt[6:])
268
self.card_probe_check.set_active(gtk.FALSE)
269
value = string.replace(value, '"', '')
271
iter = self.card_store.get_iter_first()
274
if self.card_store.get_value(iter, 0) == value:
275
path = self.card_store.get_path(iter)
276
self.card_view.set_cursor(path, self.card_col, gtk.FALSE)
277
self.card_view.scroll_to_cell(path, self.card_col, gtk.TRUE, 0.5, 0.5)
278
iter = self.card_store.iter_next(iter)
280
if opt[:10] == "--videoram":
283
for size in self.ramsize_dict.keys():
284
if int(value) == int(self.ramsize_dict[size]):
285
self.videoram_combo.entry.set_text(size)
287
if opt[:9] == "--monitor":
288
opt = string.strip(opt[9:])
289
self.monitor_probe_check.set_active(gtk.FALSE)
290
value = string.replace(value, '"', '')
292
iter = self.monitor_store.get_iter_first()
295
if self.monitor_store.get_value(iter, 0) == value:
296
path = self.monitor_store.get_path(iter)
297
self.monitor_view.set_cursor(path, self.monitor_col, gtk.FALSE)
298
self.monitor_view.scroll_to_cell(path, self.monitor_col, gtk.TRUE, 0.5, 0.5)
299
iter = self.monitor_store.iter_next(iter)
301
if opt[:7] == "--hsync":
303
self.sync_button.set_active(gtk.TRUE)
304
self.hsync_entry.set_text(string.strip(value))
305
self.monitor_probe_check.set_active(gtk.FALSE)
307
if opt[:7] == "--vsync":
309
self.sync_button.set_active(gtk.TRUE)
310
self.vsync_entry.set_text(string.strip(value))
311
self.monitor_probe_check.set_active(gtk.FALSE)