Commit 8fba6d16 authored by Jan-Michael Brummer's avatar Jan-Michael Brummer Committed by Michael Catanzaro
Browse files

Drop duplicate message in notification container

Fixes: #446
parent 728d924e
Pipeline #197532 passed with stages
in 8 minutes and 7 seconds
......@@ -19,6 +19,7 @@
*/
#include "config.h"
#include "ephy-notification.h"
#include "ephy-notification-container.h"
struct _EphyNotificationContainer {
......@@ -72,9 +73,22 @@ void
ephy_notification_container_add_notification (EphyNotificationContainer *self,
GtkWidget *notification)
{
g_autoptr (GList) children = NULL;
GList *list;
g_assert (EPHY_IS_NOTIFICATION_CONTAINER (self));
g_assert (GTK_IS_WIDGET (notification));
children = gtk_container_get_children (GTK_CONTAINER (self->grid));
for (list = children; list && list->data; list = list->next) {
EphyNotification *child_notification = EPHY_NOTIFICATION (children->data);
if (ephy_notification_is_duplicate (child_notification, EPHY_NOTIFICATION (notification))) {
gtk_widget_destroy (notification);
return;
}
}
gtk_container_add (GTK_CONTAINER (self->grid), notification);
gtk_widget_show_all (GTK_WIDGET (self));
gtk_revealer_set_reveal_child (GTK_REVEALER (self), TRUE);
......
......@@ -213,3 +213,10 @@ ephy_notification_show (EphyNotification *self)
ephy_notification_container_add_notification (ephy_notification_container_get_default (),
GTK_WIDGET (self));
}
gboolean
ephy_notification_is_duplicate (EphyNotification *notification_a,
EphyNotification *notification_b)
{
return g_strcmp0 (notification_a->head_msg, notification_b->head_msg) == 0 && g_strcmp0 (notification_a->body_msg, notification_b->body_msg) == 0;
}
......@@ -33,4 +33,7 @@ EphyNotification *ephy_notification_new (const char *head,
const char *body);
void ephy_notification_show (EphyNotification *self);
gboolean ephy_notification_is_duplicate (EphyNotification *notification_a,
EphyNotification *notification_b);
G_END_DECLS
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment