aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-04-02 08:15:39 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-02 08:15:39 +0800
commit9bc7db5333a2319828768142c527d3fb64afd999 (patch)
treead58f9ba15220d752cbeb164e99b5791446ed952
parentaf10696db7572f9933cfae0235574553d016b680 (diff)
downloadgsoc2013-evolution-9bc7db5333a2319828768142c527d3fb64afd999.tar
gsoc2013-evolution-9bc7db5333a2319828768142c527d3fb64afd999.tar.gz
gsoc2013-evolution-9bc7db5333a2319828768142c527d3fb64afd999.tar.bz2
gsoc2013-evolution-9bc7db5333a2319828768142c527d3fb64afd999.tar.lz
gsoc2013-evolution-9bc7db5333a2319828768142c527d3fb64afd999.tar.xz
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
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/calendar.c33
-rw-r--r--calendar/calendar.h8
-rw-r--r--calendar/gui/calendar.c33
-rw-r--r--calendar/gui/calendar.h8
5 files changed, 72 insertions, 22 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index f971250cde..536ac464f9 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,15 @@
+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.
+
Tue Mar 31 23:46:50 1998 Tom Tromey <tromey@cygnus.com>
* timeutil.c (format_simple_hour): `buf' now static.
diff --git a/calendar/calendar.c b/calendar/calendar.c
index b7cf72d47d..e077279461 100644
--- a/calendar/calendar.c
+++ b/calendar/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;
}
diff --git a/calendar/calendar.h b/calendar/calendar.h
index d10cfe28be..bfbee92df8 100644
--- a/calendar/calendar.h
+++ b/calendar/calendar.h
@@ -18,9 +18,11 @@ void calendar_add_object (Calendar *cal, iCalObject *obj);
void calendar_remove_object (Calendar *cal, iCalObject *obj);
void calendar_destroy (Calendar *cal);
-GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
-GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end);
-GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end);
+GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
+GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
+GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
+
+gint calendar_compare_by_dtstart (gpointer a, gpointer b);
END_GNOME_DECLS
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;
}
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
index d10cfe28be..bfbee92df8 100644
--- a/calendar/gui/calendar.h
+++ b/calendar/gui/calendar.h
@@ -18,9 +18,11 @@ void calendar_add_object (Calendar *cal, iCalObject *obj);
void calendar_remove_object (Calendar *cal, iCalObject *obj);
void calendar_destroy (Calendar *cal);
-GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
-GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end);
-GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end);
+GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
+GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
+GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
+
+gint calendar_compare_by_dtstart (gpointer a, gpointer b);
END_GNOME_DECLS