add missing Network.py
[enigma2.git] / lib / python / Components / config.py
index f8e8fd13a390dec039555628cc10890be1a83812..0d1489aa800b01d1e29362a2b2679a30676be479 100644 (file)
@@ -1,15 +1,35 @@
 #  temp stuff :)
 class configBoolean:
-       def __init__(self, reg):
-               self.reg = reg
-               self.val = 0
-       
-       def toggle(self):
-               self.val += 1
-               self.val %= 3
+       def __init__(self, parent):
+               self.parent = parent
+               
+       def checkValues(self):
+               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):
+               print "cancel"
+
+       def save(self):
+               print "save"
+
+       def handleKey(self, key):
+               if key == 1:
+                       self.parent.value = self.parent.value - 1
+               if key == 2:
+                       self.parent.value = self.parent.value + 1
+               
+               self.checkValues()                      
+
+               self.parent.change()    
+
+       def __call__(self):                     #needed by configlist
+               self.checkValues()                      
        
-       def __str__(self):
-               return ("NO", "YES", "MAYBE")[self.val]
+               return ("text", self.parent.vals[self.parent.value])
 
 class configValue:
        def __init__(self, obj):
@@ -30,29 +50,57 @@ def configEntry(obj):
 class Config:
        def __init__(self):
                pass
-       def Slider(self,reg):            # ok???
-               pass    
-       def getControlType(self, reg):
-               print "getControlType " + reg
-
-               #find the correct type in class-members
-               if reg == "blasel":
-                       return configBoolean(reg)
-
-               return configBoolean(reg)
                
 config = Config();
 
+class ConfigSlider:
+       def __init__(self, parent):
+               self.parent = parent
+
+       def cancel(self):
+               print "slider - cancel"
+
+       def save(self):
+               print "slider - save"
+
+       def checkValues(self):
+               if self.parent.value < 0:
+                       self.parent.value = 0   
+
+               if self.parent.value > 10:
+                       self.parent.value = 10  
+
+       def handleKey(self, key):
+               if key == 1:
+                       self.parent.value = self.parent.value - 1
+               if key == 2:
+                       self.parent.value = self.parent.value + 1
+                                       
+               self.checkValues()      
+               self.parent.change()    
+
+       def __call__(self):                     #needed by configlist
+               self.checkValues()      
+               return ("slider", self.parent.value * 10)
+
 class ConfigSubsection:
        def __init__(self):
                pass
 
 class configElement:
-       def __init__(self, configPath, control, defaultValue):
+       def __init__(self, configPath, control, defaultValue, vals):
                self.configPath = configPath
-               self.value = 0  #read from registry else use default
+#              self.value = 0  #read from registry else use default
+               self.value = defaultValue       #read from registry else use default
+               self.defaultValue = defaultValue
                self.controlType = control
+               self.vals = vals
                self.notifierList = [ ]
        def addNotifier(self, notifier):
                self.notifierList.append(notifier);
                notifier(self);
+       def change(self):
+               for notifier in self.notifierList:
+                       notifier(self)
+       def reload(self):
+               self.value = self.defaultValue  #HACK :-)