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
45 from Plugins.Plugin import PluginDescriptor
49 def dump(dir, p = ""):
50 if isinstance(dir, dict):
51 for (entry, val) in dir.items():
52 dump(val, p + "(dict)/" + entry)
53 if hasattr(dir, "__dict__"):
54 for name, value in dir.__dict__.items():
55 if not had.has_key(str(value)):
57 dump(value, p + "/" + str(name))
59 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
61 print p + ":" + str(dir)
63 # + ":" + str(dir.__class__)
68 def create(self, screen): pass
72 class HTMLOutputDevice(OutputDevice):
73 def create(self, comp):
74 print comp.produceHTML()
76 html = HTMLOutputDevice()
78 class GUIOutputDevice(OutputDevice):
80 def create(self, comp, desktop):
81 comp.createGUIScreen(self.parent, desktop)
86 self.delayTimer = eTimer()
87 self.delayTimer.timeout.get().append(self.processDelay)
89 self.currentDialog = None
91 self.dialogStack = [ ]
93 def processDelay(self):
96 callback = self.currentDialog.callback
98 retval = self.currentDialog.returnValue
100 if self.currentDialog.isTmp:
101 self.currentDialog.doClose()
102 # dump(self.currentDialog)
103 del self.currentDialog
105 del self.currentDialog.callback
108 if callback is not None:
112 c = self.currentDialog
115 # when execBegin opened a new dialog, don't bother showing the old one.
116 if c == self.currentDialog:
120 self.currentDialog.execEnd()
121 self.currentDialog.hide()
123 def create(self, screen, arguments):
124 # creates an instance of 'screen' (which is a class)
126 return screen(self, *arguments)
128 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
130 traceback.print_exc(file=sys.stdout)
134 def instantiateDialog(self, screen, *arguments):
138 dlg = self.create(screen, arguments)
140 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
142 traceback.print_exc(file=sys.stdout)
150 readSkin(dlg, None, dlg.skinName, self.desktop)
152 # create GUI view of this dialog
153 assert self.desktop != None
156 for (key, value) in dlg.skinAttributes:
157 if key == "zPosition":
160 dlg.instance = eWindow(self.desktop, z)
161 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
162 gui = GUIOutputDevice()
163 gui.parent = dlg.instance
164 gui.create(dlg, self.desktop)
168 def pushCurrent(self):
169 if self.currentDialog:
170 self.dialogStack.append(self.currentDialog)
173 def popCurrent(self):
174 if len(self.dialogStack):
175 self.currentDialog = self.dialogStack.pop()
178 self.currentDialog = None
180 def execDialog(self, dialog):
182 self.currentDialog = dialog
183 self.currentDialog.isTmp = False
184 self.currentDialog.callback = None # would cause re-entrancy problems.
187 def openWithCallback(self, callback, screen, *arguments):
188 dlg = self.open(screen, *arguments)
189 dlg.callback = callback
191 def open(self, screen, *arguments):
193 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
199 def keyEvent(self, code):
200 print "code " + str(code)
202 def close(self, *retval):
203 self.currentDialog.returnValue = retval
204 self.delayTimer.start(0, 1)
206 from Screens.Volume import Volume
207 from Screens.Mute import Mute
208 from GlobalActions import globalActionMap
209 from Components.config import ConfigSubsection, configSequence, configElement, configsequencearg
211 #TODO .. move this to a own .py file
213 """Volume control, handles volUp, volDown, volMute actions and display
214 a corresponding dialog"""
215 def __init__(self, session):
216 global globalActionMap
217 globalActionMap.actions["volumeUp"]=self.volUp
218 globalActionMap.actions["volumeDown"]=self.volDown
219 globalActionMap.actions["volumeMute"]=self.volMute
221 config.audio = ConfigSubsection()
222 config.audio.volume = configElement("config.audio.volume", configSequence, [100], configsequencearg.get("INTEGER", (0, 100)))
224 self.volumeDialog = session.instantiateDialog(Volume)
225 self.muteDialog = session.instantiateDialog(Mute)
227 self.hideVolTimer = eTimer()
228 self.hideVolTimer.timeout.get().append(self.volHide)
230 vol = config.audio.volume.value[0]
231 self.volumeDialog.setValue(vol)
232 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
235 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
236 config.audio.volume.save()
239 if (eDVBVolumecontrol.getInstance().isMuted()):
241 eDVBVolumecontrol.getInstance().volumeUp()
242 self.volumeDialog.show()
243 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
245 self.hideVolTimer.start(3000, True)
248 if (eDVBVolumecontrol.getInstance().isMuted()):
250 eDVBVolumecontrol.getInstance().volumeDown()
251 self.volumeDialog.show()
252 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
254 self.hideVolTimer.start(3000, True)
257 self.volumeDialog.hide()
260 eDVBVolumecontrol.getInstance().volumeToggleMute()
261 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
263 if (eDVBVolumecontrol.getInstance().isMuted()):
264 self.muteDialog.show()
266 self.muteDialog.hide()
270 session.desktop = getDesktop()
272 session.nav = Navigation()
274 screensToRun = wizardManager.getWizards()
275 for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD):
276 screensToRun.append(p.__call__)
277 screensToRun.append(Screens.InfoBar.InfoBar)
279 def runNextScreen(session, screensToRun, *result):
281 quitMainloop(*result)
283 screen = screensToRun[0]
285 if len(screensToRun):
286 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
290 runNextScreen(session, screensToRun)
292 CONNECT(keyPressedSignal(), session.keyEvent)
294 vol = VolumeControl(session)
300 session.nav.shutdown()
305 keymapparser.readKeymap()
307 skin.loadSkin(getDesktop())
309 import Components.InputDevice
310 Components.InputDevice.InitInputDevices()
312 import Components.AVSwitch
313 Components.AVSwitch.InitAVSwitch()
315 import Components.RecordingConfig
316 Components.RecordingConfig.InitRecordingConfig()
318 import Components.UsageConfig
319 Components.UsageConfig.InitUsageConfig()
321 import Components.Network
322 Components.Network.InitNetwork()
324 import Components.Lcd
325 Components.Lcd.InitLcd()
327 import Components.SetupDevices
328 Components.SetupDevices.InitSetupDevices()
330 import Components.RFmod
331 Components.RFmod.InitRFmod()
333 import Components.NimManager
335 # first, setup a screen
340 print 'EXCEPTION IN PYTHON STARTUP CODE:'
342 traceback.print_exc(file=sys.stdout)