X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/6f6514f64e4c769da57acd9c6070bc658c918fe8..b5ca0a1b4676eea8cf2fd9966634cac73bd46e5b:/lib/python/Components/config.py diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 7ab7814b..b16b93e3 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 @@ -382,7 +383,7 @@ class ConfigSequence(ConfigElement): if self.censor_char == "": value += ("%0" + str(len(str(self.limits[num][1]))) + "d") % i else: - value += (self.censorChar * len(str(self.limits[num][1]))) + value += (self.censor_char * len(str(self.limits[num][1]))) num += 1 # only mark cursor when we are selected @@ -415,7 +416,9 @@ class ConfigPosition(ConfigSequence): class ConfigClock(ConfigSequence): def __init__(self, default): - ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = default) + import time + t = time.localtime(default) + ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = [t.tm_hour, t.tm_min]) class ConfigInteger(ConfigSequence): def __init__(self, default, limits): @@ -437,10 +440,16 @@ class ConfigInteger(ConfigSequence): def tostring(self, value): return str(value) -class ConfigPIN(ConfigSequence): +class ConfigPIN(ConfigInteger): def __init__(self, default, len = 4, censor = ""): assert isinstance(default, int), "ConfigPIN default must be an integer" - ConfigSequence.__init__(self, seperator = ":", limits = [(0, (10**len)-1)], censor_char = censor, default = [default]) + if default == -1: + default = "aaaa" + ConfigSequence.__init__(self, seperator = ":", limits = [(0, (10**len)-1)], censor_char = censor, default = default) + self.len = len + + def getLength(self): + return self.len class ConfigFloat(ConfigSequence): def __init__(self, default, limits): @@ -485,7 +494,7 @@ class ConfigText(ConfigElement, NumericalTextInput): self.text = self.text.ljust(len(self.text) + 1) elif key in KEY_NUMBERS: number = self.getKey(getKeyNumber(key)) - self.text = self.text[0:self.marked_pos] + str(number) + self.text[self.marked_pos + 1:] + self.text = self.text[0:self.marked_pos] + unicode(number) + self.text[self.marked_pos + 1:] elif key == KEY_TIMEOUT: self.timeout() return