From 109a7fa77bb4745524eca8a0735b210b55b81fe0 Mon Sep 17 00:00:00 2001 From: Scott Balneaves Date: Wed, 29 Mar 2017 15:31:56 -0500 Subject: Added logic to not send notification if weather update is equal (as decided by weather_info_equal ()) to the previous update --- mateweather/main.c | 3 +++ mateweather/mateweather-applet.c | 7 ++++++- mateweather/mateweather.h | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mateweather/main.c b/mateweather/main.c index de8d8436..e59665f1 100644 --- a/mateweather/main.c +++ b/mateweather/main.c @@ -35,6 +35,9 @@ static gboolean mateweather_applet_new(MatePanelApplet* applet, const gchar* iid gw_applet->applet = applet; gw_applet->mateweather_info = NULL; +#ifdef HAVE_LIBNOTIFY + gw_applet->mateweather_previnfo = NULL; +#endif gw_applet->settings = mate_panel_applet_settings_new (applet, "org.mate.weather"); mateweather_applet_create(gw_applet); diff --git a/mateweather/mateweather-applet.c b/mateweather/mateweather-applet.c index 88840803..cde3e62e 100644 --- a/mateweather/mateweather-applet.c +++ b/mateweather/mateweather-applet.c @@ -451,7 +451,8 @@ update_finish (WeatherInfo *info, gpointer data) place_widgets(gw_applet); #ifdef HAVE_LIBNOTIFY - if (gw_applet->mateweather_pref.show_notifications) + if (gw_applet->mateweather_pref.show_notifications && + !weather_info_equal(gw_applet->mateweather_previnfo, gw_applet->mateweather_info)) { NotifyNotification *n; @@ -491,6 +492,9 @@ update_finish (WeatherInfo *info, gpointer data) g_free (detail); } } + + weather_info_free (gw_applet->mateweather_previnfo); + gw_applet->mateweather_previnfo = weather_info_clone (gw_applet->mateweather_info); #endif } else @@ -547,4 +551,5 @@ void mateweather_update (MateWeatherApplet *gw_applet) &prefs, update_finish, gw_applet); } + } diff --git a/mateweather/mateweather.h b/mateweather/mateweather.h index f486017c..a2f77b6a 100644 --- a/mateweather/mateweather.h +++ b/mateweather/mateweather.h @@ -27,6 +27,9 @@ G_BEGIN_DECLS typedef struct _MateWeatherApplet { MatePanelApplet* applet; WeatherInfo* mateweather_info; +#ifdef HAVE_LIBNOTIFY + WeatherInfo* mateweather_previnfo; +#endif GSettings* settings; -- cgit v1.2.1