[gnome-calendar] event-widget: add helper API
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] event-widget: add helper API
- Date: Thu, 18 Dec 2014 14:06:36 +0000 (UTC)
commit 719a294fae35daaac5c95596775e4eb28e87becc
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Sat Dec 13 16:13:03 2014 -0500
event-widget: add helper API
Added GcalEventWidget::is_multiday to check if an event span more than
one day.
Added GcalEventWidget::compare_by_length which compares two event
widgets according to the duration of the events they represent.
src/gcal-event-widget.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/gcal-event-widget.h | 5 +++++
2 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c
index caa8843..b74879a 100644
--- a/src/gcal-event-widget.c
+++ b/src/gcal-event-widget.c
@@ -1000,6 +1000,18 @@ gcal_event_widget_get_all_day (GcalEventWidget *event)
return all_day;
}
+gboolean
+gcal_event_widget_is_multiday (GcalEventWidget *event)
+{
+ GcalEventWidgetPrivate *priv;
+ priv = gcal_event_widget_get_instance_private (event);
+
+ if (priv->dt_end == NULL)
+ return FALSE;
+
+ return priv->dt_start->day != priv->dt_end->day;
+}
+
void
gcal_event_widget_set_has_reminders (GcalEventWidget *event,
gboolean has_reminders)
@@ -1081,3 +1093,36 @@ gcal_event_widget_equal (GcalEventWidget *widget1,
return same_id;
}
+
+/**
+ * gcal_event_widget_compare_by_length:
+ * @widget1:
+ * @widget2:
+ *
+ * Compare two widgets by the duration of the events they represent. From shortest to longest span.
+ *
+ * Returns: negative value if a < b ; zero if a = b ; positive value if a > b
+ **/
+gint
+gcal_event_widget_compare_by_length (GcalEventWidget *widget1,
+ GcalEventWidget *widget2)
+{
+ GcalEventWidgetPrivate *priv1;
+ GcalEventWidgetPrivate *priv2;
+
+ time_t time_s1, time_s2;
+ time_t time_e1, time_e2;
+
+ priv1 = gcal_event_widget_get_instance_private (widget1);
+ priv2 = gcal_event_widget_get_instance_private (widget2);
+
+ time_e1 = time_s1 = icaltime_as_timet (*(priv1->dt_start));
+ time_e2 = time_s2 = icaltime_as_timet (*(priv2->dt_start));
+
+ if (priv1->dt_end != NULL)
+ time_e1 = icaltime_as_timet (*(priv1->dt_end));
+ if (priv2->dt_end)
+ time_e2 = icaltime_as_timet (*(priv2->dt_end));
+
+ return (time_e2 - time_s2) - (time_e1 - time_s1);
+}
diff --git a/src/gcal-event-widget.h b/src/gcal-event-widget.h
index 75268c4..99fe239 100644
--- a/src/gcal-event-widget.h
+++ b/src/gcal-event-widget.h
@@ -95,6 +95,8 @@ void gcal_event_widget_set_all_day (GcalEventWidget *
gboolean gcal_event_widget_get_all_day (GcalEventWidget *event);
+gboolean gcal_event_widget_is_multiday (GcalEventWidget *event);
+
void gcal_event_widget_set_has_reminders (GcalEventWidget *event,
gboolean has_reminders);
@@ -105,6 +107,9 @@ GcalEventData* gcal_event_widget_get_data (GcalEventWidget *
gboolean gcal_event_widget_equal (GcalEventWidget *widget1,
GcalEventWidget *widget2);
+gint gcal_event_widget_compare_by_length (GcalEventWidget *widget1,
+ GcalEventWidget *widget2);
+
G_END_DECLS
#endif /* __GCAL_EVENT_WIDGET_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]