- add separation lines to the ChoiceList component
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sat, 10 Jun 2006 21:30:38 +0000 (21:30 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sat, 10 Jun 2006 21:30:38 +0000 (21:30 +0000)
- selection of left/right/stereo added to the audio channel menu

lib/python/Components/ChoiceList.py
lib/python/Screens/ChoiceBox.py
lib/python/Screens/InfoBarGenerics.py

index fe3e60085afa0d6778054efa4d8f325050cbda57..a0fbde542ac5f44263c1680c515c278a8a4e8bce 100644 (file)
@@ -18,11 +18,14 @@ RT_VALIGN_BOTTOM = 16
 
 def ChoiceEntryComponent(key, text):
        res = [ text ]
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 32, 00, 800, 25, 0, RT_HALIGN_LEFT, text[0]))
-
-       png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "key_" + key + "-fs8.png"))
-       if png is not None:
-               res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 20, png))
+       if text[0] == "--":
+               res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 00, 800, 25, 0, RT_HALIGN_LEFT, "-"*200))
+       else:
+               res.append((eListboxPythonMultiContent.TYPE_TEXT, 32, 00, 800, 25, 0, RT_HALIGN_LEFT, text[0]))
+       
+               png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "key_" + key + "-fs8.png"))
+               if png is not None:
+                       res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 20, png))
        
        return res
 
index 50fd6c5172b6da259614d8c2a28067bb1536c24e..60aa5e10452fd9fa75e0594021fc8fee807fc60a 100644 (file)
@@ -24,7 +24,7 @@ class ChoiceBox(Screen):
                pos = 0
                for x in list:
                        strpos = str(self.keys[pos])
-                       self.list.append(ChoiceEntryComponent(strpos, x))
+                       self.list.append(ChoiceEntryComponent(key = strpos, text = x))
                        if self.keys[pos] != "":
                                self.keymap[self.keys[pos]] = list[pos]
                        pos += 1
index be77021042f3397e2869151a9efe7ee2b69630b9..b7325c360910cd70dfb4408a04351d412c3e67f4 100644 (file)
@@ -1214,14 +1214,17 @@ class InfoBarAudioSelection:
                audio = service.audioTracks()
                self.audioTracks = audio
                n = audio.getNumberOfTracks()
+               keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
+               tlist = []
+               print "tlist:", tlist
                if n > 0:
-#                      self.audioChannel = service.audioChannel()
+                       self.audioChannel = service.audioChannel()
 #                      config.audio.audiochannel = configElement_nonSave("config.audio.audiochannel", configSelection, self.audioChannel.getCurrentChannel(), (("left", _("Left  >")), ("stereo", _("<  Stereo  >")), ("right", _("<  Right"))))
-                       tlist = []
+
                        for x in range(n):
                                i = audio.getTrackInfo(x)
                                language = i.getLanguage()
-                               description = i.getDescription();
+                               description = i.getDescription()
        
                                if len(language) == 3:
                                        if language in LanguageCodes:
@@ -1239,24 +1242,36 @@ class InfoBarAudioSelection:
 
 #                      tlist.insert(0, getConfigListEntry(_("Audio Channel"), config.audio.audiochannel))
 
-                       selection = 0
+                       selection = 2
                        for x in tlist:
                                if x[1] != selectedAudio:
                                        selection += 1
                                else:
                                        break
-                       
-                       self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection)
+
+                       tlist = [([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist
+                       self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys)
                else:
                        del self.audioTracks
 
        def audioSelected(self, audio):
                if audio is not None:
-                       self.audioTracks.selectTrack(audio[1])
+                       if isinstance(audio[1], str):
+                               if audio[1] == "mode":
+                                       keys = ["red", "green", "yellow"]
+                                       selection = self.audioChannel.getCurrentChannel()
+                                       tlist = [(_("left"), 0), (_("stereo"), 1), (_("right"), 2)]
+                                       self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys)
+                       else:
+                               if self.session.nav.getCurrentService().audioTracks().getNumberOfTracks() > audio[1]:
+                                       self.audioTracks.selectTrack(audio[1])
                del self.audioTracks
-#              del self.audioChannel
 #              del config.audio.audiochannel
 
+       def modeSelected(self, mode):
+               if mode is not None:
+                       self.audioChannel.selectChannel(mode[1])
+               del self.audioChannel
 class InfoBarSubserviceSelection:
        def __init__(self):
                self["SubserviceSelectionAction"] = HelpableActionMap(self, "InfobarSubserviceSelectionActions",