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 Screens.TutorialWizard import *
22 from Tools.BoundFunction import boundFunction
23 from Tools.Directories import fixOldDirectoryEntries
24 fixOldDirectoryEntries()
28 def dump(dir, p = ""):
29 if isinstance(dir, dict):
30 for (entry, val) in dir.items():
31 dump(val, p + "(dict)/" + entry)
32 if hasattr(dir, "__dict__"):
33 for name, value in dir.__dict__.items():
34 if not had.has_key(str(value)):
36 dump(value, p + "/" + str(name))
38 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
40 print p + ":" + str(dir)
42 # + ":" + str(dir.__class__)
47 def create(self, screen): pass
51 class HTMLOutputDevice(OutputDevice):
52 def create(self, comp):
53 print comp.produceHTML()
55 html = HTMLOutputDevice()
57 class GUIOutputDevice(OutputDevice):
59 def create(self, comp, desktop):
60 comp.createGUIScreen(self.parent, desktop)
65 self.delayTimer = eTimer()
66 self.delayTimer.timeout.get().append(self.processDelay)
68 self.currentDialog = None
70 self.dialogStack = [ ]
72 def processDelay(self):
75 callback = self.currentDialog.callback
77 retval = self.currentDialog.returnValue
79 if self.currentDialog.isTmp:
80 self.currentDialog.doClose()
81 # dump(self.currentDialog)
82 del self.currentDialog
84 del self.currentDialog.callback
87 if callback is not None:
91 c = self.currentDialog
94 # when execBegin opened a new dialog, don't bother showing the old one.
95 if c == self.currentDialog:
99 self.currentDialog.execEnd()
100 self.currentDialog.instance.hide()
102 def create(self, screen, arguments):
103 # creates an instance of 'screen' (which is a class)
105 return screen(self, *arguments)
107 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
109 traceback.print_exc(file=sys.stdout)
113 def instantiateDialog(self, screen, *arguments):
117 dlg = self.create(screen, arguments)
119 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
121 traceback.print_exc(file=sys.stdout)
129 readSkin(dlg, None, dlg.skinName, self.desktop)
131 # create GUI view of this dialog
132 assert self.desktop != None
133 dlg.instance = eWindow(self.desktop)
134 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
135 gui = GUIOutputDevice()
136 gui.parent = dlg.instance
137 gui.create(dlg, self.desktop)
141 def pushCurrent(self):
142 if self.currentDialog:
143 self.dialogStack.append(self.currentDialog)
146 def popCurrent(self):
147 if len(self.dialogStack):
148 self.currentDialog = self.dialogStack.pop()
151 self.currentDialog = None
153 def execDialog(self, dialog):
155 self.currentDialog = dialog
156 self.currentDialog.isTmp = False
157 self.currentDialog.callback = None # would cause re-entrancy problems.
160 def openWithCallback(self, callback, screen, *arguments):
161 dlg = self.open(screen, *arguments)
162 dlg.callback = callback
164 def open(self, screen, *arguments):
166 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
172 def keyEvent(self, code):
173 print "code " + str(code)
175 def close(self, *retval):
176 self.currentDialog.returnValue = retval
177 self.delayTimer.start(0, 1)
181 session.desktop = getDesktop()
183 session.nav = Navigation()
185 screensToRun = wizardManager.getWizards()
186 screensToRun.append(Screens.InfoBar.InfoBar)
188 def runNextScreen(session, screensToRun, *result):
192 screen = screensToRun[0]
194 if len(screensToRun):
195 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
199 runNextScreen(session, screensToRun)
201 CONNECT(keyPressedSignal(), session.keyEvent)
207 session.nav.shutdown()
212 keymapparser.readKeymap()
214 skin.loadSkin(getDesktop())
216 import Components.InputDevice
217 Components.InputDevice.InitInputDevices()
219 import Components.AVSwitch
220 Components.AVSwitch.InitAVSwitch()
222 import Components.RecordingConfig
223 Components.RecordingConfig.InitRecordingConfig()
225 import Components.Network
226 Components.Network.InitNetwork()
228 import Components.Lcd
229 Components.Lcd.InitLcd()
231 import Components.SetupDevices
232 Components.SetupDevices.InitSetupDevices()
234 import Components.RFmod
235 Components.RFmod.InitRFmod()
237 import Components.NimManager
239 # first, setup a screen
243 print 'EXCEPTION IN PYTHON STARTUP CODE:'
245 traceback.print_exc(file=sys.stdout)