[epiphany] Drop duplicate message in notification container
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Drop duplicate message in notification container
- Date: Sat, 18 Jul 2020 20:54:06 +0000 (UTC)
commit 8fba6d165ec9da7a6ae21299451b1c41cd65f7c9
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Thu Jul 16 19:53:28 2020 +0200
Drop duplicate message in notification container
Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/446
lib/ephy-notification-container.c | 14 ++++++++++++++
lib/ephy-notification.c | 7 +++++++
lib/ephy-notification.h | 3 +++
3 files changed, 24 insertions(+)
---
diff --git a/lib/ephy-notification-container.c b/lib/ephy-notification-container.c
index d55d42d4b..2c31bbb9f 100644
--- a/lib/ephy-notification-container.c
+++ b/lib/ephy-notification-container.c
@@ -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);
diff --git a/lib/ephy-notification.c b/lib/ephy-notification.c
index 3df0f3a8e..ce014a5ec 100644
--- a/lib/ephy-notification.c
+++ b/lib/ephy-notification.c
@@ -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;
+}
diff --git a/lib/ephy-notification.h b/lib/ephy-notification.h
index 2052a10e2..fa91569a3 100644
--- a/lib/ephy-notification.h
+++ b/lib/ephy-notification.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]