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