[gnome-panel/wip/muktupavels/gweather-4: 7/7] clock: port to libgweather 4
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/gweather-4: 7/7] clock: port to libgweather 4
- Date: Thu, 3 Mar 2022 09:13:45 +0000 (UTC)
commit 9a9fe133328310bdd3265c3ace9a15f2473a0f29
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Mar 1 11:06:08 2022 +0200
clock: port to libgweather 4
https://gitlab.gnome.org/GNOME/gnome-panel/-/issues/38
.gitlab-ci.yml | 2 +-
configure.ac | 4 ++--
modules/clock/Makefile.am | 1 -
modules/clock/clock-applet.c | 14 +++++------
modules/clock/clock-location-entry.c | 46 ++++++++++++++++++------------------
modules/clock/clock-location.c | 42 ++++++++++++++------------------
6 files changed, 51 insertions(+), 58 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 39f7c3927..7b55de843 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,7 +24,7 @@ variables:
libgnome-desktop-3-dev
libgnome-menu-3-dev
libgtk-3-dev
- libgweather-3-dev
+ libgweather-4-dev
libpango1.0-dev
libpolkit-gobject-1-dev
libsm-dev
diff --git a/configure.ac b/configure.ac
index 3987adfd6..a326edd4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,7 +132,7 @@ LIBECAL_REQUIRED=3.33.2
LIBEDATASERVER_REQUIRED=3.5.3
LIBSYSTEMD_REQUIRED=230
CAIRO_REQUIRED=1.0.0
-GWEATHER_REQUIRED=40.beta
+GWEATHER_REQUIRED=3.91.0
DCONF_REQUIRED=0.13.4
XRANDR_REQUIRED=1.3.0
@@ -217,7 +217,7 @@ PKG_CHECK_MODULES([CLOCK], [
glib-2.0 >= $GLIB_REQUIRED
gnome-desktop-3.0 >= $LIBGNOME_DESKTOP_REQUIRED
gtk+-3.0 >= $GTK_REQUIRED
- gweather-3.0 >= $GWEATHER_REQUIRED
+ gweather4 >= $GWEATHER_REQUIRED
pango >= $PANGO_REQUIRED
polkit-gobject-1
])
diff --git a/modules/clock/Makefile.am b/modules/clock/Makefile.am
index 6a2b4c4c1..e1174f0cb 100644
--- a/modules/clock/Makefile.am
+++ b/modules/clock/Makefile.am
@@ -48,7 +48,6 @@ org_gnome_gnome_panel_clock_la_CPPFLAGS = \
-DCLOCK_EDS_ICONDIR="\"$(CLOCK_EDS_ICONDIR)\"" \
-DEDS_DISABLE_DEPRECATED \
-DGNOME_DESKTOP_USE_UNSTABLE_API \
- -DGWEATHER_I_KNOW_THIS_IS_UNSTABLE \
-I$(top_srcdir) \
$(AM_CPPFLAGS) \
$(NULL)
diff --git a/modules/clock/clock-applet.c b/modules/clock/clock-applet.c
index dbbae9c4d..88377ce3b 100644
--- a/modules/clock/clock-applet.c
+++ b/modules/clock/clock-applet.c
@@ -980,7 +980,7 @@ fill_clock_applet (ClockApplet *cd)
cd->applet_settings = gp_applet_settings_new (applet, "org.gnome.gnome-panel.applet.clock");
cd->clock_settings = g_settings_new ("org.gnome.desktop.interface");
- cd->weather_settings = g_settings_new ("org.gnome.GWeather");
+ cd->weather_settings = g_settings_new ("org.gnome.GWeather4");
g_signal_connect (cd->clock_settings, "changed::clock-format",
G_CALLBACK (format_changed), cd);
@@ -1109,7 +1109,7 @@ get_weather_station_location (GWeatherLocation *location)
station_loc = gweather_location_get_parent (location);
g_assert (station_loc != NULL);
} else {
- station_loc = gweather_location_ref (location);
+ station_loc = g_object_ref (location);
}
while (gweather_location_get_level (station_loc) < GWEATHER_LOCATION_WEATHER_STATION) {
@@ -1120,7 +1120,7 @@ get_weather_station_location (GWeatherLocation *location)
station_loc = gweather_location_next_child (station_loc, NULL);
g_assert (station_loc != NULL);
- gweather_location_unref (tmp);
+ g_object_unref (tmp);
}
return station_loc;
@@ -1162,10 +1162,10 @@ run_prefs_edit_save (GtkButton *button,
}
station_loc = get_weather_station_location (gloc);
- gweather_location_unref (gloc);
+ g_object_unref (gloc);
weather_code = gweather_location_get_code (station_loc);
- gweather_location_unref (station_loc);
+ g_object_unref (station_loc);
if (clock_location_entry_has_custom_text (cd->location_entry)) {
name = gtk_editable_get_chars (GTK_EDITABLE (cd->location_entry), 0, -1);
@@ -1284,7 +1284,7 @@ location_changed (GObject *object,
update_coords (cd, latlon_valid, latitude, longitude);
if (gloc)
- gweather_location_unref (gloc);
+ g_object_unref (gloc);
}
static void
@@ -1748,7 +1748,7 @@ clock_applet_dispose (GObject *object)
g_clear_object (&applet->datetime_appinfo);
- g_clear_pointer (&applet->world, gweather_location_unref);
+ g_clear_object (&applet->world);
free_locations (applet);
diff --git a/modules/clock/clock-location-entry.c b/modules/clock/clock-location-entry.c
index e20529469..f522d249b 100644
--- a/modules/clock/clock-location-entry.c
+++ b/modules/clock/clock-location-entry.c
@@ -132,9 +132,9 @@ finalize (GObject *object)
priv = entry->priv;
if (priv->location)
- gweather_location_unref (priv->location);
+ g_object_unref (priv->location);
if (priv->top)
- gweather_location_unref (priv->top);
+ g_object_unref (priv->top);
if (priv->model)
g_object_unref (priv->model);
@@ -227,11 +227,11 @@ clock_location_entry_class_init (ClockLocationEntryClass *location_entry_class)
/* properties */
g_object_class_install_property (
object_class, PROP_TOP,
- g_param_spec_boxed ("top",
- "Top Location",
- "The GWeatherLocation whose children will be used to fill in the entry",
- GWEATHER_TYPE_LOCATION,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+ g_param_spec_object ("top",
+ "Top Location",
+ "The GWeatherLocation whose children will be used to fill in the entry",
+ GWEATHER_TYPE_LOCATION,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (
object_class, PROP_SHOW_NAMED_TIMEZONES,
g_param_spec_boolean ("show-named-timezones",
@@ -241,11 +241,11 @@ clock_location_entry_class_init (ClockLocationEntryClass *location_entry_class)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (
object_class, PROP_LOCATION,
- g_param_spec_boxed ("location",
- "Location",
- "The selected GWeatherLocation",
- GWEATHER_TYPE_LOCATION,
- G_PARAM_READWRITE));
+ g_param_spec_object ("location",
+ "Location",
+ "The selected GWeatherLocation",
+ GWEATHER_TYPE_LOCATION,
+ G_PARAM_READWRITE));
}
static void
@@ -256,14 +256,14 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_TOP:
- entry->priv->top = g_value_dup_boxed (value);
+ entry->priv->top = g_value_dup_object (value);
break;
case PROP_SHOW_NAMED_TIMEZONES:
entry->priv->show_named_timezones = g_value_get_boolean (value);
break;
case PROP_LOCATION:
clock_location_entry_set_location (CLOCK_LOCATION_ENTRY (object),
- g_value_get_boxed (value));
+ g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -282,7 +282,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_boolean (value, entry->priv->show_named_timezones);
break;
case PROP_LOCATION:
- g_value_set_boxed (value, entry->priv->location);
+ g_value_set_object (value, entry->priv->location);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -328,7 +328,7 @@ set_location_internal (ClockLocationEntry *entry,
priv = entry->priv;
if (priv->location)
- gweather_location_unref (priv->location);
+ g_object_unref (priv->location);
g_assert (iter == NULL || loc == NULL);
@@ -341,7 +341,7 @@ set_location_internal (ClockLocationEntry *entry,
priv->custom_text = FALSE;
g_free (name);
} else if (loc) {
- priv->location = gweather_location_ref (loc);
+ priv->location = g_object_ref (loc);
gtk_entry_set_text (GTK_ENTRY (entry), gweather_location_get_name (loc));
priv->custom_text = FALSE;
} else {
@@ -391,11 +391,11 @@ clock_location_entry_set_location (ClockLocationEntry *entry,
-1);
if (gweather_location_equal (loc, cmploc)) {
set_location_internal (entry, model, &iter, NULL);
- gweather_location_unref (cmploc);
+ g_object_unref (cmploc);
return;
}
- gweather_location_unref (cmploc);
+ g_object_unref (cmploc);
} while (gtk_tree_model_iter_next (model, &iter));
set_location_internal (entry, model, NULL, loc);
@@ -418,7 +418,7 @@ clock_location_entry_get_location (ClockLocationEntry *entry)
g_return_val_if_fail (CLOCK_IS_LOCATION_ENTRY (entry), NULL);
if (entry->priv->location)
- return gweather_location_ref (entry->priv->location);
+ return g_object_ref (entry->priv->location);
else
return NULL;
}
@@ -481,14 +481,14 @@ clock_location_entry_set_city (ClockLocationEntry *entry,
cmpcode = gweather_location_get_code (cmploc);
if (!cmpcode || strcmp (cmpcode, code) != 0) {
- gweather_location_unref (cmploc);
+ g_object_unref (cmploc);
continue;
}
if (city_name) {
cmpname = gweather_location_get_city_name (cmploc);
if (!cmpname || strcmp (cmpname, city_name) != 0) {
- gweather_location_unref (cmploc);
+ g_object_unref (cmploc);
g_free (cmpname);
continue;
}
@@ -496,7 +496,7 @@ clock_location_entry_set_city (ClockLocationEntry *entry,
}
set_location_internal (entry, model, &iter, NULL);
- gweather_location_unref (cmploc);
+ g_object_unref (cmploc);
return TRUE;
} while (gtk_tree_model_iter_next (model, &iter));
diff --git a/modules/clock/clock-location.c b/modules/clock/clock-location.c
index 0b5bf7bc7..98d094c7d 100644
--- a/modules/clock/clock-location.c
+++ b/modules/clock/clock-location.c
@@ -27,7 +27,6 @@ struct _ClockLocationPrivate {
GWeatherLocation *world;
GWeatherLocation *loc;
- GWeatherTimezone *wtz;
GTimeZone *tz;
gdouble latitude;
@@ -56,13 +55,13 @@ static void clock_location_finalize (GObject *);
static gboolean update_weather_info (gpointer user_data);
static void setup_weather_updates (ClockLocation *loc);
-static GWeatherTimezone *
+static GTimeZone *
get_gweather_timezone (ClockLocation *loc)
{
- GWeatherTimezone *tz;
+ GTimeZone *tz;
GWeatherLocation *gloc;
- gloc = gweather_location_ref (loc->priv->loc);
+ gloc = g_object_ref (loc->priv->loc);
tz = gweather_location_get_timezone (gloc);
if (tz == NULL) {
@@ -75,27 +74,27 @@ get_gweather_timezone (ClockLocation *loc)
gloc = gweather_location_get_parent (gloc);
- gweather_location_unref (tmp);
+ g_object_unref (tmp);
}
tmp = gloc;
gloc = gweather_location_find_nearest_city (gloc,
loc->priv->latitude,
loc->priv->longitude);
- gweather_location_unref (tmp);
+ g_object_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 ();
+ return g_time_zone_new_utc ();
}
tz = gweather_location_get_timezone (gloc);
- tz = gweather_timezone_ref (tz);
- gweather_location_unref (gloc);
+ tz = g_time_zone_ref (tz);
+ g_object_unref (gloc);
} else {
- tz = gweather_timezone_ref (tz);
- gweather_location_unref (gloc);
+ tz = g_time_zone_ref (tz);
+ g_object_unref (gloc);
}
return tz;
@@ -112,13 +111,12 @@ clock_location_new (GnomeWallClock *wall_clock,
{
ClockLocation *this;
ClockLocationPrivate *priv;
- const char *tzid;
this = g_object_new (CLOCK_LOCATION_TYPE, NULL);
priv = this->priv;
priv->wall_clock = g_object_ref (wall_clock);
- priv->world = gweather_location_ref (world);
+ priv->world = g_object_ref (world);
priv->loc = gweather_location_find_by_station_code (priv->world,
metar_code);
@@ -135,14 +133,11 @@ clock_location_new (GnomeWallClock *wall_clock,
gweather_location_get_coords (priv->loc, &priv->latitude, &priv->longitude);
}
- priv->wtz = get_gweather_timezone (this);
-
- tzid = gweather_timezone_get_tzid (priv->wtz);
- priv->tz = g_time_zone_new_identifier (tzid);
+ priv->tz = get_gweather_timezone (this);
if (priv->tz == NULL) {
- g_warning ("Invalid timezone identifier - %s, falling back to UTC!",
- tzid);
+ g_warning ("Failed to get timezone for - %s, falling back to UTC!",
+ priv->name);
priv->tz = g_time_zone_new_utc ();
}
@@ -226,10 +221,9 @@ clock_location_finalize (GObject *g_obj)
g_object_unref (priv->wall_clock);
- gweather_location_unref (priv->world);
- gweather_location_unref (priv->loc);
+ g_object_unref (priv->world);
+ g_object_unref (priv->loc);
- gweather_timezone_unref (priv->wtz);
g_time_zone_unref (priv->tz);
if (priv->weather_timeout)
@@ -325,7 +319,7 @@ clock_location_is_current_timezone (ClockLocation *loc)
zone = g_time_zone_get_identifier (timezone);
if (zone)
- return strcmp (zone, gweather_timezone_get_tzid (loc->priv->wtz)) == 0;
+ return strcmp (zone, g_time_zone_get_identifier (loc->priv->tz)) == 0;
else
return clock_location_get_offset (loc) == 0;
}
@@ -456,7 +450,7 @@ clock_location_make_current (ClockLocation *loc,
mcdata->data = data;
mcdata->destroy = destroy;
- set_system_timezone_async (gweather_timezone_get_tzid (loc->priv->wtz),
+ set_system_timezone_async (g_time_zone_get_identifier (loc->priv->tz),
make_current_cb,
mcdata);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]