10 import ServiceReference
12 from Navigation import Navigation
14 from skin import readSkin, applyAllAttributes
18 def dump(dir, p = ""):
19 if isinstance(dir, dict):
20 for (entry, val) in dir.items():
21 dump(val, p + "(dict)/" + entry)
22 if hasattr(dir, "__dict__"):
23 for name, value in dir.__dict__.items():
24 if not had.has_key(str(value)):
26 dump(value, p + "/" + str(name))
28 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
30 print p + ":" + str(dir)
32 # + ":" + str(dir.__class__)
37 def create(self, screen): pass
41 class HTMLOutputDevice(OutputDevice):
42 def create(self, comp):
43 print comp.produceHTML()
45 html = HTMLOutputDevice()
47 class GUIOutputDevice(OutputDevice):
49 def create(self, comp, desktop):
50 comp.createGUIScreen(self.parent, desktop)
55 self.delayTimer = eTimer()
56 self.delayTimer.timeout.get().append(self.processDelay)
58 self.currentDialog = None
60 self.dialogStack = [ ]
62 def processDelay(self):
65 callback = self.currentDialog.callback
66 retval = self.currentDialog.returnValue
68 if self.currentDialog.isTmp:
69 self.currentDialog.doClose()
71 del self.currentDialog.instance
72 # dump(self.currentDialog)
73 del self.currentDialog
75 del self.currentDialog.callback
78 if callback is not None:
82 self.currentDialog.execBegin()
83 self.currentDialog.instance.show()
86 self.currentDialog.execEnd()
87 self.currentDialog.instance.hide()
89 def create(self, screen, arguments):
90 # creates an instance of 'screen' (which is a class)
91 return screen(self, *arguments)
93 def instantiateDialog(self, screen, *arguments):
97 dlg = self.create(screen, arguments)
99 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
101 traceback.print_exc(file=sys.stdout)
106 readSkin(dlg, None, dlg.skinName, self.desktop)
108 # create GUI view of this dialog
109 assert self.desktop != None
110 dlg.instance = eWindow(self.desktop)
111 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
112 gui = GUIOutputDevice()
113 gui.parent = dlg.instance
114 gui.create(dlg, self.desktop)
118 def pushCurrent(self):
119 if self.currentDialog:
120 self.dialogStack.append(self.currentDialog)
123 def popCurrent(self):
124 if len(self.dialogStack):
125 self.currentDialog = self.dialogStack.pop()
128 def execDialog(self, dialog):
130 self.currentDialog = dialog
131 self.currentDialog.isTmp = False
132 self.currentDialog.callback = None # would cause re-entrancy problems.
135 def openWithCallback(self, callback, screen, *arguments):
136 self.open(screen, *arguments)
137 self.currentDialog.callback = callback
139 def open(self, screen, *arguments):
141 self.currentDialog = self.instantiateDialog(screen, *arguments)
142 self.currentDialog.isTmp = True
143 self.currentDialog.callback = None
146 def keyEvent(self, code):
147 print "code " + str(code)
149 def close(self, *retval):
150 self.currentDialog.returnValue = retval
151 self.delayTimer.start(0, 1)
156 session.desktop = getDesktop()
158 session.nav = Navigation()
160 session.open(Screens.InfoBar.InfoBar)
162 CONNECT(keyPressedSignal(), session.keyEvent)
166 session.nav.shutdown()
171 keymapparser.readKeymap()
173 skin.loadSkin(getDesktop())
175 import Components.InputDevice
176 Components.InputDevice.InitInputDevices()
178 import Components.AVSwitch
179 Components.AVSwitch.InitAVSwitch()
181 import Components.Network
182 Components.Network.InitNetwork()
184 import Components.Lcd
185 Components.Lcd.InitLcd()
187 import Components.SetupDevices
188 Components.SetupDevices.InitSetupDevices()
190 import Components.RFmod
191 Components.RFmod.InitRFmod()
193 import Components.NimManager
195 # first, setup a screen
199 print 'EXCEPTION IN PYTHON STARTUP CODE:'
201 traceback.print_exc(file=sys.stdout)
205 # now, run the mainloop
207 #pt = eDebugClassPtr()
208 #eDebugClass.getDebug(pt, 12)
212 #print "removing ptr..."
215 #print "p is " + str(p)
220 #bla = eDebugClass(2)