|
|
@ -312,19 +312,10 @@ const OpenweatherMenuButton = new Lang.Class({ |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
switchProvider: function() { |
|
|
|
switchProvider: function() { |
|
|
|
|
|
|
|
if (this._weather_provider == WeatherProvider.FORECAST_IO) |
|
|
|
switch (this._weather_provider) { |
|
|
|
this.useForecastIo(); |
|
|
|
case WeatherProvider.FORECAST_IO: |
|
|
|
else |
|
|
|
this.useForecastIo(); |
|
|
|
this.useOpenweathermap(); |
|
|
|
break; |
|
|
|
|
|
|
|
case WeatherProvider.OPENWEATHERMAP: |
|
|
|
|
|
|
|
this.useOpenweathermap(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
this.useOpenweathermap(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
useOpenweathermap: function() { |
|
|
|
useOpenweathermap: function() { |
|
|
@ -334,6 +325,7 @@ const OpenweatherMenuButton = new Lang.Class({ |
|
|
|
this.get_weather_icon_safely = this.owmGet_weather_icon_safely; |
|
|
|
this.get_weather_icon_safely = this.owmGet_weather_icon_safely; |
|
|
|
this.refreshWeatherCurrent = this.owmRefreshWeatherCurrent; |
|
|
|
this.refreshWeatherCurrent = this.owmRefreshWeatherCurrent; |
|
|
|
this.refreshWeatherForecast = this.owmRefreshWeatherForecast; |
|
|
|
this.refreshWeatherForecast = this.owmRefreshWeatherForecast; |
|
|
|
|
|
|
|
this.weatherProvider = "https://openweathermap.org/"; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
useForecastIo: function() { |
|
|
|
useForecastIo: function() { |
|
|
@ -343,6 +335,7 @@ const OpenweatherMenuButton = new Lang.Class({ |
|
|
|
this.get_weather_icon_safely = this.fcGet_weather_icon_safely; |
|
|
|
this.get_weather_icon_safely = this.fcGet_weather_icon_safely; |
|
|
|
this.refreshWeatherCurrent = this.fcRefreshWeatherCurrent; |
|
|
|
this.refreshWeatherCurrent = this.fcRefreshWeatherCurrent; |
|
|
|
this.refreshWeatherForecast = function() {}; |
|
|
|
this.refreshWeatherForecast = function() {}; |
|
|
|
|
|
|
|
this.weatherProvider = "https://forecast.io/"; |
|
|
|
|
|
|
|
|
|
|
|
this.fc_locale = 'en'; |
|
|
|
this.fc_locale = 'en'; |
|
|
|
let fc_locales = ['bs','de','en','es','fr','it','nl','pl','pt','ru','tet','x-pig-latin']; |
|
|
|
let fc_locales = ['bs','de','en','es','fr','it','nl','pl','pt','ru','tet','x-pig-latin']; |
|
|
@ -355,12 +348,28 @@ const OpenweatherMenuButton = new Lang.Class({ |
|
|
|
this.fc_locale = locale; |
|
|
|
this.fc_locale = locale; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getWeatherProviderURL: function() { |
|
|
|
|
|
|
|
let url=""; |
|
|
|
|
|
|
|
if (this._weather_provider == WeatherProvider.FORECAST_IO) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
url = "https://forecast.io/#/f/"; |
|
|
|
|
|
|
|
url += this.extractCoord(this._city); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
url = "https://openweathermap.org"; |
|
|
|
|
|
|
|
url += "/city/" + this.owmCityId; |
|
|
|
|
|
|
|
if (this._appid) |
|
|
|
|
|
|
|
url += "?APPID=" + this._appid; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return url; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
loadConfig: function() { |
|
|
|
loadConfig: function() { |
|
|
|
this._settings = Convenience.getSettings(WEATHER_SETTINGS_SCHEMA); |
|
|
|
this._settings = Convenience.getSettings(WEATHER_SETTINGS_SCHEMA); |
|
|
|
this._settingsC = this._settings.connect("changed", Lang.bind(this, function() { |
|
|
|
this._settingsC = this._settings.connect("changed", Lang.bind(this, function() { |
|
|
|
this.rebuildCurrentWeatherUi(); |
|
|
|
this.rebuildCurrentWeatherUi(); |
|
|
|
this.rebuildFutureWeatherUi(); |
|
|
|
this.rebuildFutureWeatherUi(); |
|
|
|
this.rebuildButtonMenu(); |
|
|
|
|
|
|
|
if (this.providerChanged()) { |
|
|
|
if (this.providerChanged()) { |
|
|
|
this.switchProvider(); |
|
|
|
this.switchProvider(); |
|
|
|
this.currentWeatherCache = undefined; |
|
|
|
this.currentWeatherCache = undefined; |
|
|
@ -370,6 +379,7 @@ const OpenweatherMenuButton = new Lang.Class({ |
|
|
|
this.currentWeatherCache = undefined; |
|
|
|
this.currentWeatherCache = undefined; |
|
|
|
this.forecastWeatherCache = undefined; |
|
|
|
this.forecastWeatherCache = undefined; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.rebuildButtonMenu(); |
|
|
|
this.parseWeatherCurrent(); |
|
|
|
this.parseWeatherCurrent(); |
|
|
|
})); |
|
|
|
})); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -862,7 +872,7 @@ const OpenweatherMenuButton = new Lang.Class({ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this._urlButton = new St.Button({ |
|
|
|
this._urlButton = new St.Button({ |
|
|
|
label: _("Weather data provided by:") + (this._use_text_on_buttons ? "\n" : " ") + "http://openweathermap.org/", |
|
|
|
label: _("Weather data provided by:") + (this._use_text_on_buttons ? "\n" : " ") + this.weatherProvider, |
|
|
|
style_class: 'system-menu-action openweather-provider' |
|
|
|
style_class: 'system-menu-action openweather-provider' |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (ExtensionUtils.versionCheck(['3.6', '3.8'], Config.PACKAGE_VERSION)) { |
|
|
|
if (ExtensionUtils.versionCheck(['3.6', '3.8'], Config.PACKAGE_VERSION)) { |
|
|
@ -870,11 +880,7 @@ const OpenweatherMenuButton = new Lang.Class({ |
|
|
|
} |
|
|
|
} |
|
|
|
this._urlButton.connect('clicked', Lang.bind(this, function() { |
|
|
|
this._urlButton.connect('clicked', Lang.bind(this, function() { |
|
|
|
this.menu.actor.hide(); |
|
|
|
this.menu.actor.hide(); |
|
|
|
let url = "http://openweathermap.org"; |
|
|
|
let url = this.getWeatherProviderURL(); |
|
|
|
if (this.owmCityId) |
|
|
|
|
|
|
|
url += "/city/" + this.owmCityId; |
|
|
|
|
|
|
|
if (this._appid) |
|
|
|
|
|
|
|
url += "?APPID=" + this._appid; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
Gtk.show_uri(null, url, global.get_current_time()); |
|
|
|
Gtk.show_uri(null, url, global.get_current_time()); |
|
|
|