From 3f8e26212c4bcca56462f09b50a681f1526e1a7c Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Tue, 2 May 2006 23:07:07 +0000 Subject: [PATCH] use ChoiceBox for audio selection (audio tracks are now sorted by description) --- lib/python/Screens/AudioSelection.py | 0 lib/python/Screens/InfoBarGenerics.py | 35 +++++++++++++++++++++++++-- lib/python/Screens/Makefile.am | 2 +- lib/python/Screens/__init__.py | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) delete mode 100644 lib/python/Screens/AudioSelection.py diff --git a/lib/python/Screens/AudioSelection.py b/lib/python/Screens/AudioSelection.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 788a67b1..1b56e430 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -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): diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am index a0ec450f..06571d81 100644 --- a/lib/python/Screens/Makefile.am +++ b/lib/python/Screens/Makefile.am @@ -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 \ diff --git a/lib/python/Screens/__init__.py b/lib/python/Screens/__init__.py index f2681e34..30f39b1c 100644 --- a/lib/python/Screens/__init__.py +++ b/lib/python/Screens/__init__.py @@ -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" ] -- 2.30.2