add optional addNotifier(initial_call=False)-support
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 9 Oct 2006 21:48:04 +0000 (21:48 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 9 Oct 2006 21:48:04 +0000 (21:48 +0000)
lib/python/Components/config.py
lib/python/Plugins/SystemPlugins/Satfinder/plugin.py

index cf94614ce56ca7cfacfe6e30ed8bb2a98c45e366..b16b93e343fb65596a52606640eb9b0fa58331aa 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
index 06a0f3fb8468f7960b1c122ce2751e55422bddeb..b8f380d3d80e986c6f78c031a54a42c719a56cc8 100644 (file)
@@ -175,13 +175,13 @@ class Satfinder(ScanSetup):
                
                self.updateSats()
 
-               self.tuning_type.addNotifier(self.retune)
-               self.tuning_sat.addNotifier(self.sat_changed)
-               self.scan_sat.frequency.addNotifier(self.retune)
-               self.scan_sat.inversion.addNotifier(self.retune)
-               self.scan_sat.symbolrate.addNotifier(self.retune)
-               self.scan_sat.polarization.addNotifier(self.retune)
-               self.scan_sat.fec.addNotifier(self.retune)
+               self.tuning_type.addNotifier(self.retune, initial_call = False)
+               self.tuning_sat.addNotifier(self.sat_changed, initial_call = False)
+               self.scan_sat.frequency.addNotifier(self.retune, initial_call = False)
+               self.scan_sat.inversion.addNotifier(self.retune, initial_call = False)
+               self.scan_sat.symbolrate.addNotifier(self.retune, initial_call = False)
+               self.scan_sat.polarization.addNotifier(self.retune, initial_call = False)
+               self.scan_sat.fec.addNotifier(self.retune, initial_call = False)
 
        def updateSats(self):
                orb_pos = self.tuning_sat.orbital_position
@@ -215,7 +215,7 @@ class Satfinder(ScanSetup):
                                        fec = "FEC_None"
                                list.append(str(x[1]) + "," + str(x[2]) + "," + pol + "," + fec)
                        self.tuning_transponder = ConfigSelection(choices = list)
-                       self.tuning_transponder.addNotifier(self.retune)
+                       self.tuning_transponder.addNotifier(self.retune, initial_call = False)
        
        def keyGo(self):
                self.retune(self.tuning_type)