X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/81ba8338641aa41e52e498b43aeefa66714819fe..a27631694342ad6f77090743b5affddef5e155e0:/lib/python/Components/config.py diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index cf94614c..b7b3baa8 100644 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -71,19 +71,20 @@ class ConfigElement(object): for x in self.notifiers: x(self) - def addNotifier(self, notifier): + def addNotifier(self, notifier, initial_call = True): assert callable(notifier), "notifiers must be callable" self.notifiers.append(notifier) - + # CHECKME: # do we want to call the notifier - # - at all when adding it? (yes) + # - at all when adding it? (yes, though optional) # - when the default is active? (yes) # - when no value *yet* has been set, # because no config has ever been read (currently yes) # (though that's not so easy to detect. # the entry could just be new.) - notifier(self) + if initial_call: + notifier(self) def disableSave(self): self.save_disabled = True @@ -164,6 +165,13 @@ class ConfigSelection(ConfigElement): def getValue(self): return self._value + def setCurrentText(self, text): + i = self.choices.index(self.value) + del self.description[self.choices[i]] + self.choices[i] = text + self.description[text] = text + self._value = text + value = property(getValue, setValue) def getIndex(self): @@ -420,7 +428,7 @@ class ConfigClock(ConfigSequence): ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = [t.tm_hour, t.tm_min]) class ConfigInteger(ConfigSequence): - def __init__(self, default, limits): + def __init__(self, default, limits = (0, 10000000000)): ConfigSequence.__init__(self, seperator = ":", limits = [limits], default = default) # you need to override this to do input validation @@ -795,7 +803,8 @@ class Config(ConfigSubsection): # we inherit from ConfigSubsection, so ... #object.__setattr__(self, "saved_value", tree["config"]) - self.setSavedValue(tree["config"]) + if "config" in tree: + self.setSavedValue(tree["config"]) def saveToFile(self, filename): f = open(filename, "w") @@ -811,7 +820,7 @@ config = Config() config.misc = ConfigSubsection() class ConfigFile: - CONFIG_FILE = resolveFilename(SCOPE_CONFIG, "config2") + CONFIG_FILE = resolveFilename(SCOPE_CONFIG, "settings") def load(self): try: