summaryrefslogtreecommitdiff
path: root/libmateweather/weather.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmateweather/weather.c')
-rw-r--r--libmateweather/weather.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/libmateweather/weather.c b/libmateweather/weather.c
index 8ffbfde..71d43a4 100644
--- a/libmateweather/weather.c
+++ b/libmateweather/weather.c
@@ -1656,3 +1656,41 @@ _weather_internal_check (void)
g_assert (G_N_ELEMENTS (conditions_str) == PHENOMENON_LAST);
g_assert (G_N_ELEMENTS (conditions_str[0]) == QUALIFIER_LAST);
}
+
+/**
+ * weather_info_equal:
+ * @info1: WeatherInfo to compare
+ * @info2: WeatherInfo to compare
+ *
+ * Returns: gboolean indicating if the two info's are "equal" (i.e. basic
+ * weather attributes are the same)
+ */
+
+gboolean
+weather_info_equal (WeatherInfo *info1, WeatherInfo *info2)
+{
+ g_return_val_if_fail (info1 != NULL, FALSE);
+ g_return_val_if_fail (info2 != NULL, FALSE);
+ g_return_val_if_fail (info1->valid, FALSE);
+ g_return_val_if_fail (info2->valid, FALSE);
+
+ /*
+ * This function is intended to be used to reduce notification spam.
+ * the idea is that unless there's a significant change to either
+ * temp, windspeed, or conditions, there's no need to issue a notification
+ * to the user.
+ */
+
+ if (info1->temp != info2->temp)
+ return FALSE;
+ if (info1->wind != info2->wind)
+ return FALSE;
+ if (info1->windspeed != info2->windspeed)
+ return FALSE;
+ if (info1->cond.significant != info2->cond.significant)
+ return FALSE;
+ if (info1->cond.phenomenon != info2->cond.phenomenon)
+ return FALSE;
+
+ return TRUE;
+}