replace subservice selection screen with ChoiceBox screen
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 2 May 2006 21:16:54 +0000 (21:16 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 2 May 2006 21:16:54 +0000 (21:16 +0000)
lib/python/Components/ChoiceList.py
lib/python/Screens/ChoiceBox.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/Makefile.am
lib/python/Screens/SubserviceSelection.py [deleted file]
lib/python/Screens/TimerEntry.py
lib/python/Screens/__init__.py

index b151453..ca58ecd 100644 (file)
@@ -27,15 +27,17 @@ def ChoiceEntryComponent(key, text):
        return res
 
 class ChoiceList(MenuList, HTMLComponent, GUIComponent):
-       def __init__(self, list):
+       def __init__(self, list, selection = 0):
                GUIComponent.__init__(self)
                self.l = eListboxPythonMultiContent()
                self.list = list
                self.l.setList(list)
                self.l.setFont(0, gFont("Regular", 20))
+               self.selection = selection
 
        GUI_WIDGET = eListbox
                
        def postWidgetCreate(self, instance):
                instance.setContent(self.l)
                instance.setItemHeight(25)
+               self.moveToIndex(self.selection)
index f38f036..50fd6c5 100644 (file)
@@ -10,7 +10,7 @@ from Components.ChoiceList import ChoiceEntryComponent, ChoiceList
 import os
 
 class ChoiceBox(Screen):
-       def __init__(self, session, title = "", list = [], keys = None):
+       def __init__(self, session, title = "", list = [], keys = None, selection = 0):
                Screen.__init__(self, session)
 
                self["text"] = Label(title)
@@ -28,7 +28,7 @@ class ChoiceBox(Screen):
                        if self.keys[pos] != "":
                                self.keymap[self.keys[pos]] = list[pos]
                        pos += 1
-               self["list"] = ChoiceList(self.list)
+               self["list"] = ChoiceList(list = self.list, selection = selection)
                                
                self["actions"] = NumberActionMap(["WizardActions", "InputActions", "ColorActions"], 
                {
index 9a88444..788a67b 100644 (file)
@@ -1164,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",
@@ -1176,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):
index cddf455..a0ec450 100644 (file)
@@ -7,7 +7,7 @@ install_PYTHON = \
        Satconfig.py ScanSetup.py NetworkSetup.py Ci.py TimerEntry.py Volume.py \
        EpgSelection.py EventView.py Mute.py Standby.py ServiceInfo.py \
        AudioSelection.py InfoBarGenerics.py HelpMenu.py Wizard.py __init__.py \
-       Dish.py SubserviceSelection.py LanguageSelection.py StartWizard.py \
+       Dish.py LanguageSelection.py StartWizard.py \
        TutorialWizard.py PluginBrowser.py MinuteInput.py Scart.py PVRState.py \
        Console.py InputBox.py ChoiceBox.py SimpleSummary.py ImageWizard.py \
        MediaPlayer.py TimerSelection.py PictureInPicture.py TimeDateInput.py
diff --git a/lib/python/Screens/SubserviceSelection.py b/lib/python/Screens/SubserviceSelection.py
deleted file mode 100644 (file)
index e69de29..0000000
index fb560a7..27e82ab 100644 (file)
@@ -9,8 +9,8 @@ from Components.Button import Button
 from Components.NimManager import nimmanager
 from Components.Label import Label
 from Components.Pixmap import Pixmap
-from Screens.SubserviceSelection import SubserviceSelection
 from Screens.MessageBox import MessageBox
+from Screens.ChoiceBox import ChoiceBox
 from RecordTimer import AFTEREVENT
 from enigma import eEPGCache
 import time
@@ -286,14 +286,23 @@ class TimerEntry(Screen):
                if self.timer.eit is not None:
                        event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit)
                        if event is not None:
-                               if event.getNumOfLinkageServices() > 0:
-                                       self.session.openWithCallback(self.subserviceSelected, SubserviceSelection, event, self.timer.service_ref.ref)
+                               n = event.getNumOfLinkageServices()
+                               if n > 0:
+                                       tlist = []
+                                       ref = self.session.nav.getCurrentlyPlayingServiceReference()
+                                       parent = self.timer.service_ref.ref
+                                       for x in range(n):
+                                               i = event.getLinkageService(parent, x)
+                                               if i.toString() == ref.toString():
+                                                       selection = x
+                                               tlist.append((i.getName(), i))
+                                       self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list = tlist, selection = selection)
                                        return
                self.close((True, self.timer))
 
        def subserviceSelected(self, service):
                if not service is None:
-                       self.timer.service_ref = ServiceReference(service)
+                       self.timer.service_ref = ServiceReference(service[1])
                self.close((True, self.timer))
 
        def keyCancel(self):
index 60bb48d..f2681e3 100644 (file)
@@ -4,6 +4,6 @@ __all__ = ["ChannelSelection", "ClockDisplay", "ConfigMenu",
        "TimerEdit", "Setup", "HarddiskSetup", "FixedMenu",
        "Satconfig", "Scanconfig", "Ci.py", "Volume.py", "Mute.py",
        "EpgSelection", "EventView", "Standby", "ServiceInfo",
-       "AudioSelection", "SubserviceSelection", "InfoBarGenerics", "HelpMenu", "Wizard",
+       "AudioSelection", "InfoBarGenerics", "HelpMenu", "Wizard",
        "PVRState", "Console", "InputBox", "ChoiceBox", "SimpleSummary",
        "TimerSelection" ]