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():
33 self.list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x))
35 if x[4] == 'und': #undefined
36 self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" "+str(x[2])+"/"+str(x[3]), ConfigNothing(), x))
38 self.list.append(getConfigListEntry(text+" TTX "+LanguageCodes[x[4]][0], ConfigNothing(), x))
39 # return _("Disable subtitles")
40 self["config"].list = self.list
41 self["config"].l.setList(self.list)
43 def getSubtitleList(self):
44 s = self.infobar and self.infobar.getCurrentServiceSubtitle()
45 l = s and s.getSubtitleList() or [ ]
48 def subtitlesEnabled(self):
49 return self.infobar.subtitles_enabled
51 def enableSubtitle(self, subtitles):
52 if self.infobar.selected_subtitle != subtitles:
53 print "enable subtitles", subtitles
54 self.infobar.subtitles_enabled = False
55 self.infobar.selected_subtitle = subtitles
56 self.infobar.subtitles_enabled = True
58 def disableSubtitles(self):
59 self.infobar.subtitles_enabled = False
62 ConfigListScreen.keyLeft(self)
65 ConfigListScreen.keyRight(self)
69 cur = self["config"].getCurrent()
70 self.enableSubtitle(cur[2])