[libgweather/benzea/wip-variant-backend] location-entry: Limit location searching to selected top node



commit 77e324b219dc22c425770576a3873510f0924674
Author: Benjamin Berg <bberg redhat com>
Date:   Sun Apr 26 21:44:46 2020 +0200

    location-entry: Limit location searching to selected top node
    
    The top node may not be the a world node. So use the private top node
    instead and only try to do a country code based lookup if the top node
    is actually of level WORLD.

 libgweather/gweather-location-entry.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/libgweather/gweather-location-entry.c b/libgweather/gweather-location-entry.c
index c161467..7e60042 100644
--- a/libgweather/gweather-location-entry.c
+++ b/libgweather/gweather-location-entry.c
@@ -694,7 +694,11 @@ match_selected (GtkEntryCompletion *completion,
                GtkTreeIter        *iter,
                gpointer            entry)
 {
-    if (model != ((GWeatherLocationEntry *)entry)->priv->model) {
+    GWeatherLocationEntryPrivate *priv;
+
+    priv = ((GWeatherLocationEntry *)entry)->priv;
+
+    if (model != priv->model) {
        GeocodePlace *place;
        char *display_name;
        GeocodeLocation *loc;
@@ -708,10 +712,10 @@ match_selected (GtkEntryCompletion *completion,
                            -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 ();
+       if (country_code != NULL && gweather_location_get_level (priv->top) == GWEATHER_LOCATION_WORLD)
+           scope = gweather_location_find_by_country_code (priv->top, country_code);
+       if (!scope)
+           scope = priv->top;
 
        loc = geocode_place_get_location (place);
        location = gweather_location_find_nearest_city (scope, geocode_location_get_latitude (loc), 
geocode_location_get_longitude (loc));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]