1 from Screen import Screen
2 from Components.ActionMap import ActionMap, HelpableActionMap
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.BlinkingPoint import BlinkingPointConditional
10 from Components.ServiceName import ServiceName
11 from Components.EventInfo import EventInfo
13 from ServiceReference import ServiceReference
14 from EpgSelection import EPGSelection
16 from Screens.MessageBox import MessageBox
17 from Screens.Volume import Volume
18 from Screens.Mute import Mute
19 from Screens.Standby import Standby
20 from Screens.EventView import EventView
22 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
29 from Menu import MainMenu, mdom
31 class InfoBarVolumeControl:
32 """Volume control, handles volUp, volDown, volMute actions and display
33 a corresponding dialog"""
35 config.audio = ConfigSubsection()
36 config.audio.volume = configElement("config.audio.volume", configSequence, [5], configsequencearg.get("INTEGER", (0, 100)))
38 self["VolumeActions"] = ActionMap( ["InfobarVolumeActions"] ,
40 "volumeUp": self.volUp,
41 "volumeDown": self.volDown,
42 "volumeMute": self.volMute,
45 self.volumeDialog = self.session.instantiateDialog(Volume)
46 self.muteDialog = self.session.instantiateDialog(Mute)
48 self.hideVolTimer = eTimer()
49 self.hideVolTimer.timeout.get().append(self.volHide)
51 vol = config.audio.volume.value[0]
52 self.volumeDialog.setValue(vol)
53 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
56 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
57 config.audio.volume.save()
60 eDVBVolumecontrol.getInstance().volumeUp()
61 self.volumeDialog.instance.show()
62 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
64 self.hideVolTimer.start(3000)
67 eDVBVolumecontrol.getInstance().volumeDown()
68 self.volumeDialog.instance.show()
69 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
71 self.hideVolTimer.start(3000)
74 self.volumeDialog.instance.hide()
77 eDVBVolumecontrol.getInstance().volumeToggleMute()
78 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
80 if (eDVBVolumecontrol.getInstance().isMuted()):
81 self.muteDialog.instance.show()
83 self.muteDialog.instance.hide()
85 class InfoBarShowHide:
86 """ InfoBar show/hide control, accepts toggleShow and hide actions, might start
94 self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] ,
96 "toggleShow": self.toggleShow,
100 self.state = self.STATE_SHOWN
102 self.onExecBegin.append(self.show)
103 self.onClose.append(self.delHideTimer)
105 self.hideTimer = eTimer()
106 self.hideTimer.timeout.get().append(self.doTimerHide)
107 self.hideTimer.start(5000)
109 def delHideTimer(self):
116 self.state = self.STATE_SHOWN
117 self.hideTimer.stop()
118 self.hideTimer.start(5000)
120 def doTimerHide(self):
121 self.hideTimer.stop()
122 if self.state == self.STATE_SHOWN:
124 self.state = self.STATE_HIDDEN
126 def toggleShow(self):
127 if self.state == self.STATE_SHOWN:
129 #pls check animation support, sorry
131 self.hideTimer.stop()
132 self.state = self.STATE_HIDDEN
133 elif self.state == self.STATE_HIDDEN:
138 self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
139 self.state = self.STATE_SHOWN
142 self.instance.m_animation.startMoveAnimation(ePoint(0, 380), ePoint(0, 600), 100)
143 self.state = self.STATE_HIDDEN
145 class NumberZap(Screen):
152 self.close(int(self["number"].getText()))
154 def keyNumberGlobal(self, number):
155 self.Timer.start(3000) #reset timer
156 self.field = self.field + str(number)
157 self["number"].setText(self.field)
158 if len(self.field) >= 4:
161 def __init__(self, session, number):
162 Screen.__init__(self, session)
163 self.field = str(number)
165 self["channel"] = Label(_("Channel:"))
167 self["number"] = Label(self.field)
169 self["actions"] = NumberActionMap( [ "SetupActions" ],
173 "1": self.keyNumberGlobal,
174 "2": self.keyNumberGlobal,
175 "3": self.keyNumberGlobal,
176 "4": self.keyNumberGlobal,
177 "5": self.keyNumberGlobal,
178 "6": self.keyNumberGlobal,
179 "7": self.keyNumberGlobal,
180 "8": self.keyNumberGlobal,
181 "9": self.keyNumberGlobal,
182 "0": self.keyNumberGlobal
185 self.Timer = eTimer()
186 self.Timer.timeout.get().append(self.keyOK)
187 self.Timer.start(3000)
189 class InfoBarPowerKey:
190 """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
193 self.powerKeyTimer = eTimer()
194 self.powerKeyTimer.timeout.get().append(self.powertimer)
195 self["PowerKeyActions"] = HelpableActionMap(self, "PowerKeyActions",
197 "powerdown": self.powerdown,
198 "powerup": self.powerup,
199 "discreteStandby": (self.standby, "Go standby"),
200 "discretePowerOff": (self.quit, "Go to deep standby"),
203 def powertimer(self):
204 print "PowerOff - Now!"
208 self.standbyblocked = 0
209 self.powerKeyTimer.start(3000)
212 self.powerKeyTimer.stop()
213 if self.standbyblocked == 0:
214 self.standbyblocked = 1
218 self.session.open(Standby, self)
224 class InfoBarNumberZap:
225 """ Handles an initial number for NumberZapping """
227 self["NumberZapActions"] = NumberActionMap( [ "NumberZapActions"],
229 "1": self.keyNumberGlobal,
230 "2": self.keyNumberGlobal,
231 "3": self.keyNumberGlobal,
232 "4": self.keyNumberGlobal,
233 "5": self.keyNumberGlobal,
234 "6": self.keyNumberGlobal,
235 "7": self.keyNumberGlobal,
236 "8": self.keyNumberGlobal,
237 "9": self.keyNumberGlobal,
238 "0": self.keyNumberGlobal,
241 def keyNumberGlobal(self, number):
242 # print "You pressed number " + str(number)
243 self.session.openWithCallback(self.numberEntered, NumberZap, number)
245 def numberEntered(self, retval):
246 # print self.servicelist
248 self.servicelist.zapToNumber(retval)
250 class InfoBarChannelSelection:
251 """ ChannelSelection - handles the channelSelection dialog and the initial
252 channelChange actions which open the channelSelection dialog """
255 self.servicelist = self.session.instantiateDialog(ChannelSelection)
257 self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
259 "switchChannelUp": self.switchChannelUp,
260 "switchChannelDown": self.switchChannelDown,
261 "zapUp": (self.zapUp, _("next channel")),
262 "zapDown": (self.zapDown, _("previous channel")),
265 def switchChannelUp(self):
266 self.servicelist.moveUp()
267 self.session.execDialog(self.servicelist)
269 def switchChannelDown(self):
270 self.servicelist.moveDown()
271 self.session.execDialog(self.servicelist)
274 self.servicelist.moveUp()
275 self.servicelist.zap()
280 self.servicelist.moveDown()
281 self.servicelist.zap()
286 """ Handles a menu action, to open the (main) menu """
288 self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions",
290 "mainMenu": (self.mainMenu, "Enter main menu..."),
294 print "loading mainmenu XML..."
295 menu = mdom.childNodes[0]
296 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
297 self.session.open(MainMenu, menu, menu.childNodes)
300 """ EPG - Opens an EPG list when the showEPGList action fires """
302 self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
304 "showEPGList": (self.showEPGList, _("show EPG...")),
307 def showEPGList(self):
308 ref=self.session.nav.getCurrentlyPlayingServiceReference()
309 ptr=eEPGCache.getInstance()
310 if ptr.startTimeQuery(ref) != -1:
311 self.session.open(EPGSelection, ref)
312 else: # try to show now/next
313 print 'no epg for service', ref.toString()
316 service = self.session.nav.getCurrentService()
317 info = service.info()
320 self.epglist.append(ptr)
323 self.epglist.append(ptr)
324 if len(self.epglist) > 0:
325 self.session.open(EventView, self.epglist[0], ServiceReference(ref), self.eventViewCallback)
329 def eventViewCallback(self, setEvent, val): #used for now/next displaying
330 if len(self.epglist) > 1:
331 tmp = self.epglist[0]
332 self.epglist[0]=self.epglist[1]
334 setEvent(self.epglist[0])
337 """provides a current/next event info display"""
339 self["Event_Now_StartTime"] = EventInfo(self.session.nav, EventInfo.Now_StartTime)
340 self["Event_Next_StartTime"] = EventInfo(self.session.nav, EventInfo.Next_StartTime)
342 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
343 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
345 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
346 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
348 class InfoBarServiceName:
350 self["ServiceName"] = ServiceName(self.session.nav)
353 """handles PVR specific actions like seeking, pause"""
355 self["PVRActions"] = HelpableActionMap(self, "InfobarPVRActions",
357 "pauseService": (self.pauseService, "pause"),
358 "unPauseService": (self.unPauseService, "continue"),
360 "seekFwd": (self.seekFwd, "skip forward"),
361 "seekBack": (self.seekBack, "skip backward"),
364 def pauseService(self):
365 self.session.nav.pause(1)
367 def unPauseService(self):
368 self.session.nav.pause(0)
370 def doSeek(self, dir, seektime):
371 service = self.session.nav.getCurrentService()
375 seekable = service.seek()
378 seekable.seekRelative(dir, 90 * seektime)
381 self.doSeek(+1, 60000)
384 self.doSeek(-1, 60000)
386 class InfoBarInstantRecord:
387 """Instant Record - handles the instantRecord action in order to
388 start/stop instant records"""
390 self["InstantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord",
392 "instantRecord": (self.instantRecord, "Instant Record..."),
394 self.recording = None
396 self["BlinkingPoint"] = BlinkingPointConditional("/usr/share/enigma2/record.png")
397 self.onShown.append(self["BlinkingPoint"].hidePoint)
399 def stopCurrentRecording(self):
400 self.session.nav.RecordTimer.removeEntry(self.recording)
401 self.recording = None
402 #self["BlinkingPoint"].stopBlinking()
404 def startInstantRecording(self):
405 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
407 # try to get event info
410 service = self.session.nav.getCurrentService()
411 info = service.info()
412 ev = info.getEvent(0)
417 # fix me, description.
418 self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
419 self.recording.dontSave = True
421 self["BlinkingPoint"].setConnect(lambda: self.recording.isRunning())
422 #self["BlinkingPoint"].startBlinking()
424 def isInstantRecordRunning(self):
425 if self.recording != None:
426 if self.recording.isRunning():
430 def recordQuestionCallback(self, answer):
434 if self.isInstantRecordRunning():
435 self.stopCurrentRecording()
437 self.startInstantRecording()
439 def instantRecord(self):
441 stat = os.stat("/hdd/movies")
443 self.session.open(MessageBox, "No HDD found!")
446 if self.isInstantRecordRunning():
447 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, _("Do you want to stop the current\n(instant) recording?"))
449 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, _("Start recording?"))
451 from Screens.AudioSelection import AudioSelection
453 class InfoBarAudioSelection:
455 self["AudioSelectionAction"] = HelpableActionMap(self, "InfobarAudioSelectionActions",
457 "audioSelection": (self.audioSelection, "Audio Options..."),
460 def audioSelection(self):
461 service = self.session.nav.getCurrentService()
462 audio = service.audioTracks()
463 n = audio.getNumberOfTracks()
465 self.session.open(AudioSelection, audio)