green -> blue
[enigma2.git] / lib / python / Screens / Subtitles.py
index 043198c8f66126ec1992e6f05789ac762759eabf..b1c4475ed0bbda94d2aa9112d69bd72fb5683b30 100644 (file)
@@ -1,8 +1,9 @@
 from Screen import Screen
+from Components.ServiceEventTracker import ServiceEventTracker
 from Components.ActionMap import ActionMap
-from Components.ConfigList import ConfigList, ConfigListScreen
+from Components.ConfigList import ConfigListScreen
 from Components.config import config, getConfigListEntry, ConfigNothing
-from Components.Label import Label
+from enigma import iPlayableService
 
 from Tools.ISO639 import LanguageCodes
 
@@ -19,6 +20,18 @@ class Subtitles(Screen, ConfigListScreen):
                self.list = []
                ConfigListScreen.__init__(self, self.list)
                self.infobar = self.session.infobar
+               self.fillList()
+
+               self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
+                       {
+                               iPlayableService.evUpdatedInfo: self.__updatedInfo
+                       })
+               self.cached_subtitle_checked = False
+               self.__selected_subtitle = None
+
+       def fillList(self):
+               del self.list[:]
+               print "self.list", self.list
                if self.subtitlesEnabled():
                        self.list.append(getConfigListEntry(_("Disable Subtitles"), ConfigNothing(), None))
                        sel = self.infobar.selected_subtitle
@@ -30,16 +43,25 @@ class Subtitles(Screen, ConfigListScreen):
                        else:
                                text = _("Enable")
                        if x[0] == 0:
-                               self.list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x))
+                               if LanguageCodes.has_key(x[4]):
+                                       self.list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x))
+                               else:
+                                       self.list.append(getConfigListEntry(text+" DVB "+x[4], ConfigNothing(), x))
                        elif x[0] == 1:
                                if x[4] == 'und': #undefined
                                        self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2]), ConfigNothing(), x))
                                else:
-                                       self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+LanguageCodes[x[4]][0], ConfigNothing(), x))
+                                       if LanguageCodes.has_key(x[4]):
+                                               self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+LanguageCodes[x[4]][0], ConfigNothing(), x))
+                                       else:
+                                               self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+x[4], ConfigNothing(), x))
 #              return _("Disable subtitles")
                self["config"].list = self.list
                self["config"].l.setList(self.list)
 
+       def __updatedInfo(self):
+               self.fillList()
+
        def getSubtitleList(self):
                s = self.infobar and self.infobar.getCurrentServiceSubtitle()
                l = s and s.getSubtitleList() or [ ]