1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.ConfigList import ConfigList, ConfigListScreen
4 from Components.config import config, getConfigListEntry, ConfigNothing
5 from Components.Label import Label
7 from Tools.ISO639 import LanguageCodes
9 class Subtitles(Screen, ConfigListScreen):
10 def __init__(self, session):
11 Screen.__init__(self, session)
13 self["actions"] = ActionMap(["SetupActions"],
16 "cancel": self.cancel,
20 ConfigListScreen.__init__(self, self.list)
21 self.infobar = self.session.infobar
22 if self.subtitlesEnabled():
23 self.list.append(getConfigListEntry(_("Disable Subtitles"), ConfigNothing(), None))
24 sel = self.infobar.selected_subtitle
27 for x in self.getSubtitleList():
28 if sel and sel[:4] == x[:4]: #ignore Language code in compare
33 if LanguageCodes.has_key(x[4]):
34 self.list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x))
36 self.list.append(getConfigListEntry(text+" DVB "+x[4], ConfigNothing(), x))
38 if x[4] == 'und': #undefined
39 self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2]), ConfigNothing(), x))
41 if LanguageCodes.has_key(x[4]):
42 self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+LanguageCodes[x[4]][0], ConfigNothing(), x))
44 self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+x[4], ConfigNothing(), x))
45 # return _("Disable subtitles")
46 self["config"].list = self.list
47 self["config"].l.setList(self.list)
49 def getSubtitleList(self):
50 s = self.infobar and self.infobar.getCurrentServiceSubtitle()
51 l = s and s.getSubtitleList() or [ ]
54 def subtitlesEnabled(self):
55 return self.infobar.subtitles_enabled
57 def enableSubtitle(self, subtitles):
58 if self.infobar.selected_subtitle != subtitles:
59 self.infobar.subtitles_enabled = False
60 self.infobar.selected_subtitle = subtitles
61 self.infobar.subtitles_enabled = True
63 def disableSubtitles(self):
64 self.infobar.subtitles_enabled = False
67 ConfigListScreen.keyLeft(self)
70 ConfigListScreen.keyRight(self)
74 cur = self["config"].getCurrent()
75 self.enableSubtitle(cur[2])