[gnome-calendar] search-model: check for duplicate events in search bar
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] search-model: check for duplicate events in search bar
- Date: Tue, 21 Jun 2022 12:29:19 +0000 (UTC)
commit be0a2312d96b5a535417d5c435c6d4343b609c59
Author: Abdullahi Usman <abdullahismn7 gmail com>
Date: Tue Jun 21 12:28:54 2022 +0000
search-model: check for duplicate events in search bar
src/search/gcal-search-model.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/src/search/gcal-search-model.c b/src/search/gcal-search-model.c
index e1f2817d..892878b3 100644
--- a/src/search/gcal-search-model.c
+++ b/src/search/gcal-search-model.c
@@ -94,6 +94,16 @@ compare_search_hits_cb (gconstpointer a,
return gcal_search_hit_compare (hit_a, hit_b);
}
+static gboolean
+search_hits_equals_cb (gconstpointer a,
+ gconstpointer b)
+{
+ GcalSearchHit *search_hit_a = GCAL_SEARCH_HIT ((gpointer) a);
+ GcalSearchHit *search_hit_b = GCAL_SEARCH_HIT ((gpointer) b);
+
+ return gcal_search_hit_compare (search_hit_a, search_hit_b) == 0;
+}
+
static GcalRange*
gcal_search_model_get_range (GcalTimelineSubscriber *subscriber)
{
@@ -108,6 +118,7 @@ gcal_search_model_add_event (GcalTimelineSubscriber *subscriber,
{
g_autoptr (GcalSearchHitEvent) search_hit = NULL;
GcalSearchModel *self;
+ guint position = -1;
self = GCAL_SEARCH_MODEL (subscriber);
@@ -118,6 +129,14 @@ gcal_search_model_add_event (GcalTimelineSubscriber *subscriber,
search_hit = gcal_search_hit_event_new (event);
+ g_list_store_find_with_equal_func (G_LIST_STORE (self->model),
+ search_hit,
+ search_hits_equals_cb,
+ &position);
+
+ if (position != -1)
+ return;
+
g_list_store_insert_sorted (G_LIST_STORE (self->model),
search_hit,
compare_search_hits_cb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]