@ -81,7 +81,9 @@ const OPENWEATHER_REFRESH_INTERVAL_FORECAST = 'refresh-interval-forecast';
const OPENWEATHER _CENTER _FORECAST _KEY = 'center-forecast' ;
const OPENWEATHER _CENTER _FORECAST _KEY = 'center-forecast' ;
const OPENWEATHER _DAYS _FORECAST = 'days-forecast' ;
const OPENWEATHER _DAYS _FORECAST = 'days-forecast' ;
const OPENWEATHER _DECIMAL _PLACES = 'decimal-places' ;
const OPENWEATHER _DECIMAL _PLACES = 'decimal-places' ;
const OPENWEATHER _USE _DEFAULT _OWM _API _KEY = 'use-default-owm-key' ;
const OPENWEATHER _OWM _API _KEY = 'appid' ;
const OPENWEATHER _OWM _API _KEY = 'appid' ;
const OPENWEATHER _OWM _DEFAULT _API _KEY = 'c93b4a667c8c9d1d1eb941621f899bb8' ;
const OPENWEATHER _FC _API _KEY = 'appid-fc' ;
const OPENWEATHER _FC _API _KEY = 'appid-fc' ;
// Keep enums in sync with GSettings schemas
// Keep enums in sync with GSettings schemas
@ -157,6 +159,7 @@ const OpenweatherMenuButton = new Lang.Class({
this . user _agent += ' ' ;
this . user _agent += ' ' ;
this . oldProvider = this . _weather _provider ;
this . oldProvider = this . _weather _provider ;
this . oldUseDefaultOwmKey = this . _use _default _owm _key ;
this . oldTranslateCondition = this . _translate _condition ;
this . oldTranslateCondition = this . _translate _condition ;
this . switchProvider ( ) ;
this . switchProvider ( ) ;
@ -364,7 +367,7 @@ const OpenweatherMenuButton = new Lang.Class({
this . weatherProvider = "https://openweathermap.org/" ;
this . weatherProvider = "https://openweathermap.org/" ;
if ( this . _appid . toString ( ) . trim ( ) === '' )
if ( this . _appid . toString ( ) . trim ( ) === '' )
Main . notify ( "Openweather" , _ ( "Openweathermap.org does not work without an api-key.\nPlease register at http://openweathermap.org/appid and paste your personal key into the preferences dialog." ) ) ;
Main . notify ( "Openweather" , _ ( "Openweathermap.org does not work without an api-key.\nEither set the swith to use the extensions default key in the preferences dialog to on or register at http://openweathermap.org/appid and paste your personal key into the preferences dialog." ) ) ;
} ,
} ,
@ -519,6 +522,13 @@ const OpenweatherMenuButton = new Lang.Class({
this . oldProvider = provider ;
this . oldProvider = provider ;
return true ;
return true ;
}
}
if ( provider == WeatherProvider . OPENWEATHERMAP ) {
let useDefaultOwmKey = this . _use _default _owm _key ;
if ( this . oldUseDefaultOwmKey != useDefaultOwmKey ) {
this . oldUseDefaultOwmKey = useDefaultOwmKey ;
return true ;
}
}
if ( provider == WeatherProvider . FORECAST _IO ) {
if ( provider == WeatherProvider . FORECAST _IO ) {
let translateCondition = this . _translate _condition ;
let translateCondition = this . _translate _condition ;
if ( this . oldTranslateCondition != translateCondition ) {
if ( this . oldTranslateCondition != translateCondition ) {
@ -717,10 +727,20 @@ const OpenweatherMenuButton = new Lang.Class({
get _appid ( ) {
get _appid ( ) {
if ( ! this . _settings )
if ( ! this . _settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
let key = this . _settings . get _string ( OPENWEATHER _OWM _API _KEY ) ;
let key = '' ;
if ( this . _use _default _owm _key )
key = OPENWEATHER _OWM _DEFAULT _API _KEY ;
else
key = this . _settings . get _string ( OPENWEATHER _OWM _API _KEY ) ;
return ( key . length == 32 ) ? key : '' ;
return ( key . length == 32 ) ? key : '' ;
} ,
} ,
get _use _default _owm _key ( ) {
if ( ! this . _settings )
this . loadConfig ( ) ;
return this . _settings . get _boolean ( OPENWEATHER _USE _DEFAULT _OWM _API _KEY ) ;
} ,
get _appid _fc ( ) {
get _appid _fc ( ) {
if ( ! this . _settings )
if ( ! this . _settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;