X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/574f425cc1ebece0aa5f09fb77a8cb7ad0310a1f..8d3e9193ba0ddaa819db9c6a0447eca74a8328a3:/lib/python/Screens/InfoBarGenerics.py diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index e39e028d..c1618184 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -391,6 +391,45 @@ class InfoBarSimpleEventView: epglist[1] = tmp setEvent(epglist[0]) +class SimpleServicelist: + def __init__(self, services): + self.services = services + self.length = len(services) + self.current = 0 + + def selectService(self, service): + if not self.length: + self.current = -1 + return False + else: + self.current = 0 + while self.services[self.current].ref != service: + self.current += 1 + if self.current >= self.length: + return False + return True + + def nextService(self): + if not self.length: + return + if self.current+1 < self.length: + self.current += 1 + else: + self.current = 0 + + def prevService(self): + if not self.length: + return + if self.current-1 > -1: + self.current -= 1 + else: + self.current = self.length - 1 + + def currentService(self): + if not self.length or self.current >= self.length: + return None + return self.services[self.current] + class InfoBarEPG: """ EPG - Opens an EPG list when the showEPGList action fires """ def __init__(self): @@ -487,19 +526,40 @@ class InfoBarEPG: elif cnt == 1: self.openBouquetEPG(bouquets[0][1], withCallback) + def changeServiceCB(self, direction, epg): + if self.serviceSel: + if direction > 0: + self.serviceSel.nextService() + else: + self.serviceSel.prevService() + epg.setService(self.serviceSel.currentService()) + + def SingleServiceEPGClosed(self, ret=False): + self.serviceSel = None + def openSingleServiceEPG(self): ref=self.session.nav.getCurrentlyPlayingServiceReference() - self.session.open(EPGSelection, ref) + if ref: + if self.servicelist.getMutableList() is not None: # bouquet in channellist + current_path = self.servicelist.getRoot() + services = self.getBouquetServices(current_path) + self.serviceSel = SimpleServicelist(services) + if self.serviceSel.selectService(ref): + self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = self.changeServiceCB) + else: + self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref) + else: + self.session.open(EPGSelection, ref) def showEventInfoPlugins(self): list = [(p.name, boundFunction(self.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EVENTINFO)] if list: list.append((_("show single service EPG..."), self.openSingleServiceEPG)) - self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = list) + self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = list, skin_name = "EPGExtensionsList") else: self.openSingleServiceEPG() - + def runPlugin(self, plugin): plugin(session = self.session, servicelist = self.servicelist) @@ -623,11 +683,6 @@ class InfoBarSeek: iPlayableService.evEOF: self.__evEOF, iPlayableService.evSOF: self.__evSOF, }) - self.eofState = 0 - self.eofTimer = eTimer() - self.eofTimer.timeout.get().append(self.doEof) - self.eofInhibitTimer = eTimer() - self.eofInhibitTimer.timeout.get().append(self.inhibitEof) self.minSpeedBackward = useSeekBackHack and 16 or 0 @@ -763,9 +818,6 @@ class InfoBarSeek: def __serviceStarted(self): self.seekstate = self.SEEK_STATE_PLAY self.__seekableStatusChanged() - if self.eofState != 0: - self.eofTimer.stop() - self.eofState = 0 def setSeekState(self, state): service = self.session.nav.getCurrentService() @@ -783,12 +835,21 @@ class InfoBarSeek: print "not pauseable." state = self.SEEK_STATE_PLAY - oldstate = self.seekstate self.seekstate = state - for i in (0, 1, 2): - if oldstate[i] != self.seekstate[i]: - (self.session.nav.pause, pauseable.setFastForward, pauseable.setSlowMotion)[i](self.seekstate[i]) + if pauseable is not None: + if self.seekstate[0]: + print "resolved to PAUSE" + pauseable.pause() + elif self.seekstate[1]: + print "resolved to FAST FORWARD" + pauseable.setFastForward(self.seekstate[1]) + elif self.seekstate[2]: + print "resolved to SLOW MOTION" + pauseable.setSlowMotion(self.seekstate[2]) + else: + print "resolved to PLAY" + pauseable.unpause() for c in self.onPlayStateChanged: c(self.seekstate) @@ -827,16 +888,6 @@ class InfoBarSeek: seekable = self.getSeek() if seekable is None: return - prevstate = self.seekstate - if self.eofState == 1: - self.eofState = 2 - self.inhibitEof() - if self.seekstate == self.SEEK_STATE_EOF: - if prevstate == self.SEEK_STATE_PAUSE: - self.setSeekState(self.SEEK_STATE_PAUSE) - else: - self.setSeekState(self.SEEK_STATE_PLAY) - self.eofInhibitTimer.start(200, True) seekable.seekTo(pts) def doSeekRelative(self, pts): @@ -844,15 +895,12 @@ class InfoBarSeek: if seekable is None: return prevstate = self.seekstate - if self.eofState == 1: - self.eofState = 2 - self.inhibitEof() + if self.seekstate == self.SEEK_STATE_EOF: if prevstate == self.SEEK_STATE_PAUSE: self.setSeekState(self.SEEK_STATE_PAUSE) else: self.setSeekState(self.SEEK_STATE_PLAY) - self.eofInhibitTimer.start(200, True) seekable.seekRelative(pts<0 and -1 or 1, abs(pts)) if abs(pts) > 100 and config.usage.show_infobar_on_skip.value: self.showAfterSeek() @@ -964,44 +1012,19 @@ class InfoBarSeek: return False def __evEOF(self): - if self.eofState == 0 and self.seekstate != self.SEEK_STATE_EOF: - self.eofState = 1 - time = self.calcRemainingTime() - if not time: - time = 3000 # Failed to calc, use default - elif time == 0: - time = 300 # Passed end, shortest wait - elif time > 15000: - self.eofState = -2 # Too long, block eof - time = 15000 - else: - time += 1000 # Add margin - self.eofTimer.start(time, True) - - def inhibitEof(self): - if self.eofState >= 1: - self.eofState = -self.eofState - self.eofTimer.stop() - self.doEof() - - def doEof(self): if self.seekstate == self.SEEK_STATE_EOF: return - if self.eofState == -2 or self.isStateBackward(self.seekstate): - self.eofState = 0 - return - # if we are seeking, we try to end up ~1s before the end, and pause there. - eofstate = self.eofState + # if we are seeking forward, we try to end up ~1s before the end, and pause there. seekstate = self.seekstate - self.eofState = 0 - if not self.seekstate == self.SEEK_STATE_PAUSE: + if self.seekstate != self.SEEK_STATE_PAUSE: self.setSeekState(self.SEEK_STATE_EOF) - if eofstate == -1 or not seekstate in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE): + + if seekstate not in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE): # if we are seeking seekable = self.getSeek() if seekable is not None: seekable.seekTo(-1) - if eofstate == 1 and seekstate == self.SEEK_STATE_PLAY: + if seekstate == self.SEEK_STATE_PLAY: # regular EOF self.doEofInternal(True) else: self.doEofInternal(False) @@ -1278,7 +1301,7 @@ class InfoBarExtensions: list.extend([(x[0](), x) for x in extensionsList]) keys += [""] * len(extensionsList) - self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys) + self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys, skin_name = "ExtensionsList") def extensionCallback(self, answer): if answer is not None: @@ -1296,7 +1319,9 @@ class InfoBarPlugins: return name def getPluginList(self): - return [((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU)] + list = [((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None, p.name) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU)] + list.sort(key = lambda e: e[2]) # sort by name + return list def runPlugin(self, plugin): if isinstance(self, InfoBarChannelSelection): @@ -1526,7 +1551,7 @@ class InfoBarInstantRecord: print "after:\n", self.recording def setEndtime(self, entry): - if entry is not None: + if entry is not None and entry >= 0: self.selectedEntry = entry self.endtime=ConfigClock(default = self.recording[self.selectedEntry].end) dlg = self.session.openWithCallback(self.TimeDateInputClosed, TimeDateInput, self.endtime) @@ -1543,7 +1568,7 @@ class InfoBarInstantRecord: self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry]) def changeDuration(self, entry): - if entry is not None: + if entry is not None and entry >= 0: self.selectedEntry = entry self.session.openWithCallback(self.inputCallback, InputBox, title=_("How many minutes do you want to record?"), text="5", maxSize=False, type=Input.NUMBER) @@ -1643,7 +1668,7 @@ class InfoBarAudioSelection: tlist = [((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n selection += 2 - self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys) + self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys, skin_name = "AudioTrackSelection") else: del self.audioTracks @@ -1667,7 +1692,7 @@ class InfoBarAudioSelection: keys = ["red", "green", "yellow"] selection = self.audioChannel.getCurrentChannel() tlist = ((_("left"), 0), (_("stereo"), 1), (_("right"), 2)) - self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys) + self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys, skin_name ="AudioModeSelection") else: del self.audioChannel if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > audio[1]: @@ -1768,7 +1793,7 @@ class InfoBarSubserviceSelection: keys = ["red", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n selection += 2 - self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = selection, keys = keys) + self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = selection, keys = keys, skin_name = "SubserviceSelection") def subserviceSelected(self, service): del self.bouquets