configBoolean is now configSelection
[enigma2.git] / lib / python / Components / config.py
index 14c03655e8d702aac685ed0960c6a2420524d350..1795d426d7ca13aa0f93fe370c3c03ad187b0ab7 100644 (file)
@@ -47,7 +47,7 @@ class configFile:
 
                fileHandle.close()              
 
-class configBoolean:
+class configSelection:
        def __init__(self, parent):
                self.parent = parent
                
@@ -81,15 +81,17 @@ class configBoolean:
 class configSequence:
        def __init__(self, parent):
                self.parent = parent
+               self.markedPos = 0
                
        def checkValues(self):
-               pass
-#              if self.parent.value < 0:
-#                      self.parent.value = 0   
-#
-#              if(self.parent.value >= (len(self.parent.vals) - 1)):
-#                      self.parent.value = len(self.parent.vals) - 1
-#
+               maxPos = len(self.parent.value) * self.parent.vals[1] 
+               print maxPos
+                       
+               if self.markedPos >= maxPos:
+                       self.markedPos = maxPos - 1
+               if self.markedPos < 0:
+                       self.markedPos = 0
+                       
        def cancel(self):
                self.parent.reload()
 
@@ -97,21 +99,37 @@ class configSequence:
                self.parent.save()
 
        def handleKey(self, key):
+               #this will no change anything on the value itself
+               #so we can handle it here in gui element
                if key == config.prevElement:
-                       self.parent.value = self.parent.value - 1
+                       self.markedPos -= 1
                if key == config.nextElement:
-                       self.parent.value = self.parent.value + 1
+                       self.markedPos += 1
                
                self.checkValues()                      
+               
+               print "markPos:",
+               print self.markedPos
 
+               #FIXME: dont call when press left/right
                self.parent.change()    
 
        def __call__(self):                     #needed by configlist
                value = ""
+               mPos = self.markedPos
+               print mPos
                for i in self.parent.value:
-                       if (value != ""):
+                       if value != "": #fixme no heading separator possible
                                value += self.parent.vals[0]
-                       value += str(i)
+                               if mPos >= len(value) - 1:
+                                       mPos += 1
+                               
+                       diff =  self.parent.vals[1] - len(str(i))
+                       if diff > 0:
+                               value += " " * diff
+                       value +=        str(i)
+               
+               value = value[0:mPos] + "_" + value[mPos + 1:]
                return ("text", value)
 
 class configValue:
@@ -168,16 +186,29 @@ class configElement:
        def datafromFile(self, control, data):
                if control == ConfigSlider:
                        return int(data);
-               elif control == configBoolean:
+               elif control == configSelection:
                        return int(data);
+               elif control == configSequence:
+                       list = [ ]
+                       part = data.split(self.vals[0])
+                       for x in part:
+                               list.append(int(x))
+                       return list
                else: 
                        return ""       
 
        def datatoFile(self, control, data):
                if control == ConfigSlider:
                        return str(data);
-               elif control == configBoolean:
+               elif control == configSelection:
                        return str(data);
+               elif control == configSequence:
+                       value = ""
+                       for i in data:
+                               if value !="":
+                                       value += self.vals[0]
+                               value += str(i)
+                       return value
                else: 
                        return ""       
 
@@ -200,6 +231,7 @@ class configElement:
                self.controlType = control
                self.vals = vals
                self.notifierList = [ ]
+               self.enabled = True
                self.loadData()         
        def addNotifier(self, notifier):
                self.notifierList.append(notifier);