10 import ServiceReference
12 from Navigation import Navigation
14 from skin import readSkin, applyAllAttributes
16 from Components.config import configfile
20 def dump(dir, p = ""):
21 if isinstance(dir, dict):
22 for (entry, val) in dir.items():
23 dump(val, p + "(dict)/" + entry)
24 if hasattr(dir, "__dict__"):
25 for name, value in dir.__dict__.items():
26 if not had.has_key(str(value)):
28 dump(value, p + "/" + str(name))
30 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
32 print p + ":" + str(dir)
34 # + ":" + str(dir.__class__)
39 def create(self, screen): pass
43 class HTMLOutputDevice(OutputDevice):
44 def create(self, comp):
45 print comp.produceHTML()
47 html = HTMLOutputDevice()
49 class GUIOutputDevice(OutputDevice):
51 def create(self, comp, desktop):
52 comp.createGUIScreen(self.parent, desktop)
57 self.delayTimer = eTimer()
58 self.delayTimer.timeout.get().append(self.processDelay)
60 self.currentDialog = None
62 self.dialogStack = [ ]
64 def processDelay(self):
67 callback = self.currentDialog.callback
68 retval = self.currentDialog.returnValue
70 if self.currentDialog.isTmp:
71 self.currentDialog.doClose()
73 del self.currentDialog.instance
74 # dump(self.currentDialog)
75 del self.currentDialog
77 del self.currentDialog.callback
80 if callback is not None:
84 self.currentDialog.execBegin()
85 self.currentDialog.instance.show()
88 self.currentDialog.execEnd()
89 self.currentDialog.instance.hide()
91 def create(self, screen, arguments):
92 # creates an instance of 'screen' (which is a class)
94 return screen(self, *arguments)
96 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), str(x))
97 raise TypeError(errstr)
99 def instantiateDialog(self, screen, *arguments):
103 dlg = self.create(screen, arguments)
105 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
107 traceback.print_exc(file=sys.stdout)
112 readSkin(dlg, None, dlg.skinName, self.desktop)
114 # create GUI view of this dialog
115 assert self.desktop != None
116 dlg.instance = eWindow(self.desktop)
117 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
118 gui = GUIOutputDevice()
119 gui.parent = dlg.instance
120 gui.create(dlg, self.desktop)
124 def pushCurrent(self):
125 if self.currentDialog:
126 self.dialogStack.append(self.currentDialog)
129 def popCurrent(self):
130 if len(self.dialogStack):
131 self.currentDialog = self.dialogStack.pop()
134 def execDialog(self, dialog):
136 self.currentDialog = dialog
137 self.currentDialog.isTmp = False
138 self.currentDialog.callback = None # would cause re-entrancy problems.
141 def openWithCallback(self, callback, screen, *arguments):
142 self.open(screen, *arguments)
143 self.currentDialog.callback = callback
145 def open(self, screen, *arguments):
147 self.currentDialog = self.instantiateDialog(screen, *arguments)
148 self.currentDialog.isTmp = True
149 self.currentDialog.callback = None
152 def keyEvent(self, code):
153 print "code " + str(code)
155 def close(self, *retval):
156 self.currentDialog.returnValue = retval
157 self.delayTimer.start(0, 1)
162 session.desktop = getDesktop()
164 session.nav = Navigation()
166 session.open(Screens.InfoBar.InfoBar)
168 CONNECT(keyPressedSignal(), session.keyEvent)
174 session.nav.shutdown()
179 keymapparser.readKeymap()
181 skin.loadSkin(getDesktop())
183 import Components.InputDevice
184 Components.InputDevice.InitInputDevices()
186 import Components.AVSwitch
187 Components.AVSwitch.InitAVSwitch()
189 import Components.Network
190 Components.Network.InitNetwork()
192 import Components.Lcd
193 Components.Lcd.InitLcd()
195 import Components.SetupDevices
196 Components.SetupDevices.InitSetupDevices()
198 import Components.RFmod
199 Components.RFmod.InitRFmod()
201 import Components.NimManager
203 # first, setup a screen
207 print 'EXCEPTION IN PYTHON STARTUP CODE:'
209 traceback.print_exc(file=sys.stdout)