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()
28 from twisted.internet import reactor
33 print "twisted not available"
37 # initialize autorun plugins and plugin menu entries
38 from Components.PluginComponent import plugins
39 plugins.readPluginList()
41 from Screens.Wizard import wizardManager
42 from Screens.StartWizard import *
43 from Screens.TutorialWizard import *
44 from Tools.BoundFunction import boundFunction
48 def dump(dir, p = ""):
49 if isinstance(dir, dict):
50 for (entry, val) in dir.items():
51 dump(val, p + "(dict)/" + entry)
52 if hasattr(dir, "__dict__"):
53 for name, value in dir.__dict__.items():
54 if not had.has_key(str(value)):
56 dump(value, p + "/" + str(name))
58 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
60 print p + ":" + str(dir)
62 # + ":" + str(dir.__class__)
67 def create(self, screen): pass
71 class HTMLOutputDevice(OutputDevice):
72 def create(self, comp):
73 print comp.produceHTML()
75 html = HTMLOutputDevice()
77 class GUIOutputDevice(OutputDevice):
79 def create(self, comp, desktop):
80 comp.createGUIScreen(self.parent, desktop)
85 self.delayTimer = eTimer()
86 self.delayTimer.timeout.get().append(self.processDelay)
88 self.currentDialog = None
90 self.dialogStack = [ ]
92 def processDelay(self):
95 callback = self.currentDialog.callback
97 retval = self.currentDialog.returnValue
99 if self.currentDialog.isTmp:
100 self.currentDialog.doClose()
101 # dump(self.currentDialog)
102 del self.currentDialog
104 del self.currentDialog.callback
107 if callback is not None:
111 c = self.currentDialog
114 # when execBegin opened a new dialog, don't bother showing the old one.
115 if c == self.currentDialog:
119 self.currentDialog.execEnd()
120 self.currentDialog.hide()
122 def create(self, screen, arguments):
123 # creates an instance of 'screen' (which is a class)
125 return screen(self, *arguments)
127 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
129 traceback.print_exc(file=sys.stdout)
133 def instantiateDialog(self, screen, *arguments):
137 dlg = self.create(screen, arguments)
139 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
141 traceback.print_exc(file=sys.stdout)
149 readSkin(dlg, None, dlg.skinName, self.desktop)
151 # create GUI view of this dialog
152 assert self.desktop != None
155 for (key, value) in dlg.skinAttributes:
156 if key == "zPosition":
159 dlg.instance = eWindow(self.desktop, z)
160 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
161 gui = GUIOutputDevice()
162 gui.parent = dlg.instance
163 gui.create(dlg, self.desktop)
167 def pushCurrent(self):
168 if self.currentDialog:
169 self.dialogStack.append(self.currentDialog)
172 def popCurrent(self):
173 if len(self.dialogStack):
174 self.currentDialog = self.dialogStack.pop()
177 self.currentDialog = None
179 def execDialog(self, dialog):
181 self.currentDialog = dialog
182 self.currentDialog.isTmp = False
183 self.currentDialog.callback = None # would cause re-entrancy problems.
186 def openWithCallback(self, callback, screen, *arguments):
187 dlg = self.open(screen, *arguments)
188 dlg.callback = callback
190 def open(self, screen, *arguments):
192 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
198 def keyEvent(self, code):
199 print "code " + str(code)
201 def close(self, *retval):
202 self.currentDialog.returnValue = retval
203 self.delayTimer.start(0, 1)
205 from Screens.Volume import Volume
206 from Screens.Mute import Mute
207 from GlobalActions import globalActionMap
208 from Components.config import ConfigSubsection, configSequence, configElement, configsequencearg
210 #TODO .. move this to a own .py file
212 """Volume control, handles volUp, volDown, volMute actions and display
213 a corresponding dialog"""
214 def __init__(self, session):
215 global globalActionMap
216 globalActionMap.actions["volumeUp"]=self.volUp
217 globalActionMap.actions["volumeDown"]=self.volDown
218 globalActionMap.actions["volumeMute"]=self.volMute
220 config.audio = ConfigSubsection()
221 config.audio.volume = configElement("config.audio.volume", configSequence, [100], configsequencearg.get("INTEGER", (0, 100)))
223 self.volumeDialog = session.instantiateDialog(Volume)
224 self.muteDialog = session.instantiateDialog(Mute)
226 self.hideVolTimer = eTimer()
227 self.hideVolTimer.timeout.get().append(self.volHide)
229 vol = config.audio.volume.value[0]
230 self.volumeDialog.setValue(vol)
231 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
234 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
235 config.audio.volume.save()
238 if (eDVBVolumecontrol.getInstance().isMuted()):
240 eDVBVolumecontrol.getInstance().volumeUp()
241 self.volumeDialog.show()
242 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
244 self.hideVolTimer.start(3000, True)
247 if (eDVBVolumecontrol.getInstance().isMuted()):
249 eDVBVolumecontrol.getInstance().volumeDown()
250 self.volumeDialog.show()
251 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
253 self.hideVolTimer.start(3000, True)
256 self.volumeDialog.hide()
259 eDVBVolumecontrol.getInstance().volumeToggleMute()
260 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
262 if (eDVBVolumecontrol.getInstance().isMuted()):
263 self.muteDialog.show()
265 self.muteDialog.hide()
269 session.desktop = getDesktop()
271 session.nav = Navigation()
273 screensToRun = wizardManager.getWizards()
274 screensToRun.append(Screens.InfoBar.InfoBar)
276 def runNextScreen(session, screensToRun, *result):
280 screen = screensToRun[0]
282 if len(screensToRun):
283 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
287 runNextScreen(session, screensToRun)
289 CONNECT(keyPressedSignal(), session.keyEvent)
291 vol = VolumeControl(session)
297 session.nav.shutdown()
302 keymapparser.readKeymap()
304 skin.loadSkin(getDesktop())
306 import Components.InputDevice
307 Components.InputDevice.InitInputDevices()
309 import Components.AVSwitch
310 Components.AVSwitch.InitAVSwitch()
312 import Components.RecordingConfig
313 Components.RecordingConfig.InitRecordingConfig()
315 import Components.UsageConfig
316 Components.UsageConfig.InitUsageConfig()
318 import Components.Network
319 Components.Network.InitNetwork()
321 import Components.Lcd
322 Components.Lcd.InitLcd()
324 import Components.SetupDevices
325 Components.SetupDevices.InitSetupDevices()
327 import Components.RFmod
328 Components.RFmod.InitRFmod()
330 import Components.NimManager
332 # first, setup a screen
337 print 'EXCEPTION IN PYTHON STARTUP CODE:'
339 traceback.print_exc(file=sys.stdout)