use ChoiceBox for audio selection (audio tracks are now sorted by description)
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 2 May 2006 23:07:07 +0000 (23:07 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 2 May 2006 23:07:07 +0000 (23:07 +0000)
lib/python/Screens/AudioSelection.py [deleted file]
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/Makefile.am
lib/python/Screens/__init__.py

diff --git a/lib/python/Screens/AudioSelection.py b/lib/python/Screens/AudioSelection.py
deleted file mode 100644 (file)
index e69de29..0000000
index 788a67b1f374fb51184e92087388aa56109c04a3..1b56e43006f18fad39bc124647bca3d290a75f93 100644 (file)
@@ -1148,7 +1148,7 @@ class InfoBarInstantRecord:
                else:
                        self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, title=_("Start recording?"), list=[(_("add recording (indefinitely)"), "indefinitely"), (_("add recording (stop after current event)"), "event"), (_("add recording (enter recording duration)"), "manualduration"),(_("don't record"), "no")])
 
-from Screens.AudioSelection import AudioSelection
+from Tools.ISO639 import LanguageCodes
 
 class InfoBarAudioSelection:
        def __init__(self):
@@ -1160,9 +1160,40 @@ class InfoBarAudioSelection:
        def audioSelection(self):
                service = self.session.nav.getCurrentService()
                audio = service.audioTracks()
+               self.audio = audio
                n = audio.getNumberOfTracks()
                if n > 0:
-                       self.session.open(AudioSelection, audio)
+                       tlist = []
+                       for x in range(n):
+                               i = audio.getTrackInfo(x)
+                               language = i.getLanguage()
+                               description = i.getDescription();
+       
+                               if len(language) == 3:
+                                       if language in LanguageCodes:
+                                               language = LanguageCodes[language][0]
+       
+                               if len(description):
+                                       description += " (" + language + ")"
+                               else:
+                                       description = language
+       
+                               tlist.append((description, x))
+                       
+                       selectedAudio = tlist[0][1]
+                       tlist.sort(lambda x,y : cmp(x[0], y[0]))
+                       selection = 0
+                       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)
+
+       def audioSelected(self, audio):
+               if audio is not None:
+                       self.audio.selectTrack(audio[1])
 
 class InfoBarSubserviceSelection:
        def __init__(self):
index a0ec450f35477c634df814bab82e99ffb60fc6df..06571d81095e3d7fa8abc12fade2aa0c6b3de3a9 100644 (file)
@@ -6,7 +6,7 @@ install_PYTHON = \
        MovieSelection.py Setup.py About.py HarddiskSetup.py FixedMenu.py \
        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 \
+       InfoBarGenerics.py HelpMenu.py Wizard.py __init__.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 \
index f2681e341a27faa9f06d8257a2eba124a41d53b0..30f39b1cd97c12a684476d6df64e4e42480d2b09 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", "InfoBarGenerics", "HelpMenu", "Wizard",
+       "InfoBarGenerics", "HelpMenu", "Wizard",
        "PVRState", "Console", "InputBox", "ChoiceBox", "SimpleSummary",
        "TimerSelection" ]