add enigma1 like radio mode (on/off switchable in usage setup)
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sun, 25 Jun 2006 20:04:21 +0000 (20:04 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sun, 25 Jun 2006 20:04:21 +0000 (20:04 +0000)
data/keymap.xml
data/setup.xml
lib/python/Components/UsageConfig.py
lib/python/Screens/ChannelSelection.py
lib/python/Screens/InfoBar.py
lib/python/Screens/InfoBarGenerics.py

index 97529668e4b2fe9874078a9abd2575126f1325ad..41b7dda063e8d20156213b60f2ec9a5ec9146ec5 100644 (file)
        <map context="InfobarActions">
                <key id="KEY_VIDEO" mapto="showMovies" flags="m" />
                <key id="KEY_RADIO" mapto="showRadio" flags="m" />
+               <key id="KEY_TV" mapto="showTv" flags="m" />
        </map>
 
        <map context="InfobarAudioSelectionActions">
index f4fea25d07bf72ec008ed89c323ff00d0046eb56..41ecdcf0f75344d92cc65c5bfd5d3811178be8cc 100644 (file)
                        <item text="Visualize positioner movement">config.usage.showdish</item>
                        <item text="Multi bouquets">config.usage.multibouquet</item>
                        <item text="Change bouquets in quickzap">config.usage.quickzap_bouquet_change</item>
+                       <item text="Enigma1 like radiomode">config.usage.e1like_radio_mode</item>
                </setup>
                <setup key="network" title="Network setup">
                        <item text="Use DHCP">config.network.dhcp</item>
                        <item text="IP Address">config.network.ip</item>
-                       <item text="Netmask">config.network.netmask</item>                      
+                       <item text="Netmask">config.network.netmask</item>
                        <item text="Gateway">config.network.gateway</item>
                        <item text="Nameserver">config.network.dns</item>
 <!--                   <item text="MAC Address">config.network.mac</item>-->
index 58051ccf469eb0d19a1d15f4e06d78657aacc50d..e10a7491ae484d7fe6a28f23f49f192680ffb93c 100644 (file)
@@ -7,3 +7,4 @@ def InitUsageConfig():
        config.usage.showdish = configElement("config.usage.showdish", configSelection, 1, (("yes", _("yes")), ("no", _("no"))) )
        config.usage.multibouquet = configElement("config.usage.multibouquet", configSelection, 1, (("yes", _("yes")), ("no", _("no"))) )
        config.usage.quickzap_bouquet_change = configElement("config.usage.quickzap_bouquet_change", configSelection, 1, (("yes", _("yes")), ("no", _("no"))) )
+       config.usage.e1like_radio_mode = configElement("config.usage.e1like_radio_mode", configSelection, 1, (("yes", _("yes")), ("no", _("no"))) )
index df1bd6c089a1cc01a8b2add62e50b1207866d3a7..0870232e59dcc898f5f494b45dfe6b0e1493388f 100644 (file)
@@ -837,9 +837,14 @@ class ChannelSelectionBase(Screen):
 HISTORYSIZE = 20
 
 #config for lastservice
-config.tv = ConfigSubsection();
-config.tv.lastservice = configElement("config.tv.lastservice", configText, "", 0);
-config.tv.lastroot = configElement("config.tv.lastroot", configText, "", 0);
+config.tv = ConfigSubsection()
+config.tv.lastservice = configElement("config.tv.lastservice", configText, "", 0)
+config.tv.lastroot = configElement("config.tv.lastroot", configText, "", 0)
+config.radio = ConfigSubsection()
+config.radio.lastservice = configElement("config.radio.lastservice", configText, "", 0)
+config.radio.lastroot = configElement("config.radio.lastroot", configText, "", 0)
+config.servicelist = ConfigSubsection()
+config.servicelist.lastmode = configElement("config.servicelist.lastmode", configText, "tv", 0)
 
 class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG):
        def __init__(self, session):
@@ -847,26 +852,66 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                ChannelSelectionEdit.__init__(self)
                ChannelSelectionEPG.__init__(self)
 
-               self["actions"] = ActionMap(["OkCancelActions"],
+               self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
                        {
                                "cancel": self.cancel,
                                "ok": self.channelSelected,
+                               "keyRadio": self.setModeRadio,
+                               "keyTV": self.setModeTv,
                        })
+
                self.onShown.append(self.__onShown)
 
                self.lastChannelRootTimer = eTimer()
                self.lastChannelRootTimer.timeout.get().append(self.__onCreate)
                self.lastChannelRootTimer.start(100,True)
 
-               self.history = [ ]
+               self.history_tv = [ ]
+               self.history_radio = [ ]
+               self.history = self.history_tv
                self.history_pos = 0
 
-       def __onCreate(self):
-               self.setTvMode()
+               self.lastservice = config.tv.lastservice
+               self.lastroot = config.tv.lastroot
+               self.revertMode = None
+
+       def setMode(self):
                self.restoreRoot()
-               lastservice=eServiceReference(config.tv.lastservice.value)
+               lastservice=eServiceReference(self.lastservice.value)
                if lastservice.valid():
                        self.setCurrentSelection(lastservice)
+
+       def setModeTv(self):
+               if self.revertMode is None and config.servicelist.lastmode.value == "radio":
+                       self.revertMode = MODE_RADIO
+               self.history = self.history_tv
+               self.lastservice = config.tv.lastservice
+               self.lastroot = config.tv.lastroot
+               config.servicelist.lastmode.value = "tv"
+               self.setTvMode()
+               self.setMode()
+
+       def setModeRadio(self):
+               if self.revertMode is None and config.servicelist.lastmode.value == "tv":
+                       self.revertMode = MODE_TV
+               if currentConfigSelectionElement(config.usage.e1like_radio_mode) == "yes":
+                       self.history = self.history_radio
+                       self.lastservice = config.radio.lastservice
+                       self.lastroot = config.radio.lastroot
+                       config.servicelist.lastmode.value = "radio"
+                       self.setRadioMode()
+                       self.setMode()
+
+       def __onCreate(self):
+               if currentConfigSelectionElement(config.usage.e1like_radio_mode) == "yes":
+                       if config.servicelist.lastmode.value == "tv":
+                               self.setModeTv()
+                       else:
+                               self.setModeRadio()
+               else:
+                       self.setModeTv()
+               lastservice=eServiceReference(self.lastservice.value)
+               if lastservice.valid():
                        self.zap()
 
        def __onShown(self):
@@ -891,12 +936,14 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
 
        #called from infoBar and channelSelected
        def zap(self):
+               self.revertMode=None
                ref = self.session.nav.getCurrentlyPlayingServiceReference()
                nref = self.getCurrentSelection()
                if ref is None or ref != nref:
                        self.session.nav.playService(nref)
                        self.saveRoot()
                        self.saveChannel()
+                       config.servicelist.lastmode.save()
                        self.addToHistory(nref)
 
        def addToHistory(self, ref):
@@ -942,34 +989,34 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
 
        def saveRoot(self):
                path = ''
-               for i in self.servicePathTV:
+               for i in self.servicePath:
                        path += i.toString()
                        path += ';'
-               if len(path) and path != config.tv.lastroot.value:
-                       config.tv.lastroot.value = path
-                       config.tv.lastroot.save()
+               if len(path) and path != self.lastroot.value:
+                       self.lastroot.value = path
+                       self.lastroot.save()
 
        def restoreRoot(self):
                self.clearPath()
                re = compile('.+?;')
-               tmp = re.findall(config.tv.lastroot.value)
+               tmp = re.findall(self.lastroot.value)
                cnt = 0
                for i in tmp:
-                       self.servicePathTV.append(eServiceReference(i[:len(i)-1]))
+                       self.servicePath.append(eServiceReference(i[:len(i)-1]))
                        cnt += 1
                if cnt:
-                       path = self.servicePathTV.pop()
+                       path = self.servicePath.pop()
                        self.enterPath(path)
                else:
                        self.showFavourites()
                        self.saveRoot()
 
        def preEnterPath(self, refstr):
-               if len(self.servicePathTV) and self.servicePathTV[0] != eServiceReference(refstr):
-                       pathstr = config.tv.lastroot.value
+               if len(self.servicePath) and self.servicePath[0] != eServiceReference(refstr):
+                       pathstr = self.lastroot.value
                        if pathstr is not None and pathstr.find(refstr) == 0:
                                self.restoreRoot()
-                               lastservice=eServiceReference(config.tv.lastservice.value)
+                               lastservice=eServiceReference(self.lastservice.value)
                                if lastservice.valid():
                                        self.setCurrentSelection(lastservice)
                                return True
@@ -981,9 +1028,9 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                        refstr = ref.toString()
                else:
                        refstr = ""
-               if refstr != config.tv.lastservice.value:
-                       config.tv.lastservice.value = refstr
-                       config.tv.lastservice.save()
+               if refstr != self.lastservice.value:
+                       self.lastservice.value = refstr
+                       self.lastservice.save()
 
        def recallPrevService(self):
                hlen = len(self.history)
@@ -999,11 +1046,17 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                        self.setHistoryPath()
 
        def cancel(self):
+               if self.revertMode is None:
+                       self.restoreRoot()
+                       lastservice=eServiceReference(self.lastservice.value)
+                       if lastservice.valid() and self.getCurrentSelection() != lastservice:
+                               self.setCurrentSelection(lastservice)
+               elif self.revertMode == MODE_TV:
+                       self.setModeTv()
+               elif self.revertMode == MODE_RADIO:
+                       self.setModeRadio()
+               self.revertMode = None
                self.close(None)
-               self.restoreRoot()
-               lastservice=eServiceReference(config.tv.lastservice.value)
-               if lastservice.valid() and self.getCurrentSelection() != lastservice:
-                       self.setCurrentSelection(lastservice)
 
 from Screens.InfoBarGenerics import InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord
 
index 5669a77a9e82348bbd8575f146529c27c06598e5..567211767d9d776e1cbcc825db36c9ccfb2ee9ad 100644 (file)
@@ -9,6 +9,7 @@ from ServiceReference import ServiceReference
 from Components.Clock import Clock
 from Components.ActionMap import ActionMap, HelpableActionMap
 from Components.ServicePosition import ServicePosition, ServicePositionGauge
+from Components.config import currentConfigSelectionElement, config
 
 from Tools.Notifications import AddNotificationWithCallback
 
@@ -43,7 +44,8 @@ class InfoBar(InfoBarShowHide,
                self["actions"] = HelpableActionMap(self, "InfobarActions",
                        {
                                "showMovies": (self.showMovies, _("Play recorded movies...")),
-                               "showRadio": (self.showRadio, _("Show the radio player..."))
+                               "showRadio": (self.showRadio, _("Show the radio player...")),
+                               "showTv": (self.showTv, _("Show the tv player...")),
                        })
                
                for x in HelpableScreen, \
@@ -61,8 +63,14 @@ class InfoBar(InfoBarShowHide,
                self["CurrentTime"] = Clock()
                # ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
 
+       def showTv(self):
+               self.showTvChannelList(True)
+
        def showRadio(self):
-               self.session.open(ChannelSelectionRadio)
+               if currentConfigSelectionElement(config.usage.e1like_radio_mode) == "yes":
+                       self.showRadioChannelList(True)
+               else:
+                       self.session.open(ChannelSelectionRadio)
 
        def showMovies(self):
                self.session.openWithCallback(self.movieSelected, MovieSelection)
index 36f1d90c0d47ba6d6bd4bd8f8ef0f66f39d3526e..be092c6d114aacfb1fd1dd2901d04e99a94fcc0a 100644 (file)
@@ -262,6 +262,18 @@ class InfoBarChannelSelection:
                                "openServiceList": (self.openServiceList, _("open service list")),
                        })
 
+       def showTvChannelList(self, zap=False):
+               self.servicelist.setModeTv()
+               if zap:
+                       self.servicelist.zap()
+               self.session.execDialog(self.servicelist)
+
+       def showRadioChannelList(self, zap=False):
+               self.servicelist.setModeRadio()
+               if zap:
+                       self.servicelist.zap()
+               self.session.execDialog(self.servicelist)
+
        def firstRun(self):
                self.onShown.remove(self.firstRun)
                config.misc.initialchannelselection.value = 0