on startup always default to favs
[enigma2.git] / lib / python / Screens / ChannelSelection.py
index 8951770a511e26b427871a56c18e8547a82e13da..332a72b2b86e38f2b222e11594c8734cf72dd8c7 100644 (file)
@@ -1,11 +1,12 @@
 from Screen import Screen
 from Components.Button import Button
 from Components.ServiceList import ServiceList
-from Components.ActionMap import ActionMap
+from Components.ActionMap import NumberActionMap
 from EpgSelection import EPGSelection
 from enigma import eServiceReference, eEPGCache, eEPGCachePtr, eServiceCenter, eServiceCenterPtr, iMutableServiceListPtr, iStaticServiceInformationPtr, eTimer
 from Components.config import config, configElement, ConfigSubsection, configText
 from Screens.FixedMenu import FixedMenu
+from Tools.NumericalTextInput import NumericalTextInput
 
 import xml.dom.minidom
 
@@ -209,8 +210,8 @@ class ChannelSelectionBase(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
 
-               self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
-               #self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet')
+               #self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
+               self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet')
 
                self["key_red"] = Button("All")
                #self["key_green"] = Button("Provider")
@@ -223,6 +224,10 @@ class ChannelSelectionBase(Screen):
                self.servicelist = self["list"]
 
                #self["okbutton"] = Button("ok", [self.channelSelected])
+               
+               self.numericalTextInput = NumericalTextInput()
+               
+               self.lastService = None
 
                self.lastServiceTimer = eTimer()
                self.lastServiceTimer.timeout.get().append(self.lastService)
@@ -270,6 +275,11 @@ class ChannelSelectionBase(Screen):
        def showFavourites(self):
                self.setRoot(self.bouquet_root)
 
+       def keyNumberGlobal(self, number):
+               print "You pressed number " + str(number)
+               print "You would go to character " + str(self.numericalTextInput.getKey(number))
+               # TODO let the servicelist jump to the next entry strating with the chosen character
+
        def enterBouquet(self, action):
                if action[:7] == "bouquet":
                        if action.find("FROM BOUQUET") != -1:
@@ -301,15 +311,18 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit):
                config.tv.lastservice = configElement("config.tv.lastservice", configText, "", 0);
                config.tv.lastroot = configElement("config.tv.lastroot", configText, "", 0);
 
-               if config.tv.lastroot.value == "":
-                       self.servicelist.setRoot(eServiceReference("""1:0:1:0:0:0:0:0:0:0:(type == 1)"""))
+               #if config.tv.lastroot.value == "":
+               #allways defaults to fav
+               #self.servicelist.setRoot(eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'))
+               self.showFavourites()
+               self.session.nav.playService(eServiceReference(config.tv.lastservice.value))
 
-               class ChannelActionMap(ActionMap):
+               class ChannelActionMap(NumberActionMap):
                        def action(self, contexts, action):
                                if not self.csel.enterBouquet(action):
                                        if action == "cancel":
                                                self.csel.handleEditCancel()
-                                       ActionMap.action(self, contexts, action)
+                                       NumberActionMap.action(self, contexts, action)
                self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions", "ContextMenuActions"],
                        {
                                "cancel": self.cancel,
@@ -317,7 +330,17 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit):
                                "mark": self.doMark,
                                "contextMenu": self.doContext,
                                "showFavourites": self.showFavourites,
-                               "showEPGList": self.showEPGList
+                               "showEPGList": self.showEPGList,
+                               "1": self.keyNumberGlobal,
+                               "2": self.keyNumberGlobal,
+                               "3": self.keyNumberGlobal,
+                               "4": self.keyNumberGlobal,
+                               "5": self.keyNumberGlobal,
+                               "6": self.keyNumberGlobal,
+                               "7": self.keyNumberGlobal,
+                               "8": self.keyNumberGlobal,
+                               "9": self.keyNumberGlobal,
+                               "0": self.keyNumberGlobal
                        })
                self["actions"].csel = self
 
@@ -344,6 +367,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit):
        def setRoot(self, root):
                if not self.movemode:
                        self.setRootBase(root)
+                       self.saveRoot(root)
 
        #called from infoBar and channelSelected
        def zap(self):
@@ -367,7 +391,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit):
        def lastService(self):
                self.lastServiceTimer.stop()
                #zap to last running tv service
-               self.setRoot(eServiceReference(config.tv.lastroot.value))
+               #self.setRoot(eServiceReference(config.tv.lastroot.value))
                self.session.nav.playService(eServiceReference(config.tv.lastservice.value))
 
 class SimpleChannelSelection(ChannelSelectionBase):
@@ -385,6 +409,16 @@ class SimpleChannelSelection(ChannelSelectionBase):
                                "cancel": self.cancel,
                                "ok": self.channelSelected,
                                "showFavourites": self.showFavourites,
+                               "1": self.keyNumberGlobal,
+                               "2": self.keyNumberGlobal,
+                               "3": self.keyNumberGlobal,
+                               "4": self.keyNumberGlobal,
+                               "5": self.keyNumberGlobal,
+                               "6": self.keyNumberGlobal,
+                               "7": self.keyNumberGlobal,
+                               "8": self.keyNumberGlobal,
+                               "9": self.keyNumberGlobal,
+                               "0": self.keyNumberGlobal
                        })
                self["actions"].csel = self