diff options
author | Benjamin Berg <bberg@redhat.com> | 2021-01-08 22:22:48 +0100 |
---|---|---|
committer | Benjamin Berg <benjamin@sipsolutions.net> | 2021-01-15 11:56:57 +0000 |
commit | 71454299b81ef15f066aac11cc12b2f042995f6c (patch) | |
tree | d1af769e7a1648cad151bc20d7a42835d14fddb1 | |
parent | 363c1dcec5172ae10871560c00069b1c4f0de2cc (diff) | |
download | gnome-settings-daemon-benzea/libgweather-api-update.tar.gz |
datetime: Make use of new gweather APIbenzea/libgweather-api-update
This mainly means free'ing the world when done and stopping to use the
now deprecated API (even though it would be acceptable in our case).
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | plugins/datetime/weather-tz.c | 23 |
2 files changed, 10 insertions, 15 deletions
diff --git a/meson.build b/meson.build index dffc0167..05fef19c 100644 --- a/meson.build +++ b/meson.build @@ -97,7 +97,7 @@ gnome_desktop_dep = dependency('gnome-desktop-3.0', version: '>= 3.37.1') gsettings_desktop_dep = dependency('gsettings-desktop-schemas', version: '>= 40') gtk_dep = dependency('gtk+-3.0', version: '>= 3.15.3') gtk_x11_dep = dependency('gtk+-x11-3.0') -gweather_dep = dependency('gweather-3.0', version: '>= 3.9.5') +gweather_dep = dependency('gweather-3.0', version: '>= 40.alpha') lcms_dep = dependency('lcms2', version: '>= 2.2') libcanberra_gtk_dep = dependency('libcanberra-gtk3') libgeoclue_dep = dependency('libgeoclue-2.0', version: '>= 2.3.1') diff --git a/plugins/datetime/weather-tz.c b/plugins/datetime/weather-tz.c index f1de2b94..2eac90a2 100644 --- a/plugins/datetime/weather-tz.c +++ b/plugins/datetime/weather-tz.c @@ -29,17 +29,14 @@ static GList * location_get_cities (GWeatherLocation *parent_location) { GList *cities = NULL; - GWeatherLocation **children; - gint i; - - children = gweather_location_get_children (parent_location); - for (i = 0; children[i]; i++) { - if (gweather_location_get_level (children[i]) == GWEATHER_LOCATION_CITY) { - cities = g_list_prepend (cities, - children[i]); + GWeatherLocation *child = NULL; + + while ((child = gweather_location_next_child (parent_location, child))) { + if (gweather_location_get_level (child) == GWEATHER_LOCATION_CITY) { + cities = g_list_prepend (cities, gweather_location_ref (child)); } else { cities = g_list_concat (cities, - location_get_cities (children[i])); + location_get_cities (child)); } } @@ -101,10 +98,10 @@ load_timezones (GList *cities) GList * weather_tz_db_get_locations (const gchar *country_code) { - GList *cities; + g_autoptr(GWeatherLocation) world = NULL; + g_autoptr(GWeatherLocation) country = NULL; + g_autolist(GWeatherLocation) cities = NULL; GList *tz_locations; - GWeatherLocation *world; - GWeatherLocation *country; world = gweather_location_get_world (); @@ -116,7 +113,5 @@ weather_tz_db_get_locations (const gchar *country_code) cities = location_get_cities (country); tz_locations = load_timezones (cities); - g_list_free (cities); - return tz_locations; } |