[gnome-applets] gweather: adapt to libgweather API changes
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] gweather: adapt to libgweather API changes
- Date: Sun, 21 Mar 2021 17:48:34 +0000 (UTC)
commit d8cb60f7238dce3d1cdd31bffdf63ded6d67c5c2
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Mar 21 18:46:59 2021 +0200
gweather: adapt to libgweather API changes
configure.ac | 4 ++++
gnome-applets/gweather/gweather-applet.c | 32 ++++++++++++++++++++++++++++++--
gnome-applets/gweather/gweather-xml.c | 22 ++++++++++++++++++++--
3 files changed, 54 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e16c84f93..7f74ad567 100644
--- a/configure.ac
+++ b/configure.ac
@@ -174,6 +174,10 @@ 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 9f2cd037f..c72232b97 100644
--- a/gnome-applets/gweather/gweather-applet.c
+++ b/gnome-applets/gweather/gweather-applet.c
@@ -56,7 +56,13 @@ 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
@@ -333,6 +339,10 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
GAction *action;
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);
@@ -366,7 +376,16 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
g_object_bind_property (gw_applet, "locked-down", action, "enabled",
G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- gw_applet->gweather_info = gweather_info_new (get_default_location (gw_applet));
+ location = get_default_location (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);
@@ -379,6 +398,10 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
monitor = g_network_monitor_get_default();
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
@@ -521,9 +544,14 @@ suncalc_timeout_cb (gpointer data)
void gweather_update (GWeatherApplet *gw_applet)
{
+ GWeatherLocation *location;
+
gtk_widget_set_tooltip_text (GTK_WIDGET (gw_applet), _("Updating..."));
- gweather_info_set_location (gw_applet->gweather_info, get_default_location (gw_applet));
+ location = get_default_location (gw_applet);
+ gweather_info_set_location (gw_applet->gweather_info, location);
+ gweather_location_unref (location);
+
gweather_info_update (gw_applet->gweather_info);
}
diff --git a/gnome-applets/gweather/gweather-xml.c b/gnome-applets/gweather/gweather-xml.c
index 96a6d8418..2621b6ee7 100644
--- a/gnome-applets/gweather/gweather-xml.c
+++ b/gnome-applets/gweather/gweather-xml.c
@@ -53,7 +53,15 @@ gweather_xml_parse_node (GWeatherLocation *gloc,
int i;
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
+
level = gweather_location_get_level (gloc);
if (!children[0] && level < GWEATHER_LOCATION_WEATHER_STATION) {
@@ -108,8 +116,14 @@ gweather_xml_parse_node (GWeatherLocation *gloc,
-1);
parent_loc = gweather_location_get_parent (gloc);
- if (parent_loc && gweather_location_get_level (parent_loc) == GWEATHER_LOCATION_CITY)
- name = gweather_location_get_name (parent_loc);
+ if (parent_loc != NULL) {
+ 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);
has_coords = gweather_location_has_coords (gloc);
@@ -162,5 +176,9 @@ 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]