Merge branch 'master' of fraxinas@git.opendreambox.org:/git/enigma2
[enigma2.git] / lib / python / Screens / LanguageSelection.py
index 7492e3ff6b468c020c56443f777798ba6e977df1..94ede08cff9cb0288553dbf7b840f80dbf746025 100644 (file)
@@ -2,22 +2,26 @@ from Screen import Screen
 
 from Components.ActionMap import ActionMap
 from Components.Language import language
 
 from Components.ActionMap import ActionMap
 from Components.Language import language
-from Components.LanguageList import *
 from Components.config import config
 from Components.Sources.List import List
 from Components.config import config
 from Components.Sources.List import List
+from Components.Label import Label
+from Components.Pixmap import Pixmap
+from Components.language_cache import LANG_TEXT
 
 
-from Tools.Directories import *
+def _cached(x):
+       return LANG_TEXT.get(config.osd.language.value, {}).get(x, "")
 
 
-from enigma import eListboxPythonMultiContent, loadPNG, eListbox, gFont, RT_HALIGN_LEFT
+from Screens.Rc import Rc
+
+from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
+
+from Tools.LoadPixmap import LoadPixmap
 
 def LanguageEntryComponent(file, name, index):
 
 def LanguageEntryComponent(file, name, index):
-       res = [ index ]
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 80, 10, 200, 50, 0, RT_HALIGN_LEFT ,name))
-       png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "countries/" + file + ".png"))
+       png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/" + file + ".png"))
        if png == None:
        if png == None:
-               png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "countries/missing.png"))
-       res.append((eListboxPythonMultiContent.TYPE_PIXMAP, 10, 5, 60, 40, png))
-       
+               png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/missing.png"))
+       res = (index, name, png)
        return res
 
 class LanguageSelection(Screen):
        return res
 
 class LanguageSelection(Screen):
@@ -27,7 +31,7 @@ class LanguageSelection(Screen):
                self.oldActiveLanguage = language.getActiveLanguage()
 
                self.list = []
                self.oldActiveLanguage = language.getActiveLanguage()
 
                self.list = []
-               self["languages"] = List(self.list, item_height=50, fonts = [gFont("Regular", 20)])
+               self["languages"] = List(self.list)
                self["languages"].onSelectionChanged.append(self.changed)
 
                self.updateList()
                self["languages"].onSelectionChanged.append(self.changed)
 
                self.updateList()
@@ -56,29 +60,32 @@ class LanguageSelection(Screen):
                language.activateLanguage(self.oldActiveLanguage)
                self.close()
 
                language.activateLanguage(self.oldActiveLanguage)
                self.close()
 
-       def run(self):
+       def run(self, justlocal = False):
                print "updating language..."
                lang = self["languages"].getCurrent()[0]
                print "updating language..."
                lang = self["languages"].getCurrent()[0]
-               language.activateLanguage(lang)
                config.osd.language.value = lang
                config.osd.language.save()
                config.osd.language.value = lang
                config.osd.language.save()
+               self.setTitle(_cached("T2"))
+               
+               if justlocal:
+                       return
+
+               language.activateLanguage(lang)
                config.misc.languageselected.value = 0
                config.misc.languageselected.save()
                config.misc.languageselected.value = 0
                config.misc.languageselected.save()
-               self.setTitle(_("Language selection"))
                print "ok"
 
        def updateList(self):
                print "ok"
 
        def updateList(self):
-               print "update list"
                first_time = len(self.list) == 0
 
                self.list = []
                if len(language.getLanguageList()) == 0: # no language available => display only english
                first_time = len(self.list) == 0
 
                self.list = []
                if len(language.getLanguageList()) == 0: # no language available => display only english
-                       self.list.append(LanguageEntryComponent("en", _("English"), "en_EN"))
+                       self.list.append(LanguageEntryComponent("en", _cached("en_EN"), "en_EN"))
                else:
                        for x in language.getLanguageList():
                else:
                        for x in language.getLanguageList():
-                               self.list.append(LanguageEntryComponent(file = x[1][3].lower(), name = _(x[1][0]), index = x[0]))
+                               self.list.append(LanguageEntryComponent(file = x[1][2].lower(), name = _cached("%s_%s" % x[1][1:3]), index = x[0]))
                #self.list.sort(key=lambda x: x[1][7])
                #self.list.sort(key=lambda x: x[1][7])
-               
+
                print "updateList"
                if first_time:
                        self["languages"].list = self.list
                print "updateList"
                if first_time:
                        self["languages"].list = self.list
@@ -87,5 +94,29 @@ class LanguageSelection(Screen):
                print "done"
 
        def changed(self):
                print "done"
 
        def changed(self):
-               self.run()
+               self.run(justlocal = True)
                self.updateList()
                self.updateList()
+
+class LanguageWizard(LanguageSelection, Rc):
+       def __init__(self, session):
+               LanguageSelection.__init__(self, session)
+               Rc.__init__(self)
+               self.onLayoutFinish.append(self.selectKeys)
+                               
+               self["wizard"] = Pixmap()
+               self["text"] = Label()
+               self.setText()
+               
+       def selectKeys(self):
+               self.clearSelectedKeys()
+               self.selectKey("UP")
+               self.selectKey("DOWN")
+               
+       def changed(self):
+               self.run(justlocal = True)
+               self.updateList()
+               self.setText()
+               
+       def setText(self):
+               
+               self["text"].setText(_cached("T1"))