[libgweather] GWeatherLocationEntry: respect country information when converting from geocode
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather] GWeatherLocationEntry: respect country information when converting from geocode
- Date: Thu, 22 Dec 2016 15:51:52 +0000 (UTC)
commit fa5d30bb8d61947299db8edd2e02c184ea1f701b
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Thu Dec 22 16:45:17 2016 +0100
GWeatherLocationEntry: respect country information when converting from geocode
Turns out that geocode-glib does give us a valid country code, so
we should make use of it and avoid blunders like putting cities in
the wrong country.
It's still possible we put cities in the wrong timezone, but given
the weirdness of timezones inside countries (I'm looking at you, Arizona),
the solution is just more cities in the static db.
https://bugzilla.gnome.org/show_bug.cgi?id=753332
libgweather/gweather-location-entry.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/libgweather/gweather-location-entry.c b/libgweather/gweather-location-entry.c
index 51cc254..a540209 100644
--- a/libgweather/gweather-location-entry.c
+++ b/libgweather/gweather-location-entry.c
@@ -662,14 +662,22 @@ match_selected (GtkEntryCompletion *completion,
char *display_name;
GeocodeLocation *loc;
GWeatherLocation *location;
+ GWeatherLocation *scope;
+ const char* country_code;
gtk_tree_model_get (model, iter,
PLACE_GWEATHER_LOCATION_ENTRY_COL_PLACE, &place,
PLACE_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, &display_name,
-1);
+ country_code = geocode_place_get_country_code (place);
+ if (country_code != NULL)
+ scope = gweather_location_find_by_country_code (gweather_location_get_world (), country_code);
+ else
+ scope = gweather_location_get_world ();
+
loc = geocode_place_get_location (place);
- location = gweather_location_find_nearest_city (NULL, geocode_location_get_latitude (loc),
geocode_location_get_longitude (loc));
+ location = gweather_location_find_nearest_city (scope, geocode_location_get_latitude (loc),
geocode_location_get_longitude (loc));
location = create_new_detached_location(location, display_name, TRUE,
geocode_location_get_latitude (loc) * M_PI / 180.0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]