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 print sys.getrefcount(self.currentDialog)
72 del self.currentDialog.instance
73 # dump(self.currentDialog)
74 del self.currentDialog
76 del self.currentDialog.callback
79 if callback is not None:
83 self.currentDialog.execBegin()
84 self.currentDialog.instance.show()
87 self.currentDialog.execEnd()
88 self.currentDialog.instance.hide()
90 def create(self, screen, arguments):
91 # creates an instance of 'screen' (which is a class)
92 return screen(self, *arguments)
94 def instantiateDialog(self, screen, *arguments):
98 dlg = self.create(screen, arguments)
100 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
102 traceback.print_exc(file=sys.stdout)
107 readSkin(dlg, None, dlg.skinName, self.desktop)
109 # create GUI view of this dialog
110 assert self.desktop != None
111 dlg.instance = eWindow(self.desktop)
112 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
113 gui = GUIOutputDevice()
114 gui.parent = dlg.instance
115 gui.create(dlg, self.desktop)
119 def pushCurrent(self):
120 if self.currentDialog:
121 self.dialogStack.append(self.currentDialog)
124 def popCurrent(self):
125 if len(self.dialogStack):
126 self.currentDialog = self.dialogStack.pop()
129 def execDialog(self, dialog):
131 self.currentDialog = dialog
132 self.currentDialog.isTmp = False
133 self.currentDialog.callback = None # would cause re-entrancy problems.
136 def openWithCallback(self, callback, screen, *arguments):
137 self.open(screen, *arguments)
138 self.currentDialog.callback = callback
140 def open(self, screen, *arguments):
142 self.currentDialog = self.instantiateDialog(screen, *arguments)
143 self.currentDialog.isTmp = True
144 self.currentDialog.callback = None
147 def keyEvent(self, code):
148 print "code " + str(code)
150 def close(self, *retval):
151 self.currentDialog.returnValue = retval
152 self.delayTimer.start(0, 1)
157 session.desktop = getDesktop()
159 session.nav = Navigation()
161 session.open(Screens.InfoBar.InfoBar)
163 CONNECT(keyPressedSignal(), session.keyEvent)
167 session.nav.shutdown()
172 keymapparser.readKeymap()
174 skin.loadSkin(getDesktop())
176 import Components.InputDevice
177 Components.InputDevice.InitInputDevices()
179 import Components.AVSwitch
180 Components.AVSwitch.InitAVSwitch()
182 import Components.Network
183 Components.Network.InitNetwork()
185 import Components.Lcd
186 Components.Lcd.InitLcd()
188 import Components.SetupDevices
189 Components.SetupDevices.InitSetupDevices()
191 import Components.RFmod
192 Components.RFmod.InitRFmod()
194 import Components.NimManager
196 # first, setup a screen
200 print 'EXCEPTION IN PYTHON STARTUP CODE:'
202 traceback.print_exc(file=sys.stdout)
206 # now, run the mainloop
208 #pt = eDebugClassPtr()
209 #eDebugClass.getDebug(pt, 12)
213 #print "removing ptr..."
216 #print "p is " + str(p)
221 #bla = eDebugClass(2)