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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
from gtk import *
from gnome.ui import *
from gnome.xmhtml import *
from iw.language import *
from iw.welcome import *
from iw.progress import *
from iw.package import *
from iw.network import *
from iw.account import *
from iw.rootpartition import *
from iw.auth import *
from iw.mouse import *
from iw.keyboard import *
from iw.format import *
from iw.congrats import *
from iw.autopartition import *
from iw.installtype import *
from iw.dependencies import *
from iw.lilo import *
from iw.installpath import *
import sys
import GdkImlib
from gnomepyfsedit import fsedit
import isys
import sys
import thread
import rpm
from thread import *
from threading import *
import time
class WaitWindow:
def __init__(self, title, text):
threads_enter ()
self.window = GtkWindow (WINDOW_POPUP)
self.window.set_title (title)
self.window.set_position (WIN_POS_CENTER)
self.window.set_modal (TRUE)
label = GtkLabel (text)
label.set_line_wrap (TRUE)
box = GtkFrame ()
box.set_border_width (10)
box.add (label)
box.set_shadow_type (SHADOW_NONE)
frame = GtkFrame ()
frame.set_shadow_type (SHADOW_OUT)
frame.add (box)
self.window.add (frame)
self.window.show_all ()
gdk_flush ()
while events_pending ():
mainiteration ()
threads_leave ()
def pop(self):
threads_enter ()
self.window.destroy ()
threads_leave ()
class GtkMainThread (Thread):
def run (self):
threads_enter ()
mainloop ()
threads_leave ()
class InstallInterface:
def setPackageProgressWindow (self, ppw):
self.ppw = ppw
def waitWindow (self, title, text):
return WaitWindow (title, text)
def packageProgressWindow (self, total, totalSize):
self.ppw.setSizes (total, totalSize)
return self.ppw
def messageWindow(self, title, text):
print text
# dialog = GnomeOkDialog (text)
# dialog.set_position (WIN_POS_CENTER)
def exceptionWindow(self, title, text):
print text
def getDDruid (self, drives):
return fsedit (1, drives)
def getBootdisk ():
return None
def getCongratulation ():
return CongratulationWindow
def run (self, todo):
gtkThread = GtkMainThread ()
gtkThread.start ()
commonSteps = [LanguageWindow, KeyboardWindow,
WelcomeWindow, InstallPathWindow]
self.finishedTODO = Event ()
self.icw = InstallControlWindow (self, commonSteps, todo)
self.icw.start ()
self.finishedTODO.wait ()
todo.setLiloLocation("hda")
class InstallControlWindow (Thread):
def instantiateWindow (self, windowClass):
ics = InstallControlState (self, self.ii, self.todo)
self.buildingWindows = 1
window = windowClass (ics)
self.buildingWindows = 0
self.windowList.append (window)
return window
def setStateList (self, list, pos):
self.stateList = []
for x in list:
instantiated = 0
for y in self.windowList:
if isinstance (y, x):
self.stateList.append (y)
instantiated = 1
break
if not instantiated:
self.stateList.append (self.instantiateWindow (x))
self.stateListIndex = pos
def prevClicked (self, *args):
prev = self.currentScreen.getPrev ()
if prev:
instantiated = 0
for x in self.windowList:
if isinstance (x, prev):
self.currentScreen = x
instantiated = 1
break
if not instantiated:
self.currentScreen = self.instantiateWindow (prev)
else:
self.stateListIndex = self.stateListIndex - 1
self.currentScreen = self.stateList[self.stateListIndex]
self.setScreen (self.currentScreen, self.prevClicked)
def nextClicked (self, *args):
next = self.currentScreen.getNext ()
if next:
instantiated = 0
for x in self.windowList:
if isinstance (x, next):
self.currentScreen = x
instantiated = 1
break
if not instantiated:
self.currentScreen = self.instantiateWindow (next)
else:
self.stateListIndex = self.stateListIndex + 1
if self.stateListIndex < len (self.stateList):
self.currentScreen = self.stateList[self.stateListIndex]
else:
self.ii.finishedTODO.set ()
sys.exit (0)
self.setScreen (self.currentScreen, self.nextClicked)
def helpClicked (self, widget, *args):
self.hbox.remove (widget)
if widget == self.hideHelpButton:
self.bin.remove (self.table)
self.installFrame.reparent (self.bin)
self.showHelpButton.show ()
self.showHelpButton.set_state (STATE_NORMAL)
self.hbox.pack_start (self.showHelpButton, FALSE)
self.hbox.reorder_child (self.showHelpButton, 0)
self.displayHelp = FALSE
else:
self.bin.remove (self.installFrame)
self.table.attach (self.installFrame, 1, 3, 0, 1)
self.bin.add (self.table)
self.html.source (self.currentScreen.getICS ().getHTML ())
self.hideHelpButton.show ()
self.showHelpButton.set_state (STATE_NORMAL)
self.hbox.pack_start (self.hideHelpButton, FALSE)
self.hbox.reorder_child (self.hideHelpButton, 0)
self.displayHelp = TRUE
def setScreen (self, screen, direction):
# if getScreen returns None, we continue advancing in direction given
new_screen = screen.getScreen ()
if not new_screen:
direction ()
return
self.update (screen.getICS ())
child = self.installFrame.children ()[0]
self.installFrame.remove (child)
child.destroy ()
self.installFrame.add (new_screen)
self.installFrame.show_all ()
def update (self, ics):
if self.buildingWindows or ics != self.currentScreen.getICS ():
return
self.installFrame.set_label (ics.getTitle ())
buttons = { "prev" : ics.getPrevButton (),
"next" : ics.getNextButton () }
for (name, button) in buttons.items ():
if button["pixmap"] == STOCK_BUTTON_PREV and not button["label"]:
buttons[name] = self.prevButtonStock
elif button["pixmap"] == STOCK_BUTTON_NEXT and not button["label"]:
buttons[name] = self.nextButtonStock
else:
buttons[name] = GnomePixmapButton (GnomeStock (button["pixmap"]), button["label"])
if name == "prev": buttons[name].connect ("clicked", self.prevClicked)
elif name == "next": buttons[name].connect ("clicked", self.nextClicked)
buttons[name].show ()
self.buttonBox.foreach (lambda x, b=self.buttonBox: b.remove (x))
self.buttonBox.pack_start (buttons["prev"])
self.buttonBox.pack_start (buttons["next"])
buttons["prev"].set_sensitive (ics.getPrevEnabled ())
buttons["next"].set_sensitive (ics.getNextEnabled ())
if ics.getHelpEnabled () == FALSE:
if self.displayHelp:
self.helpClicked (self.hideHelpButton)
elif ics.getHelpEnabled () == TRUE:
if not self.displayHelp:
self.helpClicked (self.showHelpButton)
if self.displayHelp:
self.html.source (ics.getHTML ())
def __init__ (self, ii, steps, todo):
self.ii = ii
self.todo = todo
threads_enter ()
self.window = GtkWindow ()
self.window.set_border_width (10)
self.window.set_title ("Install Control Window")
self.window.set_position (WIN_POS_CENTER)
self.window.set_default_size (640, 480)
vbox = GtkVBox (FALSE, 10)
self.buttonBox = GtkHButtonBox ()
self.buttonBox.set_layout (BUTTONBOX_END)
self.prevButtonStock = GnomePixmapButton (GnomeStock (STOCK_BUTTON_PREV), "Back")
self.nextButtonStock = GnomeStockButton (STOCK_BUTTON_NEXT)
self.finishButton = GnomePixmapButton (GnomeStock (STOCK_BUTTON_APPLY), "Finish")
self.hideHelpButton = GnomePixmapButton (GnomeStock (STOCK_BUTTON_HELP), "Hide Help")
self.showHelpButton = GnomePixmapButton (GnomeStock (STOCK_BUTTON_HELP), "Show Help")
self.hideHelpButton.connect ("clicked", self.helpClicked)
self.showHelpButton.connect ("clicked", self.helpClicked)
self.prevButtonStock.connect ("clicked", self.prevClicked)
self.nextButtonStock.connect ("clicked", self.nextClicked)
self.buttonBox.add (self.prevButtonStock)
self.buttonBox.add (self.nextButtonStock)
self.hbox = GtkHBox ()
self.hbox.pack_start (self.hideHelpButton, FALSE)
self.hbox.pack_start (self.buttonBox)
vbox.pack_end (self.hbox, FALSE)
self.html = GtkXmHTML()
# html.set_dithering(FALSE) # this forces creation of CC
self.html.set_allow_body_colors(TRUE)
self.html.source ("<HTML><BODY>HTML Help Window</BODY></HTML>")
self.displayHelp = TRUE
self.helpFrame = GtkFrame ("Help Window")
self.helpFrame.add (self.html)
table = GtkTable (1, 3, TRUE)
table.attach (self.helpFrame, 0, 1, 0, 1)
self.installFrame = GtkFrame ()
self.windowList = []
self.setStateList (steps, 0)
self.currentScreen = self.stateList[self.stateListIndex]
self.update (self.currentScreen.getICS ())
self.installFrame.add (self.currentScreen.getScreen ())
table.attach (self.installFrame, 1, 3, 0, 1)
table.set_col_spacing (0, 15)
self.bin = GtkFrame ()
self.bin.set_shadow_type (SHADOW_NONE)
self.bin.add (table)
vbox.pack_end (self.bin, TRUE, TRUE)
self.table = table
self.window.add (vbox)
threads_leave ()
Thread.__init__ (self)
def run (self):
self.mutex = allocate_lock ()
self.mutex.acquire ()
# Popup the ICW and wait for it to wake us back up
threads_enter ()
self.window.show_all ()
threads_leave ()
self.mutex.acquire ()
class InstallControlState:
def __init__ (self, cw, ii, todo, title = "Install Window",
prevEnabled = 1, nextEnabled = 0, html = ""):
self.ii = ii
self.cw = cw
self.todo = todo
self.prevEnabled = prevEnabled
self.nextEnabled = nextEnabled
self.title = title
self.html = html
self.nextButton = STOCK_BUTTON_NEXT
self.prevButton = STOCK_BUTTON_PREV
self.nextButtonLabel = None
self.prevButtonLabel = None
self.helpEnabled = 3 # Values other than TRUE or FALSE don't change the help setting
def getState (self):
return (self.title, prevEnabled, nextEnabled, prevText, nextTest)
def setTitle (self, title):
self.title = title
self.cw.update (self)
def getTitle (self):
return self.title
def setPrevEnabled (self, value):
if value == self.prevEnabled: return
self.prevEnabled = value
self.cw.update (self)
def getPrevEnabled (self):
if (self.prevEnabled != 0):
return TRUE
return FALSE
def setNextEnabled (self, value):
if value == self.nextEnabled: return
self.nextEnabled = value
self.cw.update (self)
def getNextEnabled (self):
if (self.nextEnabled != 0):
return TRUE
return FALSE
def setHTML (self, text):
self.html = text
self.cw.update (self)
def getHTML (self):
return self.html
def getToDo (self):
return self.todo
def setNextButton (self, button, label=None):
self.nextButton = button
self.nextButtonLabel = label
def getNextButton (self):
return { "pixmap" : self.nextButton, "label" : self.nextButtonLabel }
def setPrevButton (self, button, label=None):
self.prevButton = button
self.prevButtonLabel = label
def getPrevButton (self):
return { "pixmap" : self.prevButton, "label" : self.prevButtonLabel }
def setScreenPrev (self):
self.cw.prevClicked ()
def setScreenNext (self):
self.cw.nextClicked ()
def getInstallInterface (self):
return self.ii
def setHelpEnabled (self, value):
self.helpEnabled = value
self.cw.update (self)
def getHelpEnabled (self):
return self.helpEnabled
def getICW (self):
return self.cw
|