4 from Components.Language import language
12 import ServiceReference
14 from Navigation import Navigation
16 from skin import readSkin, applyAllAttributes
18 from Components.config import configfile
19 from Screens.Wizard import wizardManager
20 from Screens.StartWizard import *
21 from Tools.BoundFunction import boundFunction
25 def dump(dir, p = ""):
26 if isinstance(dir, dict):
27 for (entry, val) in dir.items():
28 dump(val, p + "(dict)/" + entry)
29 if hasattr(dir, "__dict__"):
30 for name, value in dir.__dict__.items():
31 if not had.has_key(str(value)):
33 dump(value, p + "/" + str(name))
35 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
37 print p + ":" + str(dir)
39 # + ":" + str(dir.__class__)
44 def create(self, screen): pass
48 class HTMLOutputDevice(OutputDevice):
49 def create(self, comp):
50 print comp.produceHTML()
52 html = HTMLOutputDevice()
54 class GUIOutputDevice(OutputDevice):
56 def create(self, comp, desktop):
57 comp.createGUIScreen(self.parent, desktop)
62 self.delayTimer = eTimer()
63 self.delayTimer.timeout.get().append(self.processDelay)
65 self.currentDialog = None
67 self.dialogStack = [ ]
69 def processDelay(self):
72 callback = self.currentDialog.callback
74 retval = self.currentDialog.returnValue
76 if self.currentDialog.isTmp:
77 self.currentDialog.doClose()
78 # dump(self.currentDialog)
79 del self.currentDialog
81 del self.currentDialog.callback
84 if callback is not None:
88 c = self.currentDialog
91 # when execBegin opened a new dialog, don't bother showing the old one.
92 if c == self.currentDialog:
96 self.currentDialog.execEnd()
97 self.currentDialog.instance.hide()
99 def create(self, screen, arguments):
100 # creates an instance of 'screen' (which is a class)
102 return screen(self, *arguments)
104 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
106 traceback.print_exc(file=sys.stdout)
110 def instantiateDialog(self, screen, *arguments):
114 dlg = self.create(screen, arguments)
116 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
118 traceback.print_exc(file=sys.stdout)
126 readSkin(dlg, None, dlg.skinName, self.desktop)
128 # create GUI view of this dialog
129 assert self.desktop != None
130 dlg.instance = eWindow(self.desktop)
131 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
132 gui = GUIOutputDevice()
133 gui.parent = dlg.instance
134 gui.create(dlg, self.desktop)
138 def pushCurrent(self):
139 if self.currentDialog:
140 self.dialogStack.append(self.currentDialog)
143 def popCurrent(self):
144 if len(self.dialogStack):
145 self.currentDialog = self.dialogStack.pop()
148 self.currentDialog = None
150 def execDialog(self, dialog):
152 self.currentDialog = dialog
153 self.currentDialog.isTmp = False
154 self.currentDialog.callback = None # would cause re-entrancy problems.
157 def openWithCallback(self, callback, screen, *arguments):
158 dlg = self.open(screen, *arguments)
159 dlg.callback = callback
161 def open(self, screen, *arguments):
163 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
169 def keyEvent(self, code):
170 print "code " + str(code)
172 def close(self, *retval):
173 self.currentDialog.returnValue = retval
174 self.delayTimer.start(0, 1)
178 session.desktop = getDesktop()
180 session.nav = Navigation()
182 screensToRun = wizardManager.getWizards()
183 screensToRun.append(Screens.InfoBar.InfoBar)
185 def runNextScreen(session, screensToRun, *result):
189 screen = screensToRun[0]
191 if len(screensToRun):
192 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
196 runNextScreen(session, screensToRun)
198 CONNECT(keyPressedSignal(), session.keyEvent)
204 session.nav.shutdown()
209 keymapparser.readKeymap()
211 skin.loadSkin(getDesktop())
213 import Components.InputDevice
214 Components.InputDevice.InitInputDevices()
216 import Components.AVSwitch
217 Components.AVSwitch.InitAVSwitch()
219 import Components.Network
220 Components.Network.InitNetwork()
222 import Components.Lcd
223 Components.Lcd.InitLcd()
225 import Components.SetupDevices
226 Components.SetupDevices.InitSetupDevices()
228 import Components.RFmod
229 Components.RFmod.InitRFmod()
231 import Components.NimManager
233 # first, setup a screen
237 print 'EXCEPTION IN PYTHON STARTUP CODE:'
239 traceback.print_exc(file=sys.stdout)