show hdd capacity in aboutbox
[enigma2.git] / lib / python / Components / config.py
index 7419eff54f2177319a37e70f88b8d73ed3ab8e0c..14c03655e8d702aac685ed0960c6a2420524d350 100644 (file)
@@ -12,6 +12,10 @@ class configFile:
                        line = self.file.readline()
                        if line == "":
                                break
+                       
+                       if line.startswith("#"):                #skip comments
+                               continue        
+                               
                        self.addElement(line)
                self.file.close()
 
@@ -38,10 +42,6 @@ class configFile:
                        
                        if wstr[len(wstr) - 1] != '\n':
                                wstr = wstr + "\n"
-                       
-                       #       fileHandle.write(wstr)
-                       #else:
-                       #       fileHandle.write(wstr + "\n")
 
                        fileHandle.write(wstr)
 
@@ -65,9 +65,9 @@ class configBoolean:
                self.parent.save()
 
        def handleKey(self, key):
-               if key == 1:
+               if key == config.prevElement:
                        self.parent.value = self.parent.value - 1
-               if key == 2:
+               if key == config.nextElement:
                        self.parent.value = self.parent.value + 1
                
                self.checkValues()                      
@@ -77,6 +77,42 @@ class configBoolean:
        def __call__(self):                     #needed by configlist
                self.checkValues()                      
                return ("text", self.parent.vals[self.parent.value])
+               
+class configSequence:
+       def __init__(self, parent):
+               self.parent = parent
+               
+       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
+#
+       def cancel(self):
+               self.parent.reload()
+
+       def save(self):
+               self.parent.save()
+
+       def handleKey(self, key):
+               if key == config.prevElement:
+                       self.parent.value = self.parent.value - 1
+               if key == config.nextElement:
+                       self.parent.value = self.parent.value + 1
+               
+               self.checkValues()                      
+
+               self.parent.change()    
+
+       def __call__(self):                     #needed by configlist
+               value = ""
+               for i in self.parent.value:
+                       if (value != ""):
+                               value += self.parent.vals[0]
+                       value += str(i)
+               return ("text", value)
 
 class configValue:
        def __init__(self, obj):
@@ -87,8 +123,10 @@ class configValue:
 
 class Config:
        def __init__(self):
-               pass
-               
+               self.choseElement = 0
+               self.prevElement = 1
+               self.nextElement = 2
+                                               
 config = Config();
 configfile = configFile()
 
@@ -110,9 +148,9 @@ class ConfigSlider:
                        self.parent.value = 10  
 
        def handleKey(self, key):
-               if key == 1:
+               if key == config.prevElement:
                        self.parent.value = self.parent.value - 1
-               if key == 2:
+               if key == config.nextElement:
                        self.parent.value = self.parent.value + 1
                                        
                self.checkValues()      
@@ -155,7 +193,6 @@ class configElement:
                        self.save()             #add missing value to dict
                else:
                        self.value = value
-                       print "value ok"
 
        def __init__(self, configPath, control, defaultValue, vals):
                self.configPath = configPath