moving the list generation to a seperate method
[enigma2.git] / lib / python / Screens / LanguageSelection.py
index 42f5420..1a82a31 100644 (file)
@@ -4,6 +4,7 @@ from Components.MenuList import MenuList
 from Components.ActionMap import ActionMap
 from Components.Language import language
 from Components.LanguageList import *
+from Components.config import config
 
 
 class LanguageSelection(Screen):
@@ -11,19 +12,16 @@ class LanguageSelection(Screen):
                Screen.__init__(self, session)
                
                self.list = []
-               list = language.getLanguageList()
-               for x in language.lang:
-                       print x
-                       self.list.append(LanguageEntryComponent(x[2], x[0]))
-
                self["list"] = LanguageList(self.list)
+               self.updateList()
                
-               self["actions"] = ActionMap(["OkCancelActions"], 
+               self["actions"] = ActionMap(["ListboxActions", "OkCancelActions"], 
                {
                        "ok": self.save,
-                       "cancel": self.close
+                       "cancel": self.close,
+                       "moveUp": self.up,
+                       "moveDown": self.down
                })
-               print "INIT LANGUAGESELECTION"
                
        def save(self):
                self.run()
@@ -31,3 +29,21 @@ class LanguageSelection(Screen):
        
        def run(self):
                language.activateLanguage(self["list"].l.getCurrentSelectionIndex())
+               config.osd.language.value = self["list"].l.getCurrentSelectionIndex()
+               config.osd.language.save()
+
+       def updateList(self):
+               self.list = []
+               if len(language.lang) == 0: # no language available => display only english
+                       self.list.append(LanguageEntryComponent("en", _("English")))
+               else:
+                       for x in language.lang:
+                               self.list.append(LanguageEntryComponent(x[2], _(x[0])))
+               
+               self["list"].l.setList(self.list)
+               
+       def up(self):
+               print "up"
+               
+       def down(self):
+               print "down"
\ No newline at end of file