From f644ef0dd1884b595b7fed90873ffe7b4908190d Mon Sep 17 00:00:00 2001 From: None Date: Sun, 12 Apr 2015 23:32:35 +0200 Subject: [PATCH] Rename constants from WEATHER_* to OPENWEATHER_* (cosmetical fix). --- src/extension.js | 146 +++++++++++++++++++------------------- src/forecast_io.js | 6 +- src/openweathermap_org.js | 12 ++-- src/prefs.js | 138 +++++++++++++++++------------------ 4 files changed, 151 insertions(+), 151 deletions(-) diff --git a/src/extension.js b/src/extension.js index 22c9028..37e0e4c 100644 --- a/src/extension.js +++ b/src/extension.js @@ -57,28 +57,28 @@ const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; // Settings -const WEATHER_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.openweather'; -const WEATHER_PROVIDER_KEY = 'weather-provider'; -const WEATHER_UNIT_KEY = 'unit'; -const WEATHER_WIND_SPEED_UNIT_KEY = 'wind-speed-unit'; -const WEATHER_WIND_DIRECTION_KEY = 'wind-direction'; -const WEATHER_PRESSURE_UNIT_KEY = 'pressure-unit'; -const WEATHER_CITY_KEY = 'city'; -const WEATHER_ACTUAL_CITY_KEY = 'actual-city'; -const WEATHER_TRANSLATE_CONDITION_KEY = 'translate-condition'; -const WEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons'; -const WEATHER_USE_TEXT_ON_BUTTONS_KEY = 'use-text-on-buttons'; -const WEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel'; -const WEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel'; -const WEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; -const WEATHER_SHOW_COMMENT_IN_FORECAST_KEY = 'show-comment-in-forecast'; -const WEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current'; -const WEATHER_REFRESH_INTERVAL_FORECAST = 'refresh-interval-forecast'; -const WEATHER_CENTER_FORECAST_KEY = 'center-forecast'; -const WEATHER_DAYS_FORECAST = 'days-forecast'; -const WEATHER_DECIMAL_PLACES = 'decimal-places'; -const WEATHER_OWM_API_KEY = 'appid'; -const WEATHER_FC_API_KEY = 'appid-fc'; +const OPENWEATHER_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.openweather'; +const OPENWEATHER_PROVIDER_KEY = 'weather-provider'; +const OPENWEATHER_UNIT_KEY = 'unit'; +const OPENWEATHER_WIND_SPEED_UNIT_KEY = 'wind-speed-unit'; +const OPENWEATHER_WIND_DIRECTION_KEY = 'wind-direction'; +const OPENWEATHER_PRESSURE_UNIT_KEY = 'pressure-unit'; +const OPENWEATHER_CITY_KEY = 'city'; +const OPENWEATHER_ACTUAL_CITY_KEY = 'actual-city'; +const OPENWEATHER_TRANSLATE_CONDITION_KEY = 'translate-condition'; +const OPENWEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons'; +const OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY = 'use-text-on-buttons'; +const OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel'; +const OPENWEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel'; +const OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; +const OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY = 'show-comment-in-forecast'; +const OPENWEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current'; +const OPENWEATHER_REFRESH_INTERVAL_FORECAST = 'refresh-interval-forecast'; +const OPENWEATHER_CENTER_FORECAST_KEY = 'center-forecast'; +const OPENWEATHER_DAYS_FORECAST = 'days-forecast'; +const OPENWEATHER_DECIMAL_PLACES = 'decimal-places'; +const OPENWEATHER_OWM_API_KEY = 'appid'; +const OPENWEATHER_FC_API_KEY = 'appid-fc'; // Keep enums in sync with GSettings schemas const WeatherProvider = { @@ -124,10 +124,10 @@ const WeatherPosition = { LEFT: 2 }; -const WEATHER_CONV_MPS_IN_MPH = 2.23693629; -const WEATHER_CONV_MPS_IN_KPH = 3.6; -const WEATHER_CONV_MPS_IN_KNOTS = 1.94384449; -const WEATHER_CONV_MPS_IN_FPS = 3.2808399; +const OPENWEATHER_CONV_MPS_IN_MPH = 2.23693629; +const OPENWEATHER_CONV_MPS_IN_KPH = 3.6; +const OPENWEATHER_CONV_MPS_IN_KNOTS = 1.94384449; +const OPENWEATHER_CONV_MPS_IN_FPS = 3.2808399; let _httpSession; @@ -348,7 +348,7 @@ const OpenweatherMenuButton = new Lang.Class({ }, loadConfig: function() { - this._settings = Convenience.getSettings(WEATHER_SETTINGS_SCHEMA); + this._settings = Convenience.getSettings(OPENWEATHER_SETTINGS_SCHEMA); if (this._cities.length === 0) this._cities = "-8.5211767,179.1976747>Vaiaku, Tuvalu"; @@ -439,79 +439,79 @@ const OpenweatherMenuButton = new Lang.Class({ get _weather_provider() { if (!this._settings) this.loadConfig(); - return this._settings.get_enum(WEATHER_PROVIDER_KEY); + return this._settings.get_enum(OPENWEATHER_PROVIDER_KEY); }, set _weather_provider(v) { if (!this._settings) this.loadConfig(); - this._settings.set_enum(WEATHER_PROVIDER_KEY, v); + this._settings.set_enum(OPENWEATHER_PROVIDER_KEY, v); }, get _units() { if (!this._settings) this.loadConfig(); - return this._settings.get_enum(WEATHER_UNIT_KEY); + return this._settings.get_enum(OPENWEATHER_UNIT_KEY); }, set _units(v) { if (!this._settings) this.loadConfig(); - this._settings.set_enum(WEATHER_UNIT_KEY, v); + this._settings.set_enum(OPENWEATHER_UNIT_KEY, v); }, get _wind_speed_units() { if (!this._settings) this.loadConfig(); - return this._settings.get_enum(WEATHER_WIND_SPEED_UNIT_KEY); + return this._settings.get_enum(OPENWEATHER_WIND_SPEED_UNIT_KEY); }, set _wind_speed_units(v) { if (!this._settings) this.loadConfig(); - this._settings.set_enum(WEATHER_WIND_SPEED_UNIT_KEY, v); + this._settings.set_enum(OPENWEATHER_WIND_SPEED_UNIT_KEY, v); }, get _wind_direction() { if (!this._settings) this.loadConfig(); - return this._settings.get_boolean(WEATHER_WIND_DIRECTION_KEY); + return this._settings.get_boolean(OPENWEATHER_WIND_DIRECTION_KEY); }, set _wind_direction(v) { if (!this._settings) this.loadConfig(); - return this._settings.set_boolean(WEATHER_WIND_DIRECTION_KEY, v); + return this._settings.set_boolean(OPENWEATHER_WIND_DIRECTION_KEY, v); }, get _pressure_units() { if (!this._settings) this.loadConfig(); - return this._settings.get_enum(WEATHER_PRESSURE_UNIT_KEY); + return this._settings.get_enum(OPENWEATHER_PRESSURE_UNIT_KEY); }, set _pressure_units(v) { if (!this._settings) this.loadConfig(); - this._settings.set_enum(WEATHER_PRESSURE_UNIT_KEY, v); + this._settings.set_enum(OPENWEATHER_PRESSURE_UNIT_KEY, v); }, get _cities() { if (!this._settings) this.loadConfig(); - return this._settings.get_string(WEATHER_CITY_KEY); + return this._settings.get_string(OPENWEATHER_CITY_KEY); }, set _cities(v) { if (!this._settings) this.loadConfig(); - this._settings.set_string(WEATHER_CITY_KEY, v); + this._settings.set_string(OPENWEATHER_CITY_KEY, v); }, get _actual_city() { if (!this._settings) this.loadConfig(); - var a = this._settings.get_int(WEATHER_ACTUAL_CITY_KEY); + var a = this._settings.get_int(OPENWEATHER_ACTUAL_CITY_KEY); var b = a; var cities = this._cities.split(" && "); @@ -551,7 +551,7 @@ const OpenweatherMenuButton = new Lang.Class({ if (a > l) a = l; - this._settings.set_int(WEATHER_ACTUAL_CITY_KEY, a); + this._settings.set_int(OPENWEATHER_ACTUAL_CITY_KEY, a); }, get _city() { @@ -582,173 +582,173 @@ const OpenweatherMenuButton = new Lang.Class({ get _translate_condition() { if (!this._settings) this.loadConfig(); - return this._settings.get_boolean(WEATHER_TRANSLATE_CONDITION_KEY); + return this._settings.get_boolean(OPENWEATHER_TRANSLATE_CONDITION_KEY); }, set _translate_condition(v) { if (!this._settings) this.loadConfig(); - this._settings.set_boolean(WEATHER_TRANSLATE_CONDITION_KEY, v); + this._settings.set_boolean(OPENWEATHER_TRANSLATE_CONDITION_KEY, v); }, get _getIconType() { if (!this._settings) this.loadConfig(); - return this._settings.get_boolean(WEATHER_USE_SYMBOLIC_ICONS_KEY) ? 1 : 0; + return this._settings.get_boolean(OPENWEATHER_USE_SYMBOLIC_ICONS_KEY) ? 1 : 0; }, set _getIconType(v) { if (!this._settings) this.loadConfig(); - this._settings.set_boolean(WEATHER_USE_SYMBOLIC_ICONS_KEY, v); + this._settings.set_boolean(OPENWEATHER_USE_SYMBOLIC_ICONS_KEY, v); }, get _use_text_on_buttons() { if (!this._settings) this.loadConfig(); - return this._settings.get_boolean(WEATHER_USE_TEXT_ON_BUTTONS_KEY) ? 1 : 0; + return this._settings.get_boolean(OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY) ? 1 : 0; }, set _use_text_on_buttons(v) { if (!this._settings) this.loadConfig(); - this._settings.set_boolean(WEATHER_USE_TEXT_ON_BUTTONS_KEY, v); + this._settings.set_boolean(OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY, v); }, get _text_in_panel() { if (!this._settings) this.loadConfig(); - return this._settings.get_boolean(WEATHER_SHOW_TEXT_IN_PANEL_KEY); + return this._settings.get_boolean(OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY); }, set _text_in_panel(v) { if (!this._settings) this.loadConfig(); - this._settings.set_boolean(WEATHER_SHOW_TEXT_IN_PANEL_KEY, v); + this._settings.set_boolean(OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY, v); }, get _position_in_panel() { if (!this._settings) this.loadConfig(); - return this._settings.get_enum(WEATHER_POSITION_IN_PANEL_KEY); + return this._settings.get_enum(OPENWEATHER_POSITION_IN_PANEL_KEY); }, set _position_in_panel(v) { if (!this._settings) this.loadConfig(); - this._settings.set_enum(WEATHER_POSITION_IN_PANEL_KEY, v); + this._settings.set_enum(OPENWEATHER_POSITION_IN_PANEL_KEY, v); }, get _comment_in_panel() { if (!this._settings) this.loadConfig(); - return this._settings.get_boolean(WEATHER_SHOW_COMMENT_IN_PANEL_KEY); + return this._settings.get_boolean(OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY); }, set _comment_in_panel(v) { if (!this._settings) this.loadConfig(); - this._settings.set_boolean(WEATHER_SHOW_COMMENT_IN_PANEL_KEY, v); + this._settings.set_boolean(OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY, v); }, get _comment_in_forecast() { if (!this._settings) this.loadConfig(); - return this._settings.get_boolean(WEATHER_SHOW_COMMENT_IN_FORECAST_KEY); + return this._settings.get_boolean(OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY); }, set _comment_in_forecast(v) { if (!this._settings) this.loadConfig(); - this._settings.set_boolean(WEATHER_SHOW_COMMENT_IN_FORECAST_KEY, v); + this._settings.set_boolean(OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY, v); }, get _refresh_interval_current() { if (!this._settings) this.loadConfig(); - let v = this._settings.get_int(WEATHER_REFRESH_INTERVAL_CURRENT); + let v = this._settings.get_int(OPENWEATHER_REFRESH_INTERVAL_CURRENT); return ((v >= 600) ? v : 600); }, set _refresh_interval_current(v) { if (!this._settings) this.loadConfig(); - this._settings.set_int(WEATHER_REFRESH_INTERVAL_CURRENT, ((v >= 600) ? v : 600)); + this._settings.set_int(OPENWEATHER_REFRESH_INTERVAL_CURRENT, ((v >= 600) ? v : 600)); }, get _refresh_interval_forecast() { if (!this._settings) this.loadConfig(); - let v = this._settings.get_int(WEATHER_REFRESH_INTERVAL_FORECAST); + let v = this._settings.get_int(OPENWEATHER_REFRESH_INTERVAL_FORECAST); return ((v >= 600) ? v : 600); }, set _refresh_interval_forecast(v) { if (!this._settings) this.loadConfig(); - this._settings.set_int(WEATHER_REFRESH_INTERVAL_FORECAST, ((v >= 600) ? v : 600)); + this._settings.set_int(OPENWEATHER_REFRESH_INTERVAL_FORECAST, ((v >= 600) ? v : 600)); }, get _center_forecast() { if (!this._settings) this.loadConfig(); - return this._settings.get_boolean(WEATHER_CENTER_FORECAST_KEY); + return this._settings.get_boolean(OPENWEATHER_CENTER_FORECAST_KEY); }, set _center_forecast(v) { if (!this._settings) this.loadConfig(); - this._settings.set_boolean(WEATHER_CENTER_FORECAST_KEY, v); + this._settings.set_boolean(OPENWEATHER_CENTER_FORECAST_KEY, v); }, get _days_forecast() { if (!this._settings) this.loadConfig(); - return this._settings.get_int(WEATHER_DAYS_FORECAST); + return this._settings.get_int(OPENWEATHER_DAYS_FORECAST); }, set _days_forecast(v) { if (!this._settings) this.loadConfig(); - this._settings.set_int(WEATHER_DAYS_FORECAST, v); + this._settings.set_int(OPENWEATHER_DAYS_FORECAST, v); }, get _decimal_places() { if (!this._settings) this.loadConfig(); - return this._settings.get_int(WEATHER_DECIMAL_PLACES); + return this._settings.get_int(OPENWEATHER_DECIMAL_PLACES); }, set _decimal_places(v) { if (!this._settings) this.loadConfig(); - this._settings.set_int(WEATHER_DECIMAL_PLACES, v); + this._settings.set_int(OPENWEATHER_DECIMAL_PLACES, v); }, get _appid() { if (!this._settings) this.loadConfig(); - let key = this._settings.get_string(WEATHER_OWM_API_KEY); + let key = this._settings.get_string(OPENWEATHER_OWM_API_KEY); return (key.length == 32) ? key : ''; }, set _appid(v) { if (!this._settings) this.loadConfig(); - this._settings.set_string(WEATHER_OWM_API_KEY, v); + this._settings.set_string(OPENWEATHER_OWM_API_KEY, v); }, get _appid_fc() { if (!this._settings) this.loadConfig(); - let key = this._settings.get_string(WEATHER_FC_API_KEY); + let key = this._settings.get_string(OPENWEATHER_FC_API_KEY); return (key.length == 32) ? key : ''; }, set _appid_fc(v) { if (!this._settings) this.loadConfig(); - this._settings.set_string(WEATHER_FC_API_KEY, v); + this._settings.set_string(OPENWEATHER_FC_API_KEY, v); }, _onButtonHoverChanged: function(actor, event) { @@ -1242,12 +1242,12 @@ const OpenweatherMenuButton = new Lang.Class({ let unit = 'm/s'; switch (this._wind_speed_units) { case WeatherWindSpeedUnits.MPH: - speed = (speed * WEATHER_CONV_MPS_IN_MPH).toFixed(this._decimal_places); + speed = (speed * OPENWEATHER_CONV_MPS_IN_MPH).toFixed(this._decimal_places); unit = 'mph'; break; case WeatherWindSpeedUnits.KPH: - speed = (speed * WEATHER_CONV_MPS_IN_KPH).toFixed(this._decimal_places); + speed = (speed * OPENWEATHER_CONV_MPS_IN_KPH).toFixed(this._decimal_places); unit = 'km/h'; break; @@ -1256,12 +1256,12 @@ const OpenweatherMenuButton = new Lang.Class({ break; case WeatherWindSpeedUnits.KNOTS: - speed = (speed * WEATHER_CONV_MPS_IN_KNOTS).toFixed(this._decimal_places); + speed = (speed * OPENWEATHER_CONV_MPS_IN_KNOTS).toFixed(this._decimal_places); unit = 'kn'; break; case WeatherWindSpeedUnits.FPS: - speed = (speed * WEATHER_CONV_MPS_IN_FPS).toFixed(this._decimal_places); + speed = (speed * OPENWEATHER_CONV_MPS_IN_FPS).toFixed(this._decimal_places); unit = 'ft/s'; break; diff --git a/src/forecast_io.js b/src/forecast_io.js index d240c0a..f75445e 100644 --- a/src/forecast_io.js +++ b/src/forecast_io.js @@ -41,8 +41,8 @@ const Gettext = imports.gettext.domain('gnome-shell-extension-openweather'); const _ = Gettext.gettext; -const WEATHER_URL_HOST = 'api.forecast.io'; -const WEATHER_URL_BASE = 'http://' + WEATHER_URL_HOST + '/forecast/'; +const OPENWEATHER_URL_HOST = 'api.forecast.io'; +const OPENWEATHER_URL_BASE = 'http://' + OPENWEATHER_URL_HOST + '/forecast/'; function getWeatherIcon(icon) { // clear-day weather-clear-day @@ -175,7 +175,7 @@ function refreshWeatherCurrent() { lang: this.fc_locale, units: 'si' }; - let url = WEATHER_URL_BASE + this._appid_fc + '/' + this.oldLocation; + let url = OPENWEATHER_URL_BASE + this._appid_fc + '/' + this.oldLocation; this.load_json_async(url, params, function(json) { if (json && json.currently) { diff --git a/src/openweathermap_org.js b/src/openweathermap_org.js index 3059f90..ce04481 100644 --- a/src/openweathermap_org.js +++ b/src/openweathermap_org.js @@ -41,10 +41,10 @@ const OpenweathermapOrg = Me.imports.openweathermap_org; const Gettext = imports.gettext.domain('gnome-shell-extension-openweather'); const _ = Gettext.gettext; -const WEATHER_URL_HOST = 'api.openweathermap.org'; -const WEATHER_URL_BASE = 'http://' + WEATHER_URL_HOST + '/data/2.5/'; -const WEATHER_URL_CURRENT = WEATHER_URL_BASE + 'weather'; -const WEATHER_URL_FORECAST = WEATHER_URL_BASE + 'forecast/daily'; +const OPENWEATHER_URL_HOST = 'api.openweathermap.org'; +const OPENWEATHER_URL_BASE = 'http://' + OPENWEATHER_URL_HOST + '/data/2.5/'; +const OPENWEATHER_URL_CURRENT = OPENWEATHER_URL_BASE + 'weather'; +const OPENWEATHER_URL_FORECAST = OPENWEATHER_URL_BASE + 'forecast/daily'; function getWeatherIcon(code, night) { @@ -384,7 +384,7 @@ function refreshWeatherCurrent() { if (this._appid) params.APPID = this._appid; - this.load_json_async(WEATHER_URL_CURRENT, params, function(json) { + this.load_json_async(OPENWEATHER_URL_CURRENT, params, function(json) { if (json && (Number(json.cod) == 200)) { if (this.currentWeatherCache != json) @@ -463,7 +463,7 @@ function refreshWeatherForecast() { if (this._appid) params.APPID = this._appid; - this.load_json_async(WEATHER_URL_FORECAST, params, function(json) { + this.load_json_async(OPENWEATHER_URL_FORECAST, params, function(json) { if (json && (Number(json.cod) == 200)) { if (this.forecastWeatherCache != json.list) { this.owmCityId = json.city.id; diff --git a/src/prefs.js b/src/prefs.js index e0ddcb1..83afcec 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -45,33 +45,33 @@ const Convenience = Me.imports.convenience; const EXTENSIONDIR = Me.dir.get_path(); -const WEATHER_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.openweather'; -const WEATHER_PROVIDER_KEY = 'weather-provider'; -const WEATHER_UNIT_KEY = 'unit'; -const WEATHER_PRESSURE_UNIT_KEY = 'pressure-unit'; -const WEATHER_WIND_SPEED_UNIT_KEY = 'wind-speed-unit'; -const WEATHER_WIND_DIRECTION_KEY = 'wind-direction'; -const WEATHER_CITY_KEY = 'city'; -const WEATHER_ACTUAL_CITY_KEY = 'actual-city'; -const WEATHER_TRANSLATE_CONDITION_KEY = 'translate-condition'; -const WEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons'; -const WEATHER_USE_TEXT_ON_BUTTONS_KEY = 'use-text-on-buttons'; -const WEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel'; -const WEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel'; -const WEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; -const WEATHER_SHOW_COMMENT_IN_FORECAST_KEY = 'show-comment-in-forecast'; -const WEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current'; -const WEATHER_REFRESH_INTERVAL_FORECAST = 'refresh-interval-forecast'; -const WEATHER_CENTER_FORECAST_KEY = 'center-forecast'; -const WEATHER_DAYS_FORECAST = 'days-forecast'; -const WEATHER_DECIMAL_PLACES = 'decimal-places'; -const WEATHER_OWM_API_KEY = 'appid'; -const WEATHER_FC_API_KEY = 'appid-fc'; +const OPENWEATHER_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.openweather'; +const OPENWEATHER_PROVIDER_KEY = 'weather-provider'; +const OPENWEATHER_UNIT_KEY = 'unit'; +const OPENWEATHER_PRESSURE_UNIT_KEY = 'pressure-unit'; +const OPENWEATHER_WIND_SPEED_UNIT_KEY = 'wind-speed-unit'; +const OPENWEATHER_WIND_DIRECTION_KEY = 'wind-direction'; +const OPENWEATHER_CITY_KEY = 'city'; +const OPENWEATHER_ACTUAL_CITY_KEY = 'actual-city'; +const OPENWEATHER_TRANSLATE_CONDITION_KEY = 'translate-condition'; +const OPENWEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons'; +const OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY = 'use-text-on-buttons'; +const OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel'; +const OPENWEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel'; +const OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; +const OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY = 'show-comment-in-forecast'; +const OPENWEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current'; +const OPENWEATHER_REFRESH_INTERVAL_FORECAST = 'refresh-interval-forecast'; +const OPENWEATHER_CENTER_FORECAST_KEY = 'center-forecast'; +const OPENWEATHER_DAYS_FORECAST = 'days-forecast'; +const OPENWEATHER_DECIMAL_PLACES = 'decimal-places'; +const OPENWEATHER_OWM_API_KEY = 'appid'; +const OPENWEATHER_FC_API_KEY = 'appid-fc'; //URL -const WEATHER_URL_BASE = 'https://open.mapquestapi.com/nominatim/v1/'; -const WEATHER_URL_FIND = WEATHER_URL_BASE + 'search.php'; -const WEATHER_URL_REVERSE = WEATHER_URL_BASE + 'reverse.php'; +const OPENWEATHER_URL_BASE = 'https://open.mapquestapi.com/nominatim/v1/'; +const OPENWEATHER_URL_FIND = OPENWEATHER_URL_BASE + 'search.php'; +const OPENWEATHER_URL_REVERSE = OPENWEATHER_URL_BASE + 'reverse.php'; let _httpSession; @@ -145,7 +145,7 @@ const WeatherPrefsWidget = new GObject.Class({ addressdetails: '1', q: location }; - this.loadJsonAsync(WEATHER_URL_FIND, params, Lang.bind(this, function() { + this.loadJsonAsync(OPENWEATHER_URL_FIND, params, Lang.bind(this, function() { if (!arguments[0]) return 0; let newCity = arguments[0]; @@ -457,7 +457,7 @@ const WeatherPrefsWidget = new GObject.Class({ }, loadConfig: function() { - this.Settings = Convenience.getSettings(WEATHER_SETTINGS_SCHEMA); + this.Settings = Convenience.getSettings(OPENWEATHER_SETTINGS_SCHEMA); this.Settings.connect("changed", Lang.bind(this, function() { this.refreshUI(); })); @@ -466,79 +466,79 @@ const WeatherPrefsWidget = new GObject.Class({ get weather_provider() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_enum(WEATHER_PROVIDER_KEY); + return this.Settings.get_enum(OPENWEATHER_PROVIDER_KEY); }, set weather_provider(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_enum(WEATHER_PROVIDER_KEY, v); + this.Settings.set_enum(OPENWEATHER_PROVIDER_KEY, v); }, get units() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_enum(WEATHER_UNIT_KEY); + return this.Settings.get_enum(OPENWEATHER_UNIT_KEY); }, set units(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_enum(WEATHER_UNIT_KEY, v); + this.Settings.set_enum(OPENWEATHER_UNIT_KEY, v); }, get pressure_unit() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_enum(WEATHER_PRESSURE_UNIT_KEY); + return this.Settings.get_enum(OPENWEATHER_PRESSURE_UNIT_KEY); }, set pressure_unit(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_enum(WEATHER_PRESSURE_UNIT_KEY, v); + this.Settings.set_enum(OPENWEATHER_PRESSURE_UNIT_KEY, v); }, get wind_speed_unit() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_enum(WEATHER_WIND_SPEED_UNIT_KEY); + return this.Settings.get_enum(OPENWEATHER_WIND_SPEED_UNIT_KEY); }, set wind_speed_unit(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_enum(WEATHER_WIND_SPEED_UNIT_KEY, v); + this.Settings.set_enum(OPENWEATHER_WIND_SPEED_UNIT_KEY, v); }, get wind_direction() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_boolean(WEATHER_WIND_DIRECTION_KEY); + return this.Settings.get_boolean(OPENWEATHER_WIND_DIRECTION_KEY); }, set wind_direction(v) { if (!this.Settings) this.loadConfig(); - return this.Settings.set_boolean(WEATHER_WIND_DIRECTION_KEY, v); + return this.Settings.set_boolean(OPENWEATHER_WIND_DIRECTION_KEY, v); }, get city() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_string(WEATHER_CITY_KEY); + return this.Settings.get_string(OPENWEATHER_CITY_KEY); }, set city(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_string(WEATHER_CITY_KEY, v); + this.Settings.set_string(OPENWEATHER_CITY_KEY, v); }, get actual_city() { if (!this.Settings) this.loadConfig(); - let a = this.Settings.get_int(WEATHER_ACTUAL_CITY_KEY); + let a = this.Settings.get_int(OPENWEATHER_ACTUAL_CITY_KEY); let citys = this.city.split(" && "); if (citys && typeof citys == "string") @@ -577,177 +577,177 @@ const WeatherPrefsWidget = new GObject.Class({ if (a > l) a = l; - this.Settings.set_int(WEATHER_ACTUAL_CITY_KEY, a); + this.Settings.set_int(OPENWEATHER_ACTUAL_CITY_KEY, a); }, get translate_condition() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_boolean(WEATHER_TRANSLATE_CONDITION_KEY); + return this.Settings.get_boolean(OPENWEATHER_TRANSLATE_CONDITION_KEY); }, set translate_condition(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_boolean(WEATHER_TRANSLATE_CONDITION_KEY, v); + this.Settings.set_boolean(OPENWEATHER_TRANSLATE_CONDITION_KEY, v); }, get icon_type() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_boolean(WEATHER_USE_SYMBOLIC_ICONS_KEY); + return this.Settings.get_boolean(OPENWEATHER_USE_SYMBOLIC_ICONS_KEY); }, set icon_type(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_boolean(WEATHER_USE_SYMBOLIC_ICONS_KEY, v); + this.Settings.set_boolean(OPENWEATHER_USE_SYMBOLIC_ICONS_KEY, v); }, get use_text_on_buttons() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_boolean(WEATHER_USE_TEXT_ON_BUTTONS_KEY); + return this.Settings.get_boolean(OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY); }, set use_text_on_buttons(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_boolean(WEATHER_USE_TEXT_ON_BUTTONS_KEY, v); + this.Settings.set_boolean(OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY, v); }, get text_in_panel() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_boolean(WEATHER_SHOW_TEXT_IN_PANEL_KEY); + return this.Settings.get_boolean(OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY); }, set text_in_panel(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_boolean(WEATHER_SHOW_TEXT_IN_PANEL_KEY, v); + this.Settings.set_boolean(OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY, v); }, get position_in_panel() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_enum(WEATHER_POSITION_IN_PANEL_KEY); + return this.Settings.get_enum(OPENWEATHER_POSITION_IN_PANEL_KEY); }, set position_in_panel(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_enum(WEATHER_POSITION_IN_PANEL_KEY, v); + this.Settings.set_enum(OPENWEATHER_POSITION_IN_PANEL_KEY, v); }, get comment_in_panel() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_boolean(WEATHER_SHOW_COMMENT_IN_PANEL_KEY); + return this.Settings.get_boolean(OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY); }, set comment_in_panel(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_boolean(WEATHER_SHOW_COMMENT_IN_PANEL_KEY, v); + this.Settings.set_boolean(OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY, v); }, get comment_in_forecast() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_boolean(WEATHER_SHOW_COMMENT_IN_FORECAST_KEY); + return this.Settings.get_boolean(OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY); }, set comment_in_forecast(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_boolean(WEATHER_SHOW_COMMENT_IN_FORECAST_KEY, v); + this.Settings.set_boolean(OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY, v); }, get refresh_interval_current() { if (!this.Settings) this.loadConfig(); - let v = this.Settings.get_int(WEATHER_REFRESH_INTERVAL_CURRENT); + let v = this.Settings.get_int(OPENWEATHER_REFRESH_INTERVAL_CURRENT); return ((v >= 600) ? v : 600); }, set refresh_interval_current(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_int(WEATHER_REFRESH_INTERVAL_CURRENT, ((v >= 600) ? v : 600)); + this.Settings.set_int(OPENWEATHER_REFRESH_INTERVAL_CURRENT, ((v >= 600) ? v : 600)); }, get refresh_interval_forecast() { if (!this.Settings) this.loadConfig(); - let v = this.Settings.get_int(WEATHER_REFRESH_INTERVAL_FORECAST); + let v = this.Settings.get_int(OPENWEATHER_REFRESH_INTERVAL_FORECAST); return ((v >= 600) ? v : 600); }, set refresh_interval_forecast(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_int(WEATHER_REFRESH_INTERVAL_FORECAST, ((v >= 600) ? v : 600)); + this.Settings.set_int(OPENWEATHER_REFRESH_INTERVAL_FORECAST, ((v >= 600) ? v : 600)); }, get center_forecast() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_boolean(WEATHER_CENTER_FORECAST_KEY); + return this.Settings.get_boolean(OPENWEATHER_CENTER_FORECAST_KEY); }, set center_forecast(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_boolean(WEATHER_CENTER_FORECAST_KEY, v); + this.Settings.set_boolean(OPENWEATHER_CENTER_FORECAST_KEY, v); }, get days_forecast() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_int(WEATHER_DAYS_FORECAST) - 2; + return this.Settings.get_int(OPENWEATHER_DAYS_FORECAST) - 2; }, set days_forecast(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_int(WEATHER_DAYS_FORECAST, v + 2); + this.Settings.set_int(OPENWEATHER_DAYS_FORECAST, v + 2); }, get decimal_places() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_int(WEATHER_DECIMAL_PLACES); + return this.Settings.get_int(OPENWEATHER_DECIMAL_PLACES); }, set decimal_places(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_int(WEATHER_DECIMAL_PLACES, v); + this.Settings.set_int(OPENWEATHER_DECIMAL_PLACES, v); }, get appid() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_string(WEATHER_OWM_API_KEY); + return this.Settings.get_string(OPENWEATHER_OWM_API_KEY); }, set appid(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_string(WEATHER_OWM_API_KEY, v); + this.Settings.set_string(OPENWEATHER_OWM_API_KEY, v); }, get appid_fc() { if (!this.Settings) this.loadConfig(); - return this.Settings.get_string(WEATHER_FC_API_KEY); + return this.Settings.get_string(OPENWEATHER_FC_API_KEY); }, set appid_fc(v) { if (!this.Settings) this.loadConfig(); - this.Settings.set_string(WEATHER_FC_API_KEY, v); + this.Settings.set_string(OPENWEATHER_FC_API_KEY, v); }, extractLocation: function(a) {