aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/config.py
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2008-06-06 00:15:53 +0000
committerFelix Domke <tmbinc@elitedvb.net>2008-06-06 00:15:53 +0000
commita7245fd6ecdfcf08f1347c0d319dd9003a14a1e9 (patch)
treea4d8984be57a7ef4989fcd68d618db057e6758c9 /lib/python/Components/config.py
parent0d37c6252427a7090525d263753700e9037f10e1 (diff)
downloadenigma2-a7245fd6ecdfcf08f1347c0d319dd9003a14a1e9.tar.gz
enigma2-a7245fd6ecdfcf08f1347c0d319dd9003a14a1e9.zip
translatable ConfigSet, by Tero Manninen
Diffstat (limited to 'lib/python/Components/config.py')
-rw-r--r--lib/python/Components/config.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py
index 50103904..1757ef40 100644
--- a/lib/python/Components/config.py
+++ b/lib/python/Components/config.py
@@ -1026,8 +1026,24 @@ class ConfigSubsection(object):
class ConfigSet(ConfigElement):
def __init__(self, choices, default = []):
ConfigElement.__init__(self)
- choices.sort()
- self.choices = choices
+ self.choices = []
+ self.description = {}
+ if isinstance(choices, list):
+ choices.sort()
+ for x in choices:
+ if isinstance(x, tuple):
+ self.choices.append(x[0])
+ self.description[x[0]] = str(x[1])
+ else:
+ self.choices.append(x)
+ self.description[x] = str(x)
+ else:
+ assert False, "ConfigSet choices must be a list!"
+ if len(self.choices) == 0:
+ self.choices = [""]
+ self.description[""] = ""
+ if default is None:
+ default = []
self.pos = -1
default.sort()
self.default = default
@@ -1058,11 +1074,11 @@ class ConfigSet(ConfigElement):
def genString(self, lst):
res = ""
for x in lst:
- res += str(x)+" "
+ res += self.description[x]+" "
return res
def getText(self):
- self.genString(self.value)
+ return self.genString(self.value)
def getMulti(self, selected):
if not selected or self.pos == -1:
@@ -1078,9 +1094,9 @@ class ConfigSet(ConfigElement):
val1 = self.genString(tmp[:ind])
val2 = " "+self.genString(tmp[ind+1:])
if mem:
- chstr = " "+str(ch)+" "
+ chstr = " "+self.description[ch]+" "
else:
- chstr = "("+str(ch)+")"
+ chstr = "("+self.description[ch]+")"
return ("mtext", val1+chstr+val2, range(len(val1),len(val1)+len(chstr)))
def onDeselect(self, session):