diff --git a/data/org.gnome.shell.extensions.openweather.gschema.xml.in b/data/org.gnome.shell.extensions.openweather.gschema.xml.in
index d5cd10f..b437994 100644
--- a/data/org.gnome.shell.extensions.openweather.gschema.xml.in
+++ b/data/org.gnome.shell.extensions.openweather.gschema.xml.in
@@ -134,6 +134,10 @@
''
<_summary>Your personal API key from openweathermap.org
+
+ true
+ <_summary>Use the extensions default API key from openweathermap.org
+
''
<_summary>Your personal API key from forecast.io
diff --git a/data/weather-settings.ui b/data/weather-settings.ui
index 55c0aee..73c94e0 100644
--- a/data/weather-settings.ui
+++ b/data/weather-settings.ui
@@ -495,7 +495,7 @@
0
- 1
+ 2
@@ -521,7 +521,7 @@
1
- 1
+ 2
@@ -533,7 +533,7 @@
1
- 2
+ 3
@@ -546,7 +546,7 @@
0
- 2
+ 3
@@ -560,7 +560,7 @@
0
- 4
+ 5
@@ -574,7 +574,7 @@
0
- 5
+ 6
@@ -590,7 +590,7 @@
1
- 4
+ 5
@@ -606,7 +606,7 @@
1
- 5
+ 6
@@ -616,10 +616,34 @@
0
- 3
+ 4
2
+
+
+
+ 0
+ 1
+
+
+
+
+
+ 1
+ 1
+
+
1
diff --git a/src/extension.js b/src/extension.js
index e31d973..84114dd 100644
--- a/src/extension.js
+++ b/src/extension.js
@@ -81,7 +81,9 @@ 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_USE_DEFAULT_OWM_API_KEY = 'use-default-owm-key';
const OPENWEATHER_OWM_API_KEY = 'appid';
+const OPENWEATHER_OWM_DEFAULT_API_KEY = 'c93b4a667c8c9d1d1eb941621f899bb8';
const OPENWEATHER_FC_API_KEY = 'appid-fc';
// Keep enums in sync with GSettings schemas
@@ -157,6 +159,7 @@ const OpenweatherMenuButton = new Lang.Class({
this.user_agent += ' ';
this.oldProvider = this._weather_provider;
+ this.oldUseDefaultOwmKey = this._use_default_owm_key;
this.oldTranslateCondition = this._translate_condition;
this.switchProvider();
@@ -364,7 +367,7 @@ const OpenweatherMenuButton = new Lang.Class({
this.weatherProvider = "https://openweathermap.org/";
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;
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) {
let translateCondition = this._translate_condition;
if (this.oldTranslateCondition != translateCondition) {
@@ -717,10 +727,20 @@ const OpenweatherMenuButton = new Lang.Class({
get _appid() {
if (!this._settings)
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 : '';
},
+ get _use_default_owm_key() {
+ if (!this._settings)
+ this.loadConfig();
+ return this._settings.get_boolean(OPENWEATHER_USE_DEFAULT_OWM_API_KEY);
+ },
+
get _appid_fc() {
if (!this._settings)
this.loadConfig();
diff --git a/src/prefs.js b/src/prefs.js
index fabc76c..a8ecc2f 100644
--- a/src/prefs.js
+++ b/src/prefs.js
@@ -65,6 +65,7 @@ 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_USE_DEFAULT_OWM_API_KEY = 'use-default-owm-key';
const OPENWEATHER_OWM_API_KEY = 'appid';
const OPENWEATHER_FC_API_KEY = 'appid-fc';
const OPENWEATHER_GC_APP_KEY = 'geolocation-appid-mapquest';
@@ -976,6 +977,18 @@ const WeatherPrefsWidget = new GObject.Class({
this.Settings.set_string(OPENWEATHER_OWM_API_KEY, v);
},
+ get use_default_owm_key() {
+ if (!this.Settings)
+ this.loadConfig();
+ return this.Settings.get_boolean(OPENWEATHER_USE_DEFAULT_OWM_API_KEY);
+ },
+
+ set use_default_owm_key(v) {
+ if (!this.Settings)
+ this.loadConfig();
+ this.Settings.set_boolean(OPENWEATHER_USE_DEFAULT_OWM_API_KEY, v);
+ },
+
get appid_fc() {
if (!this.Settings)
this.loadConfig();