add InfoBarTimeshiftState, fix timeshift after zap, fix seekactions
[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                 self.onLayoutFinish.append(self.selectActiveLanguage)
18                                 
19                 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions"], 
20                 {
21                         "ok": self.save,
22                         "cancel": self.close,
23                         "up": self.up,
24                         "down": self.down,
25                         "left": self.left,
26                         "right": self.right
27                 }, -1)
28                 
29         def selectActiveLanguage(self):
30                 self["list"].instance.moveSelectionTo(language.activeLanguage)
31                 
32         def save(self):
33                 self.run()
34                 self.close()
35         
36         def run(self):
37                 language.activateLanguage(self["list"].l.getCurrentSelectionIndex())
38                 config.osd.language.value = self["list"].l.getCurrentSelectionIndex()
39                 config.osd.language.save()
40                 self.setTitle(_("Language selection"))
41
42         def updateList(self):
43                 self.list = []
44                 if len(language.lang) == 0: # no language available => display only english
45                         self.list.append(LanguageEntryComponent("en", _("English")))
46                 else:
47                         for x in language.lang:
48                                 self.list.append(LanguageEntryComponent(x[3].lower(), _(x[0])))
49                 
50                 self["list"].l.setList(self.list)
51
52         def up(self):
53                 self["list"].instance.moveSelection(self["list"].instance.moveUp)
54                 self.run()
55                 self.updateList()
56                 
57         def down(self):
58                 self["list"].instance.moveSelection(self["list"].instance.moveDown)
59                 self.run()
60                 self.updateList()
61
62         def left(self):
63                 self["list"].instance.moveSelection(self["list"].instance.pageUp)
64                 self.run()
65                 self.updateList()
66                 
67         def right(self):
68                 self["list"].instance.moveSelection(self["list"].instance.pageDown)
69                 self.run()
70                 self.updateList()