diff --git a/data/Makefile.am b/data/Makefile.am
index cded425..590e149 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -7,7 +7,7 @@ uuid = openweather-extension@jenslody.de
extensiondir = $(topextensiondir)/$(uuid)
-dist_extension_DATA = OpenWeather.png stylesheet.css weather-settings.ui
+dist_extension_DATA = OpenWeather.png stylesheet.css prefs.css weather-settings.ui
nodist_extension_DATA = metadata.json $(EXTRA_EXTENSION)
diff --git a/data/metadata.json.in b/data/metadata.json.in
index 00352a0..6caf37c 100644
--- a/data/metadata.json.in
+++ b/data/metadata.json.in
@@ -2,7 +2,7 @@
"uuid": "@uuid@",
"name": "OpenWeather",
"description": "Weather extension to display weather information from https://openweathermap.org/ or https://darksky.net for almost all locations in the world.\nFor openweathermap.org, you can either use the extensions default-key or register at https://openweathermap.org/appid and set the appropriate switch in the preferences dialog to \"off\".\nFor Dark Sky you have to register at https://darksky.net/dev/register and get a personal API-key.\n\nSince version 29 this extensions uses coordinates to store the locations and makes the names editable to support multiple weather-providers!\nIf you update from versions prior to 29 to 29 or greater (with darksky.net - support) you have to recreate your locations.",
-"shell-version": [ "3.32", "3.34", "3.36", "3.38" ],
+"shell-version": [ "40" ],
"localedir": "@LOCALEDIR@",
"url": "@url@",
"version": "@version@"
diff --git a/data/prefs.css b/data/prefs.css
new file mode 100644
index 0000000..63fa531
--- /dev/null
+++ b/data/prefs.css
@@ -0,0 +1,7 @@
+.openweather-dialog {
+background-color: white;
+padding: 10px;
+}
+.openweather-dialog label {
+color: black;
+}
diff --git a/data/weather-settings.ui b/data/weather-settings.ui
index 90f97c7..b00fd9c 100644
--- a/data/weather-settings.ui
+++ b/data/weather-settings.ui
@@ -1,7 +1,6 @@
-
-
+ 100
- 0.10000000000000001
+ 0.12
-
- 500
- 300
- True
- False
+
+ 1
+
+
+ vertical
+ 500
+ 300
+
+
+ 1
+ 300
+ 250
+
+
+ search-liststore
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
dummy
+
+
- False
- True
- center-on-parent
- True
- True
- dialog
+ 1
+ 1
- True
- False
- 5vertical
- True
- False
+ centerstart
- True
+ 1Search by location or coordinatesend
-
- False
- False
- 0
-
- True
- False5350
- True
- True
- True
+ 1edit-clear-symbolic
- False
- False
+ 0
+ 0Clear entrye.g. Vaiaku, Tuvalu or -8.5211767,179.1976747
-
- False
- True
- 0
- Find
- True
- True
- True
-
+ 1
-
- False
- True
- 1
-
-
- False
- True
- 1
-
- True
- False50
@@ -277,45 +197,24 @@
https://darksky.net
-
- False
- True
- 2
-
- True
- False
+ center55
-
- False
- False
- 3
-
- True
- Falsebaseline
- False
+ 0Cancel
- True
- True
- True
- start
-
+ 1
+ center
-
- False
- False
- 0
-
@@ -323,33 +222,17 @@
Save
- True
- True
- True
+ 1
-
- False
- True
- end
- 2
-
-
- False
- True
- end
- 4
-
-
-
@@ -360,1013 +243,761 @@
- True
- True
- True
+ 1
-
- True
- False
- True
- True
- vertical
-
-
- True
- True
- in
- 300
- 250
+
+
+
+ 1
+ 1
+ vertical
-
- True
- True
- tree-liststore
- True
- 0
- False
- 12
- 1
-
-
+
+ 1
+ 300
+ 250
+
+
+ tree-liststore
+ 1
+ 0
+ 0
+ 12
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+ list-add
+
+
+
+
+ list-remove
+
+
+
+
+ accessories-text-editor
+
-
- True
- True
- 0
-
-
-
-
- True
- False
- icons
- 1
+
+
+
+ Locations
+
+
+
+
+
+
+ 1
+
+
+ 1
+ 1
+ 5
+ 5
-
- True
- False
- list-add
+
+ start
+ 1
+ Chose default weather provider
+
+ 0
+ 0
+
-
- False
- True
-
-
- True
- False
- list-remove
+
+ start
+ 1
+ Personal Api key from openweathermap.org
+
+ 0
+ 2
+
-
- False
- True
-
-
- True
- False
- gtk-edit
+
+
+ https://openweathermap.org
+ https://darksky.net
+
+
+ 1
+ 0
+
+
+
+
+
+ 32
+ 32
+
+ 1
+ 2
+
+
+
+
+
+ 32
+ 32
+
+ 1
+ 3
+
+
+
+
+
+ start
+ 1
+ Personal Api key from Dark Sky
+
+ 0
+ 3
+
+
+
+
+
+ start
+ 1
+ Refresh timeout for current weather [min]
+ end
+
+ 0
+ 5
+
+
+
+
+
+ start
+ 1
+ Refresh timeout for weather forecast [min]
+ end
+
+ 0
+ 6
+
+
+
+
+
+ current-refresh-adjustment
+ 5
+ 1
+ if-valid
+ 10
+
+ 1
+ 5
+
+
+
+
+
+ Note: the forecast-timout is not used for Dark Sky, because they do not provide seperate downloads for current weather and forecasts.
+ forecast-refresh-adjustment
+ 5
+ 1
+ 10
+
+ 1
+ 6
+
+
+
+
+
+
+ 0
+ 4
+ 2
+
+
+
+
+
+ start
+ Use extensions api-key for openweathermap.org
+
+ 0
+ 1
+
+
+
+
+
+ Switch off, if you have your own api-key for openweathermap.org and put it into the text-box below.
+ center
+
+ 1
+ 1
+
-
- False
- True
-
-
- False
- True
- 1
-
-
-
-
-
-
- True
- False
- Locations
-
-
- False
-
-
-
-
- True
- False
- True
- True
- 10
- 5
- 5
-
-
- True
- False
- start
- True
- Chose default weather provider
-
-
- 0
- 0
-
-
-
-
- True
- False
- start
- True
- Personal Api key from openweathermap.org
-
-
- 0
- 2
-
-
-
-
- True
- False
-
- https://openweathermap.org
- https://darksky.net
-
-
-
- 1
- 0
-
-
-
-
- True
- True
- 32
- 32
-
-
- 1
- 2
-
-
-
-
- True
- True
- 32
- 32
-
-
- 1
- 3
-
-
-
-
- True
- False
- start
- True
- Personal Api key from Dark Sky
-
-
- 0
- 3
-
-
-
-
- True
- False
- start
- True
- Refresh timeout for current weather [min]
- end
-
-
- 0
- 5
-
-
-
-
- True
- False
- start
- True
- Refresh timeout for weather forecast [min]
- end
-
-
- 0
- 6
-
-
-
-
- True
- True
- number
- current-refresh-adjustment
- 5
- True
- if-valid
- 10
-
-
- 1
- 5
-
-
-
-
- True
- True
- Note: the forecast-timout is not used for Dark Sky, because they do not provide seperate downloads for current weather and forecasts.
- number
- forecast-refresh-adjustment
- 5
- True
- 10
-
-
- 1
- 6
-
-
-
-
- True
- False
-
-
- 0
- 4
- 2
-
-
-
-
- True
- False
- start
- Use extensions api-key for openweathermap.org
-
-
- 0
- 1
-
-
-
-
- True
- True
- Switch off, if you have your own api-key for openweathermap.org and put it into the text-box below.
- center
+
+
+
+ Weather provider
-
- 1
- 1
-
-
+
-
- 1
-
-
-
-
- True
- False
- Weather provider
-
-
- 1
- False
-
-
- True
- False
- True
- True
- 10
- 5
- 5
-
-
- True
- False
- Chose geolocation provider
-
-
- 0
- 0
-
-
-
-
- True
- False
-
- https://nominatim.openstreetmap.org/
- https://geocode.farm/
- https://open.mapquestapi.com/nominatim/
-
-
-
- 1
- 0
-
-
-
-
- True
- False
- Personal AppKey from developer.mapquest.com
-
-
- 0
- 1
-
-
-
-
- True
- True
- True
- 32
- 32
-
-
- 1
- 1
-
-
-
-
+ 2
-
-
-
-
- True
- False
- Geolocation provider
-
-
- 2
- False
-
-
-
-
- True
- False
- True
- True
- 10
- 5
- 5
-
-
- True
- False
- Temperature Unit
-
-
- 0
- 0
-
-
-
-
- True
- False
- Wind Speed Unit
-
-
- 0
- 1
-
-
-
-
- True
- False
- Pressure Unit
-
-
- 0
- 2
-
-
-
-
- True
- False
-
- °C
- °F
- K
- °Ra
- °Ré
- °Rø
- °De
- °N
-
+
+
+ 1
+ 1
+ 5
+ 5
+
+
+ Chose geolocation provider
+
+ 0
+ 0
+
+
+
+
+
+
+ https://nominatim.openstreetmap.org/
+ https://geocode.farm/
+ https://open.mapquestapi.com/nominatim/
+
+
+ 1
+ 0
+
+
+
+
+
+ Personal AppKey from developer.mapquest.com
+
+ 0
+ 1
+
+
+
+
+
+ 1
+ 32
+ 32
+
+ 1
+ 1
+
+
+
-
- 1
- 0
-
-
-
-
- True
- False
-
- km/h
- mph
- m/s
- kn
- ft/s
- Beaufort
-
+
+
+
+ Geolocation provider
-
- 1
- 1
-
-
-
-
- True
- False
-
- hPa
- inHg
- bar
- Pa
- kPa
- atm
- at
- Torr
- psi
- mmHg
- mbar
-
-
-
- 1
- 2
-
-
+
-
- 3
-
-
-
-
- True
- False
- Units
-
-
- 3
- False
-
-
- True
- False
- True
- True
- 10
- 5
- 5
-
-
- True
- False
- Position in Panel
-
-
- 0
- 0
-
-
-
-
- True
- False
- Position of menu-box [%] from 0 (left) to 100 (right)
-
-
- 0
- 1
-
-
-
-
- True
- False
- Wind Direction by Arrows
-
-
- 0
- 2
-
-
-
-
- True
- False
- Translate Conditions
-
-
- 0
- 3
-
-
-
-
- True
- False
- Symbolic Icons
-
-
- 0
- 4
-
-
-
-
- True
- False
- Text on buttons
-
-
- 0
- 5
-
-
-
-
- True
- False
- Temperature in Panel
-
-
- 0
- 6
-
-
-
-
- True
- False
- Conditions in Panel
-
-
- 0
- 7
-
-
-
-
- True
- False
- Conditions in Forecast
-
-
- 0
- 8
-
-
-
-
- True
- False
- Center forecast
-
-
- 0
- 9
-
-
-
-
- True
- False
- Number of days in forecast
-
-
- 0
- 10
-
-
-
-
- True
- False
- Maximal number of digits after the decimal point
-
-
- 0
- 11
-
-
-
-
- True
- False
-
- Center
- Right
- Left
-
-
-
- 1
- 0
-
-
-
-
- 200
- True
- True
- True
- menu-alignment-adjustment
- True
- False
- 100
-
-
- 1
- 1
-
-
-
-
- True
- True
- center
-
-
- 1
- 2
-
-
-
-
- True
- True
- center
-
-
- 1
- 3
-
-
-
-
- True
- True
- center
-
-
- 1
- 4
-
-
-
-
- True
- True
- center
-
-
- 1
- 5
-
-
-
-
- True
- True
- center
-
-
- 1
- 6
-
-
-
-
- True
- True
- center
-
-
- 1
- 7
-
-
-
-
- True
- True
- center
-
-
- 1
- 8
-
-
-
-
- True
- True
- center
-
-
- 1
- 9
-
-
-
-
- True
- False
-
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
-
-
- 1
- 10
-
-
-
-
- True
- False
-
- 0
- 1
- 2
- 3
-
-
-
- 1
- 11
-
-
-
-
- True
- False
- start
- True
- Maximal number of characters in location label
+
+ 3
+
+
+ 1
+ 1
+ 5
+ 5
+
+
+ Temperature Unit
+
+ 0
+ 0
+
+
+
+
+
+ Wind Speed Unit
+
+ 0
+ 1
+
+
+
+
+
+ Pressure Unit
+
+ 0
+ 2
+
+
+
+
+
+
+ °C
+ °F
+ K
+ °Ra
+ °Ré
+ °Rø
+ °De
+ °N
+
+
+ 1
+ 0
+
+
+
+
+
+
+ km/h
+ mph
+ m/s
+ kn
+ ft/s
+ Beaufort
+
+
+ 1
+ 1
+
+
+
+
+
+
+ hPa
+ inHg
+ bar
+ Pa
+ kPa
+ atm
+ at
+ Torr
+ psi
+ mmHg
+ mbar
+
+
+ 1
+ 2
+
+
+
-
- 0
- 12
-
-
-
-
- True
- True
- number
- max-loc-chars-adj
- 5
- True
+
+
+
+ Units
-
- 1
- 12
-
-
+
-
- 4
-
-
-
-
- True
- False
- Layout
-
-
- 4
- False
-
-
- False
- 24
- 24
- True
- True
- vertical
- 5
-
-
- True
- False
- OpenWeather.png
-
-
- False
- True
- 10
- 0
-
-
-
-
- True
- False
- <b>Openweather</b>
- True
-
-
- False
- True
- 1
-
-
-
-
- True
- False
- center
-
-
- True
- False
- end
- Version:
- False
-
-
- False
- True
- 0
-
-
-
-
- True
- False
+
+ 4
+
+
+ 1
+ 1
+ 5
+ 5
+
+
+ Position in Panel
+
+ 0
+ 0
+
+
+
+
+
+ Position of menu-box [%] from 0 (left) to 100 (right)
+
+ 0
+ 1
+
+
+
+
+
+ Wind Direction by Arrows
+
+ 0
+ 2
+
+
+
+
+
+ Translate Conditions
+
+ 0
+ 3
+
+
+
+
+
+ Symbolic Icons
+
+ 0
+ 4
+
+
+
+
+
+ Text on buttons
+
+ 0
+ 5
+
+
+
+
+
+ Temperature in Panel
+
+ 0
+ 6
+
+
+
+
+
+ Conditions in Panel
+
+ 0
+ 7
+
+
+
+
+
+ Conditions in Forecast
+
+ 0
+ 8
+
+
+
+
+
+ Center forecast
+
+ 0
+ 9
+
+
+
+
+
+ Number of days in forecast
+
+ 0
+ 10
+
+
+
+
+
+ Maximal number of digits after the decimal point
+
+ 0
+ 11
+
+
+
+
+
+
+ Center
+ Right
+ Left
+
+
+ 1
+ 0
+
+
+
+
+
+ 200
+ 1
+ menu-alignment-adjustment
+ 1
+ 0
+ 100
+
+ 1
+ 1
+
+
+
+
+
+ center
+
+ 1
+ 2
+
+
+
+
+
+ center
+
+ 1
+ 3
+
+
+
+
+
+ center
+
+ 1
+ 4
+
+
+
+
+
+ center
+
+ 1
+ 5
+
+
+
+
+
+ center
+
+ 1
+ 6
+
+
+
+
+
+ center
+
+ 1
+ 7
+
+
+
+
+
+ center
+
+ 1
+ 8
+
+
+
+
+
+ center
+
+ 1
+ 9
+
+
+
+
+
+
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+
+
+ 1
+ 10
+
+
+
+
+
+
+ 0
+ 1
+ 2
+ 3
+
+
+ 1
+ 11
+
+
+
+
+ start
- unknown (self-build ?)
- end
+ 1
+ Maximal number of characters in location label
+
+ 0
+ 12
+
+
+
+
+
+ max-loc-chars-adj
+ 5
+ 1
+
+ 1
+ 12
+
-
- False
- True
- 1
-
-
- False
- True
- 2
-
-
-
-
- True
- False
- <span>Weather extension to display weather information from <a href="https://openweathermap.org/">Openweathermap</a> or <a href="https://darksky.net">Dark Sky</a> for almost all locations in the world.</span>
- True
- center
- True
- word-char
- 1
+
+
+
+ Layout
-
- False
- True
- 3
-
-
-
-
- True
- False
- center
+
+
+
+
+
+ 5
+
+
+ 24
+ 24
+ 1
+ 1
+ vertical5
-
- True
- False
- Maintained by
+
+ OpenWeather.png
-
- False
- True
- 0
-
-
- True
- True
- Jens Lody (<a href="mailto:openweather@jenslody.de">openweather@jenslody.de</a>)
- True
+
+ <b>Openweather</b>
+ 1
+
+
+
+
+ center
+
+
+ end
+ Version:
+
+
+
+
+ start
+ unknown (self-build ?)
+ end
+
+
+
+
+
+
+ <span>Weather extension to display weather information from <a href="https://openweathermap.org/">Openweathermap</a> or <a href="https://darksky.net">Dark Sky</a> for almost all locations in the world.</span>
+ 1
+ center
+ 1
+ word-char
+ 1
+
+
+
+
+ center
+ 5
+
+
+ Maintained by
+
+
+
+
+ Jens Lody (<a href="mailto:openweather@jenslody.de">openweather@jenslody.de</a>)
+ 1
+
+
+
+
+
+
+ Webpage
+ 1
+ center
+ https://gitlab.com/jenslody/gnome-shell-extension-openweather
+
+
+
+
+ 1
+ end
+ <span size="small">This program comes with ABSOLUTELY NO WARRANTY.
+See the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, version 2 or later</a> for details.</span>
+ 1
+ center
+ 1
-
- False
- True
- 1
-
-
- False
- True
- 4
-
-
-
-
- Webpage
- True
- True
- True
-
- center
- none
- https://gitlab.com/jenslody/gnome-shell-extension-openweather
-
-
- False
- True
- 5
-
-
-
-
- True
- True
- end
- <span size="small">This program comes with ABSOLUTELY NO WARRANTY.
-See the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, version 2 or later</a> for details.</span>
- True
- center
- True
+
+
+
+ About
-
- True
- True
- 6
-
-
-
-
- 5
-
-
-
-
- True
- False
- About
+
-
- 5
- False
-
diff --git a/gnome-shell-extension-openweather.cbp b/gnome-shell-extension-openweather.cbp
index 56f9514..59cd5ea 100644
--- a/gnome-shell-extension-openweather.cbp
+++ b/gnome-shell-extension-openweather.cbp
@@ -31,6 +31,7 @@
+
@@ -80,10 +81,7 @@
-
-
-
diff --git a/src/prefs.js b/src/prefs.js
index f357751..c710300 100644
--- a/src/prefs.js
+++ b/src/prefs.js
@@ -93,6 +93,15 @@ const GeolocationProvider = {
MAPQUEST: 2
};
+let provider = new Gtk.CssProvider();
+
+provider.load_from_path(Me.dir.get_path() + '/prefs.css');
+Gtk.StyleContext.add_provider_for_display(
+ Gdk.Display.get_default(),
+ provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+
let _httpSession;
let mCities = null;
@@ -138,7 +147,10 @@ const WeatherPrefsWidget = new GObject.Class({
this.editCoord = this.Window.get_object("edit-coord");
this.editCombo = this.Window.get_object("edit-combo");
this.searchWidget = this.Window.get_object("search-widget");
- this.searchMenu = this.Window.get_object("search-menu");
+ this.searchMenuWidget = this.Window.get_object("search-menu-widget");
+ this.searchScrolledWindow = this.Window.get_object("search-scrolledwindow");
+ this.searchTreeview = this.Window.get_object("search-treeview");
+ this.searchListstore = this.Window.get_object("search-liststore");
this.searchName = this.Window.get_object("search-name");
this.searchCombo = this.Window.get_object("search-combo");
@@ -147,7 +159,9 @@ const WeatherPrefsWidget = new GObject.Class({
this.editCoord.connect("icon-release", Lang.bind(this, this.clearEntry));
this.Window.get_object("tree-toolbutton-add").connect("clicked", Lang.bind(this, function() {
- this.searchWidget.show_all();
+ this.searchName.set_text("");
+ this.clearSearchMenu();
+ this.searchWidget.show();
}));
this.Window.get_object("tree-toolbutton-remove").connect("clicked", Lang.bind(this, this.removeCity));
@@ -158,6 +172,11 @@ const WeatherPrefsWidget = new GObject.Class({
this.selectionChanged(selection);
}));
+ this.searchSelection = this.Window.get_object("search-selection");
+ this.searchSelection.connect("changed", Lang.bind(this, function(selection) {
+ this.searchSelectionChanged(selection);
+ }));
+
this.Window.get_object("button-edit-cancel").connect("clicked", Lang.bind(this, this.editCancel));
this.Window.get_object("button-edit-save").connect("clicked", Lang.bind(this, this.editSave));
@@ -175,13 +194,7 @@ const WeatherPrefsWidget = new GObject.Class({
if (location === "")
return 0;
- let item = new Gtk.MenuItem();
- let spinner = new Gtk.Spinner();
- spinner.start();
- item.add(spinner);
-
- this.searchMenu.append(item);
- this.showSearchMenu();
+ this.appendToSearchList( _("Searching ..."));
if (this.geolocation_provider == GeolocationProvider.OPENSTREETMAPS) {
let params = {
@@ -193,18 +206,12 @@ const WeatherPrefsWidget = new GObject.Class({
this.loadJsonAsync(OPENWEATHER_URL_OSM_FIND, params, Lang.bind(this, function() {
this.clearSearchMenu();
if (!arguments[0]) {
- let item = new Gtk.MenuItem({
- label: _("Invalid data when searching for \"%s\"").format(location)
- });
- this.searchMenu.append(item);
+ this.appendToSearchList(_("Invalid data when searching for \"%s\"").format(location));
} else {
let newCity = arguments[0];
if (Number(newCity.length) < 1) {
- let item = new Gtk.MenuItem({
- label: _("\"%s\" not found").format(location)
- });
- this.searchMenu.append(item);
+ this.appendToSearchList(_("\"%s\" not found").format(location));
} else {
var m = {};
for (var i in newCity) {
@@ -212,11 +219,7 @@ const WeatherPrefsWidget = new GObject.Class({
let cityText = newCity[i].display_name;
let cityCoord = "[" + newCity[i].lat + "," + newCity[i].lon + "]";
- let item = new Gtk.MenuItem({
- label: cityText + " " + cityCoord
- });
- item.connect("activate", Lang.bind(this, this.onActivateItem));
- this.searchMenu.append(item);
+ this.appendToSearchList(cityText + " " + cityCoord);
}
}
}
@@ -226,14 +229,8 @@ const WeatherPrefsWidget = new GObject.Class({
} else if (this.geolocation_provider == GeolocationProvider.MAPQUEST) {
if (this.geolocation_appid_mapquest === '') {
this.clearSearchMenu();
- let item = new Gtk.MenuItem({
- label: "You need an AppKey to search on openmapquest."
- });
- this.searchMenu.append(item);
- item = new Gtk.MenuItem({
- label: "Please visit https://developer.mapquest.com/ ."
- });
- this.searchMenu.append(item);
+ this.appendToSearchList(_("You need an AppKey to search on openmapquest."));
+ this.appendToSearchList(_("Please visit https://developer.mapquest.com/ ."));
this.showSearchMenu();
return 0;
}
@@ -247,26 +244,14 @@ const WeatherPrefsWidget = new GObject.Class({
this.loadJsonAsync(OPENWEATHER_URL_MAPQUEST_FIND, params, Lang.bind(this, function() {
this.clearSearchMenu();
if (!arguments[0]) {
- let item = new Gtk.MenuItem({
- label: _("Invalid data when searching for \"%s\"").format(location)
- });
- this.searchMenu.append(item);
- item = new Gtk.MenuItem({
- label: "Do you use a valid AppKey to search on openmapquest ?"
- });
- this.searchMenu.append(item);
- item = new Gtk.MenuItem({
- label: "If not, please visit https://developer.mapquest.com/ ."
- });
- this.searchMenu.append(item);
+ this.appendToSearchList(_("Invalid data when searching for \"%s\"").format(location));
+ this.appendToSearchList(_("Do you use a valid AppKey to search on openmapquest ?"));
+ this.appendToSearchList(_("If not, please visit https://developer.mapquest.com/ ."));
} else {
let newCity = arguments[0];
if (Number(newCity.length) < 1) {
- let item = new Gtk.MenuItem({
- label: _("\"%s\" not found").format(location)
- });
- this.searchMenu.append(item);
+ this.appendToSearchList(_("\"%s\" not found").format(location));
} else {
var m = {};
for (var i in newCity) {
@@ -274,11 +259,7 @@ const WeatherPrefsWidget = new GObject.Class({
let cityText = newCity[i].display_name;
let cityCoord = "[" + newCity[i].lat + "," + newCity[i].lon + "]";
- let item = new Gtk.MenuItem({
- label: cityText + " " + cityCoord
- });
- item.connect("activate", Lang.bind(this, this.onActivateItem));
- this.searchMenu.append(item);
+ this.appendToSearchList(cityText + " " + cityCoord);
}
}
}
@@ -294,23 +275,14 @@ const WeatherPrefsWidget = new GObject.Class({
this.clearSearchMenu();
if (!arguments[0]) {
- let item = new Gtk.MenuItem({
- label: _("Invalid data when searching for \"%s\"").format(location)
- });
- this.searchMenu.append(item);
+ this.appendToSearchList(_("Invalid data when searching for \"%s\"").format(location));
} else {
let newCity = arguments[0].geocoding_results;
if (Number(newCity.length) < 1) {
- let item = new Gtk.MenuItem({
- label: _("Invalid data when searching for \"%s\"").format(location)
- });
- this.searchMenu.append(item);
+ this.appendToSearchList(_("Invalid data when searching for \"%s\"").format(location));
} else {
if (Number(newCity.STATUS.result_count) < 1) {
- let item = new Gtk.MenuItem({
- label: _("\"%s\" not found").format(location)
- });
- this.searchMenu.append(item);
+ this.appendToSearchList(_("\"%s\" not found").format(location));
} else {
var m = {};
newCity = newCity.RESULTS;
@@ -319,11 +291,7 @@ const WeatherPrefsWidget = new GObject.Class({
let cityText = newCity[i].formatted_address;
let cityCoord = "[" + newCity[i].COORDINATES.latitude + "," + newCity[i].COORDINATES.longitude + "]";
- let item = new Gtk.MenuItem({
- label: cityText + " " + cityCoord
- });
- item.connect("activate", Lang.bind(this, this.onActivateItem));
- this.searchMenu.append(item);
+ this.appendToSearchList(cityText + " " + cityCoord);
}
}
@@ -372,7 +340,7 @@ const WeatherPrefsWidget = new GObject.Class({
this.treeview.append_column(column);
let renderer = new Gtk.CellRendererText();
- column.pack_start(renderer, null);
+ column.pack_start(renderer, false);
column.add_attribute(renderer, "text", 0);
column.set_cell_data_func(renderer, function() {
@@ -382,12 +350,22 @@ const WeatherPrefsWidget = new GObject.Class({
column.set_title(_("Provider"));
this.treeview.append_column(column);
- column.pack_start(renderer, null);
+ column.pack_start(renderer, false);
column.add_attribute(renderer, "text", 1);
column.set_cell_data_func(renderer, function() {
arguments[1].markup = arguments[2].get_value(arguments[3], 1);
});
+ column = new Gtk.TreeViewColumn();
+ column.set_title(_("Result"));
+ this.searchTreeview.append_column(column);
+
+ column.pack_start(renderer, false);
+ column.add_attribute(renderer, "text", 0);
+
+ column.set_cell_data_func(renderer, function() {
+ arguments[1].markup = arguments[2].get_value(arguments[3], 0);
+ });
this.location_length_spin = this.Window.get_object("max_loc_chars");
this.location_length_spin.set_value(this.loc_len_current);
@@ -407,15 +385,15 @@ const WeatherPrefsWidget = new GObject.Class({
let theObjects = this.Window.get_objects();
for (let i in theObjects) {
- let name = theObjects[i].get_name ? theObjects[i].get_name() : 'dummy';
+ let name = theObjects[i].get_buildable_id ? theObjects[i].get_buildable_id() : 'dummy';
if (this[name] !== undefined) {
- if (theObjects[i].class_path()[1].indexOf('GtkEntry') != -1)
+ if (theObjects[i].get_name().indexOf('GtkEntry') != -1)
this.initEntry(theObjects[i]);
- else if (theObjects[i].class_path()[1].indexOf('GtkComboBoxText') != -1)
+ else if (theObjects[i].get_name().indexOf('GtkComboBoxText') != -1)
this.initComboBox(theObjects[i]);
- else if (theObjects[i].class_path()[1].indexOf('GtkSwitch') != -1)
+ else if (theObjects[i].get_name().indexOf('GtkSwitch') != -1)
this.initSwitch(theObjects[i]);
- else if (theObjects[i].class_path()[1].indexOf('GtkScale') != -1)
+ else if (theObjects[i].get_name().indexOf('GtkScale') != -1)
this.initScale(theObjects[i]);
this.configWidgets.push([theObjects[i], name]);
}
@@ -424,6 +402,13 @@ const WeatherPrefsWidget = new GObject.Class({
this.Window.get_object('version').set_label(Me.metadata.version.toString());
},
+ appendToSearchList: function(text) {
+ let current = this.searchListstore.get_iter_first();
+
+ current = this.searchListstore.append();
+ this.searchListstore.set_value(current, 0, text);
+ },
+
clearEntry: function() {
arguments[0].set_text("");
},
@@ -433,14 +418,9 @@ const WeatherPrefsWidget = new GObject.Class({
},
showSearchMenu: function() {
- this.searchMenu.show_all();
- if (typeof this.searchMenu.popup_at_widget === "function") {
- this.searchMenu.popup_at_widget(this.searchName, Gdk.Gravity.SOUTH_WEST, Gdk.Gravity.NORTH_WEST, null);
- }
- else
- {
- this.searchMenu.popup(null, null, Lang.bind(this, this.placeSearchMenu), 0, this.searchName);
- }
+ this.searchSelection.unselect_all();
+ this.searchMenuWidget.show();
+ this.searchSelection.set_mode(Gtk.SelectionMode.SINGLE);
},
placeSearchMenu: function() {
@@ -450,14 +430,15 @@ const WeatherPrefsWidget = new GObject.Class({
},
clearSearchMenu: function() {
- let children = this.searchMenu.get_children();
- for (let i in children) {
- this.searchMenu.remove(children[i]);
- }
+ this.searchSelection.unselect_all();
+ this.searchSelection.set_mode(Gtk.SelectionMode.NONE);
+ if (this.searchListstore !== undefined)
+ this.searchListstore.clear();
+ this.searchMenuWidget.hide();
},
initEntry: function(theEntry) {
- let name = theEntry.get_name();
+ let name = theEntry.get_buildable_id();
theEntry.text = this[name];
if (this[name].length != 32)
theEntry.set_icon_from_icon_name(Gtk.PositionType.LEFT, 'dialog-warning');
@@ -473,21 +454,21 @@ const WeatherPrefsWidget = new GObject.Class({
},
initComboBox: function(theComboBox) {
- let name = theComboBox.get_name();
+ let name = theComboBox.get_buildable_id();
theComboBox.connect("changed", Lang.bind(this, function() {
this[name] = arguments[0].active;
}));
},
initSwitch: function(theSwitch) {
- let name = theSwitch.get_name();
+ let name = theSwitch.get_buildable_id();
theSwitch.connect("notify::active", Lang.bind(this, function() {
this[name] = arguments[0].active;
}));
},
initScale: function(theScale) {
- let name = theScale.get_name();
+ let name = theScale.get_buildable_id();
theScale.set_value(this[name]);
this[name+'Timeout'] = undefined;
theScale.connect("value-changed", Lang.bind(this, function(slider) {
@@ -552,6 +533,15 @@ const WeatherPrefsWidget = new GObject.Class({
this.actual_city = parseInt(a.to_string());
},
+ searchSelectionChanged: function(select) {
+ let a = select.get_selected_rows()[0][0];
+ if ( a !== undefined ) {
+ let b = this.searchListstore.get_iter(a);
+ this.searchName.set_text(this.searchListstore.get_value(b[1], 0).toString());
+ }
+ this.clearSearchMenu();
+ },
+
removeCity: function() {
let city = this.city.split(" && ");
if (!city.length)
@@ -559,28 +549,26 @@ const WeatherPrefsWidget = new GObject.Class({
let ac = this.actual_city;
let textDialog = _("Remove %s ?").format(this.extractLocation(city[ac]));
let dialog = new Gtk.Dialog({
- title: ""
+ title: "",
+ css_classes: ['openweather-dialog']
});
let label = new Gtk.Label({
label: textDialog
});
label.margin_bottom = 12;
- dialog.set_border_width(12);
- dialog.set_modal(1);
- dialog.set_resizable(0);
+ dialog.set_modal(true);
+ dialog.set_resizable(false);
//dialog.set_transient_for(***** Need parent Window *****);
+ dialog.add_button(_("No"), 0);
+ let d = dialog.add_button(_("Yes"), 1);
- dialog.add_button(Gtk.STOCK_NO, 0);
- let d = dialog.add_button(Gtk.STOCK_YES, 1);
-
- d.set_can_default(true);
- dialog.set_default(d);
+ dialog.set_default_response(0);
let dialog_area = dialog.get_content_area();
- dialog_area.pack_start(label, 0, 0, 0);
+ dialog_area.append(label);
dialog.connect("response", Lang.bind(this, function(w, response_id) {
- if (response_id) {
+ if (response_id == 1) {
if (city.length === 0)
city = [];
@@ -601,7 +589,7 @@ const WeatherPrefsWidget = new GObject.Class({
return 0;
}));
- dialog.show_all();
+ dialog.show();
return 0;
},
@@ -613,7 +601,7 @@ const WeatherPrefsWidget = new GObject.Class({
this.editName.set_text(this.extractLocation(city[ac]));
this.editCoord.set_text(this.extractCoord(city[ac]));
this.editCombo.set_active(this.extractProvider(city[ac]) + 1);
- this.editWidget.show_all();
+ this.editWidget.show();
return 0;
},
@@ -1115,6 +1103,6 @@ function init() {
function buildPrefsWidget() {
let prefs = new WeatherPrefsWidget();
let widget = prefs.mainWidget;
- widget.show_all();
+ widget.show();
return widget;
}