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.getPluginList(runAutostartPlugins=True)
39 from Screens.Wizard import wizardManager
40 from Screens.StartWizard import *
41 from Screens.TutorialWizard import *
42 from Tools.BoundFunction import boundFunction
46 def dump(dir, p = ""):
47 if isinstance(dir, dict):
48 for (entry, val) in dir.items():
49 dump(val, p + "(dict)/" + entry)
50 if hasattr(dir, "__dict__"):
51 for name, value in dir.__dict__.items():
52 if not had.has_key(str(value)):
54 dump(value, p + "/" + str(name))
56 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
58 print p + ":" + str(dir)
60 # + ":" + str(dir.__class__)
65 def create(self, screen): pass
69 class HTMLOutputDevice(OutputDevice):
70 def create(self, comp):
71 print comp.produceHTML()
73 html = HTMLOutputDevice()
75 class GUIOutputDevice(OutputDevice):
77 def create(self, comp, desktop):
78 comp.createGUIScreen(self.parent, desktop)
83 self.delayTimer = eTimer()
84 self.delayTimer.timeout.get().append(self.processDelay)
86 self.currentDialog = None
88 self.dialogStack = [ ]
90 def processDelay(self):
93 callback = self.currentDialog.callback
95 retval = self.currentDialog.returnValue
97 if self.currentDialog.isTmp:
98 self.currentDialog.doClose()
99 # dump(self.currentDialog)
100 del self.currentDialog
102 del self.currentDialog.callback
105 if callback is not None:
109 c = self.currentDialog
112 # when execBegin opened a new dialog, don't bother showing the old one.
113 if c == self.currentDialog:
117 self.currentDialog.execEnd()
118 self.currentDialog.hide()
120 def create(self, screen, arguments):
121 # creates an instance of 'screen' (which is a class)
123 return screen(self, *arguments)
125 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
127 traceback.print_exc(file=sys.stdout)
131 def instantiateDialog(self, screen, *arguments):
135 dlg = self.create(screen, arguments)
137 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
139 traceback.print_exc(file=sys.stdout)
147 readSkin(dlg, None, dlg.skinName, self.desktop)
149 # create GUI view of this dialog
150 assert self.desktop != None
153 for (key, value) in dlg.skinAttributes:
154 if key == "zPosition":
157 dlg.instance = eWindow(self.desktop, z)
158 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
159 gui = GUIOutputDevice()
160 gui.parent = dlg.instance
161 gui.create(dlg, self.desktop)
165 def pushCurrent(self):
166 if self.currentDialog:
167 self.dialogStack.append(self.currentDialog)
170 def popCurrent(self):
171 if len(self.dialogStack):
172 self.currentDialog = self.dialogStack.pop()
175 self.currentDialog = None
177 def execDialog(self, dialog):
179 self.currentDialog = dialog
180 self.currentDialog.isTmp = False
181 self.currentDialog.callback = None # would cause re-entrancy problems.
184 def openWithCallback(self, callback, screen, *arguments):
185 dlg = self.open(screen, *arguments)
186 dlg.callback = callback
188 def open(self, screen, *arguments):
190 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
196 def keyEvent(self, code):
197 print "code " + str(code)
199 def close(self, *retval):
200 self.currentDialog.returnValue = retval
201 self.delayTimer.start(0, 1)
203 from Screens.Volume import Volume
204 from Screens.Mute import Mute
205 from GlobalActions import globalActionMap
206 from Components.config import ConfigSubsection, configSequence, configElement, configsequencearg
208 #TODO .. move this to a own .py file
210 """Volume control, handles volUp, volDown, volMute actions and display
211 a corresponding dialog"""
212 def __init__(self, session):
213 global globalActionMap
214 globalActionMap.actions["volumeUp"]=self.volUp
215 globalActionMap.actions["volumeDown"]=self.volDown
216 globalActionMap.actions["volumeMute"]=self.volMute
218 config.audio = ConfigSubsection()
219 config.audio.volume = configElement("config.audio.volume", configSequence, [100], configsequencearg.get("INTEGER", (0, 100)))
221 self.volumeDialog = session.instantiateDialog(Volume)
222 self.muteDialog = session.instantiateDialog(Mute)
224 self.hideVolTimer = eTimer()
225 self.hideVolTimer.timeout.get().append(self.volHide)
227 vol = config.audio.volume.value[0]
228 self.volumeDialog.setValue(vol)
229 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
232 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
233 config.audio.volume.save()
236 if (eDVBVolumecontrol.getInstance().isMuted()):
238 eDVBVolumecontrol.getInstance().volumeUp()
239 self.volumeDialog.show()
240 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
242 self.hideVolTimer.start(3000, True)
245 if (eDVBVolumecontrol.getInstance().isMuted()):
247 eDVBVolumecontrol.getInstance().volumeDown()
248 self.volumeDialog.show()
249 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
251 self.hideVolTimer.start(3000, True)
254 self.volumeDialog.hide()
257 eDVBVolumecontrol.getInstance().volumeToggleMute()
258 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
260 if (eDVBVolumecontrol.getInstance().isMuted()):
261 self.muteDialog.show()
263 self.muteDialog.hide()
267 session.desktop = getDesktop()
269 session.nav = Navigation()
271 screensToRun = wizardManager.getWizards()
272 screensToRun.append(Screens.InfoBar.InfoBar)
274 def runNextScreen(session, screensToRun, *result):
278 screen = screensToRun[0]
280 if len(screensToRun):
281 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
285 runNextScreen(session, screensToRun)
287 CONNECT(keyPressedSignal(), session.keyEvent)
289 vol = VolumeControl(session)
295 session.nav.shutdown()
300 keymapparser.readKeymap()
302 skin.loadSkin(getDesktop())
304 import Components.InputDevice
305 Components.InputDevice.InitInputDevices()
307 import Components.AVSwitch
308 Components.AVSwitch.InitAVSwitch()
310 import Components.RecordingConfig
311 Components.RecordingConfig.InitRecordingConfig()
313 import Components.UsageConfig
314 Components.UsageConfig.InitUsageConfig()
316 import Components.Network
317 Components.Network.InitNetwork()
319 import Components.Lcd
320 Components.Lcd.InitLcd()
322 import Components.SetupDevices
323 Components.SetupDevices.InitSetupDevices()
325 import Components.RFmod
326 Components.RFmod.InitRFmod()
328 import Components.NimManager
330 # first, setup a screen
333 plugins.getPluginList(runAutoendPlugins=True)
335 print 'EXCEPTION IN PYTHON STARTUP CODE:'
337 traceback.print_exc(file=sys.stdout)