replace subservice selection screen with ChoiceBox screen
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 7e9aaadfa6a9d218974149a999eb4d89bdb562ed..788a67b1f374fb51184e92087388aa56109c04a3 100644 (file)
@@ -342,6 +342,8 @@ class InfoBarSimpleEventView:
 class InfoBarEPG:
        """ EPG - Opens an EPG list when the showEPGList action fires """
        def __init__(self):
+               self.dlg_stack = [ ]
+               self.bouquetSel = None
                self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions", 
                        {
                                "showEventInfo": (self.openEventView, _("show EPG...")),
@@ -357,8 +359,7 @@ class InfoBarEPG:
                        self.servicelist.setCurrentSelection(service) #select the service in servicelist
                        self.servicelist.zap()
 
-       def openBouquetEPG(self, bouquet, withCallback=True):
-               ptr=eEPGCache.getInstance()
+       def getBouquetServices(self, bouquet):
                services = [ ]
                servicelist = eServiceCenter.getInstance().list(bouquet)
                if not servicelist is None:
@@ -369,16 +370,37 @@ class InfoBarEPG:
                                if service.flags: #ignore non playable services
                                        continue
                                services.append(ServiceReference(service))
+               return services
+
+       def openBouquetEPG(self, bouquet, withCallback=True):
+               services = self.getBouquetServices(bouquet)
                if len(services):
                        self.epg_bouquet = bouquet
                        if withCallback:
-                               self.session.openWithCallback(self.closed, EPGSelection, services, self.zapToService)
+                               self.dlg_stack.append(self.session.openWithCallback(self.closed, EPGSelection, services, self.zapToService, None, self.changeBouquetCB))
                        else:
-                               self.session.open(EPGSelection, services, self.zapToService)
+                               self.session.open(EPGSelection, services, self.zapToService, None, self.changeBouquetCB)
 
-       def closed(self, ret):
+       def changeBouquetCB(self, direction, epg):
+               if self.bouquetSel:
+                       if direction > 0:
+                               self.bouquetSel.down()
+                       else:
+                               self.bouquetSel.up()
+                       bouquet = self.bouquetSel.getCurrent()
+                       services = self.getBouquetServices(bouquet)
+                       if len(services):
+                               self.epg_bouquet = bouquet
+                               epg.setServices(services)
+
+       def closed(self, ret=False):
+               closedScreen = self.dlg_stack.pop()
+               if self.bouquetSel and closedScreen == self.bouquetSel:
+                       self.bouquetSel = None
                if ret:
-                       self.close(ret)
+                       dlgs=len(self.dlg_stack)
+                       assert dlgs>0
+                       self.dlg_stack[dlgs-1].close(dlgs > 1)
 
        def openMultiServiceEPG(self, withCallback=True):
                bouquets = self.servicelist.getBouquetList()
@@ -388,16 +410,19 @@ class InfoBarEPG:
                        cnt = len(bouquets)
                if cnt > 1: # show bouquet list
                        if withCallback:
-                               self.session.openWithCallback(self.closed, BouquetSelector, bouquets, self.openBouquetEPG)
+                               self.bouquetSel = self.session.openWithCallback(self.closed, BouquetSelector, bouquets, self.openBouquetEPG, enableWrapAround=True)
+                               self.dlg_stack.append(self.bouquetSel)
                        else:
-                               self.session.open(BouquetSelector, bouquets, self.openBouquetEPG)
+                               self.bouquetSel = self.session.open(BouquetSelector, bouquets, self.openBouquetEPG, enableWrapAround=True)
                elif cnt == 1: 
                        self.openBouquetEPG(bouquets[0][1], withCallback)
 
        def openSingleServiceEPG(self):
                ref=self.session.nav.getCurrentlyPlayingServiceReference()
-               ptr=eEPGCache.getInstance()
-               self.session.openWithCallback(self.closed, EPGSelection, ref)
+               self.session.open(EPGSelection, ref)
+
+       def openSimilarList(self, eventid, refstr):
+               self.session.open(EPGSelection, refstr, None, eventid)
 
        def openEventView(self):
                self.epglist = [ ]
@@ -419,7 +444,7 @@ class InfoBarEPG:
                                if ptr:
                                        self.epglist.append(ptr)
                if len(self.epglist) > 0:
-                       self.session.open(EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG)
+                       self.dlg_stack.append(self.session.openWithCallback(self.closed, EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList))
                else:
                        print "no epg for the service avail.. so we show multiepg instead of eventinfo"
                        self.openMultiServiceEPG(False)
@@ -1139,8 +1164,6 @@ class InfoBarAudioSelection:
                if n > 0:
                        self.session.open(AudioSelection, audio)
 
-from Screens.SubserviceSelection import SubserviceSelection
-
 class InfoBarSubserviceSelection:
        def __init__(self):
                self["SubserviceSelectionAction"] = HelpableActionMap(self, "InfobarSubserviceSelectionActions",
@@ -1151,13 +1174,23 @@ class InfoBarSubserviceSelection:
        def subserviceSelection(self):
                service = self.session.nav.getCurrentService()
                subservices = service.subServices()
+               
                n = subservices.getNumberOfSubservices()
+               selection = 0
                if n > 0:
-                       self.session.openWithCallback(self.subserviceSelected, SubserviceSelection, subservices)
+                       ref = self.session.nav.getCurrentlyPlayingServiceReference()
+                       tlist = []
+                       for x in range(n):
+                               i = subservices.getSubservice(x)
+                               if i.toString() == ref.toString():
+                                       selection = x
+                               tlist.append((i.getName(), i))
+
+                       self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = selection)
 
        def subserviceSelected(self, service):
                if not service is None:
-                       self.session.nav.playService(service)
+                       self.session.nav.playService(service[1])
 
 class InfoBarAdditionalInfo:
        def __init__(self):
@@ -1183,9 +1216,9 @@ class InfoBarAdditionalInfo:
                self.onLayoutFinish.append(self["ButtonYellowText"].update)
 
                self["ButtonBlue"] = PixmapConditional(withTimer = False)
-               self["ButtonBlue"].setConnect(lambda: False)
+               self["ButtonBlue"].setConnect(lambda: True)
                self["ButtonBlueText"] = LabelConditional(text = _("Extensions"), withTimer = False)
-               self["ButtonBlueText"].setConnect(lambda: False)
+               self["ButtonBlueText"].setConnect(lambda: True)
                self.onLayoutFinish.append(self["ButtonBlue"].update)
                self.onLayoutFinish.append(self["ButtonBlueText"].update)