- add config slider
[enigma2.git] / lib / python / Components / config.py
1 #  temp stuff :)
2 class configBoolean:
3         def __init__(self, reg):
4                 self.reg = reg
5                 self.val = 0
6         
7         def toggle(self):
8                 self.val += 1
9                 self.val %= 3
10         
11         def __str__(self):
12                 return ("NO", "YES", "MAYBE")[self.val]
13
14 class configValue:
15         def __init__(self, obj):
16                 self.obj = obj
17                 
18         def __str__(self):
19                 return self.obj
20
21 def configEntry(obj):
22         # das hier ist ein zugriff auf die registry...
23         if obj == "HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/SDTV/FLASHES/GREEN":
24                 return ("SDTV green flashes", configBoolean(obj))
25         elif obj == "HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/HDTV/FLASHES/GREEN":
26                 return ("HDTV reen flashes", configBoolean(obj))
27         else:
28                 return ("invalid", "")
29
30 class Config:
31         def __init__(self):
32                 pass
33                 
34 config = Config();
35
36 class ConfigSlider:
37         def __init__(self, parent):
38                 self.parent = parent
39                 self.val = parent.value
40         def handleKey(self, key):
41                 if key == 1:
42                         self.val = self.val - 1
43                 if key == 2:
44                         self.val = self.val + 1
45                         
46                 if self.val < 0:
47                         self.val = 0    
48
49                 if self.val > 10:
50                         self.val = 10   
51         
52         def __call__(self):                     #needed by configlist
53                 return ("slider", self.val * 10)
54
55 class ConfigSubsection:
56         def __init__(self):
57                 pass
58
59 class configElement:
60         def __init__(self, configPath, control, defaultValue):
61                 self.configPath = configPath
62                 self.value = 0  #read from registry else use default
63                 self.controlType = control
64                 self.notifierList = [ ]
65         def addNotifier(self, notifier):
66                 self.notifierList.append(notifier);
67                 notifier(self);