X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/e635b7a6b5ba34a299c952833bff5158d6c09fad..f3f5c94e2c2da033c5ddc9b27372221087911fd8:/lib/python/Components/config.py diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index f8e8fd13..0d1489aa 100644 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -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 :-)