whitespace fixes
[enigma2.git] / lib / python / Screens / LanguageSelection.py
index 6b18121ff81f725e29a9d252a82b6ffc0545582e..83d03403782bf63c517385026e68622230721ad0 100644 (file)
@@ -11,6 +11,8 @@ class LanguageSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
                
+               self.oldActiveLanguage = language.getActiveLanguage()
+               
                self.list = []
                self["list"] = LanguageList(self.list)
                self.updateList()
@@ -19,7 +21,7 @@ class LanguageSelection(Screen):
                self["actions"] = ActionMap(["OkCancelActions", "DirectionActions"], 
                {
                        "ok": self.save,
-                       "cancel": self.close,
+                       "cancel": self.cancel,
                        "up": self.up,
                        "down": self.down,
                        "left": self.left,
@@ -27,26 +29,38 @@ class LanguageSelection(Screen):
                }, -1)
                
        def selectActiveLanguage(self):
-               self["list"].instance.moveSelectionTo(language.activeLanguage)
+               activeLanguage = language.getActiveLanguage()
+               pos = 0
+               for x in self.list:
+                       if x[0] == activeLanguage:
+                               self["list"].instance.moveSelectionTo(pos)
+                               break
+                       pos += 1
                
        def save(self):
                self.run()
                self.close()
        
+       def cancel(self):
+               language.activateLanguage(self.oldActiveLanguage)
+               self.close()
+       
        def run(self):
-               language.activateLanguage(self["list"].l.getCurrentSelectionIndex())
-               config.osd.language.value = self["list"].l.getCurrentSelectionIndex()
+               language.activateLanguage(self["list"].l.getCurrentSelection()[0])
+               config.osd.language.value = self["list"].l.getCurrentSelection()[0]
                config.osd.language.save()
+               config.misc.languageselected.value = 0
+               config.misc.languageselected.save()
                self.setTitle(_("Language selection"))
 
        def updateList(self):
                self.list = []
-               if len(language.lang) == 0: # no language available => display only english
-                       self.list.append(LanguageEntryComponent("en", _("English")))
+               if len(language.getLanguageList()) == 0: # no language available => display only english
+                       self.list.append(LanguageEntryComponent("en", _("English"), "en_EN"))
                else:
-                       for x in language.lang:
-                               self.list.append(LanguageEntryComponent(x[3].lower(), _(x[0])))
-               
+                       for x in language.getLanguageList():
+                               self.list.append(LanguageEntryComponent(file = x[1][3].lower(), name = _(x[1][0]), index = x[0]))
+               #self.list.sort(key=lambda x: x[1][7])
                self["list"].l.setList(self.list)
 
        def up(self):