1 from Tools import RedirectOutput
5 from Components.Language import language
13 import ServiceReference
15 from Navigation import Navigation
17 from skin import readSkin, applyAllAttributes
19 from Components.config import configfile
20 from Tools.Directories import InitFallbackFiles
22 eDVBDB.getInstance().reloadBouquets()
25 from twisted.internet import e2reactor
28 from twisted.internet import reactor
36 # initialize autorun plugins and plugin menu entries
37 from Components.PluginComponent import plugins
38 plugins.readPluginList()
40 from Screens.Wizard import wizardManager
41 from Screens.StartWizard import *
42 from Screens.TutorialWizard import *
43 from Tools.BoundFunction import boundFunction
47 def dump(dir, p = ""):
48 if isinstance(dir, dict):
49 for (entry, val) in dir.items():
50 dump(val, p + "(dict)/" + entry)
51 if hasattr(dir, "__dict__"):
52 for name, value in dir.__dict__.items():
53 if not had.has_key(str(value)):
55 dump(value, p + "/" + str(name))
57 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
59 print p + ":" + str(dir)
61 # + ":" + str(dir.__class__)
66 def create(self, screen): pass
70 class HTMLOutputDevice(OutputDevice):
71 def create(self, comp):
72 print comp.produceHTML()
74 html = HTMLOutputDevice()
76 class GUIOutputDevice(OutputDevice):
78 def create(self, comp, desktop):
79 comp.createGUIScreen(self.parent, desktop)
84 self.delayTimer = eTimer()
85 self.delayTimer.timeout.get().append(self.processDelay)
87 self.currentDialog = None
89 self.dialogStack = [ ]
91 def processDelay(self):
94 callback = self.currentDialog.callback
96 retval = self.currentDialog.returnValue
98 if self.currentDialog.isTmp:
99 self.currentDialog.doClose()
100 # dump(self.currentDialog)
101 del self.currentDialog
103 del self.currentDialog.callback
106 if callback is not None:
110 c = self.currentDialog
113 # when execBegin opened a new dialog, don't bother showing the old one.
114 if c == self.currentDialog:
118 self.currentDialog.execEnd()
119 self.currentDialog.hide()
121 def create(self, screen, arguments):
122 # creates an instance of 'screen' (which is a class)
124 return screen(self, *arguments)
126 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
128 traceback.print_exc(file=sys.stdout)
132 def instantiateDialog(self, screen, *arguments):
136 dlg = self.create(screen, arguments)
138 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
140 traceback.print_exc(file=sys.stdout)
148 readSkin(dlg, None, dlg.skinName, self.desktop)
150 # create GUI view of this dialog
151 assert self.desktop != None
154 for (key, value) in dlg.skinAttributes:
155 if key == "zPosition":
158 dlg.instance = eWindow(self.desktop, z)
159 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
160 gui = GUIOutputDevice()
161 gui.parent = dlg.instance
162 gui.create(dlg, self.desktop)
166 def pushCurrent(self):
167 if self.currentDialog:
168 self.dialogStack.append(self.currentDialog)
171 def popCurrent(self):
172 if len(self.dialogStack):
173 self.currentDialog = self.dialogStack.pop()
176 self.currentDialog = None
178 def execDialog(self, dialog):
180 self.currentDialog = dialog
181 self.currentDialog.isTmp = False
182 self.currentDialog.callback = None # would cause re-entrancy problems.
185 def openWithCallback(self, callback, screen, *arguments):
186 dlg = self.open(screen, *arguments)
187 dlg.callback = callback
189 def open(self, screen, *arguments):
191 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
197 def keyEvent(self, code):
198 print "code " + str(code)
200 def close(self, *retval):
201 self.currentDialog.returnValue = retval
202 self.delayTimer.start(0, 1)
204 from Screens.Volume import Volume
205 from Screens.Mute import Mute
206 from GlobalActions import globalActionMap
207 from Components.config import ConfigSubsection, configSequence, configElement, configsequencearg
209 #TODO .. move this to a own .py file
211 """Volume control, handles volUp, volDown, volMute actions and display
212 a corresponding dialog"""
213 def __init__(self, session):
214 global globalActionMap
215 globalActionMap.actions["volumeUp"]=self.volUp
216 globalActionMap.actions["volumeDown"]=self.volDown
217 globalActionMap.actions["volumeMute"]=self.volMute
219 config.audio = ConfigSubsection()
220 config.audio.volume = configElement("config.audio.volume", configSequence, [100], configsequencearg.get("INTEGER", (0, 100)))
222 self.volumeDialog = session.instantiateDialog(Volume)
223 self.muteDialog = session.instantiateDialog(Mute)
225 self.hideVolTimer = eTimer()
226 self.hideVolTimer.timeout.get().append(self.volHide)
228 vol = config.audio.volume.value[0]
229 self.volumeDialog.setValue(vol)
230 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
233 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
234 config.audio.volume.save()
237 if (eDVBVolumecontrol.getInstance().isMuted()):
239 eDVBVolumecontrol.getInstance().volumeUp()
240 self.volumeDialog.show()
241 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
243 self.hideVolTimer.start(3000, True)
246 if (eDVBVolumecontrol.getInstance().isMuted()):
248 eDVBVolumecontrol.getInstance().volumeDown()
249 self.volumeDialog.show()
250 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
252 self.hideVolTimer.start(3000, True)
255 self.volumeDialog.hide()
258 eDVBVolumecontrol.getInstance().volumeToggleMute()
259 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
261 if (eDVBVolumecontrol.getInstance().isMuted()):
262 self.muteDialog.show()
264 self.muteDialog.hide()
268 session.desktop = getDesktop()
270 session.nav = Navigation()
272 screensToRun = wizardManager.getWizards()
273 screensToRun.append(Screens.InfoBar.InfoBar)
275 def runNextScreen(session, screensToRun, *result):
279 screen = screensToRun[0]
281 if len(screensToRun):
282 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
286 runNextScreen(session, screensToRun)
288 CONNECT(keyPressedSignal(), session.keyEvent)
290 vol = VolumeControl(session)
296 session.nav.shutdown()
301 keymapparser.readKeymap()
303 skin.loadSkin(getDesktop())
305 import Components.InputDevice
306 Components.InputDevice.InitInputDevices()
308 import Components.AVSwitch
309 Components.AVSwitch.InitAVSwitch()
311 import Components.RecordingConfig
312 Components.RecordingConfig.InitRecordingConfig()
314 import Components.UsageConfig
315 Components.UsageConfig.InitUsageConfig()
317 import Components.Network
318 Components.Network.InitNetwork()
320 import Components.Lcd
321 Components.Lcd.InitLcd()
323 import Components.SetupDevices
324 Components.SetupDevices.InitSetupDevices()
326 import Components.RFmod
327 Components.RFmod.InitRFmod()
329 import Components.NimManager
331 # first, setup a screen
336 print 'EXCEPTION IN PYTHON STARTUP CODE:'
338 traceback.print_exc(file=sys.stdout)