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)
93 return screen(self, *arguments)
95 def instantiateDialog(self, screen, *arguments):
99 dlg = self.create(screen, arguments)
101 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
103 traceback.print_exc(file=sys.stdout)
108 readSkin(dlg, None, dlg.skinName, self.desktop)
110 # create GUI view of this dialog
111 assert self.desktop != None
112 dlg.instance = eWindow(self.desktop)
113 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
114 gui = GUIOutputDevice()
115 gui.parent = dlg.instance
116 gui.create(dlg, self.desktop)
120 def pushCurrent(self):
121 if self.currentDialog:
122 self.dialogStack.append(self.currentDialog)
125 def popCurrent(self):
126 if len(self.dialogStack):
127 self.currentDialog = self.dialogStack.pop()
130 def execDialog(self, dialog):
132 self.currentDialog = dialog
133 self.currentDialog.isTmp = False
134 self.currentDialog.callback = None # would cause re-entrancy problems.
137 def openWithCallback(self, callback, screen, *arguments):
138 self.open(screen, *arguments)
139 self.currentDialog.callback = callback
141 def open(self, screen, *arguments):
143 self.currentDialog = self.instantiateDialog(screen, *arguments)
144 self.currentDialog.isTmp = True
145 self.currentDialog.callback = None
148 def keyEvent(self, code):
149 print "code " + str(code)
151 def close(self, *retval):
152 self.currentDialog.returnValue = retval
153 self.delayTimer.start(0, 1)
158 session.desktop = getDesktop()
160 session.nav = Navigation()
162 session.open(Screens.InfoBar.InfoBar)
164 CONNECT(keyPressedSignal(), session.keyEvent)
170 session.nav.shutdown()
175 keymapparser.readKeymap()
177 skin.loadSkin(getDesktop())
179 import Components.InputDevice
180 Components.InputDevice.InitInputDevices()
182 import Components.AVSwitch
183 Components.AVSwitch.InitAVSwitch()
185 import Components.Network
186 Components.Network.InitNetwork()
188 import Components.Lcd
189 Components.Lcd.InitLcd()
191 import Components.SetupDevices
192 Components.SetupDevices.InitSetupDevices()
194 import Components.RFmod
195 Components.RFmod.InitRFmod()
197 import Components.NimManager
199 # first, setup a screen
203 print 'EXCEPTION IN PYTHON STARTUP CODE:'
205 traceback.print_exc(file=sys.stdout)