From 39fa811374b7119173120175e70fb4f197bc0aba Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 18 Jun 2013 20:37:04 +0200 Subject: Trigger config_change handlers when the config has changed using a USR1 signal --- src/core.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index 9e12ba03..9476bd42 100644 --- a/src/core.py +++ b/src/core.py @@ -370,7 +370,18 @@ class Core(object): log.debug("Theme reloaded.") # reload the config from the disk log.debug("Reloading the config…") - config.__init__(config.file_name) + # Copy the old config in a dict + old_config = config.to_dict() + config.read_file(config.file_name) + # Compare old and current config, to trigger the callbacks of all + # modified options + for section in config.sections(): + old_section = old_config.get(section, {}) + for option in config.options(section): + old_value = old_section.get(option) + new_value = config.get(option, "", section) + if new_value != old_value: + self.trigger_configuration_change(option, new_value) log.debug("Config reloaded.") # in case some roster options have changed roster.modified() -- cgit v1.2.3