/[gli]/branches/overhaul/src/fe/gtk/RcDotConf.py
Gentoo

Contents of /branches/overhaul/src/fe/gtk/RcDotConf.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1623 - (show annotations) (download) (as text)
Fri Jan 19 10:19:38 2007 UTC (7 years, 6 months ago) by agaffney
File MIME type: text/x-python
File size: 11404 byte(s)
remove Help button
rearrange Stage screen
1 # Copyright 1999-2005 Gentoo Foundation
2 # This source code is distributed under the terms of version 2 of the GNU
3 # General Public License as published by the Free Software Foundation, a copy
4 # of which can be found in the main directory of this project.
5
6 import gtk
7 import os
8 import GLIScreen
9 import GLIUtility
10 from Widgets import Widgets
11
12 class Panel(GLIScreen.GLIScreen):
13 """
14 The make.conf section of the installer.
15
16 @author: John N. Laliberte <allanonl@bu.edu>
17 @license: GPL
18 """
19 # Attributes:
20 title="rc.conf Settings"
21
22 # Operations
23 def __init__(self, controller):
24 GLIScreen.GLIScreen.__init__(self, controller)
25
26 vert = gtk.VBox(False, 10) # This box is content so it should fill space to force title to top
27 horiz = gtk.HBox(False, 10)
28
29 content_str = """
30 This is where you setup rc.conf."""
31 # pack the description
32 vert.pack_start(gtk.Label(content_str), expand=False, fill=False, padding=10)
33
34 # keymap
35 hbox = gtk.HBox(False, 0)
36 label = gtk.Label("KEYMAP:")
37 label.set_size_request(150, -1)
38 #label.set_justify(gtk.JUSTIFY_LEFT)
39 hbox.pack_start(label, expand=False, fill=False, padding=25)
40 self.keymap = gtk.combo_box_new_text()
41 self.keymap.set_name("KEYMAP")
42 self.keymap.set_size_request(150, -1)
43 hbox.pack_start(self.keymap, expand=False, fill=False, padding=5)
44 vert.pack_start(hbox,expand=False,fill=False,padding=0)
45
46 # set_windowskeys
47 hbox = gtk.HBox(False, 0)
48 label = gtk.Label("SET_WINDOWKEYS:")
49 label.set_size_request(150, -1)
50 hbox.pack_start(label, expand=False, fill=False, padding=25)
51 self.windowkeys = gtk.combo_box_new_text()
52 self.windowkeys.set_name("SET_WINDOWKEYS")
53 self.windowkeys.set_size_request(150, -1)
54 hbox.pack_start(self.windowkeys, expand=False, fill=False, padding=5)
55 vert.pack_start(hbox,expand=False,fill=False,padding=0)
56
57 # extended_keymaps
58 hbox = gtk.HBox(False, 0)
59 label = gtk.Label("EXTENDED_KEYMAPS:")
60 label.set_size_request(150, -1)
61 hbox.pack_start(label, expand=False, fill=False, padding=25)
62 self.extended_keymaps = gtk.Entry()
63 self.extended_keymaps.set_name("EXTENDED_KEYMAPS")
64 self.extended_keymaps.set_size_request(150, -1)
65 hbox.pack_start(self.extended_keymaps, expand=False, fill=False, padding=5)
66 vert.pack_start(hbox,expand=False,fill=False,padding=0)
67
68 # consolefont
69 hbox = gtk.HBox(False, 0)
70 label = gtk.Label("CONSOLEFONT:")
71 label.set_size_request(150, -1)
72 hbox.pack_start(label, expand=False, fill=False, padding=25)
73 self.consolefont = gtk.combo_box_new_text()
74 self.consolefont.set_name("CONSOLEFONT")
75 self.consolefont.set_size_request(150, -1)
76 hbox.pack_start(self.consolefont, expand=False, fill=False, padding=5)
77 vert.pack_start(hbox,expand=False,fill=False,padding=0)
78
79 # consoletranslation
80 hbox = gtk.HBox(False, 0)
81 label = gtk.Label("CONSOLETRANSLATION:")
82 label.set_size_request(150, -1)
83 hbox.pack_start(label, expand=False, fill=False, padding=25)
84 self.consoletranslation = gtk.combo_box_new_text()
85 self.consoletranslation.set_name("CONSOLETRANSLATION")
86 self.consoletranslation.set_size_request(150, -1)
87 hbox.pack_start(self.consoletranslation, expand=False, fill=False, padding=5)
88 vert.pack_start(hbox,expand=False,fill=False,padding=0)
89
90 # clock
91 hbox = gtk.HBox(False, 0)
92 label = gtk.Label("CLOCK:")
93 label.set_size_request(150, -1)
94 hbox.pack_start(label, expand=False, fill=False, padding=25)
95 self.clock = gtk.combo_box_new_text()
96 self.clock.set_name("CLOCK")
97 self.clock.set_size_request(150, -1)
98 hbox.pack_start(self.clock, expand=False, fill=False, padding=5)
99 vert.pack_start(hbox,expand=False,fill=False,padding=0)
100
101 # editor
102 hbox = gtk.HBox(False, 0)
103 label = gtk.Label("EDITOR:")
104 label.set_size_request(150, -1)
105 hbox.pack_start(label, expand=False, fill=False, padding=25)
106 self.editor = gtk.combo_box_entry_new_text()
107 self.editor.set_name("EDITOR")
108 self.editor.set_size_request(150, -1)
109 hbox.pack_start(self.editor, expand=False, fill=False, padding=5)
110 vert.pack_start(hbox,expand=False,fill=False,padding=0)
111
112 # protocols
113 hbox = gtk.HBox(False, 0)
114 label = gtk.Label("PROTOCOLS:")
115 label.set_size_request(150, -1)
116 hbox.pack_start(label, expand=False, fill=False, padding=25)
117 self.protocols = gtk.Entry()
118 self.protocols.set_name("PROTOCOLS")
119 self.protocols.set_size_request(150, -1)
120 hbox.pack_start(self.protocols, expand=False, fill=False, padding=5)
121 vert.pack_start(hbox,expand=False,fill=False,padding=0)
122
123 # displaymanager
124 hbox = gtk.HBox(False, 0)
125 label = gtk.Label("DISPLAYMANAGER:")
126 label.set_size_request(150, -1)
127 hbox.pack_start(label, expand=False, fill=False, padding=25)
128 self.displaymanager = gtk.combo_box_new_text()
129 self.displaymanager.set_name("DISPLAYMANAGER")
130 self.displaymanager.set_size_request(150, -1)
131 hbox.pack_start(self.displaymanager, expand=False, fill=False, padding=5)
132 vert.pack_start(hbox,expand=False,fill=False,padding=0)
133
134 # xsession
135 hbox = gtk.HBox(False, 0)
136 label = gtk.Label("XSESSION:")
137 label.set_size_request(150, -1)
138 hbox.pack_start(label, expand=False, fill=False, padding=25)
139 self.xsession = gtk.combo_box_entry_new_text()
140 self.xsession.set_name("XSESSION")
141 self.xsession.set_size_request(150, -1)
142 hbox.pack_start(self.xsession, expand=False, fill=False, padding=5)
143 vert.pack_start(hbox,expand=False,fill=False,padding=0)
144
145 # populate the gui elements
146 self.populate_keymap_combo()
147 self.populate_windowkeys_combo()
148 self.populate_consolefont_combo()
149 self.populate_consoletranslation_combo()
150 self.populate_clock_combo()
151 self.populate_editor_combo()
152 self.protocols.set_text("1 2")
153 self.populate_displaymanager_combo()
154 self.populate_xsession_combo()
155
156 self.add_content(vert)
157
158 # setup the types of gui elements for access later
159 self.data = {self.keymap:"combo",
160 self.windowkeys:"combo",
161 self.extended_keymaps:"entry",
162 self.consolefont:"combo",
163 self.consoletranslation:"combo",
164 self.clock:"combo",
165 self.editor:"comboentry",
166 self.protocols:"entry",
167 self.displaymanager:"combo",
168 self.xsession:"comboentry"
169 }
170
171
172 def populate_keymap_combo(self, default="us"):
173 # Adds all the keymaps to the dropdown
174 keymaps = GLIUtility.generate_keymap_list()
175
176 for i in range(len(keymaps)):
177 keymap = keymaps[i]
178 self.keymap.append_text(keymap)
179
180 # select the default
181 if keymap == default:
182 self.keymap.set_active(i)
183
184 def populate_windowkeys_combo(self, default=1):
185 self.windowkeys.append_text("No")
186 self.windowkeys.append_text("Yes")
187 self.windowkeys.set_active(default)
188
189 def populate_consolefont_combo(self, default="default8x16"):
190 # Adds all the consolefonts
191 consolefonts = GLIUtility.generate_consolefont_list()
192 for i in range(len(consolefonts)):
193 consolefont = consolefonts[i]
194 self.consolefont.append_text(consolefont)
195
196 # select the default
197 if consolefont == default:
198 self.consolefont.set_active(i)
199
200 def populate_consoletranslation_combo(self, default=0):
201 self.consoletranslation.append_text("commented out")
202
203 consoletranslations = GLIUtility.generate_consoletranslation_list()
204
205 for i in range(len(consoletranslations)):
206 consoletran = consoletranslations[i]
207 self.consoletranslation.append_text(consoletran)
208
209 self.consoletranslation.set_active(default)
210
211 def populate_clock_combo(self, default=0):
212 self.clock.append_text("UTC")
213 self.clock.append_text("local")
214 self.clock.set_active(default)
215
216 def populate_editor_combo(self,default=0):
217 self.editor.append_text("/bin/nano")
218 self.editor.append_text("/usr/bin/vim")
219 self.editor.append_text("/usr/bin/emacs")
220 self.editor.set_active(default)
221
222 def populate_displaymanager_combo(self,default=0):
223 self.displaymanager.append_text("commented out")
224 self.displaymanager.append_text("xdm")
225 self.displaymanager.append_text("kdm")
226 self.displaymanager.append_text("gdm")
227 self.displaymanager.append_text("entrance")
228 self.displaymanager.set_active(0)
229
230 def populate_xsession_combo(self,default=-1):
231 self.xsession.append_text("Gnome")
232 self.xsession.append_text("fluxbox")
233 self.xsession.append_text("Xsession")
234 self.xsession.set_active(-1)
235
236 def get_combo_current_text(self, widget):
237 model = widget.get_model()
238 active = widget.get_active()
239
240 return model[active][0]
241
242 def set_combo_current_text(self, widget , text):
243 if text=="##commented##": text = "commented out"
244 # need to find the element in the combo box
245 # that they selected in the file, and activate it.
246 #iter = widget.get_active_iter()
247 model = widget.get_model()
248 iter = model.get_iter_first()
249
250 i=0 # keep track of what to set active.
251 while iter != None:
252 # retrieve the text and test.
253 #print model.get_value(iter,0)
254 # if the value in the combobox equals whats in the xmlfile,
255 # select it!
256 if model.get_value(iter,0) == text:
257 widget.set_active(i)
258
259 iter = model.iter_next(iter)
260 i+=1
261
262 def generate_rc_conf_dictionary(self):
263 rc_conf = {}
264
265 for item in self.data.keys():
266 # depending on what kind of gui element it is,
267 # we need to get the data out of it differently.
268 # equivalent of a switch statement in python...
269 result = {
270 'combo': lambda item: self.get_combo_current_text(item),
271 'entry': lambda item: item.get_text(),
272 'comboentry': lambda item: item.get_child().get_text()
273 }[self.data[item]](item)
274
275 # put it into the dictionary to be returned
276 # consoletransation / displaymanager can be commented out
277 # if result is commented out, set it to the 'special' string
278 # so _edit_config can know to comment it out.
279 if result == "commented out":
280 result = "##commented##"
281
282 rc_conf[item.get_name()] = result
283
284
285 return rc_conf
286
287 def load_rc_conf_dictionary(self, rc_conf):
288 for item in self.data.keys():
289 # depending on what kind of gui element it is,
290 # we need to get the data out of it differently.
291 # equivalent of a switch statement in python...
292 try:
293 result = {
294 'combo': lambda item: self.set_combo_current_text(item,rc_conf[item.get_name()]),
295 'entry': lambda item: item.set_text(rc_conf[item.get_name()]),
296 'comboentry': lambda item: item.get_child().set_text(rc_conf[item.get_name()])
297 }[self.data[item]](item)
298 except KeyError:
299 # that value didn't exist in the stored profile
300 # debugging only here
301 #print "KeyError"
302 pass
303
304 def activate(self):
305 # FIXME: <codeman> this is a temp hack fix for rc.conf as it will not work with new baselayout.
306 self.etc_files = self.controller.install_profile.get_etc_files()
307 if not "rc.conf" in self.etc_files:
308 self.etc_files['rc.conf'] = {}
309 rc_conf = self.etc_files['rc.conf']
310 self.load_rc_conf_dictionary(rc_conf)
311 #print "loaded: "+str(rc_conf)
312
313 self.controller.SHOW_BUTTON_EXIT = True
314 # self.controller.SHOW_BUTTON_HELP = True
315 self.controller.SHOW_BUTTON_BACK = True
316 self.controller.SHOW_BUTTON_FORWARD = True
317 self.controller.SHOW_BUTTON_FINISH = False
318
319 def deactivate(self):
320 value = True
321 rc_conf = self.generate_rc_conf_dictionary()
322 #print "saving:"+str(rc_conf)
323
324 try:
325 self.etc_files['rc.conf'] = rc_conf
326 self.controller.install_profile.set_etc_files(self.etc_files)
327 except:
328 msgbox=Widgets().error_Box("Error","An internal error occurred!")
329 msgbox.run()
330 msgbox.destroy()
331 return value

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20