1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.ActionMap import NumberActionMap
4 from Components.Label import Label
5 from Components.config import configfile, configsequencearg
6 from Components.config import config, configElement, ConfigSubsection, configSequence
7 from ChannelSelection import ChannelSelection
9 from Components.ServiceName import ServiceName
10 from Components.EventInfo import EventInfo
12 from EpgSelection import EPGSelection
14 from Screens.MessageBox import MessageBox
15 from Screens.Volume import Volume
16 from Screens.Mute import Mute
17 from Screens.Standby import Standby
19 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
26 from Menu import MainMenu, mdom
28 class InfoBarVolumeControl:
29 """Volume control, handles volUp, volDown, volMute actions and display
30 a corresponding dialog"""
32 config.audio = ConfigSubsection()
33 config.audio.volume = configElement("config.audio.volume", configSequence, [5], configsequencearg.get("INTEGER", (0, 100)))
35 self["VolumeActions"] = ActionMap( ["InfobarVolumeActions"] ,
37 "volumeUp": self.volUp,
38 "volumeDown": self.volDown,
39 "volumeMute": self.volMute,
42 self.volumeDialog = self.session.instantiateDialog(Volume)
43 self.muteDialog = self.session.instantiateDialog(Mute)
45 self.hideVolTimer = eTimer()
46 self.hideVolTimer.timeout.get().append(self.volHide)
48 vol = config.audio.volume.value[0]
49 self.volumeDialog.setValue(vol)
50 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
53 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
54 config.audio.volume.save()
57 eDVBVolumecontrol.getInstance().volumeUp()
58 self.volumeDialog.instance.show()
59 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
61 self.hideVolTimer.start(3000)
64 eDVBVolumecontrol.getInstance().volumeDown()
65 self.volumeDialog.instance.show()
66 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
68 self.hideVolTimer.start(3000)
71 self.volumeDialog.instance.hide()
74 eDVBVolumecontrol.getInstance().volumeToggleMute()
75 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
77 if (eDVBVolumecontrol.getInstance().isMuted()):
78 self.muteDialog.instance.show()
80 self.muteDialog.instance.hide()
82 class InfoBarShowHide:
83 """ InfoBar show/hide control, accepts toggleShow and hide actions, might start
91 self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] ,
93 "toggleShow": self.toggleShow,
97 self.state = self.STATE_HIDDEN
99 self.hideTimer = eTimer()
100 self.hideTimer.timeout.get().append(self.doTimerHide)
101 #self.hideTimer.start(1000)
106 def doTimerHide(self):
107 if self.state == self.STATE_SHOWN:
109 self.state = self.STATE_HIDDEN
111 def toggleShow(self):
112 if self.state == self.STATE_SHOWN:
114 #pls check animation support, sorry
116 self.state = self.STATE_HIDDEN
120 self.state = self.STATE_SHOWN
121 #TODO: make it customizable
122 self.hideTimer.start(5000)
125 self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
126 self.state = self.STATE_SHOWN
129 self.instance.m_animation.startMoveAnimation(ePoint(0, 380), ePoint(0, 600), 100)
130 self.state = self.STATE_HIDDEN
132 class NumberZap(Screen):
139 print "do the action here"
142 def keyNumberGlobal(self, number):
143 self.Timer.start(3000) #reset timer
144 self.field = self.field + str(number)
145 self["number"].setText(self.field)
146 if len(self.field) >= 4:
149 def __init__(self, session, number):
150 Screen.__init__(self, session)
151 self.field = str(number)
153 self["number"] = Label(self.field)
155 self["actions"] = NumberActionMap( [ "SetupActions" ],
159 "1": self.keyNumberGlobal,
160 "2": self.keyNumberGlobal,
161 "3": self.keyNumberGlobal,
162 "4": self.keyNumberGlobal,
163 "5": self.keyNumberGlobal,
164 "6": self.keyNumberGlobal,
165 "7": self.keyNumberGlobal,
166 "8": self.keyNumberGlobal,
167 "9": self.keyNumberGlobal,
168 "0": self.keyNumberGlobal
171 self.Timer = eTimer()
172 self.Timer.timeout.get().append(self.keyOK)
173 self.Timer.start(3000)
175 class InfoBarPowerKey:
176 """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
179 self.powerKeyTimer = eTimer()
180 self.powerKeyTimer.timeout.get().append(self.powertimer)
181 self["PowerKeyActions"] = ActionMap( ["PowerKeyActions"],
183 "powerdown": self.powerdown,
184 "powerup": self.powerup,
187 def powertimer(self):
188 print "PowerOff - Now!"
192 self.standbyblocked = 0
193 self.powerKeyTimer.start(3000)
196 self.powerKeyTimer.stop()
197 if self.standbyblocked == 0:
198 self.standbyblocked = 1
199 self.session.open(Standby, self)
204 class InfoBarNumberZap:
205 """ Handles an initial number for NumberZapping """
207 self["NumberZapActions"] = NumberActionMap( [ "NumberZapActions"],
209 "1": self.keyNumberGlobal,
210 "2": self.keyNumberGlobal,
211 "3": self.keyNumberGlobal,
212 "4": self.keyNumberGlobal,
213 "5": self.keyNumberGlobal,
214 "6": self.keyNumberGlobal,
215 "7": self.keyNumberGlobal,
216 "8": self.keyNumberGlobal,
217 "9": self.keyNumberGlobal,
218 "0": self.keyNumberGlobal,
221 def keyNumberGlobal(self, number):
222 print "You pressed number " + str(number)
223 self.session.open(NumberZap, number)
225 class InfoBarChannelSelection:
226 """ ChannelSelection - handles the channelSelection dialog and the initial
227 channelChange actions which open the channelSelection dialog """
230 self.servicelist = self.session.instantiateDialog(ChannelSelection)
232 self["ChannelSelectActions"] = ActionMap( ["InfobarChannelSelection"],
234 "switchChannelUp": self.switchChannelUp,
235 "switchChannelDown": self.switchChannelDown,
237 "zapDown": self.zapDown,
240 def switchChannelUp(self):
241 self.servicelist.moveUp()
242 self.session.execDialog(self.servicelist)
244 def switchChannelDown(self):
245 self.servicelist.moveDown()
246 self.session.execDialog(self.servicelist)
249 self.servicelist.moveUp()
250 self.servicelist.zap()
253 self.servicelist.moveDown()
254 self.servicelist.zap()
257 """ Handles a menu action, to open the (main) menu """
259 self["MenuActions"] = ActionMap( [ "InfobarMenuActions" ],
261 "mainMenu": self.mainMenu,
265 print "loading mainmenu XML..."
266 menu = mdom.childNodes[0]
267 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
268 self.session.open(MainMenu, menu, menu.childNodes)
271 """ EPG - Opens an EPG list when the showEPGList action fires """
273 self["EPGActions"] = ActionMap( [ "InfobarEPGActions" ],
275 "showEPGList": self.showEPGList,
278 def showEPGList(self):
279 ref=self.session.nav.getCurrentlyPlayingServiceReference()
280 ptr=eEPGCache.getInstance()
281 if ptr.startTimeQuery(ref) != -1:
282 self.session.open(EPGSelection, ref)
284 print 'no epg for service', ref.toString()
287 """provides a current/next event info display"""
289 self["Event_Now_StartTime"] = EventInfo(self.session.nav, EventInfo.Now_StartTime)
290 self["Event_Next_StartTime"] = EventInfo(self.session.nav, EventInfo.Next_StartTime)
292 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
293 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
295 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
296 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
298 class InfoBarServiceName:
300 self["ServiceName"] = ServiceName(self.session.nav)
303 """handles PVR specific actions like seeking, pause"""
305 self["PVRActions"] = ActionMap( [ "InfobarPVRActions" ],
307 "pauseService": self.pauseService,
308 "unPauseService": self.unPauseService,
310 "seekFwd": self.seekFwd,
311 "seekBack": self.seekBack,
314 def pauseService(self):
315 self.session.nav.pause(1)
317 def unPauseService(self):
318 self.session.nav.pause(0)
320 def doSeek(self, dir, seektime):
321 service = self.session.nav.getCurrentService()
325 seekable = service.seek()
328 seekable.seekRelative(dir, 90 * seektime)
331 self.doSeek(+1, 60000)
334 self.doSeek(-1, 60000)
336 class InfoBarInstantRecord:
337 """Instant Record - handles the instantRecord action in order to
338 start/stop instant records"""
340 self["InstnantRecordActions"] = ActionMap( [ "InfobarInstantRecord" ],
342 "instantRecord": self.instantRecord,
344 self.recording = None
346 def stopCurrentRecording(self):
347 self.session.nav.RecordTimer.removeEntry(self.recording)
348 self.recording = None
350 def startInstantRecording(self):
351 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
353 # try to get event info
356 service = self.session.nav.getCurrentService()
357 info = service.info()
358 ev = info.getEvent(0)
363 # fix me, description.
364 self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
366 def recordQuestionCallback(self, answer):
370 if self.recording != None:
371 self.stopCurrentRecording()
373 self.startInstantRecording()
375 def instantRecord(self):
377 stat = os.stat("/hdd/movies")
379 self.session.open(MessageBox, "No HDD found!")
382 if self.recording != None:
383 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Do you want to stop the current\n(instant) recording?")
385 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Start recording?")
387 from Screens.AudioSelection import AudioSelection
389 class InfoBarAudioSelection:
391 self["AudioSelectionAction"] = ActionMap( [ "InfobarAudioSelectionActions" ],
393 "audioSelection": self.audioSelection,
396 def audioSelection(self):
397 service = self.session.nav.getCurrentService()
398 audio = service.audioTracks()
399 n = audio.getNumberOfTracks()
401 self.session.open(AudioSelection, audio)