From: Roy Marples Date: Tue, 12 Oct 2010 10:58:35 +0000 (+0000) Subject: Don't spam the last message if the same. X-Git-Tag: dhcpcd-ui-0.5.2~2 X-Git-Url: https://roy.marples.name/git?ds=sidebyside Don't spam the last message if the same. --- diff --git a/src/dhcpcd-gtk/main.c b/src/dhcpcd-gtk/main.c index 9734ad5..222ef5c 100644 --- a/src/dhcpcd-gtk/main.c +++ b/src/dhcpcd-gtk/main.c @@ -177,6 +177,8 @@ notify_close(void) } #ifdef NOTIFY +static char *notify_last_msg; + static void notify_closed(void) { @@ -188,6 +190,14 @@ notify(const char *title, const char *msg, const char *icon) { char **msgs, **m; + /* Don't spam the same message */ + if (notify_last_msg) { + if (strcmp(msg, notify_last_msg) == 0) + return; + g_free(notify_last_msg); + } + notify_last_msg = g_strdup(msg); + msgs = g_strsplit(msg, "\n", 0); for (m = msgs; *m; m++) g_message("%s", *m);