aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/calendar.c
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-17 12:49:37 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-17 12:49:37 +0800
commit541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72 (patch)
treea1eee2c2ff904bb8244e2a3645ecd4027615fde8 /calendar/gui/calendar.c
parentfe09695939f1d4bcf08b297cf4ade552944514ab (diff)
downloadgsoc2013-evolution-541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72.tar
gsoc2013-evolution-541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72.tar.gz
gsoc2013-evolution-541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72.tar.bz2
gsoc2013-evolution-541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72.tar.lz
gsoc2013-evolution-541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72.tar.xz
gsoc2013-evolution-541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72.tar.zst
gsoc2013-evolution-541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72.zip
New event generation api in place -miguel
svn path=/trunk/; revision=146
Diffstat (limited to 'calendar/gui/calendar.c')
-rw-r--r--calendar/gui/calendar.c65
1 files changed, 59 insertions, 6 deletions
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index dd0a5cca3f..8ad0208ac5 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -111,6 +111,23 @@ ice (time_t t)
return buffer;
}
+void
+calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure)
+{
+ for (; objects; objects = objects->next){
+ iCalObject *object = objects->data;
+
+ if ((start <= object->dtstart) && (object->dtend <= end))
+ (*cb)(object, object->dtstart, object->dtend, closure);
+ }
+}
+
+void
+calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure)
+{
+ calendar_iterate_on_objects (cal->events, start, end, cb, closure);
+}
+
GList *
calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func)
{
@@ -131,12 +148,6 @@ calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompar
}
GList *
-calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
-{
- return calendar_get_objects_in_range (cal->events, start, end, sort_func);
-}
-
-GList *
calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func)
{
return calendar_get_objects_in_range (cal->todo, start, end, sort_func);
@@ -241,3 +252,45 @@ calendar_save (Calendar *cal, char *fname)
cleanStrTbl ();
}
+static void
+calendar_object_compare_by_start (gpointer a, gpointer b)
+{
+ CalendarObject *ca = a;
+ CalendarObject *cb = b;
+ time_t diff;
+
+ diff = ca->ev_start - cb->ev_start;
+ return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
+}
+
+static void
+assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
+{
+ CalendarObject *co;
+ GList **l = c;
+
+ co = g_new (CalendarObject, 1);
+ co->ev_start = start;
+ co->ev_end = end;
+ co->ico = obj;
+ *l = g_list_insert_sorted (*l, co, calendar_object_compare_by_start);
+}
+
+void
+calendar_destroy_event_list (GList *l)
+{
+ GList *p;
+
+ for (p = l; p; p = p->next)
+ g_free (l->data);
+ g_list_free (l);
+}
+
+GList *
+calendar_get_events_in_range (Calendar *cal, time_t start, time_t end)
+{
+ GList *l = 0;
+
+ calendar_iterate (cal, start, end, assemble_event_list, &l);
+ return l;
+}