aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/e-alert-bar.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/widgets/misc/e-alert-bar.c b/widgets/misc/e-alert-bar.c
index cae1bc0172..c20a74e4d0 100644
--- a/widgets/misc/e-alert-bar.c
+++ b/widgets/misc/e-alert-bar.c
@@ -243,13 +243,45 @@ e_alert_bar_new (void)
return g_object_new (E_TYPE_ALERT_BAR, NULL);
}
+struct DuplicateData
+{
+ gboolean found;
+ EAlert *looking_for;
+};
+
+static void
+find_duplicate_cb (gpointer data, gpointer user_data)
+{
+ EAlert *alert = data;
+ struct DuplicateData *dd = user_data;
+
+ g_return_if_fail (alert != NULL);
+ g_return_if_fail (dd != NULL);
+ g_return_if_fail (dd->looking_for != NULL);
+
+ dd->found = dd->found || (
+ e_alert_get_message_type (alert) == e_alert_get_message_type (dd->looking_for) &&
+ g_strcmp0 (e_alert_get_primary_text (alert), e_alert_get_primary_text (dd->looking_for)) == 0 &&
+ g_strcmp0 (e_alert_get_secondary_text (alert), e_alert_get_secondary_text (dd->looking_for)) == 0);
+}
+
void
e_alert_bar_add_alert (EAlertBar *alert_bar,
EAlert *alert)
{
+ struct DuplicateData dd;
+
g_return_if_fail (E_IS_ALERT_BAR (alert_bar));
g_return_if_fail (E_IS_ALERT (alert));
+ dd.found = FALSE;
+ dd.looking_for = alert;
+
+ g_queue_foreach (&alert_bar->priv->alerts, find_duplicate_cb, &dd);
+
+ if (dd.found)
+ return;
+
g_signal_connect (
alert, "response",
G_CALLBACK (alert_bar_response_cb), alert_bar);