From d1f483f0b06bbc16dc399972e8a124ee7d40f9c2 Mon Sep 17 00:00:00 2001 From: simon04 Date: Sat, 4 Jun 2011 23:55:22 +0200 Subject: [PATCH] Watch for gsetting changes and update accordingly. --- src/extension.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/extension.js b/src/extension.js index a38cfcb..30a8f29 100644 --- a/src/extension.js +++ b/src/extension.js @@ -82,6 +82,27 @@ WeatherMenuButton.prototype = { this._translate_condition = this._settings.get_boolean(WEATHER_TRANSLATE_CONDITION_KEY); this._icontype = this._settings.get_boolean(WEATHER_SYMBOLIC_ICONS) ? St.IconType.SYMBOLIC : St.IconType.FULLCOLOR; + // Watch settings for changes + let load_settings_and_refresh_weather = Lang.bind(this, function() { + this._units = this._settings.get_enum(WEATHER_UNIT_KEY); + this._city = this._settings.get_string(WEATHER_CITY_KEY); + this._woeid = this._settings.get_string(WEATHER_WOEID_KEY); + this._translate_condition = this._settings.get_boolean(WEATHER_TRANSLATE_CONDITION_KEY); + this._icontype = this._settings.get_boolean(WEATHER_SYMBOLIC_ICONS) ? St.IconType.SYMBOLIC : St.IconType.FULLCOLOR; + this.refreshWeather(); + }); + this._settings.connect('changed::' + WEATHER_UNIT_KEY, load_settings_and_refresh_weather); + this._settings.connect('changed::' + WEATHER_CITY_KEY, load_settings_and_refresh_weather); + this._settings.connect('changed::' + WEATHER_WOEID_KEY, load_settings_and_refresh_weather); + this._settings.connect('changed::' + WEATHER_TRANSLATE_CONDITION_KEY, load_settings_and_refresh_weather); + this._settings.connect('changed::' + WEATHER_SYMBOLIC_ICONS, Lang.bind(this, function() { + this._icontype = this._settings.get_boolean(WEATHER_SYMBOLIC_ICONS) ? St.IconType.SYMBOLIC : St.IconType.FULLCOLOR; + this._weatherIcon.icon_type = this._icontype; + this._currentWeatherIcon.icon_type = this._icontype; + this._forecast[0].Icon.icon_type = this._icontype; + this._forecast[1].Icon.icon_type = this._icontype; + })); + // Panel icon this._weatherIcon = new St.Icon({ icon_type: this._icontype,