fix off-by-one error on the progress and fix vars in ToolExistsPrecondition
[enigma2.git] / lib / python / Components / config.py
index 59fb725599c572048b6d5269fd36a55807943de4..b0f5fe6d9ed13de26096777b25ad61bae5414b15 100644 (file)
@@ -363,11 +363,11 @@ class ConfigSequence(ConfigElement):
                for i in self._value:
                        max_pos += len(str(self.limits[num][1]))
 
                for i in self._value:
                        max_pos += len(str(self.limits[num][1]))
 
-                       while self._value[num] < self.limits[num][0]:
-                               self._value[num] += 1
+                       if self._value[num] < self.limits[num][0]:
+                               self._value[num] = self.limits[num][0]
 
 
-                       while self._value[num] > self.limits[num][1]:
-                               self._value[num] -= 1
+                       if self._value[num] > self.limits[num][1]:
+                               self._value[num] = self.limits[num][1]
 
                        num += 1
 
 
                        num += 1
 
@@ -517,7 +517,7 @@ class ConfigClock(ConfigSequence):
                ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = [t.tm_hour, t.tm_min])
 
 class ConfigInteger(ConfigSequence):
                ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = [t.tm_hour, t.tm_min])
 
 class ConfigInteger(ConfigSequence):
-       def __init__(self, default, limits = (0, 10000000000)):
+       def __init__(self, default, limits = (0, 9999999999)):
                ConfigSequence.__init__(self, seperator = ":", limits = [limits], default = default)
        
        # you need to override this to do input validation
                ConfigSequence.__init__(self, seperator = ":", limits = [limits], default = default)
        
        # you need to override this to do input validation
@@ -1005,10 +1005,10 @@ class ConfigSubsection(object):
                values = dict(values)
                
                self.content.stored_values = values
                values = dict(values)
                
                self.content.stored_values = values
-               
+
                for (key, val) in self.content.items.items():
                        if key in values:
                for (key, val) in self.content.items.items():
                        if key in values:
-                               val.setSavedValue(values[key])
+                               val.saved_value = values[key]
 
        saved_value = property(getSavedValue, setSavedValue)
 
 
        saved_value = property(getSavedValue, setSavedValue)
 
@@ -1026,8 +1026,24 @@ class ConfigSubsection(object):
 class ConfigSet(ConfigElement):
        def __init__(self, choices, default = []):
                ConfigElement.__init__(self)
 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
                self.pos = -1
                default.sort()
                self.default = default
@@ -1058,11 +1074,11 @@ class ConfigSet(ConfigElement):
        def genString(self, lst):
                res = ""
                for x in lst:
        def genString(self, lst):
                res = ""
                for x in lst:
-                       res += str(x)+" "
+                       res += self.description[x]+" "
                return res
 
        def getText(self):
                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:
 
        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:
                        val1 = self.genString(tmp[:ind])
                        val2 = " "+self.genString(tmp[ind+1:])
                        if mem:
-                               chstr = " "+str(ch)+" "
+                               chstr = " "+self.description[ch]+" "
                        else:
                        else:
-                               chstr = "("+str(ch)+")"
+                               chstr = "("+self.description[ch]+")"
                        return ("mtext", val1+chstr+val2, range(len(val1),len(val1)+len(chstr)))
 
        def onDeselect(self, session):
                        return ("mtext", val1+chstr+val2, range(len(val1),len(val1)+len(chstr)))
 
        def onDeselect(self, session):