[gnome-calendar] Added gcal_compare_event_widget_by_date function.



commit 0e39c4f618cbac52a05b3db84c53b469afc69173
Author: Erick PÃrez Castellanos <erick red gmail com>
Date:   Thu Nov 22 11:10:36 2012 -0500

    Added gcal_compare_event_widget_by_date function.
    
    Method added so I can sort the widgets by its start date on
    the views.

 src/gcal-utils.c |   21 +++++++++++++++++++++
 src/gcal-utils.h |    3 +++
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-utils.c b/src/gcal-utils.c
index 34be8e4..c1b3325 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 <libedataserver/libedataserver.h>
 #include <libedataserverui/libedataserverui.h>
@@ -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 5e18835..39e5698 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,



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