[libgweather/benzea/wip-variant-backend] location-entry: Use internal API to create detached locations



commit c2fb487d1648ccb3e76f13081d68d5ab4cee551c
Author: Benjamin Berg <bberg redhat com>
Date:   Sun Apr 26 14:57:33 2020 +0200

    location-entry: Use internal API to create detached locations
    
    The location entry had a copy of the function that is already provided.
    Remove the copy.

 libgweather/gweather-location-entry.c | 54 ++---------------------------------
 1 file changed, 3 insertions(+), 51 deletions(-)
---
diff --git a/libgweather/gweather-location-entry.c b/libgweather/gweather-location-entry.c
index b6c7e23..6f5e757 100644
--- a/libgweather/gweather-location-entry.c
+++ b/libgweather/gweather-location-entry.c
@@ -67,12 +67,6 @@ static void set_location_internal (GWeatherLocationEntry *entry,
                                   GtkTreeModel          *model,
                                   GtkTreeIter           *iter,
                                   GWeatherLocation      *loc);
-static GWeatherLocation *
-create_new_detached_location (GWeatherLocation *nearest_station,
-                              const char       *name,
-                              gboolean          latlon_valid,
-                              gdouble           latitude,
-                              gdouble           longitude);
 static void
 fill_location_entry_model (GtkTreeStore *store, GWeatherLocation *loc,
                           const char *parent_display_name,
@@ -728,9 +722,9 @@ match_selected (GtkEntryCompletion *completion,
        loc = geocode_place_get_location (place);
        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,
-                                               geocode_location_get_longitude (loc) * M_PI / 180.0);
+       location = _gweather_location_new_detached (location, display_name, TRUE,
+                                                    geocode_location_get_latitude (loc) * M_PI / 180.0,
+                                                    geocode_location_get_longitude (loc) * M_PI / 180.0);
 
        set_location_internal (entry, model, NULL, location);
 
@@ -849,45 +843,3 @@ gweather_location_entry_new (GWeatherLocation *top)
                         "top", top,
                         NULL);
 }
-
-static GWeatherLocation *
-create_new_detached_location (GWeatherLocation *nearest_station,
-                              const char       *name,
-                              gboolean          latlon_valid,
-                              gdouble           latitude,
-                              gdouble           longitude)
-{
-    GWeatherLocation *self;
-    char *normalized;
-
-    self = g_slice_new0 (GWeatherLocation);
-    self->ref_count = 1;
-    self->level = GWEATHER_LOCATION_DETACHED;
-    self->english_name = g_strdup (name);
-    self->local_name = g_strdup (name);
-
-    normalized = g_utf8_normalize (name, -1, G_NORMALIZE_ALL);
-    self->english_sort_name = g_utf8_casefold (normalized, -1);
-    self->local_sort_name = g_strdup (self->english_sort_name);
-    g_free (normalized);
-
-    self->parent = nearest_station;
-    self->children = NULL;
-
-    if (nearest_station)
-       self->station_code = g_strdup (nearest_station->station_code);
-
-    g_assert (nearest_station || latlon_valid);
-
-    if (latlon_valid) {
-       self->latlon_valid = TRUE;
-       self->latitude = latitude;
-       self->longitude = longitude;
-    } else {
-       self->latlon_valid = nearest_station->latlon_valid;
-       self->latitude = nearest_station->latitude;
-       self->longitude = nearest_station->longitude;
-    }
-
-    return self;
-}


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