diff --git a/src/gcal-utils.c b/src/gcal-utils.c index 34be8e4b..c1b33252 100644 --- a/src/gcal-utils.c +++ b/src/gcal-utils.c @@ -19,6 +19,8 @@ */ #include "gcal-utils.h" +#include "gcal-event-widget.h" +#include "gcal-view.h" #include #include @@ -258,6 +260,25 @@ gcal_get_pixbuf_from_color (GdkColor *color) return pix; } +gint +gcal_compare_event_widget_by_date (gconstpointer a, + gconstpointer b) +{ + /* negative value if a < b; zero if a = b; positive value if a > b. */ + GcalViewChild *a_child; + GcalViewChild *b_child; + icaltimetype *a_date; + icaltimetype *b_date; + + a_child = (GcalViewChild*) a; + b_child = (GcalViewChild*) b; + + a_date = gcal_event_widget_get_date (GCAL_EVENT_WIDGET (a_child->widget)); + b_date = gcal_event_widget_get_date (GCAL_EVENT_WIDGET (b_child->widget)); + + return icaltime_compare (*a_date, *b_date); +} + /* Function to do a last minute fixup of the AM/PM stuff if the locale * and gettext haven't done it right. Most English speaking countries * except the USA use the 24 hour clock (UK, Australia etc). However diff --git a/src/gcal-utils.h b/src/gcal-utils.h index 5e188356..39e56987 100644 --- a/src/gcal-utils.h +++ b/src/gcal-utils.h @@ -81,6 +81,9 @@ gchar* gcal_get_month_name (gint GdkPixbuf* gcal_get_pixbuf_from_color (GdkColor *color); +gint gcal_compare_event_widget_by_date (gconstpointer a, + gconstpointer b); + /* code brought from evolution */ gsize e_strftime_fix_am_pm (gchar *str, gsize max,