X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/aa3e781f31a04223416f0a34b25ab95fc0bef429..58f644a3102613e874ecc0faf999da16c353f264:/lib/python/Components/config.py diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 5d582abb..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): @@ -27,3 +47,60 @@ def configEntry(obj): else: return ("invalid", "") +class Config: + def __init__(self): + pass + +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, vals): + self.configPath = configPath +# 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 :-)