[gnome-calendar/gbsneto/timeline: 22/36] timeline: Add API to gather events at a certain range



commit 72952e42cba9c8674d143fa0c8b4ff303101f9e3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Mar 27 10:39:54 2020 -0300

    timeline: Add API to gather events at a certain range
    
    Will be used by the month popover.

 src/core/gcal-timeline.c | 17 +++++++++++++++++
 src/core/gcal-timeline.h |  4 ++++
 2 files changed, 21 insertions(+)
---
diff --git a/src/core/gcal-timeline.c b/src/core/gcal-timeline.c
index be0d57f9..6cace9e4 100644
--- a/src/core/gcal-timeline.c
+++ b/src/core/gcal-timeline.c
@@ -744,6 +744,23 @@ gcal_timeline_remove_subscriber (GcalTimeline           *self,
   GCAL_EXIT;
 }
 
+GPtrArray*
+gcal_timeline_get_events_at_range (GcalTimeline *self,
+                                   GDateTime    *range_start,
+                                   GDateTime    *range_end)
+{
+  g_autoptr (GPtrArray) events_at_range = NULL;
+
+  g_return_val_if_fail (GCAL_IS_TIMELINE (self), NULL);
+  g_return_val_if_fail (range_start != NULL, NULL);
+  g_return_val_if_fail (range_end != NULL, NULL);
+  g_return_val_if_fail (g_date_time_compare (range_start, range_end) < 0, NULL);
+
+  events_at_range = gcal_range_tree_get_data_at_range (self->events, range_start, range_end);
+
+  return g_steal_pointer (&events_at_range);
+}
+
 const gchar*
 gcal_timeline_get_filter (GcalTimeline *self)
 {
diff --git a/src/core/gcal-timeline.h b/src/core/gcal-timeline.h
index c18d297c..03d037d8 100644
--- a/src/core/gcal-timeline.h
+++ b/src/core/gcal-timeline.h
@@ -43,6 +43,10 @@ void                 gcal_timeline_add_subscriber                (GcalTimeline
 void                 gcal_timeline_remove_subscriber             (GcalTimeline           *self,
                                                                   GcalTimelineSubscriber *subscriber);
 
+GPtrArray*           gcal_timeline_get_events_at_range           (GcalTimeline       *self,
+                                                                  GDateTime          *range_start,
+                                                                  GDateTime          *range_end);
+
 const gchar*         gcal_timeline_get_filter                    (GcalTimeline       *self);
 
 void                 gcal_timeline_set_filter                    (GcalTimeline       *self,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]