X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/3f8e26212c4bcca56462f09b50a681f1526e1a7c..48f2728ecdeabde7de0f497f8a69dbddcb047b90:/lib/python/Screens/InfoBarGenerics.py diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 1b56e430..2624209c 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -13,7 +13,7 @@ from Components.PluginComponent import plugins from Components.ProgressBar import * from Components.ServiceEventTracker import ServiceEventTracker from Components.ServiceName import ServiceName -from Components.config import config, configElement, ConfigSubsection, configSequence, configElementBoolean +from Components.config import config, configElement, ConfigSubsection, configSequence, configElementBoolean, configSelection, configElement_nonSave, getConfigListEntry from Components.config import configfile, configsequencearg from Components.TimerList import TimerEntryComponent from Components.TunerInfo import TunerInfo @@ -265,7 +265,7 @@ class InfoBarChannelSelection: config.misc.initialchannelselection.value = 0 config.misc.initialchannelselection.save() self.switchChannelDown() - + def historyBack(self): self.servicelist.historyBack() @@ -342,8 +342,15 @@ class InfoBarSimpleEventView: class InfoBarEPG: """ EPG - Opens an EPG list when the showEPGList action fires """ def __init__(self): + self.__event_tracker = ServiceEventTracker(screen=self, eventmap= + { + iPlayableService.evUpdatedEventInfo: self.__evEventInfoChanged, + }) + + self.is_now_next = False self.dlg_stack = [ ] self.bouquetSel = None + self.eventView = None self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions", { "showEventInfo": (self.openEventView, _("show EPG...")), @@ -397,10 +404,12 @@ class InfoBarEPG: closedScreen = self.dlg_stack.pop() if self.bouquetSel and closedScreen == self.bouquetSel: self.bouquetSel = None + elif self.eventView and closedScreen == self.eventView: + self.eventView = None if ret: dlgs=len(self.dlg_stack) - assert dlgs>0 - self.dlg_stack[dlgs-1].close(dlgs > 1) + if dlgs > 0: + self.dlg_stack[dlgs-1].close(dlgs > 1) def openMultiServiceEPG(self, withCallback=True): bouquets = self.servicelist.getBouquetList() @@ -424,27 +433,41 @@ class InfoBarEPG: def openSimilarList(self, eventid, refstr): self.session.open(EPGSelection, refstr, None, eventid) - def openEventView(self): + def getNowNext(self): self.epglist = [ ] service = self.session.nav.getCurrentService() - ref = self.session.nav.getCurrentlyPlayingServiceReference() - info = service.info() - ptr=info.getEvent(0) + info = service and service.info() + ptr = info and info.getEvent(0) if ptr: self.epglist.append(ptr) - ptr=info.getEvent(1) + ptr = info and info.getEvent(1) if ptr: self.epglist.append(ptr) + + def __evEventInfoChanged(self): + if self.is_now_next and len(self.dlg_stack) == 1: + self.getNowNext() + assert self.eventView + if len(self.epglist): + self.eventView.setEvent(self.epglist[0]) + + def openEventView(self): + ref = self.session.nav.getCurrentlyPlayingServiceReference() + self.getNowNext() if len(self.epglist) == 0: + self.is_now_next = False epg = eEPGCache.getInstance() - ptr = epg.lookupEventTime(ref, -1) + ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1) if ptr: self.epglist.append(ptr) ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1) if ptr: self.epglist.append(ptr) + else: + self.is_now_next = True if len(self.epglist) > 0: - self.dlg_stack.append(self.session.openWithCallback(self.closed, EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList)) + self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList) + self.dlg_stack.append(self.eventView) else: print "no epg for the service avail.. so we show multiepg instead of eventinfo" self.openMultiServiceEPG(False) @@ -983,6 +1006,8 @@ class InfoBarTimeshift: self.timeshift_enabled = False self.__seekableStatusChanged() +from Screens.PiPSetup import PiPSetup + class InfoBarExtensions: def __init__(self): self.pipshown = False @@ -991,36 +1016,45 @@ class InfoBarExtensions: { "extensions": (self.extensions, "Extensions..."), }) - + + PIPON = 0 + PIPOFF = 1 + MOVEPIP = 2 + PIPSWAP = 3 + def extensions(self): list = [] if self.pipshown == False: - list.append((_("Activate Picture in Picture"), "pipon")) + list.append((_("Activate Picture in Picture"), self.PIPON)) elif self.pipshown == True: - list.append((_("Disable Picture in Picture"), "pipoff")) + list.append((_("Disable Picture in Picture"), self.PIPOFF)) + list.append((_("Move Picture in Picture"), self.MOVEPIP)) + list.append((_("Swap services"), self.PIPSWAP)) self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list) def extensionCallback(self, answer): if answer is not None: - if answer[1] == "pipon": - self.session.nav.stopService() + if answer[1] == self.PIPON: self.pip = self.session.instantiateDialog(PictureInPicture) - #self.pip.show() newservice = self.session.nav.getCurrentlyPlayingServiceReference() - self.pipservice = eServiceCenter.getInstance().play(newservice) - if self.pipservice and not self.pipservice.setTarget(1): - self.pipservice.start() + + if self.pip.playService(newservice): self.pipshown = True else: - self.pipservice = None + self.pipshown = False del self.pip - - elif answer[1] == "pipoff": - #self.pip.hide() - self.pipservice = None + self.session.nav.playService(newservice) + elif answer[1] == self.PIPOFF: del self.pip self.pipshown = False + elif answer[1] == self.PIPSWAP: + swapservice = self.pip.getCurrentService() + self.pip.playService(self.session.nav.getCurrentlyPlayingServiceReference()) + self.session.nav.playService(swapservice) + + elif answer[1] == self.MOVEPIP: + self.session.open(PiPSetup, pip = self.pip) from RecordTimer import parseEvent @@ -1160,9 +1194,11 @@ class InfoBarAudioSelection: def audioSelection(self): service = self.session.nav.getCurrentService() audio = service.audioTracks() - self.audio = audio + self.audioTracks = audio n = audio.getNumberOfTracks() if n > 0: +# self.audioChannel = service.audioChannel() +# config.audio.audiochannel = configElement_nonSave("config.audio.audiochannel", configSelection, self.audioChannel.getCurrentChannel(), (("left", _("Left >")), ("stereo", _("< Stereo >")), ("right", _("< Right")))) tlist = [] for x in range(n): i = audio.getTrackInfo(x) @@ -1182,6 +1218,9 @@ class InfoBarAudioSelection: selectedAudio = tlist[0][1] tlist.sort(lambda x,y : cmp(x[0], y[0])) + +# tlist.insert(0, getConfigListEntry(_("Audio Channel"), config.audio.audiochannel)) + selection = 0 for x in tlist: if x[1] != selectedAudio: @@ -1190,18 +1229,67 @@ class InfoBarAudioSelection: break self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection) + else: + del self.audioTracks def audioSelected(self, audio): if audio is not None: - self.audio.selectTrack(audio[1]) + self.audioTracks.selectTrack(audio[1]) + del self.audioTracks +# del self.audioChannel +# del config.audio.audiochannel class InfoBarSubserviceSelection: def __init__(self): self["SubserviceSelectionAction"] = HelpableActionMap(self, "InfobarSubserviceSelectionActions", { - "subserviceSelection": (self.subserviceSelection, "Subservice list..."), + "subserviceSelection": (self.subserviceSelection, _("Subservice list...")), }) + self["SubserviceQuickzapAction"] = HelpableActionMap(self, "InfobarSubserviceQuickzapActions", + { + "nextSubservice": (self.nextSubservice, _("Switch to next subservice")), + "prevSubservice": (self.prevSubservice, _("Switch to previous subservice")) + }, -1) + self["SubserviceQuickzapAction"].setEnabled(False) + + self.session.nav.event.append(self.checkSubservicesAvail) # we like to get service events + + def checkSubservicesAvail(self, ev): + if ev == iPlayableService.evUpdatedEventInfo: + service = self.session.nav.getCurrentService() + subservices = service.subServices() + if subservices.getNumberOfSubservices() == 0: + self["SubserviceQuickzapAction"].setEnabled(False) + + def nextSubservice(self): + self.changeSubservice(+1) + + def prevSubservice(self): + self.changeSubservice(-1) + + def changeSubservice(self, direction): + service = self.session.nav.getCurrentService() + subservices = service.subServices() + n = subservices.getNumberOfSubservices() + if n > 0: + selection = -1 + ref = self.session.nav.getCurrentlyPlayingServiceReference() + for x in range(n): + if subservices.getSubservice(x).toString() == ref.toString(): + selection = x + if selection != -1: + selection += direction + if selection >= n: + selection=0 + elif selection < 0: + selection=n-1 + newservice = subservices.getSubservice(selection) + if newservice.valid(): + del subservices + del service + self.session.nav.playService(newservice) + def subserviceSelection(self): service = self.session.nav.getCurrentService() subservices = service.subServices() @@ -1221,6 +1309,7 @@ class InfoBarSubserviceSelection: def subserviceSelected(self, service): if not service is None: + self["SubserviceQuickzapAction"].setEnabled(True) self.session.nav.playService(service[1]) class InfoBarAdditionalInfo: @@ -1323,8 +1412,11 @@ class InfoBarNotifications: Notifications.notificationAdded.append(self.checkNotificationsIfExecing) def checkNotificationsIfExecing(self): - if self.execing: - self.checkNotifications() + try: + if self.execing: + self.checkNotifications() + except: + print "******************************* A SEVERE ERROR HAPPENED... Someone who understands the code... please fix :) *******" def checkNotifications(self): if len(Notifications.notifications): @@ -1333,9 +1425,9 @@ class InfoBarNotifications: print "open",n cb = n[0] if cb is not None: - self.session.openWithCallback(cb, *n[1:]) + self.session.openWithCallback(cb, n[1], *n[2], **n[3]) else: - self.session.open(*n[1:]) + self.session.open(n[1], *n[2], **n[3]) class InfoBarServiceNotifications: def __init__(self):