1 from Screen import Screen
2 from Components.ServiceEventTracker import ServiceEventTracker
3 from Components.ActionMap import ActionMap
4 from Components.ConfigList import ConfigListScreen
5 from Components.config import config, getConfigListEntry, ConfigNothing
6 from enigma import iPlayableService
8 from Tools.ISO639 import LanguageCodes
10 class Subtitles(Screen, ConfigListScreen):
11 def __init__(self, session):
12 Screen.__init__(self, session)
14 self["actions"] = ActionMap(["SetupActions"],
17 "cancel": self.cancel,
21 ConfigListScreen.__init__(self, self.list)
22 self.infobar = self.session.infobar
25 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
27 iPlayableService.evUpdatedInfo: self.__updatedInfo
29 self.cached_subtitle_checked = False
30 self.__selected_subtitle = None
34 print "self.list", self.list
35 if self.subtitlesEnabled():
36 self.list.append(getConfigListEntry(_("Disable Subtitles"), ConfigNothing(), None))
37 sel = self.infobar.selected_subtitle
40 for x in self.getSubtitleList():
41 if sel and sel[:4] == x[:4]: #ignore Language code in compare
46 if LanguageCodes.has_key(x[4]):
47 self.list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x))
49 self.list.append(getConfigListEntry(text+" DVB "+x[4], ConfigNothing(), x))
51 if x[4] == 'und': #undefined
52 self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2]), ConfigNothing(), x))
54 if LanguageCodes.has_key(x[4]):
55 self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+LanguageCodes[x[4]][0], ConfigNothing(), x))
57 self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+x[4], ConfigNothing(), x))
59 types = [" UTF-8 text "," SSA / AAS "," .SRT file "]
60 if x[4] == 'und': #undefined
61 self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d" % x[1], ConfigNothing(), x))
63 if LanguageCodes.has_key(x[4]):
64 self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles") + ' ' + LanguageCodes[x[4]][0], ConfigNothing(), x))
66 self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d " % x[1] +x[4], ConfigNothing(), x))
67 # return _("Disable subtitles")
68 self["config"].list = self.list
69 self["config"].l.setList(self.list)
71 def __updatedInfo(self):
74 def getSubtitleList(self):
75 s = self.infobar and self.infobar.getCurrentServiceSubtitle()
76 l = s and s.getSubtitleList() or [ ]
79 def subtitlesEnabled(self):
80 return self.infobar.subtitles_enabled
82 def enableSubtitle(self, subtitles):
83 if self.infobar.selected_subtitle != subtitles:
84 self.infobar.subtitles_enabled = False
85 self.infobar.selected_subtitle = subtitles
86 self.infobar.subtitles_enabled = True
88 def disableSubtitles(self):
89 self.infobar.subtitles_enabled = False
92 ConfigListScreen.keyLeft(self)
95 ConfigListScreen.keyRight(self)
99 cur = self["config"].getCurrent()
100 self.enableSubtitle(cur[2])