[gnome-calendar] utils: add helper method for component construction
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] utils: add helper method for component construction
- Date: Thu, 4 Dec 2014 22:46:18 +0000 (UTC)
commit 78bced937e3088c2105a352f80a930e335d33cf0
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Thu Dec 4 15:41:00 2014 -0500
utils: add helper method for component construction
src/gcal-utils.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/gcal-utils.h | 4 ++++
2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-utils.c b/src/gcal-utils.c
index 5a3c130..3bc65fb 100644
--- a/src/gcal-utils.c
+++ b/src/gcal-utils.c
@@ -397,6 +397,56 @@ get_first_weekday (void)
return 0;
}
+/**
+ * build_component_from_details:
+ * @summary:
+ * @initial_date:
+ * @final_date:
+ *
+ * Create a component with the provided details
+ *
+ * Returns: (Transfer full): an { link ECalComponent} object
+ **/
+ECalComponent*
+build_component_from_details (const gchar *summary,
+ const icaltimetype *initial_date,
+ const icaltimetype *final_date)
+{
+ ECalComponent *event;
+
+ ECalComponentDateTime dt;
+ ECalComponentText summ;
+ icaltimetype *dt_start;
+
+ event = e_cal_component_new ();
+ e_cal_component_set_new_vtype (event, E_CAL_COMPONENT_EVENT);
+
+ dt_start = gcal_dup_icaltime (initial_date);
+ dt.value = dt_start;
+ dt.tzid = NULL;
+ e_cal_component_set_dtstart (event, &dt);
+
+ if (final_date != NULL)
+ {
+ *dt.value = *final_date;
+ e_cal_component_set_dtend (event, &dt);
+ }
+ else
+ {
+ icaltime_adjust (dt_start, 1, 0, 0, 0);
+ *dt.value = *dt_start;
+ e_cal_component_set_dtend (event, &dt);
+ }
+
+ summ.altrep = NULL;
+ summ.value = summary;
+ e_cal_component_set_summary (event, &summ);
+
+ e_cal_component_commit_sequence (event);
+
+ return event;
+}
+
/* 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 25ecccf..dad6c80 100644
--- a/src/gcal-utils.h
+++ b/src/gcal-utils.h
@@ -86,6 +86,10 @@ gchar* get_uuid_from_component (ESource
gint get_first_weekday (void);
+ECalComponent* build_component_from_details (const gchar *summary,
+ const icaltimetype *initial_date,
+ const icaltimetype *final_date);
+
/* 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]