fix channelselection in timeredit dialog
[enigma2.git] / lib / python / Components / config.py
index 104e4465ce73eeb9973e82dc379fcf512aeae561..e9c8b1c15207ababdff7f09105ebc6046ce61657 100644 (file)
@@ -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):
@@ -415,7 +423,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):
@@ -491,7 +501,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