use number keys for predefined pip positions
[enigma2.git] / lib / python / Screens / EpgSelection.py
index a5b61a1cfe540d41a0eb761b3029d27600b74efc..331fe75e11b3233c1255fd7ab0c7b9171b0f99ea 100644 (file)
@@ -19,9 +19,10 @@ from time import localtime
 import xml.dom.minidom
 
 class EPGSelection(Screen):
-       def __init__(self, session, service, zapFunc=None, eventid=None):
+       def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None):
                Screen.__init__(self, session)
-               self.asked_specific_time = False
+               self.bouquetChangeCB = bouquetChangeCB
+               self.ask_time = -1 #now
                self["key_red"] = Button("")
                self.closeRecursive = False
                if isinstance(service, str) and eventid != None:
@@ -69,13 +70,23 @@ class EPGSelection(Screen):
                                "yellow": self.yellowButtonPressed,
                                "blue": self.blueButtonPressed,
                                "info": self.infoKeyPressed,
-                               "zapTo": self.zapTo,
-                               "input_date_time": self.enterDateTime
+                               "red": self.zapTo,
+                               "input_date_time": self.enterDateTime,
+                               "nextBouquet": self.nextBouquet,
+                               "prevBouquet": self.prevBouquet
                        })
                self["actions"].csel = self
 
                self.onLayoutFinish.append(self.onCreate)
 
+       def nextBouquet(self):
+               if self.bouquetChangeCB:
+                       self.bouquetChangeCB(1, self)
+
+       def prevBouquet(self):
+               if self.bouquetChangeCB:
+                       self.bouquetChangeCB(-1, self)
+
        def enterDateTime(self):
                if self.type == EPG_TYPE_MULTI:
                        self.session.openWithCallback(self.onDateTimeInputClosed, TimeDateInput)
@@ -83,7 +94,7 @@ class EPGSelection(Screen):
        def onDateTimeInputClosed(self, ret):
                if len(ret) > 1:
                        if ret[0]:
-                               self.asked_specific_time=True
+                               self.ask_time=ret[1]
                                self["list"].fillMultiEPG(self.services, ret[1])
 
        def closeScreen(self):
@@ -106,12 +117,16 @@ class EPGSelection(Screen):
        def openSimilarList(self, eventid, refstr):
                self.session.open(EPGSelection, refstr, None, eventid)
 
+       def setServices(self, services):
+               self.services = services
+               self.onCreate()
+
        #just used in multipeg
        def onCreate(self):
                l = self["list"]
                if self.type == EPG_TYPE_MULTI:
                        l.recalcEntrySize()
-                       l.fillMultiEPG(self.services)
+                       l.fillMultiEPG(self.services, self.ask_time)
                elif self.type == EPG_TYPE_SINGLE:
                        if SINGLE_CPP == 0:
                                l.recalcEntrySize()
@@ -138,16 +153,16 @@ class EPGSelection(Screen):
                                setEvent(cur[0])
 
        def zapTo(self): # just used in multiepg
-               if self.zapFunc != None:
-                       self.closeRecursive = True
-                       ref = self["list"].getCurrent()[1]
-                       self.zapFunc(ref.ref)
+               if self.zapFunc and self["key_red"].getText() == "Zap":
+                       lst = self["list"]
+                       count = lst.getCurrentChangeCount()
+                       if count == 0:
+                               self.closeRecursive = True
+                               ref = lst.getCurrent()[1]
+                               self.zapFunc(ref.ref)
 
        def eventSelected(self):
-               if self.type == EPG_TYPE_MULTI:
-                       self.zapTo()
-               else:
-                       self.infoKeyPressed()
+               self.infoKeyPressed()
 
        def yellowButtonPressed(self):
                if self.type == EPG_TYPE_MULTI:
@@ -193,13 +208,16 @@ class EPGSelection(Screen):
                        self["now_text"].hide()
                        self["next_text"].hide()
                        self["more_text"].hide()
+                       self["key_red"].setText("")
                else:
                        if state == 1:
+                               self["key_red"].setText("Zap")
                                self["now_button_sel"].show()
                                self["now_button"].hide()
                        else:
                                self["now_button"].show()
                                self["now_button_sel"].hide()
+                               self["key_red"].setText("")
 
                        if state == 2:
                                self["next_button_sel"].show()
@@ -218,7 +236,7 @@ class EPGSelection(Screen):
        def onSelectionChanged(self):
                if self.type == EPG_TYPE_MULTI:
                        count = self["list"].getCurrentChangeCount()
-                       if self.asked_specific_time:
+                       if self.ask_time != -1:
                                self.applyButtonState(0)
                        elif count > 1:
                                self.applyButtonState(3)