diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-04-02 08:15:39 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-02 08:15:39 +0800 |
commit | 9bc7db5333a2319828768142c527d3fb64afd999 (patch) | |
tree | ad58f9ba15220d752cbeb164e99b5791446ed952 /calendar/gui/calendar.c | |
parent | af10696db7572f9933cfae0235574553d016b680 (diff) | |
download | gsoc2013-evolution-9bc7db5333a2319828768142c527d3fb64afd999.tar.gz gsoc2013-evolution-9bc7db5333a2319828768142c527d3fb64afd999.tar.zst gsoc2013-evolution-9bc7db5333a2319828768142c527d3fb64afd999.zip |
These functions now take a sort_func parameter, which is of type
1998-04-01 Federico Mena Quintero <federico@nuclecu.unam.mx>
* calendar.c (calendar_get_objects_in_range):
(calendar_get_events_in_range):
(calendar_get_journal_in_range):
(calendar_get_journal_in_range): These functions now take a
sort_func parameter, which is of type GCompareFunc. If the
specified value is non-NULL, it will return a sorted list.
Otherwise, it will return an unordered list.
(calendar_compare_by_dtstart): Provide a generic sorting routine
for calendar objects.
svn path=/trunk/; revision=88
Diffstat (limited to 'calendar/gui/calendar.c')
-rw-r--r-- | calendar/gui/calendar.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c index b7cf72d47d..e077279461 100644 --- a/calendar/gui/calendar.c +++ b/calendar/gui/calendar.c @@ -86,7 +86,7 @@ calendar_destroy (Calendar *cal) } static GList * -calendar_get_objects_in_range (GList *objects, time_t start, time_t end) +calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func) { GList *new_events = 0; @@ -94,25 +94,42 @@ calendar_get_objects_in_range (GList *objects, time_t start, time_t end) iCalObject *object = objects->data; if ((start <= object->dtstart) && (end >= object->dtend)) - new_events = g_list_prepend (new_events, object); + if (sort_func) + new_events = g_list_insert_sorted (new_events, object, sort_func); + else + new_events = g_list_prepend (new_events, object); } return new_events; } GList * -calendar_get_events_in_range (Calendar *cal, time_t start, time_t end) +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); + 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) +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); + return calendar_get_objects_in_range (cal->todo, start, end, sort_func); } GList * -calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end) +calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func) { - return calendar_get_objects_in_range (cal->journal, start, end); + return calendar_get_objects_in_range (cal->journal, start, end, sort_func); +} + +gint +calendar_compare_by_dtstart (gpointer a, gpointer b) +{ + iCalObject *obj1, *obj2; + time_t diff; + + obj1 = a; + obj2 = b; + + diff = obj1->dtstart - obj2->dtstart; + + return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; } |