[gnome-applets/wip/muktupavels/gweather-4: 1/3] gweather: bump libgweather required version to 40.beta
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/muktupavels/gweather-4: 1/3] gweather: bump libgweather required version to 40.beta
- Date: Sun, 27 Feb 2022 14:01:21 +0000 (UTC)
commit 9b6873f5293d5452583c97914f09b67cff86e0cf
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Feb 25 21:23:20 2022 +0200
gweather: bump libgweather required version to 40.beta
configure.ac | 6 +---
gnome-applets/gweather/gweather-applet.c | 10 ------
gnome-applets/gweather/gweather-xml.c | 62 ++++++++++++++++----------------
3 files changed, 33 insertions(+), 45 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0b8d92414..47900c603 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,7 +75,7 @@ LIBNOTIFY_REQUIRED=0.7
UPOWER_REQUIRED=0.99.8
ADWAITA_ICON_THEME_REQUIRED=3.14.0
LIBXML_REQUIRED=2.5.0
-GWEATHER_REQUIRED=3.28.0
+GWEATHER_REQUIRED=40.beta
GUCHARMAP3_REQUIRED=2.33.0
POLKIT_REQUIRED=0.97
dnl ***************************************************************************
@@ -173,10 +173,6 @@ PKG_CHECK_MODULES(XML2, libxml-2.0 >= $LIBXML_REQUIRED)
dnl -- check for libgweather (required) ------------------
PKG_CHECK_MODULES(LIBGWEATHER, gweather-3.0 >= $GWEATHER_REQUIRED)
-PKG_CHECK_EXISTS([gweather-3.0 >= 40.beta],
- AC_DEFINE([HAVE_GWEATHER_40], [1],
- [Define if gweather is 40 or newer]))
-
dnl -- check for tracker-sparql (required for tracker-search-bar) ------------
PKG_CHECK_MODULES([TRACKER_SEARCH_BAR], [
tracker-sparql-3.0
diff --git a/gnome-applets/gweather/gweather-applet.c b/gnome-applets/gweather/gweather-applet.c
index c72232b97..bfdca7248 100644
--- a/gnome-applets/gweather/gweather-applet.c
+++ b/gnome-applets/gweather/gweather-applet.c
@@ -56,13 +56,9 @@ get_default_location (GWeatherApplet *gw_applet)
location = gweather_location_find_by_station_code (world, station_code);
g_variant_unref (default_loc);
-#ifdef HAVE_GWEATHER_40
gweather_location_unref (world);
return location;
-#else
- return gweather_location_ref (location);
-#endif
}
static void
@@ -340,9 +336,7 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
const char *menu_resource;
AtkObject *atk_obj;
GWeatherLocation *location;
-#ifdef HAVE_GWEATHER_40
const char *contact_info;
-#endif
GNetworkMonitor*monitor;
gp_applet_set_flags (GP_APPLET (gw_applet), GP_APPLET_FLAGS_EXPAND_MINOR);
@@ -380,12 +374,10 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
gw_applet->gweather_info = gweather_info_new (location);
gweather_location_unref (location);
-#ifdef HAVE_GWEATHER_40
gweather_info_set_application_id (gw_applet->gweather_info, "org.gnome.gnome-applets");
contact_info = "https://gitlab.gnome.org/GNOME/gnome-applets/-/raw/master/gnome-applets.doap";
gweather_info_set_contact_info (gw_applet->gweather_info, contact_info);
-#endif
gweather_info_set_enabled_providers (gw_applet->gweather_info,
GWEATHER_PROVIDER_ALL);
@@ -399,9 +391,7 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
g_signal_connect (monitor, "network-changed",
G_CALLBACK (network_changed), gw_applet);
-#ifdef HAVE_GWEATHER_40
gweather_info_update (gw_applet->gweather_info);
-#endif
}
gboolean
diff --git a/gnome-applets/gweather/gweather-xml.c b/gnome-applets/gweather/gweather-xml.c
index 2621b6ee7..d7124c2e5 100644
--- a/gnome-applets/gweather/gweather-xml.c
+++ b/gnome-applets/gweather/gweather-xml.c
@@ -45,26 +45,20 @@ gweather_xml_parse_node (GWeatherLocation *gloc,
GtkTreeStore *store, GtkTreeIter *parent)
{
GtkTreeIter iter, *self = &iter;
- GWeatherLocation **children, *parent_loc;
+ GWeatherLocation *first_child;
+ GWeatherLocation *second_child;
+ GWeatherLocation *parent_loc;
GWeatherLocationLevel level;
const char *name, *code;
double latitude, longitude;
gboolean has_coords;
- int i;
+ GWeatherLocation *child;
name = gweather_location_get_name (gloc);
-
-#ifdef HAVE_GWEATHER_40
- /* FIXME: Use gweather_location_next_child! */
-#endif
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- children = gweather_location_get_children (gloc);
- G_GNUC_END_IGNORE_DEPRECATIONS
-
+ first_child = gweather_location_next_child (gloc, NULL);
level = gweather_location_get_level (gloc);
- if (!children[0] && level < GWEATHER_LOCATION_WEATHER_STATION) {
+ if (first_child == NULL && level < GWEATHER_LOCATION_WEATHER_STATION) {
return TRUE;
}
@@ -92,20 +86,28 @@ gweather_xml_parse_node (GWeatherLocation *gloc,
gtk_tree_store_set (store, &iter,
GWEATHER_XML_COL_LOCATION_NAME, name,
-1);
- if (children[0] && !children[1]) {
- code = gweather_location_get_code (children[0]);
- has_coords = gweather_location_has_coords (children[0]);
- latitude = longitude = 0;
- if (has_coords) {
- gweather_location_get_coords (children[0], &latitude, &longitude);
+
+ if (first_child != NULL) {
+ gweather_location_ref (first_child);
+ second_child = gweather_location_next_child (gloc, first_child);
+
+ if (second_child == NULL) {
+ code = gweather_location_get_code (first_child);
+ has_coords = gweather_location_has_coords (first_child);
+ latitude = longitude = 0;
+ if (has_coords) {
+ gweather_location_get_coords (first_child, &latitude, &longitude);
+ }
+
+ gtk_tree_store_set (store, &iter,
+ GWEATHER_XML_COL_METAR_CODE, code,
+ GWEATHER_XML_COL_LATLON_VALID, has_coords,
+ GWEATHER_XML_COL_LATITUDE, latitude,
+ GWEATHER_XML_COL_LONGITUDE, longitude,
+ -1);
}
- gtk_tree_store_set (store, &iter,
- GWEATHER_XML_COL_METAR_CODE, code,
- GWEATHER_XML_COL_LATLON_VALID, has_coords,
- GWEATHER_XML_COL_LATITUDE, latitude,
- GWEATHER_XML_COL_LONGITUDE, longitude,
- -1);
+ g_clear_pointer (&second_child, gweather_location_unref);
}
break;
@@ -120,9 +122,7 @@ gweather_xml_parse_node (GWeatherLocation *gloc,
if (gweather_location_get_level (parent_loc) == GWEATHER_LOCATION_CITY)
name = gweather_location_get_name (parent_loc);
-#ifdef HAVE_GWEATHER_40
gweather_location_unref (parent_loc);
-#endif
}
code = gweather_location_get_code (gloc);
@@ -150,8 +150,12 @@ gweather_xml_parse_node (GWeatherLocation *gloc,
break;
}
- for (i = 0; children[i]; i++) {
- if (!gweather_xml_parse_node (children[i], store, self)) {
+ g_clear_pointer (&first_child, gweather_location_unref);
+
+ child = NULL;
+ while ((child = gweather_location_next_child (gloc, child)) != NULL) {
+ if (!gweather_xml_parse_node (child, store, self)) {
+ gweather_location_unref (child);
return FALSE;
}
}
@@ -176,9 +180,7 @@ gweather_xml_load_locations (void)
store = NULL;
}
-#ifdef HAVE_GWEATHER_40
gweather_location_unref (world);
-#endif
return (GtkTreeModel *)store;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]