[gnome-panel] clock: adapt to libgweather API changes
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] clock: adapt to libgweather API changes
- Date: Sun, 21 Mar 2021 15:44:12 +0000 (UTC)
commit 769ca437d455980b31cbed920f12d994d70ea52a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Mar 21 17:43:35 2021 +0200
clock: adapt to libgweather API changes
configure.ac | 4 ++++
modules/clock/clock-applet.c | 15 +++++++++++++++
modules/clock/clock-location.c | 41 +++++++++++++++++++++++++++++++++++++++--
3 files changed, 58 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9edc052eb..ff83b1dd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -222,6 +222,10 @@ PKG_CHECK_MODULES([CLOCK], [
polkit-gobject-1
])
+PKG_CHECK_EXISTS([gweather-3.0 >= 40.beta],
+ AC_DEFINE([HAVE_GWEATHER_40], [1],
+ [Define if gweather is 40 or newer]))
+
# Check whether to enable e-d-s support for clock applet
AC_MSG_CHECKING([whether to enable evolution-data-server support])
AC_ARG_ENABLE([eds],
diff --git a/modules/clock/clock-applet.c b/modules/clock/clock-applet.c
index dda02f3ca..d6f0da487 100644
--- a/modules/clock/clock-applet.c
+++ b/modules/clock/clock-applet.c
@@ -1284,10 +1284,15 @@ get_weather_station_location (GWeatherLocation *location)
* is the nearest weather station.
*/
if (gweather_location_get_level (location) == GWEATHER_LOCATION_DETACHED) {
+#ifdef HAVE_GWEATHER_40
+ station_loc = gweather_location_get_parent (location);
+ g_assert (station_loc != NULL);
+#else
station_loc = gweather_location_get_parent (location);
g_assert (station_loc != NULL);
station_loc = gweather_location_ref (station_loc);
+#endif
} else {
station_loc = gweather_location_ref (location);
}
@@ -1297,10 +1302,16 @@ get_weather_station_location (GWeatherLocation *location)
tmp = station_loc;
+#ifdef HAVE_GWEATHER_40
+ station_loc = gweather_location_next_child (station_loc, NULL);
+ g_assert (station_loc != NULL);
+#else
station_loc = gweather_location_get_children (station_loc)[0];
g_assert (station_loc != NULL);
station_loc = gweather_location_ref (station_loc);
+#endif
+
gweather_location_unref (tmp);
}
@@ -1983,6 +1994,10 @@ clock_applet_dispose (GObject *object)
g_clear_object (&applet->datetime_appinfo);
+#ifdef HAVE_GWEATHER_40
+ g_clear_pointer (&applet->world, gweather_location_unref);
+#endif
+
free_locations (applet);
if (applet->location_tiles != NULL) {
diff --git a/modules/clock/clock-location.c b/modules/clock/clock-location.c
index c19531ec0..cabc00816 100644
--- a/modules/clock/clock-location.c
+++ b/modules/clock/clock-location.c
@@ -212,23 +212,42 @@ clock_location_get_gweather_timezone (ClockLocation *loc)
GWeatherTimezone *tz;
GWeatherLocation *gloc;
- gloc = loc->priv->loc;
+ gloc = gweather_location_ref (loc->priv->loc);
tz = gweather_location_get_timezone (gloc);
if (tz == NULL) {
+ GWeatherLocation *tmp;
+
/* Some weather stations do not have timezone information.
* In this case, we need to find the nearest city. */
- while (gweather_location_get_level (gloc) >= GWEATHER_LOCATION_CITY)
+ while (gweather_location_get_level (gloc) >= GWEATHER_LOCATION_CITY) {
+ tmp = gloc;
+
+#ifdef HAVE_GWEATHER_40
gloc = gweather_location_get_parent (gloc);
+#else
+ gloc = gweather_location_get_parent (gloc);
+ gloc = gweather_location_ref (gloc);
+#endif
+
+ gweather_location_unref (tmp);
+ }
+
+ tmp = gloc;
gloc = gweather_location_find_nearest_city (gloc,
loc->priv->latitude,
loc->priv->longitude);
+ gweather_location_unref (tmp);
+
if (gloc == NULL) {
g_warning ("Could not find the nearest city for location \"%s\"",
gweather_location_get_name (loc->priv->loc));
return gweather_timezone_get_utc ();
}
tz = gweather_location_get_timezone (gloc);
+ gweather_location_unref (gloc);
+ } else {
+ gweather_location_unref (gloc);
}
return tz;
@@ -491,6 +510,10 @@ static void
setup_weather_updates (ClockLocation *loc)
{
ClockLocationPrivate *priv;
+#ifdef HAVE_GWEATHER_40
+ const char *contact_info;
+ GWeatherProvider providers;
+#endif
priv = loc->priv;
@@ -503,8 +526,22 @@ setup_weather_updates (ClockLocation *loc)
priv->weather_info = gweather_info_new (priv->loc);
+#ifdef HAVE_GWEATHER_40
+ gweather_info_set_application_id (priv->weather_info, "org.gnome.gnome-panel");
+
+ contact_info = "https://gitlab.gnome.org/GNOME/gnome-panel/-/raw/master/gnome-panel.doap";
+ gweather_info_set_contact_info (priv->weather_info, contact_info);
+
+ providers = GWEATHER_PROVIDER_METAR | GWEATHER_PROVIDER_IWIN;
+ gweather_info_set_enabled_providers (priv->weather_info, providers);
+#endif
+
g_signal_connect (priv->weather_info, "updated",
G_CALLBACK (weather_info_updated), loc);
set_weather_update_timeout (loc);
+
+#ifdef HAVE_GWEATHER_40
+ gweather_info_update (priv->weather_info);
+#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]