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.Pixmap import Pixmap, PixmapConditional
10 from Components.BlinkingPixmap import BlinkingPixmapConditional
11 from Components.ServiceName import ServiceName
12 from Components.EventInfo import EventInfo
14 from ServiceReference import ServiceReference
15 from EpgSelection import EPGSelection
17 from Screens.MessageBox import MessageBox
18 from Screens.Volume import Volume
19 from Screens.Mute import Mute
20 from Screens.Standby import Standby
21 from Screens.EventView import EventView
23 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
30 from Menu import MainMenu, mdom
32 class InfoBarVolumeControl:
33 """Volume control, handles volUp, volDown, volMute actions and display
34 a corresponding dialog"""
36 config.audio = ConfigSubsection()
37 config.audio.volume = configElement("config.audio.volume", configSequence, [5], configsequencearg.get("INTEGER", (0, 100)))
39 self["VolumeActions"] = ActionMap( ["InfobarVolumeActions"] ,
41 "volumeUp": self.volUp,
42 "volumeDown": self.volDown,
43 "volumeMute": self.volMute,
46 self.volumeDialog = self.session.instantiateDialog(Volume)
47 self.muteDialog = self.session.instantiateDialog(Mute)
49 self.hideVolTimer = eTimer()
50 self.hideVolTimer.timeout.get().append(self.volHide)
52 vol = config.audio.volume.value[0]
53 self.volumeDialog.setValue(vol)
54 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
57 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
58 config.audio.volume.save()
61 if (eDVBVolumecontrol.getInstance().isMuted()):
63 eDVBVolumecontrol.getInstance().volumeUp()
64 self.volumeDialog.instance.show()
65 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
67 self.hideVolTimer.start(3000)
70 if (eDVBVolumecontrol.getInstance().isMuted()):
72 eDVBVolumecontrol.getInstance().volumeDown()
73 self.volumeDialog.instance.show()
74 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
76 self.hideVolTimer.start(3000)
79 self.volumeDialog.instance.hide()
82 eDVBVolumecontrol.getInstance().volumeToggleMute()
83 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
85 if (eDVBVolumecontrol.getInstance().isMuted()):
86 self.muteDialog.instance.show()
88 self.muteDialog.instance.hide()
90 class InfoBarShowHide:
91 """ InfoBar show/hide control, accepts toggleShow and hide actions, might start
99 self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] ,
101 "toggleShow": self.toggleShow,
105 self.state = self.STATE_SHOWN
107 self.onExecBegin.append(self.show)
108 self.onClose.append(self.delHideTimer)
110 self.hideTimer = eTimer()
111 self.hideTimer.timeout.get().append(self.doTimerHide)
112 self.hideTimer.start(5000)
114 def delHideTimer(self):
121 self.state = self.STATE_SHOWN
122 self.hideTimer.stop()
123 self.hideTimer.start(5000)
125 def doTimerHide(self):
126 self.hideTimer.stop()
127 if self.state == self.STATE_SHOWN:
129 self.state = self.STATE_HIDDEN
131 def toggleShow(self):
132 if self.state == self.STATE_SHOWN:
134 #pls check animation support, sorry
136 self.hideTimer.stop()
137 self.state = self.STATE_HIDDEN
138 elif self.state == self.STATE_HIDDEN:
143 self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
144 self.state = self.STATE_SHOWN
147 self.instance.m_animation.startMoveAnimation(ePoint(0, 380), ePoint(0, 600), 100)
148 self.state = self.STATE_HIDDEN
150 class NumberZap(Screen):
157 self.close(int(self["number"].getText()))
159 def keyNumberGlobal(self, number):
160 self.Timer.start(3000) #reset timer
161 self.field = self.field + str(number)
162 self["number"].setText(self.field)
163 if len(self.field) >= 4:
166 def __init__(self, session, number):
167 Screen.__init__(self, session)
168 self.field = str(number)
170 self["channel"] = Label(_("Channel:"))
172 self["number"] = Label(self.field)
174 self["actions"] = NumberActionMap( [ "SetupActions" ],
178 "1": self.keyNumberGlobal,
179 "2": self.keyNumberGlobal,
180 "3": self.keyNumberGlobal,
181 "4": self.keyNumberGlobal,
182 "5": self.keyNumberGlobal,
183 "6": self.keyNumberGlobal,
184 "7": self.keyNumberGlobal,
185 "8": self.keyNumberGlobal,
186 "9": self.keyNumberGlobal,
187 "0": self.keyNumberGlobal
190 self.Timer = eTimer()
191 self.Timer.timeout.get().append(self.keyOK)
192 self.Timer.start(3000)
194 class InfoBarPowerKey:
195 """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
198 self.powerKeyTimer = eTimer()
199 self.powerKeyTimer.timeout.get().append(self.powertimer)
200 self["PowerKeyActions"] = HelpableActionMap(self, "PowerKeyActions",
202 "powerdown": self.powerdown,
203 "powerup": self.powerup,
204 "discreteStandby": (self.standby, "Go standby"),
205 "discretePowerOff": (self.quit, "Go to deep standby"),
208 def powertimer(self):
209 print "PowerOff - Now!"
213 self.standbyblocked = 0
214 self.powerKeyTimer.start(3000)
217 self.powerKeyTimer.stop()
218 if self.standbyblocked == 0:
219 self.standbyblocked = 1
223 self.session.open(Standby, self)
229 class InfoBarNumberZap:
230 """ Handles an initial number for NumberZapping """
232 self["NumberZapActions"] = NumberActionMap( [ "NumberZapActions"],
234 "1": self.keyNumberGlobal,
235 "2": self.keyNumberGlobal,
236 "3": self.keyNumberGlobal,
237 "4": self.keyNumberGlobal,
238 "5": self.keyNumberGlobal,
239 "6": self.keyNumberGlobal,
240 "7": self.keyNumberGlobal,
241 "8": self.keyNumberGlobal,
242 "9": self.keyNumberGlobal,
243 "0": self.keyNumberGlobal,
246 def keyNumberGlobal(self, number):
247 # print "You pressed number " + str(number)
248 self.session.openWithCallback(self.numberEntered, NumberZap, number)
250 def numberEntered(self, retval):
251 # print self.servicelist
253 self.zapToNumber(retval)
255 def searchNumberHelper(self, serviceHandler, num, bouquet):
256 servicelist = serviceHandler.list(bouquet)
257 if not servicelist is None:
259 serviceIterator = servicelist.getNext()
260 if not serviceIterator.valid(): #check end of list
262 if serviceIterator.flags: #assume normal dvb service have no flags set
265 if not num: #found service with searched number ?
266 return serviceIterator, 0
269 def zapToNumber(self, number):
270 bouquet = self.servicelist.bouquet_root
272 serviceHandler = eServiceCenter.getInstance()
273 if bouquet.toString().find('FROM BOUQUET "bouquets.') == -1: #FIXME HACK
274 service, number = self.searchNumberHelper(serviceHandler, number, bouquet)
276 bouquetlist = serviceHandler.list(bouquet)
277 if not bouquetlist is None:
279 bouquet = bouquetlist.getNext()
280 if not bouquet.valid(): #check end of list
282 if ((bouquet.flags & eServiceReference.flagDirectory) != eServiceReference.flagDirectory):
284 service, number = self.searchNumberHelper(serviceHandler, number, bouquet)
285 if not service is None:
286 self.session.nav.playService(service) #play service
287 if self.servicelist.getRoot() != bouquet: #already in correct bouquet?
288 self.servicelist.setRoot(bouquet)
289 self.servicelist.setCurrentSelection(service) #select the service in servicelist
291 class InfoBarChannelSelection:
292 """ ChannelSelection - handles the channelSelection dialog and the initial
293 channelChange actions which open the channelSelection dialog """
296 self.servicelist = self.session.instantiateDialog(ChannelSelection)
298 self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
300 "switchChannelUp": self.switchChannelUp,
301 "switchChannelDown": self.switchChannelDown,
302 "zapUp": (self.zapUp, _("next channel")),
303 "zapDown": (self.zapDown, _("previous channel")),
306 def switchChannelUp(self):
307 self.servicelist.moveUp()
308 self.session.execDialog(self.servicelist)
310 def switchChannelDown(self):
311 self.servicelist.moveDown()
312 self.session.execDialog(self.servicelist)
315 self.servicelist.moveUp()
316 self.servicelist.zap()
321 self.servicelist.moveDown()
322 self.servicelist.zap()
327 """ Handles a menu action, to open the (main) menu """
329 self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions",
331 "mainMenu": (self.mainMenu, "Enter main menu..."),
335 print "loading mainmenu XML..."
336 menu = mdom.childNodes[0]
337 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
338 self.session.open(MainMenu, menu, menu.childNodes)
341 """ EPG - Opens an EPG list when the showEPGList action fires """
343 self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
345 "showEPGList": (self.showEPGList, _("show EPG...")),
348 def showEPGList(self):
349 ref=self.session.nav.getCurrentlyPlayingServiceReference()
350 ptr=eEPGCache.getInstance()
351 if ptr.startTimeQuery(ref) != -1:
352 self.session.open(EPGSelection, ref)
353 else: # try to show now/next
354 print 'no epg for service', ref.toString()
357 service = self.session.nav.getCurrentService()
358 info = service.info()
361 self.epglist.append(ptr)
364 self.epglist.append(ptr)
365 if len(self.epglist) > 0:
366 self.session.open(EventView, self.epglist[0], ServiceReference(ref), self.eventViewCallback)
370 def eventViewCallback(self, setEvent, val): #used for now/next displaying
371 if len(self.epglist) > 1:
372 tmp = self.epglist[0]
373 self.epglist[0]=self.epglist[1]
375 setEvent(self.epglist[0])
378 """provides a current/next event info display"""
380 self["Event_Now_StartTime"] = EventInfo(self.session.nav, EventInfo.Now_StartTime)
381 self["Event_Next_StartTime"] = EventInfo(self.session.nav, EventInfo.Next_StartTime)
383 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
384 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
386 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
387 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
389 class InfoBarServiceName:
391 self["ServiceName"] = ServiceName(self.session.nav)
394 """handles PVR specific actions like seeking, pause"""
396 self["PVRActions"] = HelpableActionMap(self, "InfobarPVRActions",
398 "pauseService": (self.pauseService, "pause"),
399 "unPauseService": (self.unPauseService, "continue"),
401 "seekFwd": (self.seekFwd, "skip forward"),
402 "seekBack": (self.seekBack, "skip backward"),
405 def pauseService(self):
406 self.session.nav.pause(1)
408 def unPauseService(self):
409 self.session.nav.pause(0)
411 def doSeek(self, dir, seektime):
412 service = self.session.nav.getCurrentService()
416 seekable = service.seek()
419 seekable.seekRelative(dir, 90 * seektime)
422 self.doSeek(+1, 60000)
425 self.doSeek(-1, 60000)
427 class InfoBarInstantRecord:
428 """Instant Record - handles the instantRecord action in order to
429 start/stop instant records"""
431 self["InstantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord",
433 "instantRecord": (self.instantRecord, "Instant Record..."),
435 self.recording = None
437 self["BlinkingPoint"] = BlinkingPixmapConditional()
438 self.onShown.append(self["BlinkingPoint"].hidePixmap)
439 self["BlinkingPoint"].setConnect(self.session.nav.RecordTimer.isRecording)
441 def stopCurrentRecording(self):
442 self.session.nav.RecordTimer.removeEntry(self.recording)
443 self.recording = None
445 def startInstantRecording(self):
446 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
448 # try to get event info
451 service = self.session.nav.getCurrentService()
452 info = service.info()
453 ev = info.getEvent(0)
458 # fix me, description.
459 self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
460 self.recording.dontSave = True
462 #self["BlinkingPoint"].setConnect(lambda: self.recording.isRunning())
464 def isInstantRecordRunning(self):
465 if self.recording != None:
466 if self.recording.isRunning():
470 def recordQuestionCallback(self, answer):
474 if self.isInstantRecordRunning():
475 self.stopCurrentRecording()
477 self.startInstantRecording()
479 def instantRecord(self):
481 stat = os.stat("/hdd/movies")
483 self.session.open(MessageBox, "No HDD found!")
486 if self.isInstantRecordRunning():
487 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, _("Do you want to stop the current\n(instant) recording?"))
489 self.session.openWithCallback(self.recordQuestionCallback, MessageBox, _("Start recording?"))
491 from Screens.AudioSelection import AudioSelection
493 class InfoBarAudioSelection:
495 self["AudioSelectionAction"] = HelpableActionMap(self, "InfobarAudioSelectionActions",
497 "audioSelection": (self.audioSelection, "Audio Options..."),
500 def audioSelection(self):
501 service = self.session.nav.getCurrentService()
502 audio = service.audioTracks()
503 n = audio.getNumberOfTracks()
505 self.session.open(AudioSelection, audio)
507 class InfoBarAdditionalInfo:
509 self["DolbyActive"] = PixmapConditional()
510 # TODO: get the info from c++ somehow
511 self["DolbyActive"].setConnect(lambda: False)
513 self["CryptActive"] = PixmapConditional()
514 # TODO: get the info from c++ somehow
515 self["CryptActive"].setConnect(lambda: False)
517 self["FormatActive"] = PixmapConditional()
518 # TODO: get the info from c++ somehow
519 self["FormatActive"].setConnect(lambda: False)
521 self["ButtonRed"] = Pixmap()
522 self["ButtonRedText"] = Label(_("Record"))
523 self["ButtonGreen"] = Pixmap()
524 self["ButtonYellow"] = Pixmap()
525 self["ButtonBlue"] = Pixmap()