From: Andreas Monzner Date: Fri, 17 Feb 2006 01:46:56 +0000 (+0000) Subject: add zapping history.. useable with < > buttons X-Git-Tag: 2.6.0~4152 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/d8db49b1ebcfd2a886be1536bbbc12d214e185a5 add zapping history.. useable with < > buttons --- diff --git a/data/keymap.xml b/data/keymap.xml index 17164d40..e21e70db 100644 --- a/data/keymap.xml +++ b/data/keymap.xml @@ -76,7 +76,8 @@ - + + diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index 20fc0993..476348f7 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -746,6 +746,8 @@ class ChannelSelectionBase(Screen): return bouquets return None +HISTORYSIZE = 20 + class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG): def __init__(self, session): ChannelSelectionBase.__init__(self,session) @@ -770,13 +772,16 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect self.lastChannelRootTimer.timeout.get().append(self.__onCreate) self.lastChannelRootTimer.start(100,True) + self.history = [ ] + self.history_pos = 0 + def __onCreate(self): self.setTvMode() self.restoreRoot() lastservice=eServiceReference(config.tv.lastservice.value) if lastservice.valid(): self.setCurrentSelection(lastservice) - self.session.nav.playService(lastservice) + self.zap() def __onShown(self): self.recallBouquetMode() @@ -801,9 +806,46 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect #called from infoBar and channelSelected def zap(self): ref = self.session.nav.getCurrentlyPlayingServiceReference() - if ref is None or ref != self.getCurrentSelection(): - self.session.nav.playService(self.getCurrentSelection()) + nref = self.getCurrentSelection() + if ref is None or ref != nref: + self.session.nav.playService(nref) + self.saveRoot() + self.saveChannel() + tmp=self.servicePath[:] + tmp.append(nref) + try: + del self.history[self.history_pos+1:] + except: + pass + self.history.append(tmp) + hlen = len(self.history) + if hlen > HISTORYSIZE: + del self.history[0] + self.history_pos = hlen-1 + + def historyBack(self): + hlen = len(self.history) + if hlen > 1 and self.history_pos > 0: + self.history_pos -= 1 + self.setHistoryPath() + + def historyNext(self): + hlen = len(self.history) + if hlen > 1 and self.history_pos < (hlen-1): + self.history_pos += 1 + self.setHistoryPath() + + def setHistoryPath(self): + path = self.history[self.history_pos][:] + ref = path.pop() + self.servicePath = path self.saveRoot() + plen = len(path) + root = path[plen-1] + if self.getRoot() != root: + self.setRoot(root) + self.session.nav.playService(ref) + self.setCurrentSelection(ref) self.saveChannel() def saveRoot(self): diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 0cc610a1..2f368537 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -278,8 +278,16 @@ class InfoBarChannelSelection: "switchChannelDown": self.switchChannelDown, "zapUp": (self.zapUp, _("next channel")), "zapDown": (self.zapDown, _("previous channel")), + "historyBack": (self.historyBack, _("previous channel in history")), + "historyNext": (self.historyNext, _("next channel in history")) }) + def historyBack(self): + self.servicelist.historyBack() + + def historyNext(self): + self.servicelist.historyNext() + def switchChannelUp(self): self.servicelist.moveUp() self.session.execDialog(self.servicelist)