toggle between epg types with info
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index a659b5be6d2626bd4aaed85c6fec66adabf1d418..393f6901c40f3c25476e6a61ee29dfb86b096054 100644 (file)
@@ -5,7 +5,7 @@ from Components.Label import *
 from Components.ProgressBar import *
 from Components.config import configfile, configsequencearg
 from Components.config import config, configElement, ConfigSubsection, configSequence
-from ChannelSelection import ChannelSelection
+from ChannelSelection import ChannelSelection, BouquetSelector
 
 from Components.Pixmap import Pixmap, PixmapConditional
 from Components.BlinkingPixmap import BlinkingPixmapConditional
@@ -358,11 +358,68 @@ class InfoBarEPG:
        def __init__(self):
                self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions", 
                        {
-                               "showEPGList": (self.showEPGList, _("show EPG...")),
+                               "showEPGList": (self.openSingleServiceEPG, _("show EPG...")),
                        })
 
        def showEPGList(self):
+               bouquets = self.servicelist.getBouquetList()
+               if bouquets is None:
+                       cnt = 0
+               else:
+                       cnt = len(bouquets)
+               if cnt > 1: # show bouquet list
+                       self.session.open(BouquetSelector, bouquets, self.openBouquetEPG)
+               elif cnt == 1: # add to only one existing bouquet
+                       self.openBouquetEPG(bouquets[0][1])
+               else: #no bouquets so we open single epg
+                       self.openSingleEPGSelector(self.session.nav.getCurrentlyPlayingServiceReference())
+
+       def bouquetEPGCallback(self, info):
+               if info:
+                       self.openSingleServiceEPG()
+       
+       def singleEPGCallback(self, info):
+               if info:
+                       self.showEPGList()
+                       
+       def openSingleServiceEPG(self):
                ref=self.session.nav.getCurrentlyPlayingServiceReference()
+               ptr=eEPGCache.getInstance()
+               if ptr.startTimeQuery(ref) != -1:
+                       self.session.openWithCallback(self.singleEPGCallback, EPGSelection, ref)
+               else: # try to show now/next
+                       print 'no epg for service', ref.toString()
+                       try:
+                               self.epglist = [ ]
+                               service = self.session.nav.getCurrentService()
+                               info = service.info()
+                               ptr=info.getEvent(0)
+                               if ptr:
+                                       self.epglist.append(ptr)
+                               ptr=info.getEvent(1)
+                               if ptr:
+                                       self.epglist.append(ptr)
+                               if len(self.epglist) > 0:
+                                       self.session.open(EventView, self.epglist[0], ServiceReference(ref), self.eventViewCallback)
+                       except:
+                               pass    
+       
+       def openBouquetEPG(self, bouquet):
+               ptr=eEPGCache.getInstance()
+               services = [ ]
+               servicelist = eServiceCenter.getInstance().list(bouquet)
+               if not servicelist is None:
+                       while True:
+                               service = servicelist.getNext()
+                               if not service.valid(): #check if end of list
+                                       break
+                               if service.flags: #ignore non playable services
+                                       continue
+                               services.append(ServiceReference(service))
+               if len(services):
+                       self.session.openWithCallback(self.bouquetEPGCallback, EPGSelection, services)
+
+       def openSingleEPGSelector(self, ref):
                ptr=eEPGCache.getInstance()
                if ptr.startTimeQuery(ref) != -1:
                        self.session.open(EPGSelection, ref)
@@ -383,7 +440,7 @@ class InfoBarEPG:
                        except:
                                pass
 
-       def eventViewCallback(self, setEvent, val): #used for now/next displaying
+       def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
                if len(self.epglist) > 1:
                        tmp = self.epglist[0]
                        self.epglist[0]=self.epglist[1]