M!102 - Port to libgweather4
Adds support for linking against gweather4 (pass -DWITH_GWEATHER4=ON). Closes https://gitlab.gnome.org/GNOME/evolution/-/merge_requests/102
This commit is contained in:
parent
ac7484481b
commit
d848856c94
@ -92,6 +92,7 @@ set(geocode_glib_minimum_version 3.10)
|
||||
set(gladeui_minimum_version 3.10.0)
|
||||
set(gnome_autoar_minimum_version 0.1.1)
|
||||
set(gweather_minimum_version 3.10)
|
||||
set(gweather4_minimum_version 3.91.0)
|
||||
set(libcanberra_gtk_minimum_version 0.25)
|
||||
set(libnotify_minimum_version 0.7)
|
||||
set(libunity_minimum_version 7.1.4)
|
||||
@ -668,7 +669,14 @@ endif(ENABLE_TEXT_HIGHLIGHT)
|
||||
add_printable_option(ENABLE_WEATHER "Enable weather calendars" ON)
|
||||
|
||||
if(ENABLE_WEATHER)
|
||||
pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar" GWEATHER gweather-3.0>=${gweather_minimum_version})
|
||||
add_printable_variable(WITH_GWEATHER4 "Use GWeather 4 instead of 3" OFF)
|
||||
|
||||
if(WITH_GWEATHER4)
|
||||
pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar" GWEATHER gweather4>=${gweather4_minimum_version})
|
||||
else(WITH_GWEATHER4)
|
||||
pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar" GWEATHER gweather-3.0>=${gweather_minimum_version})
|
||||
endif(WITH_GWEATHER4)
|
||||
|
||||
pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar" GEO geocode-glib-1.0>=${geocode_glib_minimum_version})
|
||||
endif(ENABLE_WEATHER)
|
||||
|
||||
|
@ -93,6 +93,9 @@
|
||||
/* When defined GSpell usage is enabled */
|
||||
#cmakedefine HAVE_GSPELL 1
|
||||
|
||||
/* Defined when linking against gweather4. Cannot just use GWEATHER_CHECK_VERSION because 40.0 made the versions non-monotonic. */
|
||||
#cmakedefine WITH_GWEATHER4 1
|
||||
|
||||
/* Source code highlighting utility */
|
||||
#cmakedefine HIGHLIGHT_COMMAND "@HIGHLIGHT_COMMAND@"
|
||||
|
||||
|
@ -125,9 +125,17 @@ finalize (GObject *object)
|
||||
priv = entry->priv;
|
||||
|
||||
if (priv->location)
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (priv->location);
|
||||
#else
|
||||
gweather_location_unref (priv->location);
|
||||
#endif
|
||||
if (priv->top)
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (priv->top);
|
||||
#else
|
||||
gweather_location_unref (priv->top);
|
||||
#endif
|
||||
if (priv->model)
|
||||
g_object_unref (priv->model);
|
||||
|
||||
@ -214,11 +222,15 @@ e_weather_location_entry_class_init (EWeatherLocationEntryClass *location_entry_
|
||||
|
||||
g_object_class_install_property (
|
||||
object_class, PROP_TOP,
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_param_spec_object ("top",
|
||||
#else
|
||||
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));
|
||||
#endif
|
||||
"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,
|
||||
@ -230,11 +242,15 @@ e_weather_location_entry_class_init (EWeatherLocationEntryClass *location_entry_
|
||||
|
||||
g_object_class_install_property (
|
||||
object_class, PROP_LOCATION,
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_param_spec_object ("location",
|
||||
#else
|
||||
g_param_spec_boxed ("location",
|
||||
"Location",
|
||||
"The selected GWeatherLocation",
|
||||
GWEATHER_TYPE_LOCATION,
|
||||
G_PARAM_READWRITE));
|
||||
#endif
|
||||
"Location",
|
||||
"The selected GWeatherLocation",
|
||||
GWEATHER_TYPE_LOCATION,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -247,14 +263,22 @@ set_property (GObject *object,
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_TOP:
|
||||
#ifdef WITH_GWEATHER4
|
||||
entry->priv->top = g_value_dup_object (value);
|
||||
#else
|
||||
entry->priv->top = g_value_dup_boxed (value);
|
||||
#endif
|
||||
break;
|
||||
case PROP_SHOW_NAMED_TIMEZONES:
|
||||
entry->priv->show_named_timezones = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_LOCATION:
|
||||
e_weather_location_entry_set_location (E_WEATHER_LOCATION_ENTRY (object),
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_value_get_object (value));
|
||||
#else
|
||||
g_value_get_boxed (value));
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -275,7 +299,11 @@ get_property (GObject *object,
|
||||
g_value_set_boolean (value, entry->priv->show_named_timezones);
|
||||
break;
|
||||
case PROP_LOCATION:
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_value_set_object (value, entry->priv->location);
|
||||
#else
|
||||
g_value_set_boxed (value, entry->priv->location);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -321,7 +349,11 @@ set_location_internal (EWeatherLocationEntry *entry,
|
||||
priv = entry->priv;
|
||||
|
||||
if (priv->location)
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (priv->location);
|
||||
#else
|
||||
gweather_location_unref (priv->location);
|
||||
#endif
|
||||
|
||||
g_return_if_fail (iter == NULL || loc == NULL);
|
||||
|
||||
@ -334,7 +366,11 @@ set_location_internal (EWeatherLocationEntry *entry,
|
||||
priv->custom_text = FALSE;
|
||||
g_free (name);
|
||||
} else if (loc) {
|
||||
#ifdef WITH_GWEATHER4
|
||||
priv->location = g_object_ref (loc);
|
||||
#else
|
||||
priv->location = gweather_location_ref (loc);
|
||||
#endif
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), gweather_location_get_name (loc));
|
||||
priv->custom_text = FALSE;
|
||||
} else {
|
||||
@ -384,11 +420,19 @@ e_weather_location_entry_set_location (EWeatherLocationEntry *entry,
|
||||
-1);
|
||||
if (gweather_location_equal (loc, cmploc)) {
|
||||
set_location_internal (entry, model, &iter, NULL);
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (cmploc);
|
||||
#else
|
||||
gweather_location_unref (cmploc);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (cmploc);
|
||||
#else
|
||||
gweather_location_unref (cmploc);
|
||||
#endif
|
||||
} while (gtk_tree_model_iter_next (model, &iter));
|
||||
|
||||
set_location_internal (entry, model, NULL, loc);
|
||||
@ -411,7 +455,11 @@ e_weather_location_entry_get_location (EWeatherLocationEntry *entry)
|
||||
g_return_val_if_fail (E_WEATHER_IS_LOCATION_ENTRY (entry), NULL);
|
||||
|
||||
if (entry->priv->location)
|
||||
#ifdef WITH_GWEATHER4
|
||||
return g_object_ref (entry->priv->location);
|
||||
#else
|
||||
return gweather_location_ref (entry->priv->location);
|
||||
#endif
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
@ -474,14 +522,22 @@ e_weather_location_entry_set_city (EWeatherLocationEntry *entry,
|
||||
|
||||
cmpcode = gweather_location_get_code (cmploc);
|
||||
if (!cmpcode || strcmp (cmpcode, code) != 0) {
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (cmploc);
|
||||
#else
|
||||
gweather_location_unref (cmploc);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if (city_name) {
|
||||
cmpname = gweather_location_get_city_name (cmploc);
|
||||
if (!cmpname || strcmp (cmpname, city_name) != 0) {
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (cmploc);
|
||||
#else
|
||||
gweather_location_unref (cmploc);
|
||||
#endif
|
||||
g_free (cmpname);
|
||||
continue;
|
||||
}
|
||||
@ -489,7 +545,11 @@ e_weather_location_entry_set_city (EWeatherLocationEntry *entry,
|
||||
}
|
||||
|
||||
set_location_internal (entry, model, &iter, NULL);
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (cmploc);
|
||||
#else
|
||||
gweather_location_unref (cmploc);
|
||||
#endif
|
||||
return TRUE;
|
||||
} while (gtk_tree_model_iter_next (model, &iter));
|
||||
|
||||
@ -611,7 +671,11 @@ fill_location_entry_model (GtkListStore *store,
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_clear_object (&child);
|
||||
#else
|
||||
g_clear_pointer (&child, gweather_location_unref);
|
||||
#endif
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
@ -72,10 +72,18 @@ cal_config_weather_location_to_string (GBinding *binding,
|
||||
GWeatherLocation *location;
|
||||
gchar *string = NULL;
|
||||
|
||||
#ifdef WITH_GWEATHER4
|
||||
location = g_value_get_object (source_value);
|
||||
#else
|
||||
location = g_value_get_boxed (source_value);
|
||||
#endif
|
||||
#if GWEATHER_CHECK_VERSION(3, 39, 0)
|
||||
if (location)
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_ref (location);
|
||||
#else
|
||||
gweather_location_ref (location);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
while (location && !gweather_location_has_coords (location)) {
|
||||
@ -83,7 +91,11 @@ cal_config_weather_location_to_string (GBinding *binding,
|
||||
GWeatherLocation *child = location;
|
||||
|
||||
location = gweather_location_get_parent (child);
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (child);
|
||||
#else
|
||||
gweather_location_unref (child);
|
||||
#endif
|
||||
#else
|
||||
location = gweather_location_get_parent (location);
|
||||
#endif
|
||||
@ -101,7 +113,9 @@ cal_config_weather_location_to_string (GBinding *binding,
|
||||
|
||||
string = g_strdup_printf ("%s/%s", lat_str, lon_str);
|
||||
|
||||
#if GWEATHER_CHECK_VERSION(3, 39, 0)
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (location);
|
||||
#elif GWEATHER_CHECK_VERSION(3, 39, 0)
|
||||
gweather_location_unref (location);
|
||||
#endif
|
||||
}
|
||||
@ -134,7 +148,11 @@ cal_config_weather_find_location_by_coords (GWeatherLocation *start,
|
||||
gweather_location_get_coords (location, &lat, &lon);
|
||||
|
||||
if (lat == latitude && lon == longitude) {
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_ref (location);
|
||||
#else
|
||||
gweather_location_ref (location);
|
||||
#endif
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@ -145,7 +163,11 @@ cal_config_weather_find_location_by_coords (GWeatherLocation *start,
|
||||
|
||||
result = cal_config_weather_find_location_by_coords (child, latitude, longitude);
|
||||
if (result) {
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (child);
|
||||
#else
|
||||
gweather_location_unref (child);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -154,7 +176,11 @@ cal_config_weather_find_location_by_coords (GWeatherLocation *start,
|
||||
for (ii = 0; children[ii]; ii++) {
|
||||
location = cal_config_weather_find_location_by_coords (children[ii], latitude, longitude);
|
||||
if (location) {
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_ref (location);
|
||||
#else
|
||||
gweather_location_ref (location);
|
||||
#endif
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@ -194,7 +220,11 @@ cal_config_weather_string_to_location (GBinding *binding,
|
||||
|
||||
match = cal_config_weather_find_location_by_coords (world, latitude, longitude);
|
||||
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_value_take_object (target_value, match);
|
||||
#else
|
||||
g_value_take_boxed (target_value, match);
|
||||
#endif
|
||||
|
||||
g_strfreev (tokens);
|
||||
|
||||
@ -320,8 +350,13 @@ cal_config_weather_insert_widgets (ESourceConfigBackend *backend,
|
||||
G_BINDING_SYNC_CREATE,
|
||||
cal_config_weather_string_to_location,
|
||||
cal_config_weather_location_to_string,
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_ref (world),
|
||||
g_object_unref);
|
||||
#else
|
||||
gweather_location_ref (world),
|
||||
(GDestroyNotify) gweather_location_unref);
|
||||
#endif
|
||||
|
||||
e_binding_bind_property (
|
||||
extension, "units",
|
||||
@ -329,7 +364,9 @@ cal_config_weather_insert_widgets (ESourceConfigBackend *backend,
|
||||
G_BINDING_BIDIRECTIONAL |
|
||||
G_BINDING_SYNC_CREATE);
|
||||
|
||||
#if GWEATHER_CHECK_VERSION(3, 39, 0)
|
||||
#ifdef WITH_GWEATHER4
|
||||
g_object_unref (world);
|
||||
#elif GWEATHER_CHECK_VERSION(3, 39, 0)
|
||||
gweather_location_unref (world);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user