add ability to remove list and config from a wizard
[enigma2.git] / lib / python / Screens / LanguageSelection.py
1 from Screen import Screen
2
3 from Components.MenuList import MenuList
4 from Components.ActionMap import ActionMap
5 from Components.Language import language
6 from Components.LanguageList import *
7 from Components.config import config
8
9
10 class LanguageSelection(Screen):
11         def __init__(self, session):
12                 Screen.__init__(self, session)
13                 
14                 self.list = []
15                 self["list"] = LanguageList(self.list)
16                 self.updateList()
17                 
18                 self["actions"] = ActionMap(["WizardActions"], 
19                 {
20                         "ok": self.save,
21                         "back": self.close,
22                         "up": self.up,
23                         "down": self.down
24                 }, -1)
25                 
26         def save(self):
27                 self.run()
28                 self.close()
29         
30         def run(self):
31                 language.activateLanguage(self["list"].l.getCurrentSelectionIndex())
32                 config.osd.language.value = self["list"].l.getCurrentSelectionIndex()
33                 config.osd.language.save()
34                 self.session.currentDialog.instance.setTitle(_("Language selection"))
35
36         def updateList(self):
37                 self.list = []
38                 if len(language.lang) == 0: # no language available => display only english
39                         self.list.append(LanguageEntryComponent("en", _("English")))
40                 else:
41                         for x in language.lang:
42                                 self.list.append(LanguageEntryComponent(x[2], _(x[0])))
43                 
44                 self["list"].l.setList(self.list)
45
46         def up(self):
47                 self["list"].instance.moveSelection(self["list"].instance.moveUp)
48                 self.run()
49                 self.updateList()
50                 
51         def down(self):
52                 self["list"].instance.moveSelection(self["list"].instance.moveDown)
53                 self.run()
54                 self.updateList()