[evolution/wip/mcrha/eds-libical-glib] src/calendar/gui more e-comp-editor-page-...-s
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/mcrha/eds-libical-glib] src/calendar/gui more e-comp-editor-page-...-s
- Date: Thu, 28 Mar 2019 11:12:45 +0000 (UTC)
commit e309c3b24c273109a5a1bf9ea114b6fe9387a77d
Author: Milan Crha <mcrha redhat com>
Date: Thu Mar 28 12:13:32 2019 +0100
src/calendar/gui more e-comp-editor-page-...-s
src/calendar/gui/e-comp-editor-page-recurrence.c | 252 ++++++-----
src/calendar/gui/e-comp-editor-page-reminders.c | 534 ++++++++++++-----------
src/calendar/gui/e-comp-editor-page-schedule.c | 144 +++---
3 files changed, 517 insertions(+), 413 deletions(-)
---
diff --git a/src/calendar/gui/e-comp-editor-page-recurrence.c
b/src/calendar/gui/e-comp-editor-page-recurrence.c
index bdc72c4332..10ebba36e7 100644
--- a/src/calendar/gui/e-comp-editor-page-recurrence.c
+++ b/src/calendar/gui/e-comp-editor-page-recurrence.c
@@ -163,8 +163,8 @@ ecep_recurrence_update_preview (ECompEditorPageRecurrence *page_recurrence)
ECompEditor *comp_editor;
ECalClient *client;
ECalComponent *comp;
- icalcomponent *icalcomp;
- const icalcomponent *editing_comp;
+ ICalComponent *icomp;
+ const ICalComponent *editing_comp;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_RECURRENCE (page_recurrence));
g_return_if_fail (E_IS_CALENDAR (page_recurrence->priv->preview));
@@ -177,39 +177,42 @@ ecep_recurrence_update_preview (ECompEditorPageRecurrence *page_recurrence)
e_calendar_item_clear_marks (e_calendar_get_item (E_CALENDAR (page_recurrence->priv->preview)));
editing_comp = e_comp_editor_get_component (comp_editor);
- if (!editing_comp || e_cal_util_component_is_instance ((icalcomponent *) editing_comp)) {
+ if (!editing_comp || e_cal_util_component_is_instance ((ICalComponent *) editing_comp)) {
g_clear_object (&comp_editor);
return;
}
- icalcomp = icalcomponent_new_clone ((icalcomponent *) editing_comp);
+ icomp = i_cal_component_new_clone ((ICalComponent *) editing_comp);
e_comp_editor_set_updating (comp_editor, TRUE);
- e_comp_editor_fill_component (comp_editor, icalcomp);
+ e_comp_editor_fill_component (comp_editor, icomp);
e_comp_editor_set_updating (comp_editor, FALSE);
- comp = e_cal_component_new_from_icalcomponent (icalcomp);
+ comp = e_cal_component_new_from_icalcomponent (icomp);
if (comp) {
- icaltimezone *zone = NULL;
+ ICalTimezone *zone = NULL;
- icalcomp = e_cal_component_get_icalcomponent (comp);
+ icomp = e_cal_component_get_icalcomponent (comp);
- if (icalcomponent_get_first_property (icalcomp, ICAL_DTSTART_PROPERTY)) {
- struct icaltimetype dt;
+ if (e_cal_util_component_has_property (icomp, I_CAL_DTSTART_PROPERTY)) {
+ ICalTime *dt;
- dt = icalcomponent_get_dtstart (icalcomp);
- zone = (icaltimezone *) dt.zone;
+ dt = i_cal_component_get_dtstart (icomp);
+ zone = i_cal_time_get_timezone (dt);
}
- e_cal_component_rescan (comp);
-
- if (!zone)
+ if (!zone) {
zone = calendar_config_get_icaltimezone ();
+ if (zone)
+ g_object_ref (zone);
+ }
tag_calendar_by_comp (
E_CALENDAR (page_recurrence->priv->preview), comp,
client, zone, TRUE, FALSE, FALSE, page_recurrence->priv->cancellable);
+
+ g_clear_object (&zone);
g_object_unref (comp);
}
@@ -234,7 +237,7 @@ ecep_recurrence_changed (ECompEditorPageRecurrence *page_recurrence)
static void
ecep_recurrence_append_exception (ECompEditorPageRecurrence *page_recurrence,
- const struct icaltimetype itt)
+ const ICalTime *itt)
{
GtkTreeView *view;
GtkTreeIter iter;
@@ -247,23 +250,27 @@ ecep_recurrence_append_exception (ECompEditorPageRecurrence *page_recurrence,
static void
ecep_recurrence_fill_exception_widgets (ECompEditorPageRecurrence *page_recurrence,
- icalcomponent *component)
+ ICalComponent *component)
{
- icalproperty *prop;
+ ICalProperty *prop;
e_date_time_list_clear (page_recurrence->priv->exceptions_store);
- for (prop = icalcomponent_get_first_property (component, ICAL_EXDATE_PROPERTY);
+ for (prop = i_cal_component_get_first_property (component, I_CAL_EXDATE_PROPERTY);
prop;
- prop = icalcomponent_get_next_property (component, ICAL_EXDATE_PROPERTY)) {
- struct icaltimetype itt;
+ g_object_unref (prop), prop = i_cal_component_get_next_property (component,
I_CAL_EXDATE_PROPERTY)) {
+ ICalTime *itt;
- itt = icalproperty_get_exdate (prop);
- if (!icaltime_is_valid_time (itt) ||
- icaltime_is_null_time (itt))
+ itt = i_cal_property_get_exdate (prop);
+ if (!itt || !i_cal_time_is_valid_time (itt) ||
+ i_cal_time_is_null_time (itt)) {
+ g_clear_object (&itt);
continue;
+ }
ecep_recurrence_append_exception (page_recurrence, itt);
+
+ g_clear_object (&itt);
}
}
@@ -325,18 +332,21 @@ ecep_recurrence_exceptions_add_clicked_cb (GtkButton *button,
dialog = ecep_recurrence_create_exception_dialog (page_recurrence, _("Add exception"), &date_edit);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- struct icaltimetype itt = icaltime_null_time ();
+ gint year, month, day;
+
+ if (e_date_edit_get_date (E_DATE_EDIT (date_edit), &year, &month, &day)) {
+ ICalTime *itt = i_cal_time_null_time ();
- /* We use DATE values for exceptions, so we don't need a TZID. */
- itt.zone = NULL;
- itt.hour = 0;
- itt.minute = 0;
- itt.second = 0;
- itt.is_date = 1;
+ /* We use DATE values for exceptions, so we don't need a TZID. */
+ i_cal_time_set_timezone (itt, NULL);
+ i_cal_time_set_date (itt, year, month, day);
+ i_cal_time_set_time (itt, 0, 0, 0);
+ i_cal_time_set_is_date (itt, TRUE);
- if (e_date_edit_get_date (E_DATE_EDIT (date_edit), &itt.year, &itt.month, &itt.day)) {
ecep_recurrence_append_exception (page_recurrence, itt);
ecep_recurrence_changed (page_recurrence);
+
+ g_clear_object (&itt);
}
}
@@ -348,7 +358,7 @@ ecep_recurrence_exceptions_edit_clicked_cb (GtkButton *button,
ECompEditorPageRecurrence *page_recurrence)
{
GtkWidget *dialog, *date_edit;
- const struct icaltimetype *current_itt;
+ const ICalTime *current_itt;
GtkTreeSelection *selection;
GtkTreeIter iter;
@@ -362,21 +372,24 @@ ecep_recurrence_exceptions_edit_clicked_cb (GtkButton *button,
dialog = ecep_recurrence_create_exception_dialog (page_recurrence, _("Modify exception"), &date_edit);
e_date_edit_set_date (E_DATE_EDIT (date_edit),
- current_itt->year, current_itt->month, current_itt->day);
+ i_cal_time_get_year (current_itt), i_cal_time_get_month (current_itt), i_cal_time_get_day
(current_itt));
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- struct icaltimetype itt = icaltime_null_time ();
+ gint year, month, day;
+
+ if (e_date_edit_get_date (E_DATE_EDIT (date_edit), &year, &month, &day)) {
+ ICalTime *itt = i_cal_time_null_time ();
- /* We use DATE values for exceptions, so we don't need a TZID. */
- itt.zone = NULL;
- itt.hour = 0;
- itt.minute = 0;
- itt.second = 0;
- itt.is_date = 1;
+ /* We use DATE values for exceptions, so we don't need a TZID. */
+ i_cal_time_set_timezone (itt, NULL);
+ i_cal_time_set_date (itt, year, month, day);
+ i_cal_time_set_time (itt, 0, 0, 0);
+ i_cal_time_set_is_date (itt, TRUE);
- if (e_date_edit_get_date (E_DATE_EDIT (date_edit), &itt.year, &itt.month, &itt.day)) {
e_date_time_list_set_date_time (page_recurrence->priv->exceptions_store, &iter, itt);
ecep_recurrence_changed (page_recurrence);
+
+ g_clear_object (&itt);
}
}
@@ -436,11 +449,16 @@ static struct tm
ecep_recurrence_get_current_time_cb (ECalendarItem *calitem,
gpointer user_data)
{
- struct icaltimetype today;
+ ICalTime *today;
+ struct tm tm;
- today = icaltime_today ();
+ today = i_cal_time_today ();
- return e_cal_util_icaltime_to_tm (&today);
+ tm = e_cal_util_icaltime_to_tm (today);
+
+ g_clear_object (&today);
+
+ return tm;
}
static GtkWidget *
@@ -913,7 +931,7 @@ ecep_recurrence_make_ending_until_special (ECompEditorPageRecurrence *page_recur
{
ECompEditor *comp_editor;
guint32 flags;
- const icalcomponent *icomp;
+ const ICalComponent *icomp;
EDateEdit *date_edit;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_RECURRENCE (page_recurrence));
@@ -939,13 +957,13 @@ ecep_recurrence_make_ending_until_special (ECompEditorPageRecurrence *page_recur
icomp = e_comp_editor_get_component (comp_editor);
if ((flags & E_COMP_EDITOR_FLAG_IS_NEW) != 0 && icomp) {
- struct icaltimetype itt;
+ ICalTime *itt;
- itt = icalcomponent_get_dtstart ((icalcomponent *) icomp);
+ itt = i_cal_component_get_dtstart ((ICalComponent *) icomp);
/* Setting the default until time to 2 weeks */
- icaltime_adjust (&itt, 14, 0, 0, 0);
+ i_cal_time_adjust (itt, 14, 0, 0, 0);
- e_date_edit_set_date (date_edit, itt.year, itt.month, itt.day);
+ e_date_edit_set_date (date_edit, i_cal_time_get_year (itt), i_cal_time_get_month (itt),
i_cal_time_get_day (itt));
} else {
e_date_edit_set_date (date_edit,
page_recurrence->priv->ending_date_tt.year,
@@ -1055,7 +1073,7 @@ ecep_recurrence_make_ending_special (ECompEditorPageRecurrence *page_recurrence)
static void
ecep_recurrence_fill_ending_date (ECompEditorPageRecurrence *page_recurrence,
struct icalrecurrencetype *rrule,
- icalcomponent *component)
+ ICalComponent *component)
{
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_RECURRENCE (page_recurrence));
@@ -1073,13 +1091,16 @@ ecep_recurrence_fill_ending_date (ECompEditorPageRecurrence *page_recurrence,
/* Ending date */
if (!rrule->until.is_date) {
- icaltimezone *from_zone, *to_zone;
- struct icaltimetype dtstart;
+ icaltimezone *from_zone, *to_zone = NULL;
+ ICalTimezone *izone;
+ ICalTime *dtstart;
- dtstart = icalcomponent_get_dtstart (component);
+ dtstart = i_cal_component_get_dtstart (component);
from_zone = icaltimezone_get_utc_timezone ();
- to_zone = (icaltimezone *) dtstart.zone;
+ izone = dtstart ? i_cal_time_get_timezone (dtstart) : NULL;
+ if (izone)
+ to_zone = i_cal_object_get_native (I_CAL_OBJECT (izone));
if (to_zone)
icaltimezone_convert_time (&rrule->until, from_zone, to_zone);
@@ -1088,6 +1109,8 @@ ecep_recurrence_fill_ending_date (ECompEditorPageRecurrence *page_recurrence,
rrule->until.minute = 0;
rrule->until.second = 0;
rrule->until.is_date = TRUE;
+
+ g_clear_object (&izone);
}
page_recurrence->priv->ending_date_tt = rrule->until;
@@ -1115,24 +1138,26 @@ ecep_recurrence_fill_ending_date (ECompEditorPageRecurrence *page_recurrence,
* for use in a WeekdayPicker widget.
*/
static guint8
-ecep_recurrence_get_start_weekday_mask (icalcomponent *component)
+ecep_recurrence_get_start_weekday_mask (ICalComponent *component)
{
- struct icaltimetype dtstart;
+ ICalTime *dtstart;
guint8 retval;
if (!component)
return 0;
- dtstart = icalcomponent_get_dtstart (component);
+ dtstart = i_cal_component_get_dtstart (component);
- if (icaltime_is_valid_time (dtstart)) {
+ if (dtstart && i_cal_time_is_valid_time (dtstart)) {
gshort weekday;
- weekday = icaltime_day_of_week (dtstart);
+ weekday = i_cal_time_day_of_week (dtstart);
retval = 0x1 << (weekday - 1);
} else
retval = 0;
+ g_clear_object (&dtstart);
+
return retval;
}
@@ -1141,7 +1166,7 @@ ecep_recurrence_get_start_weekday_mask (icalcomponent *component)
*/
static void
ecep_recurrence_set_special_defaults (ECompEditorPageRecurrence *page_recurrence,
- icalcomponent *component)
+ ICalComponent *component)
{
guint8 mask;
@@ -1199,11 +1224,12 @@ ecep_recurrence_clear_widgets (ECompEditorPageRecurrence *page_recurrence)
static void
ecep_recurrence_simple_recur_to_comp (ECompEditorPageRecurrence *page_recurrence,
- icalcomponent *component)
+ ICalComponent *component)
{
struct icalrecurrencetype r;
enum ending_type ending_type;
- icalproperty *prop;
+ ICalProperty *prop;
+ ICalRecurrence *recur;
gboolean date_set;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_RECURRENCE (page_recurrence));
@@ -1406,8 +1432,12 @@ ecep_recurrence_simple_recur_to_comp (ECompEditorPageRecurrence *page_recurrence
e_cal_util_component_remove_property_by_kind (component, I_CAL_RRULE_PROPERTY, TRUE);
/* Set the recurrence */
- prop = icalproperty_new_rrule (r);
- icalcomponent_add_property (component, prop);
+ recur = i_cal_object_construct (I_CAL_TYPE_RECURRENCE, &r, NULL, FALSE, NULL);
+
+ prop = i_cal_property_new_rrule (recur);
+ i_cal_component_take_property (component, prop);
+
+ g_clear_object (&recur);
}
static void
@@ -1460,35 +1490,36 @@ ecep_recurrence_sensitize_widgets (ECompEditorPage *page,
static void
ecep_recurrence_fill_widgets (ECompEditorPage *page,
- icalcomponent *component)
+ ICalComponent *component)
{
ECompEditorPageRecurrence *page_recurrence;
struct icalrecurrencetype rrule;
- icalproperty *prop;
+ ICalRecurrence *recur;
+ ICalProperty *prop;
GtkAdjustment *adj;
gint n_by_second, n_by_minute, n_by_hour;
gint n_by_day, n_by_month_day, n_by_year_day;
gint n_by_week_no, n_by_month, n_by_set_pos;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_RECURRENCE (page));
- g_return_if_fail (component != NULL);
+ g_return_if_fail (I_CAL_IS_COMPONENT (component));
E_COMP_EDITOR_PAGE_CLASS (e_comp_editor_page_recurrence_parent_class)->fill_widgets (page, component);
page_recurrence = E_COMP_EDITOR_PAGE_RECURRENCE (page);
- switch (icalcomponent_isa (component)) {
- case ICAL_VEVENT_COMPONENT:
+ switch (i_cal_component_isa (component)) {
+ case I_CAL_VEVENT_COMPONENT:
gtk_button_set_label (GTK_BUTTON (page_recurrence->priv->recr_check_box),
/* Translators: Entire string is for example: 'This appointment
recurs/Every[x][day(s)][for][1]occurrences' (combobox options are in [square brackets]) */
C_("ECompEditorPageRecur", "This appointment rec_urs"));
break;
- case ICAL_VTODO_COMPONENT:
+ case I_CAL_VTODO_COMPONENT:
gtk_button_set_label (GTK_BUTTON (page_recurrence->priv->recr_check_box),
/* Translators: Entire string is for example: 'This task
recurs/Every[x][day(s)][for][1]occurrences' (combobox options are in [square brackets]) */
C_("ECompEditorPageRecur", "This task rec_urs"));
break;
- case ICAL_VJOURNAL_COMPONENT:
+ case I_CAL_VJOURNAL_COMPONENT:
gtk_button_set_label (GTK_BUTTON (page_recurrence->priv->recr_check_box),
/* Translators: Entire string is for example: 'This memo
recurs/Every[x][day(s)][for][1]occurrences' (combobox options are in [square brackets]) */
C_("ECompEditorPageRecur", "This memo rec_urs"));
@@ -1511,9 +1542,9 @@ ecep_recurrence_fill_widgets (ECompEditorPage *page,
ecep_recurrence_set_special_defaults (page_recurrence, component);
/* No recurrences? */
- if (!icalcomponent_get_first_property (component, ICAL_RDATE_PROPERTY)
- && !icalcomponent_get_first_property (component, ICAL_RRULE_PROPERTY)
- && !icalcomponent_get_first_property (component, ICAL_EXRULE_PROPERTY)) {
+ if (!e_cal_util_component_has_property (component, I_CAL_RDATE_PROPERTY) &&
+ !e_cal_util_component_has_property (component, I_CAL_RRULE_PROPERTY) &&
+ !e_cal_util_component_has_property (component, I_CAL_EXRULE_PROPERTY)) {
g_signal_handlers_block_matched (page_recurrence->priv->recr_check_box, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, page_recurrence);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page_recurrence->priv->recr_check_box),
FALSE);
g_signal_handlers_unblock_matched (page_recurrence->priv->recr_check_box,
G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, page_recurrence);
@@ -1525,18 +1556,29 @@ ecep_recurrence_fill_widgets (ECompEditorPage *page,
/* See if it is a custom set we don't support */
- if ((icalcomponent_get_first_property (component, ICAL_RRULE_PROPERTY) &&
- icalcomponent_get_next_property (component, ICAL_RRULE_PROPERTY)) ||
- icalcomponent_get_first_property (component, ICAL_RDATE_PROPERTY) ||
- icalcomponent_get_first_property (component, ICAL_EXRULE_PROPERTY))
+ if (i_cal_component_count_properties (component, I_CAL_RRULE_PROPERTY) > 1 ||
+ e_cal_util_component_has_property (component, I_CAL_RDATE_PROPERTY) ||
+ e_cal_util_component_has_property (component, I_CAL_EXRULE_PROPERTY))
goto custom;
/* Down to one rule, so test that one */
- prop = icalcomponent_get_first_property (component, ICAL_RRULE_PROPERTY);
+ prop = i_cal_component_get_first_property (component, I_CAL_RRULE_PROPERTY);
g_return_if_fail (prop != NULL);
- rrule = icalproperty_get_rrule (prop);
+ recur = i_cal_property_get_rrule (prop);
+ if (recur && i_cal_object_get_native (I_CAL_OBJECT (recur))) {
+ struct icalrecurrencetype *tmp_rrule;
+
+ tmp_rrule = i_cal_object_get_native (I_CAL_OBJECT (recur));
+ rrule = *tmp_rrule;
+ } else {
+ g_clear_object (&prop);
+
+ g_return_if_reached ();
+ }
+
+ g_clear_object (&prop);
/* Any lower frequency? */
@@ -1672,12 +1714,14 @@ ecep_recurrence_fill_widgets (ECompEditorPage *page,
goto custom;
if (nth == -1) {
- struct icaltimetype dtstart;
+ ICalTime *dtstart;
- dtstart = icalcomponent_get_dtstart (component);
+ dtstart = i_cal_component_get_dtstart (component);
- page_recurrence->priv->month_index = dtstart.day;
+ page_recurrence->priv->month_index = dtstart ? i_cal_time_get_day (dtstart) :
0;
page_recurrence->priv->month_num = MONTH_NUM_LAST;
+
+ g_clear_object (&dtstart);
} else {
page_recurrence->priv->month_index = nth;
page_recurrence->priv->month_num = MONTH_NUM_DAY;
@@ -1801,18 +1845,18 @@ ecep_recurrence_fill_widgets (ECompEditorPage *page,
static gboolean
ecep_recurrence_fill_component (ECompEditorPage *page,
- icalcomponent *component)
+ ICalComponent *component)
{
ECompEditorPageRecurrence *page_recurrence;
ECompEditor *comp_editor;
GtkTreeModel *model;
GtkTreeIter iter;
- icalproperty *prop;
+ ICalProperty *prop;
gboolean recurs;
gboolean valid_iter;
g_return_val_if_fail (E_IS_COMP_EDITOR_PAGE_RECURRENCE (page), FALSE);
- g_return_val_if_fail (component != NULL, FALSE);
+ g_return_val_if_fail (I_CAL_IS_COMPONENT (component), FALSE);
page_recurrence = E_COMP_EDITOR_PAGE_RECURRENCE (page);
@@ -1849,12 +1893,12 @@ ecep_recurrence_fill_component (ECompEditorPage *page,
for (valid_iter = gtk_tree_model_get_iter_first (model, &iter); valid_iter;
valid_iter = gtk_tree_model_iter_next (model, &iter)) {
- const icaltimetype *dt;
+ ICalTime *dt;
dt = e_date_time_list_get_date_time (E_DATE_TIME_LIST (model), &iter);
g_return_val_if_fail (dt != NULL, FALSE);
- if (!icaltime_is_valid_time (*dt)) {
+ if (!i_cal_time_is_valid_time (dt)) {
e_comp_editor_set_validation_error (comp_editor,
page, page_recurrence->priv->exceptions_tree_view,
_("Recurrence exception date is invalid"));
@@ -1862,22 +1906,22 @@ ecep_recurrence_fill_component (ECompEditorPage *page,
return FALSE;
}
- prop = icalproperty_new_exdate (*dt);
- cal_comp_util_update_tzid_parameter (prop, *dt);
+ prop = i_cal_property_new_exdate (dt);
+ cal_comp_util_update_tzid_parameter (prop, dt);
- icalcomponent_add_property (component, prop);
+ i_cal_component_take_property (component, prop);
}
if (gtk_widget_get_visible (page_recurrence->priv->recr_ending_combo) &&
gtk_widget_get_sensitive (page_recurrence->priv->recr_ending_combo) &&
e_dialog_combo_box_get (page_recurrence->priv->recr_ending_combo, ending_types_map) ==
ENDING_UNTIL) {
/* check whether the "until" date is in the future */
- struct icaltimetype tt = icaltime_null_time ();
+ gint year, month, day;
gboolean ok = TRUE;
- if (e_date_edit_get_date (E_DATE_EDIT (page_recurrence->priv->ending_date_edit), &tt.year,
&tt.month, &tt.day)) {
+ if (e_date_edit_get_date (E_DATE_EDIT (page_recurrence->priv->ending_date_edit), &year,
&month, &day)) {
ECompEditorPropertyPart *dtstart_part = NULL;
- struct icaltimetype dtstart = icaltime_null_time ();
+ ICalTime *dtstart = NULL;
e_comp_editor_get_time_parts (comp_editor, &dtstart_part, NULL);
if (dtstart_part) {
@@ -1885,20 +1929,26 @@ ecep_recurrence_fill_component (ECompEditorPage *page,
E_COMP_EDITOR_PROPERTY_PART_DATETIME (dtstart_part));
}
- tt.is_date = 1;
- tt.zone = NULL;
+ if (dtstart && i_cal_time_is_valid_time (dtstart)) {
+ ICalTime *tt;
+
+ tt = i_cal_time_null_time ();
+ i_cal_time_set_timezone (tt, NULL);
+ i_cal_time_set_is_date (tt, TRUE);
+ i_cal_time_set_date (tt, year, month, day);
- if (icaltime_is_valid_time (dtstart)) {
- ok = icaltime_compare_date_only (dtstart, tt) <= 0;
+ ok = i_cal_time_compare_date_only (dtstart, tt) <= 0;
if (!ok) {
e_date_edit_set_date (E_DATE_EDIT
(page_recurrence->priv->ending_date_edit),
- dtstart.year, dtstart.month, dtstart.day);
+ i_cal_time_get_year (dtstart), i_cal_time_get_month
(dtstart), i_cal_time_get_day (dtstart));
} else {
/* to have the date shown in "normalized" format */
e_date_edit_set_date (E_DATE_EDIT
(page_recurrence->priv->ending_date_edit),
- tt.year, tt.month, tt.day);
+ i_cal_time_get_year (tt), i_cal_time_get_month (tt),
i_cal_time_get_day (tt));
}
+
+ g_clear_object (&tt);
}
}
diff --git a/src/calendar/gui/e-comp-editor-page-reminders.c b/src/calendar/gui/e-comp-editor-page-reminders.c
index dfe378ca4c..afec40bcc8 100644
--- a/src/calendar/gui/e-comp-editor-page-reminders.c
+++ b/src/calendar/gui/e-comp-editor-page-reminders.c
@@ -239,51 +239,59 @@ ecep_reminders_get_text_view_text (GtkWidget *text_view)
return gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE);
}
-static void
+static gboolean
ecep_reminders_remove_needs_description_property (ECalComponentAlarm *alarm)
{
- icalcomponent *component;
- icalproperty *prop;
+ ECalComponentPropertyBag *bag;
+ guint ii, sz;
- g_return_if_fail (alarm != NULL);
+ g_return_val_if_fail (alarm != NULL, FALSE);
- component = e_cal_component_alarm_get_icalcomponent (alarm);
- g_return_if_fail (component != NULL);
+ bag = e_cal_component_alarm_get_property_bag (alarm);
+ g_return_val_if_fail (bag != NULL, FALSE);
- for (prop = icalcomponent_get_first_property (component, ICAL_X_PROPERTY);
- prop;
- prop = icalcomponent_get_next_property (component, ICAL_X_PROPERTY)) {
+ sz = e_cal_component_property_bag_get_count (bag);
+ for (ii = 0; ii < sz; ii++) {
+ ICalProperty *prop;
const gchar *x_name;
- x_name = icalproperty_get_x_name (prop);
+ prop = e_cal_component_property_bag_get (bag, ii);
+ if (!prop || i_cal_property_isa (prop) != I_CAL_X_PROPERTY)
+ continue;
+
+ x_name = i_cal_property_get_x_name (prop);
if (g_str_equal (x_name, X_EVOLUTION_NEEDS_DESCRIPTION)) {
- icalcomponent_remove_property (component, prop);
- icalproperty_free (prop);
- break;
+ e_cal_component_property_bag_remove (bag, ii);
+ return TRUE;
}
}
+
+ return FALSE;
}
static gboolean
ecep_reminders_has_needs_description_property (ECalComponentAlarm *alarm)
{
- icalcomponent *component;
- icalproperty *prop;
+ ECalComponentPropertyBag *bag;
+ guint ii, sz;
g_return_val_if_fail (alarm != NULL, FALSE);
- component = e_cal_component_alarm_get_icalcomponent (alarm);
- g_return_val_if_fail (component != NULL, FALSE);
+ bag = e_cal_component_alarm_get_property_bag (alarm);
+ g_return_val_if_fail (bag != NULL, FALSE);
- for (prop = icalcomponent_get_first_property (component, ICAL_X_PROPERTY);
- prop;
- prop = icalcomponent_get_next_property (component, ICAL_X_PROPERTY)) {
+ sz = e_cal_component_property_bag_get_count (bag);
+ for (ii = 0; ii < sz; ii++) {
+ ICalProperty *prop;
const gchar *x_name;
- x_name = icalproperty_get_x_name (prop);
- if (g_str_equal (x_name, X_EVOLUTION_NEEDS_DESCRIPTION)) {
+ prop = e_cal_component_property_bag_get (bag, ii);
+ if (!prop || i_cal_property_isa (prop) != I_CAL_X_PROPERTY)
+ continue;
+
+ x_name = i_cal_property_get_x_name (prop);
+ if (g_str_equal (x_name, X_EVOLUTION_NEEDS_DESCRIPTION))
return TRUE;
- }
}
return FALSE;
@@ -292,20 +300,20 @@ ecep_reminders_has_needs_description_property (ECalComponentAlarm *alarm)
static void
ecep_reminders_add_needs_description_property (ECalComponentAlarm *alarm)
{
- icalcomponent *component;
- icalproperty *prop;
+ ECalComponentPropertyBag *bag;
+ ICalProperty *prop;
g_return_if_fail (alarm != NULL);
if (ecep_reminders_has_needs_description_property (alarm))
return;
- component = e_cal_component_alarm_get_icalcomponent (alarm);
- g_return_if_fail (component != NULL);
+ bag = e_cal_component_alarm_get_property_bag (alarm);
+ g_return_if_fail (bag != NULL);
- prop = icalproperty_new_x ("1");
- icalproperty_set_x_name (prop, X_EVOLUTION_NEEDS_DESCRIPTION);
- icalcomponent_add_property (component, prop);
+ prop = i_cal_property_new_x ("1");
+ i_cal_property_set_x_name (prop, X_EVOLUTION_NEEDS_DESCRIPTION);
+ e_cal_component_property_bag_take (bag, prop);
}
static void
@@ -345,10 +353,11 @@ ecep_reminders_reset_alarm_widget (ECompEditorPageReminders *page_reminders)
static void
ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
{
- ECalComponentAlarmTrigger trigger;
+ ECalComponentAlarmTrigger *trigger;
ECalComponentAlarmAction action;
- ECalComponentAlarmRepeat repeat;
+ ECalComponentAlarmRepeat *repeat;
ECalComponentAlarm *alarm;
+ ICalDuration *duration;
GtkTreeSelection *selection;
GtkTreeIter iter;
@@ -360,8 +369,8 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
alarm = (ECalComponentAlarm *) e_alarm_list_get_alarm (page_reminders->priv->alarm_list, &iter);
g_return_if_fail (alarm != NULL);
- e_cal_component_alarm_get_action (alarm, &action);
- e_cal_component_alarm_get_trigger (alarm, &trigger);
+ action = e_cal_component_alarm_get_action (alarm);
+ trigger = e_cal_component_alarm_get_trigger (alarm);
e_comp_editor_page_set_updating (E_COMP_EDITOR_PAGE (page_reminders), TRUE);
@@ -373,7 +382,7 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
}
/* Alarm Types */
- switch (trigger.type) {
+ switch (e_cal_component_alarm_trigger_get_kind (trigger)) {
case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START:
e_dialog_combo_box_set (page_reminders->priv->relative_to_combo,
E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, time_map);
break;
@@ -382,10 +391,11 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
e_dialog_combo_box_set (page_reminders->priv->relative_to_combo,
E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END, time_map);
break;
default:
- g_warning ("%s: Unexpected alarm trigger type (%d)", G_STRLOC, trigger.type);
+ g_warning ("%s: Unexpected alarm trigger type (%d)", G_STRLOC,
e_cal_component_alarm_trigger_get_kind (trigger));
}
- switch (trigger.u.rel_duration.is_neg) {
+ duration = e_cal_component_alarm_trigger_get_duration (trigger);
+ switch (i_cal_duration_is_neg (duration)) {
case 1:
e_dialog_combo_box_set (page_reminders->priv->relative_time_combo, BEFORE, relative_map);
break;
@@ -395,47 +405,49 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
break;
}
- if (trigger.u.rel_duration.days) {
+ if (i_cal_duration_get_days (duration)) {
e_dialog_combo_box_set (page_reminders->priv->unit_combo, DAYS, value_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->time_spin),
- trigger.u.rel_duration.days);
- } else if (trigger.u.rel_duration.hours) {
+ i_cal_duration_get_days (duration));
+ } else if (i_cal_duration_get_hours (duration)) {
e_dialog_combo_box_set (page_reminders->priv->unit_combo, HOURS, value_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->time_spin),
- trigger.u.rel_duration.hours);
- } else if (trigger.u.rel_duration.minutes) {
+ i_cal_duration_get_hours (duration));
+ } else if (i_cal_duration_get_minutes (duration)) {
e_dialog_combo_box_set (page_reminders->priv->unit_combo, MINUTES, value_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->time_spin),
- trigger.u.rel_duration.minutes);
+ i_cal_duration_get_minutes (duration));
} else {
e_dialog_combo_box_set (page_reminders->priv->unit_combo, MINUTES, value_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->time_spin), 0);
}
/* Repeat options */
- e_cal_component_alarm_get_repeat (alarm, &repeat);
+ repeat = e_cal_component_alarm_get_repeat (alarm);
- if (repeat.repetitions) {
+ if (e_cal_component_alarm_repeat_get_repetitions (repeat)) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page_reminders->priv->repeat_check), TRUE);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->repeat_times_spin),
- repeat.repetitions);
+ e_cal_component_alarm_repeat_get_repetitions (repeat));
- if (repeat.duration.minutes) {
+ duration = e_cal_component_alarm_repeat_get_interval (repeat);
+
+ if (i_cal_duration_get_minutes (duration)) {
e_dialog_combo_box_set (page_reminders->priv->repeat_unit_combo, DUR_MINUTES,
duration_units_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin),
- repeat.duration.minutes);
+ i_cal_duration_get_minutes (duration));
}
- if (repeat.duration.hours) {
+ if (i_cal_duration_get_hours (duration)) {
e_dialog_combo_box_set (page_reminders->priv->repeat_unit_combo, DUR_HOURS,
duration_units_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin),
- repeat.duration.hours);
+ i_cal_duration_get_hours (duration));
}
- if (repeat.duration.days) {
+ if (i_cal_duration_get_days (duration)) {
e_dialog_combo_box_set (page_reminders->priv->repeat_unit_combo, DUR_DAYS,
duration_units_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin),
- repeat.duration.days);
+ i_cal_duration_get_days (duration));
}
} else {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page_reminders->priv->repeat_check), FALSE);
@@ -448,11 +460,17 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
switch (action) {
case E_CAL_COMPONENT_ALARM_AUDIO: {
- const gchar *url;
- icalattach *attach = NULL;
+ GSList *attachments;
+ const gchar *url = NULL;
+
+ attachments = e_cal_component_alarm_get_attachments (alarm);
+ /* Audio alarm can have only one attachment, the file to play */
+ if (attachments && !attachments->next) {
+ ICalAttach *attach = attachments->data;
+
+ url = attach ? i_cal_attach_get_url (attach) : NULL;
+ }
- e_cal_component_alarm_get_attach (alarm, &attach);
- url = attach ? icalattach_get_url (attach) : NULL;
if (url && *url) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(page_reminders->priv->custom_sound_check), TRUE);
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER
(page_reminders->priv->custom_sound_chooser), url);
@@ -460,19 +478,16 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(page_reminders->priv->custom_sound_check), FALSE);
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER
(page_reminders->priv->custom_sound_chooser));
}
-
- if (attach)
- icalattach_unref (attach);
} break;
case E_CAL_COMPONENT_ALARM_DISPLAY: {
- ECalComponentText description;
+ ECalComponentText* description;
- e_cal_component_alarm_get_description (alarm, &description);
+ description = e_cal_component_alarm_get_description (alarm);
- if (description.value && *description.value) {
+ if (description && e_cal_component_text_get_value (description) &&
e_cal_component_text_get_value (description)[0]) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(page_reminders->priv->custom_message_check), TRUE);
- ecep_reminders_set_text_view_text (page_reminders->priv->custom_message_text_view,
description.value);
+ ecep_reminders_set_text_view_text (page_reminders->priv->custom_message_text_view,
e_cal_component_text_get_value (description));
} else {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(page_reminders->priv->custom_message_check), FALSE);
ecep_reminders_set_text_view_text (page_reminders->priv->custom_message_text_view,
NULL);
@@ -482,38 +497,36 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
case E_CAL_COMPONENT_ALARM_EMAIL: {
ENameSelectorModel *name_selector_model;
EDestinationStore *destination_store;
- ECalComponentText description;
- GSList *attendee_list, *link;
+ ECalComponentText *description;
+ GSList *attendees, *link;
/* Attendees */
name_selector_model = e_name_selector_peek_model (page_reminders->priv->name_selector);
e_name_selector_model_peek_section (name_selector_model, SECTION_NAME, NULL,
&destination_store);
- e_cal_component_alarm_get_attendee_list (alarm, &attendee_list);
- for (link = attendee_list; link; link = g_slist_next (link)) {
- ECalComponentAttendee *a = link->data;
+ attendees = e_cal_component_alarm_get_attendees (alarm);
+ for (link = attendees; link; link = g_slist_next (link)) {
+ ECalComponentAttendee *att = link->data;
EDestination *dest;
dest = e_destination_new ();
- if (a->cn && *a->cn)
- e_destination_set_name (dest, a->cn);
+ if (att && e_cal_component_attendee_get_cn (att) && e_cal_component_attendee_get_cn
(att)[0])
+ e_destination_set_name (dest, e_cal_component_attendee_get_cn (att));
- if (a->value && *a->value)
- e_destination_set_email (dest, itip_strip_mailto (a->value));
+ if (att && e_cal_component_attendee_get_value (att) &&
e_cal_component_attendee_get_value (att)[0])
+ e_destination_set_email (dest, itip_strip_mailto
(e_cal_component_attendee_get_value (att)));
e_destination_store_append_destination (destination_store, dest);
g_object_unref (dest);
}
- e_cal_component_free_attendee_list (attendee_list);
-
/* Description */
- e_cal_component_alarm_get_description (alarm, &description);
- if (description.value && *description.value) {
+ description = e_cal_component_alarm_get_description (alarm);
+ if (description && e_cal_component_text_get_value (description) &&
e_cal_component_text_get_value (description)[0]) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(page_reminders->priv->custom_email_message_check), TRUE);
- ecep_reminders_set_text_view_text
(page_reminders->priv->custom_email_message_text_view, description.value);
+ ecep_reminders_set_text_view_text
(page_reminders->priv->custom_email_message_text_view, e_cal_component_text_get_value (description));
} else {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(page_reminders->priv->custom_email_message_check), FALSE);
ecep_reminders_set_text_view_text
(page_reminders->priv->custom_email_message_text_view, NULL);
@@ -521,26 +534,27 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
} break;
case E_CAL_COMPONENT_ALARM_PROCEDURE: {
- const gchar *url;
- icalattach *attach = NULL;
+ const gchar *url = NULL;
+ GSList *attachments;
- e_cal_component_alarm_get_attach (alarm, (&attach));
- url = attach ? icalattach_get_url (attach) : NULL;
+ attachments = e_cal_component_alarm_get_attachments (alarm);
+ if (attachments && !attachments->next) {
+ ICalAttach *attach = attachments->data;
+ url = attach ? i_cal_attach_get_url (attach) : NULL;
+ }
if (url && *url) {
- ECalComponentText description;
+ ECalComponentText *description;
- e_cal_component_alarm_get_description (alarm, &description);
+ description = e_cal_component_alarm_get_description (alarm);
gtk_entry_set_text (GTK_ENTRY (page_reminders->priv->custom_app_path_entry), url);
- gtk_entry_set_text (GTK_ENTRY (page_reminders->priv->custom_app_args_entry),
description.value ? description.value : "");
+ gtk_entry_set_text (GTK_ENTRY (page_reminders->priv->custom_app_args_entry),
+ (description && e_cal_component_text_get_value (description)) ?
e_cal_component_text_get_value (description) : "");
} else {
gtk_entry_set_text (GTK_ENTRY (page_reminders->priv->custom_app_path_entry), "");
gtk_entry_set_text (GTK_ENTRY (page_reminders->priv->custom_app_args_entry), "");
}
-
- if (attach)
- icalattach_unref (attach);
} break;
default:
g_warning ("%s: Unexpected alarm action (%d)", G_STRLOC, action);
@@ -552,10 +566,11 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
static void
ecep_reminders_widgets_to_selected (ECompEditorPageReminders *page_reminders)
{
- ECalComponentAlarmTrigger trigger;
+ ECalComponentAlarmTrigger *trigger;
ECalComponentAlarmAction action;
- ECalComponentAlarmRepeat repeat;
+ ECalComponentAlarmRepeat *repeat = NULL;
ECalComponentAlarm *alarm;
+ ICalDuration *duration;
GtkTreeSelection *selection;
GtkTreeIter iter;
@@ -570,71 +585,75 @@ ecep_reminders_widgets_to_selected (ECompEditorPageReminders *page_reminders)
alarm = e_cal_component_alarm_new ();
- /* Fill out the alarm */
- memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger));
+ duration = i_cal_duration_null_duration ();
- trigger.type = e_dialog_combo_box_get (page_reminders->priv->relative_to_combo, time_map);
if (e_dialog_combo_box_get (page_reminders->priv->relative_time_combo, relative_map) == BEFORE)
- trigger.u.rel_duration.is_neg = 1;
+ i_cal_duration_set_is_neg (duration, TRUE);
else
- trigger.u.rel_duration.is_neg = 0;
+ i_cal_duration_set_is_neg (duration, FALSE);
switch (e_dialog_combo_box_get (page_reminders->priv->unit_combo, value_map)) {
case MINUTES:
- trigger.u.rel_duration.minutes = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (page_reminders->priv->time_spin));
+ i_cal_duration_set_minutes (duration, gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (page_reminders->priv->time_spin)));
break;
case HOURS:
- trigger.u.rel_duration.hours = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (page_reminders->priv->time_spin));
+ i_cal_duration_set_hours (duration, gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (page_reminders->priv->time_spin)));
break;
case DAYS:
- trigger.u.rel_duration.days = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (page_reminders->priv->time_spin));
+ i_cal_duration_set_days (duration, gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (page_reminders->priv->time_spin)));
break;
default:
g_return_if_reached ();
}
- e_cal_component_alarm_set_trigger (alarm, trigger);
+
+ trigger = e_cal_component_alarm_trigger_new_relative (
+ e_dialog_combo_box_get (page_reminders->priv->relative_to_combo, time_map),
+ duration);
+
+ g_object_unref (duration);
+
+ e_cal_component_alarm_take_trigger (alarm, trigger);
action = e_dialog_combo_box_get (page_reminders->priv->kind_combo, action_map);
e_cal_component_alarm_set_action (alarm, action);
/* Repeat stuff */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page_reminders->priv->repeat_check))) {
- repeat.repetitions = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (page_reminders->priv->repeat_times_spin));
-
- memset (&repeat.duration, 0, sizeof (repeat.duration));
+ duration = i_cal_duration_null_duration ();
switch (e_dialog_combo_box_get (page_reminders->priv->repeat_unit_combo, duration_units_map))
{
case DUR_MINUTES:
- repeat.duration.minutes = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin));
+ i_cal_duration_set_minutes (duration, gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin)));
break;
case DUR_HOURS:
- repeat.duration.hours = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin));
+ i_cal_duration_set_hours (duration, gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin)));
break;
case DUR_DAYS:
- repeat.duration.days = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin));
+ i_cal_duration_set_days (duration, gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (page_reminders->priv->repeat_every_spin)));
break;
default:
g_return_if_reached ();
}
- } else {
- memset (&repeat, 0, sizeof (repeat));
- repeat.repetitions = 0;
+
+ repeat = e_cal_component_alarm_repeat_new (gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (page_reminders->priv->repeat_times_spin)), duration);
+
+ g_object_unref (duration);
}
- e_cal_component_alarm_set_repeat (alarm, repeat);
+ e_cal_component_alarm_take_repeat (alarm, repeat);
/* Options */
switch (action) {
@@ -649,11 +668,12 @@ ecep_reminders_widgets_to_selected (ECompEditorPageReminders *page_reminders)
url = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER
(page_reminders->priv->custom_sound_chooser));
if (url && *url) {
- icalattach *attach;
+ ICalAttach *attach;
+ GSList *attachments;
- attach = icalattach_new_from_url (url);
- e_cal_component_alarm_set_attach (alarm, attach);
- icalattach_unref (attach);
+ attach = i_cal_attach_new_from_url (url);
+ attachments = g_slist_prepend (NULL, attach);
+ e_cal_component_alarm_take_attachments (alarm, attachments);
}
g_free (url);
@@ -676,15 +696,15 @@ ecep_reminders_widgets_to_selected (ECompEditorPageReminders *page_reminders)
case E_CAL_COMPONENT_ALARM_DISPLAY:
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(page_reminders->priv->custom_message_check))) {
- ECalComponentText description;
gchar *text;
text = ecep_reminders_get_text_view_text
(page_reminders->priv->custom_message_text_view);
if (text && *text) {
- description.value = text;
- description.altrep = NULL;
+ ECalComponentText *description;
- e_cal_component_alarm_set_description (alarm, &description);
+ description = e_cal_component_text_new (text, NULL);
+
+ e_cal_component_alarm_take_description (alarm, description);
ecep_reminders_remove_needs_description_property (alarm);
}
@@ -694,7 +714,7 @@ ecep_reminders_widgets_to_selected (ECompEditorPageReminders *page_reminders)
break;
case E_CAL_COMPONENT_ALARM_EMAIL: {
- GSList *attendee_list = NULL;
+ GSList *attendees = NULL;
ENameSelectorModel *name_selector_model;
EDestinationStore *destination_store;
GList *destinations, *link;
@@ -706,33 +726,35 @@ ecep_reminders_widgets_to_selected (ECompEditorPageReminders *page_reminders)
for (link = destinations; link; link = g_list_next (link)) {
EDestination *dest = link->data;
- ECalComponentAttendee *a;
+ ECalComponentAttendee *att;
+ gchar *mailto;
+
+ mailto = g_strconcat ("MAILTO:", e_destination_get_email (dest), NULL);
+ att = e_cal_component_attendee_new ();
+ e_cal_component_attendee_set_value (att, mailto);
+ e_cal_component_attendee_set_cn (att, e_destination_get_name (dest));
+ e_cal_component_attendee_set_cutype (att, I_CAL_CUTYPE_INDIVIDUAL);
+ e_cal_component_attendee_set_partstat (att, I_CAL_PARTSTAT_NEEDSACTION);
+ e_cal_component_attendee_set_role (att, I_CAL_ROLE_REQPARTICIPANT);
- a = g_new0 (ECalComponentAttendee, 1);
- a->value = e_destination_get_email (dest);
- a->cn = e_destination_get_name (dest);
- a->cutype = ICAL_CUTYPE_INDIVIDUAL;
- a->status = ICAL_PARTSTAT_NEEDSACTION;
- a->role = ICAL_ROLE_REQPARTICIPANT;
+ attendees = g_slist_prepend (attendees, att);
- attendee_list = g_slist_append (attendee_list, a);
+ g_free (mailto);
}
- e_cal_component_alarm_set_attendee_list (alarm, attendee_list);
+ e_cal_component_alarm_take_attendees (alarm, g_slist_reverse (attendees));
- e_cal_component_free_attendee_list (attendee_list);
g_list_free (destinations);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(page_reminders->priv->custom_email_message_check))) {
- ECalComponentText description;
gchar *text;
text = ecep_reminders_get_text_view_text
(page_reminders->priv->custom_email_message_text_view);
if (text && *text) {
- description.value = text;
- description.altrep = NULL;
+ ECalComponentText *description;
- e_cal_component_alarm_set_description (alarm, &description);
+ description = e_cal_component_text_new (text, NULL);
+ e_cal_component_alarm_take_description (alarm, description);
ecep_reminders_remove_needs_description_property (alarm);
}
@@ -742,22 +764,20 @@ ecep_reminders_widgets_to_selected (ECompEditorPageReminders *page_reminders)
} break;
case E_CAL_COMPONENT_ALARM_PROCEDURE: {
- ECalComponentText description;
- icalattach *attach;
+ ECalComponentText *description;
+ GSList *attachments;
const gchar *text;
text = gtk_entry_get_text (GTK_ENTRY (page_reminders->priv->custom_app_path_entry));
- attach = icalattach_new_from_url (text ? text : "");
- e_cal_component_alarm_set_attach (alarm, attach);
- icalattach_unref (attach);
+ attachments = g_slist_prepend (NULL, i_cal_attach_new_from_url (text ? text : ""));
+ e_cal_component_alarm_take_attachments (alarm, attachments);
text = gtk_entry_get_text (GTK_ENTRY (page_reminders->priv->custom_app_args_entry));
- description.value = text;
- description.altrep = NULL;
+ description = e_cal_component_text_new (text, NULL);
- e_cal_component_alarm_set_description (alarm, &description);
+ e_cal_component_alarm_take_description (alarm, description);
ecep_reminders_remove_needs_description_property (alarm);
} break;
@@ -793,7 +813,7 @@ ecep_reminders_alarms_combo_changed_cb (GtkComboBox *combo_box,
ECompEditorPageReminders *page_reminders)
{
ECalComponentAlarm *alarm;
- ECalComponentAlarmTrigger trigger;
+ ICalDuration *duration;
gint alarm_type;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_REMINDERS (page_reminders));
@@ -830,35 +850,35 @@ ecep_reminders_alarms_combo_changed_cb (GtkComboBox *combo_box,
e_cal_component_alarm_set_action (alarm, E_CAL_COMPONENT_ALARM_DISPLAY);
- memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger));
- trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
- trigger.u.rel_duration.is_neg = 1;
+ duration = i_cal_duration_null_duration ();
+
+ i_cal_duration_set_is_neg (duration, TRUE);
switch (alarm_type) {
case ALARM_15_MINUTES:
- trigger.u.rel_duration.minutes = 15;
+ i_cal_duration_set_minutes (duration, 15);
break;
case ALARM_1_HOUR:
- trigger.u.rel_duration.hours = 1;
+ i_cal_duration_set_hours (duration, 1);
break;
case ALARM_1_DAY:
- trigger.u.rel_duration.days = 1;
+ i_cal_duration_set_days (duration, 1);
break;
case ALARM_USER_TIME:
switch (page_reminders->priv->alarm_units) {
case E_DURATION_DAYS:
- trigger.u.rel_duration.days = page_reminders->priv->alarm_interval;
+ i_cal_duration_set_days (duration, page_reminders->priv->alarm_interval);
break;
case E_DURATION_HOURS:
- trigger.u.rel_duration.hours = page_reminders->priv->alarm_interval;
+ i_cal_duration_set_hours (duration, page_reminders->priv->alarm_interval);
break;
case E_DURATION_MINUTES:
- trigger.u.rel_duration.minutes = page_reminders->priv->alarm_interval;
+ i_cal_duration_set_minutes (duration, page_reminders->priv->alarm_interval);
break;
}
break;
@@ -867,10 +887,12 @@ ecep_reminders_alarms_combo_changed_cb (GtkComboBox *combo_box,
break;
}
- e_cal_component_alarm_set_trigger (alarm, trigger);
+ e_cal_component_alarm_take_trigger (alarm,
+ e_cal_component_alarm_trigger_new_relative (E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START,
duration));
ecep_reminders_add_needs_description_property (alarm);
e_alarm_list_append (page_reminders->priv->alarm_list, NULL, alarm);
e_cal_component_alarm_free (alarm);
+ g_object_unref (duration);
}
static void
@@ -880,7 +902,7 @@ ecep_reminders_alarms_add_clicked_cb (GtkButton *button,
GtkTreeSelection *selection;
GtkTreeIter iter;
ECalComponentAlarm *alarm;
- ECalComponentAlarmTrigger trigger;
+ ICalDuration *duration;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_REMINDERS (page_reminders));
@@ -888,13 +910,14 @@ ecep_reminders_alarms_add_clicked_cb (GtkButton *button,
ecep_reminders_add_needs_description_property (alarm);
- memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger));
- trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
- trigger.u.rel_duration.is_neg = 1;
- trigger.u.rel_duration.minutes = 15;
+ duration = i_cal_duration_null_duration ();
+ i_cal_duration_set_is_neg (duration, TRUE);
+ i_cal_duration_set_minutes (duration, 15);
e_cal_component_alarm_set_action (alarm, E_CAL_COMPONENT_ALARM_DISPLAY);
- e_cal_component_alarm_set_trigger (alarm, trigger);
+ e_cal_component_alarm_take_trigger (alarm,
+ e_cal_component_alarm_trigger_new_relative (E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START,
duration));
+ g_object_unref (duration);
e_alarm_list_append (page_reminders->priv->alarm_list, &iter, alarm);
@@ -1082,65 +1105,68 @@ ecep_reminders_is_custom_alarm (ECalComponentAlarm *ca,
gint user_interval,
gint *alarm_type)
{
- ECalComponentAlarmTrigger trigger;
- ECalComponentAlarmRepeat repeat;
+ ECalComponentAlarmTrigger *trigger;
+ ECalComponentAlarmRepeat *repeat;
ECalComponentAlarmAction action;
- ECalComponentText desc;
- icalattach *attach;
+ ECalComponentText *desc;
+ ICalDuration *duration;
+ GSList *attachments;
- e_cal_component_alarm_get_action (ca, &action);
+ action = e_cal_component_alarm_get_action (ca);
if (action != E_CAL_COMPONENT_ALARM_DISPLAY)
return TRUE;
- e_cal_component_alarm_get_attach (ca, &attach);
- if (attach)
+ attachments = e_cal_component_alarm_get_attachments (ca);
+ if (attachments)
return TRUE;
if (!ecep_reminders_has_needs_description_property (ca)) {
- e_cal_component_alarm_get_description (ca, &desc);
- if (!desc.value || !old_summary || strcmp (desc.value, old_summary))
+ desc = e_cal_component_alarm_get_description (ca);
+ if (!desc || !e_cal_component_text_get_value (desc) ||
+ !old_summary || strcmp (e_cal_component_text_get_value (desc), old_summary))
return TRUE;
}
- e_cal_component_alarm_get_repeat (ca, &repeat);
- if (repeat.repetitions != 0)
+ repeat = e_cal_component_alarm_get_repeat (ca);
+ if (repeat && e_cal_component_alarm_repeat_get_repetitions (repeat) != 0)
return TRUE;
if (e_cal_component_alarm_has_attendees (ca))
return TRUE;
- e_cal_component_alarm_get_trigger (ca, &trigger);
- if (trigger.type != E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START)
+ trigger = e_cal_component_alarm_get_trigger (ca);
+ if (!trigger || e_cal_component_alarm_trigger_get_kind (trigger) !=
E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START)
return TRUE;
- if (trigger.u.rel_duration.is_neg != 1)
+ duration = e_cal_component_alarm_trigger_get_duration (trigger);
+ if (!duration || i_cal_duration_is_neg (duration) != 1)
return TRUE;
- if (trigger.u.rel_duration.weeks != 0)
+ if (i_cal_duration_get_weeks (duration) != 0)
return TRUE;
- if (trigger.u.rel_duration.seconds != 0)
+ if (i_cal_duration_get_seconds (duration) != 0)
return TRUE;
- if (trigger.u.rel_duration.days == 1
- && trigger.u.rel_duration.hours == 0
- && trigger.u.rel_duration.minutes == 0) {
+ if (i_cal_duration_get_days (duration) == 1 &&
+ i_cal_duration_get_hours (duration) == 0 &&
+ i_cal_duration_get_minutes (duration) == 0) {
if (alarm_type)
*alarm_type = ALARM_1_DAY;
return FALSE;
}
- if (trigger.u.rel_duration.days == 0
- && trigger.u.rel_duration.hours == 1
- && trigger.u.rel_duration.minutes == 0) {
+ if (i_cal_duration_get_days (duration) == 0 &&
+ i_cal_duration_get_hours (duration) == 1 &&
+ i_cal_duration_get_minutes (duration) == 0) {
if (alarm_type)
*alarm_type = ALARM_1_HOUR;
return FALSE;
}
- if (trigger.u.rel_duration.days == 0
- && trigger.u.rel_duration.hours == 0
- && trigger.u.rel_duration.minutes == 15) {
+ if (i_cal_duration_get_days (duration) == 0 &&
+ i_cal_duration_get_hours (duration) == 0 &&
+ i_cal_duration_get_minutes (duration) == 15) {
if (alarm_type)
*alarm_type = ALARM_15_MINUTES;
return FALSE;
@@ -1149,9 +1175,9 @@ ecep_reminders_is_custom_alarm (ECalComponentAlarm *ca,
if (user_interval != -1) {
switch (user_units) {
case E_DURATION_DAYS:
- if (trigger.u.rel_duration.days == user_interval
- && trigger.u.rel_duration.hours == 0
- && trigger.u.rel_duration.minutes == 0) {
+ if (i_cal_duration_get_days (duration) == user_interval &&
+ i_cal_duration_get_hours (duration) == 0 &&
+ i_cal_duration_get_minutes (duration) == 0) {
if (alarm_type)
*alarm_type = ALARM_USER_TIME;
return FALSE;
@@ -1159,9 +1185,9 @@ ecep_reminders_is_custom_alarm (ECalComponentAlarm *ca,
break;
case E_DURATION_HOURS:
- if (trigger.u.rel_duration.days == 0
- && trigger.u.rel_duration.hours == user_interval
- && trigger.u.rel_duration.minutes == 0) {
+ if (i_cal_duration_get_days (duration) == 0 &&
+ i_cal_duration_get_hours (duration) == user_interval &&
+ i_cal_duration_get_minutes (duration) == 0) {
if (alarm_type)
*alarm_type = ALARM_USER_TIME;
return FALSE;
@@ -1169,9 +1195,9 @@ ecep_reminders_is_custom_alarm (ECalComponentAlarm *ca,
break;
case E_DURATION_MINUTES:
- if (trigger.u.rel_duration.days == 0
- && trigger.u.rel_duration.hours == 0
- && trigger.u.rel_duration.minutes == user_interval) {
+ if (i_cal_duration_get_days (duration) == 0 &&
+ i_cal_duration_get_hours (duration) == 0 &&
+ i_cal_duration_get_minutes (duration) == user_interval) {
if (alarm_type)
*alarm_type = ALARM_USER_TIME;
return FALSE;
@@ -1185,7 +1211,7 @@ ecep_reminders_is_custom_alarm (ECalComponentAlarm *ca,
static gboolean
ecep_reminders_is_custom_alarm_uid_list (ECalComponent *comp,
- GList *alarms,
+ GSList *alarm_uids,
const gchar *old_summary,
EDurationType user_units,
gint user_interval,
@@ -1194,10 +1220,13 @@ ecep_reminders_is_custom_alarm_uid_list (ECalComponent *comp,
ECalComponentAlarm *ca;
gboolean result;
- if (g_list_length (alarms) > 1)
+ if (!alarm_uids)
+ return FALSE;
+
+ if (alarm_uids->next)
return TRUE;
- ca = e_cal_component_get_alarm (comp, alarms->data);
+ ca = e_cal_component_get_alarm (comp, alarm_uids->data);
result = ecep_reminders_is_custom_alarm (ca, old_summary, user_units, user_interval, alarm_type);
e_cal_component_alarm_free (ca);
@@ -1365,13 +1394,14 @@ ecep_reminders_sensitize_widgets (ECompEditorPage *page,
static void
ecep_reminders_fill_widgets (ECompEditorPage *page,
- icalcomponent *component)
+ ICalComponent *component)
{
ECompEditorPageReminders *page_reminders;
ECalComponent *comp;
+ ICalComponent *valarm;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_REMINDERS (page));
- g_return_if_fail (component != NULL);
+ g_return_if_fail (I_CAL_IS_COMPONENT (component));
E_COMP_EDITOR_PAGE_CLASS (e_comp_editor_page_reminders_parent_class)->fill_widgets (page, component);
@@ -1379,19 +1409,22 @@ ecep_reminders_fill_widgets (ECompEditorPage *page,
e_alarm_list_clear (page_reminders->priv->alarm_list);
- if (!icalcomponent_get_first_component (component, ICAL_VALARM_COMPONENT)) {
+ valarm = i_cal_component_get_first_component (component, I_CAL_VALARM_COMPONENT);
+ if (!valarm) {
e_dialog_combo_box_set (page_reminders->priv->alarms_combo, ALARM_NONE,
page_reminders->priv->alarm_map);
return;
}
- comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (component));
+ g_object_unref (valarm);
+
+ comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (component));
if (comp && e_cal_component_has_alarms (comp)) {
GSList *alarms, *link;
gint alarm_type;
alarms = e_cal_component_get_alarm_uids (comp);
- if (ecep_reminders_is_custom_alarm_uid_list (comp, alarms, icalcomponent_get_summary
(component),
+ if (ecep_reminders_is_custom_alarm_uid_list (comp, alarms, i_cal_component_get_summary
(component),
page_reminders->priv->alarm_units, page_reminders->priv->alarm_interval, &alarm_type))
alarm_type = ALARM_CUSTOM;
@@ -1427,22 +1460,22 @@ ecep_reminders_fill_widgets (ECompEditorPage *page,
static gboolean
ecep_reminders_fill_component (ECompEditorPage *page,
- icalcomponent *component)
+ ICalComponent *component)
{
ECompEditorPageReminders *page_reminders;
ECalComponent *comp;
- icalcomponent *changed_comp, *alarm;
+ ICalComponent *changed_comp, *alarm;
GtkTreeModel *model;
GtkTreeIter iter;
gboolean valid_iter;
g_return_val_if_fail (E_IS_COMP_EDITOR_PAGE_REMINDERS (page), FALSE);
- g_return_val_if_fail (component != NULL, FALSE);
+ g_return_val_if_fail (I_CAL_IS_COMPONENT (component), FALSE);
if (!E_COMP_EDITOR_PAGE_CLASS (e_comp_editor_page_reminders_parent_class)->fill_component (page,
component))
return TRUE;
- comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (component));
+ comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (component));
g_return_val_if_fail (comp != NULL, FALSE);
page_reminders = E_COMP_EDITOR_PAGE_REMINDERS (page);
@@ -1456,8 +1489,7 @@ ecep_reminders_fill_component (ECompEditorPage *page,
valid_iter = gtk_tree_model_iter_next (model, &iter)) {
ECalComponentAlarm *alarm, *alarm_copy;
ECalComponentAlarmAction action = E_CAL_COMPONENT_ALARM_UNKNOWN;
- icalcomponent *icalcomp;
- icalproperty *prop;
+ ECalComponentPropertyBag *bag;
alarm = (ECalComponentAlarm *) e_alarm_list_get_alarm (page_reminders->priv->alarm_list,
&iter);
if (!alarm) {
@@ -1468,79 +1500,73 @@ ecep_reminders_fill_component (ECompEditorPage *page,
/* We set the description of the alarm if it's got
* the X-EVOLUTION-NEEDS-DESCRIPTION property.
*/
- icalcomp = e_cal_component_alarm_get_icalcomponent (alarm);
- for (prop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
- prop;
- prop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY)) {
- const gchar *x_name;
-
- x_name = icalproperty_get_x_name (prop);
- if (g_str_equal (x_name, X_EVOLUTION_NEEDS_DESCRIPTION)) {
- ECalComponentText summary;
-
- e_cal_component_get_summary (comp, &summary);
- e_cal_component_alarm_set_description (alarm, &summary);
-
- icalcomponent_remove_property (icalcomp, prop);
- icalproperty_free (prop);
- break;
- }
+ if (ecep_reminders_remove_needs_description_property (alarm)) {
+ ECalComponentText *summary;
+
+ summary = e_cal_component_get_summary (comp);
+ e_cal_component_alarm_take_description (alarm, summary);
}
- e_cal_component_alarm_get_action (alarm, &action);
+ action = e_cal_component_alarm_get_action (alarm);
- prop = icalcomponent_get_first_property (icalcomp, ICAL_SUMMARY_PROPERTY);
+ bag = e_cal_component_alarm_get_property_bag (alarm);
if (action == E_CAL_COMPONENT_ALARM_EMAIL) {
- ECalComponentText summary = { NULL, NULL };
+ ECalComponentText *summary;
+ const gchar *text;
+ guint idx;
+
+ summary = e_cal_component_get_summary (comp);
+ text = (summary && e_cal_component_text_get_value (summary)) ?
e_cal_component_text_get_value (summary) : "";
- e_cal_component_get_summary (comp, &summary);
+ idx = e_cal_component_property_bag_get_first_by_kind (bag, I_CAL_SUMMARY_PROPERTY);
+ if (idx < e_cal_component_property_bag_get_count (bag)) {
+ ICalProperty *prop;
- if (prop) {
- icalproperty_set_summary (prop, summary.value ? summary.value : "");
+ prop = e_cal_component_property_bag_get (bag, idx);
+ i_cal_property_set_summary (prop, text);
} else {
- prop = icalproperty_new_summary (summary.value ? summary.value : "");
- icalcomponent_add_property (icalcomp, prop);
+ e_cal_component_property_bag_take (bag, i_cal_property_new_summary (text));
}
- } else if (prop) {
- icalcomponent_remove_property (icalcomp, prop);
- icalproperty_free (prop);
+
+ e_cal_component_text_free (summary);
+ } else {
+ e_cal_component_property_bag_remove_by_kind (bag, I_CAL_SUMMARY_PROPERTY, TRUE);
}
- prop = icalcomponent_get_first_property (icalcomp, ICAL_DESCRIPTION_PROPERTY);
if (action == E_CAL_COMPONENT_ALARM_EMAIL || action == E_CAL_COMPONENT_ALARM_DISPLAY) {
- if (!prop) {
+ if (e_cal_component_property_bag_get_first_by_kind (bag, I_CAL_DESCRIPTION_PROPERTY)
=
+ e_cal_component_property_bag_get_count (bag)) {
const gchar *description;
- description = icalcomponent_get_description
(e_cal_component_get_icalcomponent (comp));
+ description = i_cal_component_get_description
(e_cal_component_get_icalcomponent (comp));
- prop = icalproperty_new_description (description ? description : "");
- icalcomponent_add_property (icalcomp, prop);
+ e_cal_component_property_bag_take (bag, i_cal_property_new_description
(description ? description : ""));
}
- } else if (prop) {
- icalcomponent_remove_property (icalcomp, prop);
- icalproperty_free (prop);
+ } else {
+ e_cal_component_property_bag_remove_by_kind (bag, I_CAL_DESCRIPTION_PROPERTY, TRUE);
}
/* We clone the alarm to maintain the invariant that the alarm
* structures in the list did *not* come from the component.
*/
- alarm_copy = e_cal_component_alarm_clone (alarm);
+ alarm_copy = e_cal_component_alarm_copy (alarm);
e_cal_component_add_alarm (comp, alarm_copy);
e_cal_component_alarm_free (alarm_copy);
}
- while (alarm = icalcomponent_get_first_component (component, ICAL_VALARM_COMPONENT), alarm) {
- icalcomponent_remove_component (component, alarm);
- icalcomponent_free (alarm);
+ while (alarm = i_cal_component_get_first_component (component, I_CAL_VALARM_COMPONENT), alarm) {
+ i_cal_component_remove_component (component, alarm);
+ g_object_unref (alarm);
}
changed_comp = e_cal_component_get_icalcomponent (comp);
if (changed_comp) {
/* Move all VALARM components into the right 'component' */
- while (alarm = icalcomponent_get_first_component (changed_comp, ICAL_VALARM_COMPONENT),
alarm) {
- icalcomponent_remove_component (changed_comp, alarm);
- icalcomponent_add_component (component, alarm);
+ while (alarm = i_cal_component_get_first_component (changed_comp, I_CAL_VALARM_COMPONENT),
alarm) {
+ i_cal_component_remove_component (changed_comp, alarm);
+ i_cal_component_add_component (component, alarm);
+ g_object_unref (alarm);
}
} else {
g_warn_if_reached ();
diff --git a/src/calendar/gui/e-comp-editor-page-schedule.c b/src/calendar/gui/e-comp-editor-page-schedule.c
index dc44ea6df6..10c728c4b7 100644
--- a/src/calendar/gui/e-comp-editor-page-schedule.c
+++ b/src/calendar/gui/e-comp-editor-page-schedule.c
@@ -118,7 +118,7 @@ ecep_schedule_editor_times_changed_cb (ECompEditor *comp_editor,
ECompEditorPropertyPartDatetime *dtstart, *dtend;
ECompEditorPropertyPart *dtstart_part = NULL, *dtend_part = NULL;
EDateEdit *start_date_edit, *end_date_edit;
- struct icaltimetype start_tt, end_tt;
+ ICalTime *start_tt, *end_tt;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_SCHEDULE (page_schedule));
g_return_if_fail (page_schedule->priv->selector != NULL);
@@ -134,23 +134,42 @@ ecep_schedule_editor_times_changed_cb (ECompEditor *comp_editor,
start_tt = e_comp_editor_property_part_datetime_get_value (dtstart);
end_tt = e_comp_editor_property_part_datetime_get_value (dtend);
+ if (!start_tt || !end_tt) {
+ g_clear_object (&start_tt);
+ g_clear_object (&end_tt);
+ return;
+ }
+
/* For All Day Events, if DTEND is after DTSTART, we subtract 1 day from it. */
- if (start_tt.is_date && end_tt.is_date &&
- icaltime_compare_date_only (end_tt, start_tt) > 0)
- icaltime_adjust (&end_tt, -1, 0, 0, 0);
+ if (i_cal_time_is_date (start_tt) && i_cal_time_is_date (end_tt) &&
+ i_cal_time_compare_date_only (end_tt, start_tt) > 0)
+ i_cal_time_adjust (end_tt, -1, 0, 0, 0);
e_comp_editor_page_set_updating (E_COMP_EDITOR_PAGE (page_schedule), TRUE);
start_date_edit = E_DATE_EDIT (page_schedule->priv->selector->start_date_edit);
end_date_edit = E_DATE_EDIT (page_schedule->priv->selector->end_date_edit);
- e_date_edit_set_date (start_date_edit, start_tt.year, start_tt.month, start_tt.day);
- e_date_edit_set_time_of_day (start_date_edit, start_tt.hour, start_tt.minute);
-
- e_date_edit_set_date (end_date_edit, end_tt.year, end_tt.month, end_tt.day);
- e_date_edit_set_time_of_day (end_date_edit, end_tt.hour, end_tt.minute);
+ e_date_edit_set_date (start_date_edit,
+ i_cal_time_get_year (start_tt),
+ i_cal_time_get_month (start_tt),
+ i_cal_time_get_day (start_tt));
+ e_date_edit_set_time_of_day (start_date_edit,
+ i_cal_time_get_hour (start_tt),
+ i_cal_time_get_minute (start_tt));
+
+ e_date_edit_set_date (end_date_edit,
+ i_cal_time_get_year (end_tt),
+ i_cal_time_get_month (end_tt),
+ i_cal_time_get_day (end_tt));
+ e_date_edit_set_time_of_day (end_date_edit,
+ i_cal_time_get_hour (end_tt),
+ i_cal_time_get_minute (end_tt));
e_comp_editor_page_set_updating (E_COMP_EDITOR_PAGE (page_schedule), FALSE);
+
+ g_clear_object (&start_tt);
+ g_clear_object (&end_tt);
}
static void
@@ -178,7 +197,8 @@ ecep_schedule_set_time_to_editor (ECompEditorPageSchedule *page_schedule)
ECompEditorPropertyPartDatetime *dtstart, *dtend;
ECompEditorPropertyPart *dtstart_part = NULL, *dtend_part = NULL;
ECompEditor *comp_editor;
- struct icaltimetype start_tt, end_tt;
+ ICalTime *start_tt, *end_tt;
+ gint year, month, day, hour, minute;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_SCHEDULE (page_schedule));
g_return_if_fail (E_IS_MEETING_TIME_SELECTOR (page_schedule->priv->selector));
@@ -199,42 +219,41 @@ ecep_schedule_set_time_to_editor (ECompEditorPageSchedule *page_schedule)
start_tt = e_comp_editor_property_part_datetime_get_value (dtstart);
end_tt = e_comp_editor_property_part_datetime_get_value (dtend);
- e_date_edit_get_date (
- E_DATE_EDIT (selector->start_date_edit),
- &start_tt.year,
- &start_tt.month,
- &start_tt.day);
- e_date_edit_get_time_of_day (
- E_DATE_EDIT (selector->start_date_edit),
- &start_tt.hour,
- &start_tt.minute);
- e_date_edit_get_date (
- E_DATE_EDIT (selector->end_date_edit),
- &end_tt.year,
- &end_tt.month,
- &end_tt.day);
- e_date_edit_get_time_of_day (
- E_DATE_EDIT (selector->end_date_edit),
- &end_tt.hour,
- &end_tt.minute);
+ if (!start_tt || !end_tt) {
+ g_clear_object (&start_tt);
+ g_clear_object (&end_tt);
+ return;
+ }
+
+ e_date_edit_get_date (E_DATE_EDIT (selector->start_date_edit), &year, &month, &day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (selector->start_date_edit), &hour, &minute);
+ i_cal_time_set_date (start_tt, year, month, day);
+ i_cal_time_set_time (start_tt, hour, minute, 0);
+
+ e_date_edit_get_date (E_DATE_EDIT (selector->end_date_edit), &year, &month, &day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (selector->end_date_edit), &hour, &minute);
+ i_cal_time_set_date (end_tt, year, month, day);
+ i_cal_time_set_time (end_tt, hour, minute, 0);
if (!e_date_edit_get_show_time (E_DATE_EDIT (selector->start_date_edit))) {
/* For All-Day Events, we set the timezone to NULL, and add 1 day to DTEND. */
- start_tt.is_date = TRUE;
- start_tt.zone = NULL;
- end_tt.is_date = TRUE;
- end_tt.zone = NULL;
+ i_cal_time_set_timezone (start_tt, NULL);
+ i_cal_time_set_is_date (start_tt, TRUE);
+ i_cal_time_set_timezone (end_tt, NULL);
+ i_cal_time_set_is_date (end_tt, TRUE);
- icaltime_adjust (&end_tt, 1, 0, 0, 0);
+ i_cal_time_adjust (end_tt, 1, 0, 0, 0);
} else {
- start_tt.is_date = FALSE;
- end_tt.is_date = FALSE;
+ i_cal_time_set_is_date (start_tt, FALSE);
+ i_cal_time_set_is_date (end_tt, FALSE);
}
e_comp_editor_property_part_datetime_set_value (dtstart, start_tt);
e_comp_editor_property_part_datetime_set_value (dtend, end_tt);
g_clear_object (&comp_editor);
+ g_clear_object (&start_tt);
+ g_clear_object (&end_tt);
}
static void
@@ -276,17 +295,17 @@ ecep_schedule_sensitize_widgets (ECompEditorPage *page,
static void
ecep_schedule_fill_widgets (ECompEditorPage *page,
- icalcomponent *component)
+ ICalComponent *component)
{
ECompEditorPageSchedule *page_schedule;
ECompEditorPropertyPartDatetime *dtstart, *dtend;
ECompEditorPropertyPart *dtstart_part = NULL, *dtend_part = NULL;
ECompEditor *comp_editor;
EMeetingTimeSelector *selector;
- struct icaltimetype start_tt, end_tt;
+ ICalTime *start_tt, *end_tt;
g_return_if_fail (E_IS_COMP_EDITOR_PAGE_SCHEDULE (page));
- g_return_if_fail (component != NULL);
+ g_return_if_fail (I_CAL_IS_COMPONENT (component));
E_COMP_EDITOR_PAGE_CLASS (e_comp_editor_page_schedule_parent_class)->fill_widgets (page, component);
@@ -314,51 +333,60 @@ ecep_schedule_fill_widgets (ECompEditorPage *page,
start_tt = e_comp_editor_property_part_datetime_get_value (dtstart);
end_tt = e_comp_editor_property_part_datetime_get_value (dtend);
- if (start_tt.is_date) {
+ if (!start_tt || !end_tt) {
+ g_clear_object (&comp_editor);
+ g_clear_object (&start_tt);
+ g_clear_object (&end_tt);
+ return;
+ }
+
+ if (i_cal_time_is_date (start_tt)) {
/* For All-Day Events, we set the timezone to NULL, and add 1 day to DTEND. */
- start_tt.is_date = TRUE;
- start_tt.zone = NULL;
- end_tt.is_date = TRUE;
- end_tt.zone = NULL;
+ i_cal_time_set_timezone (start_tt, NULL);
+ i_cal_time_set_is_date (start_tt, TRUE);
+ i_cal_time_set_timezone (end_tt, NULL);
+ i_cal_time_set_is_date (end_tt, TRUE);
- icaltime_adjust (&end_tt, 1, 0, 0, 0);
+ i_cal_time_adjust (end_tt, 1, 0, 0, 0);
} else {
- start_tt.is_date = FALSE;
- end_tt.is_date = FALSE;
+ i_cal_time_set_is_date (start_tt, FALSE);
+ i_cal_time_set_is_date (end_tt, FALSE);
}
e_comp_editor_page_set_updating (page, TRUE);
e_date_edit_set_date (
E_DATE_EDIT (selector->start_date_edit),
- start_tt.year,
- start_tt.month,
- start_tt.day);
+ i_cal_time_get_year (start_tt),
+ i_cal_time_get_month (start_tt),
+ i_cal_time_get_day (start_tt));
e_date_edit_set_time_of_day (
E_DATE_EDIT (selector->start_date_edit),
- start_tt.hour,
- start_tt.minute);
+ i_cal_time_get_hour (start_tt),
+ i_cal_time_get_minute (start_tt));
e_date_edit_set_date (
E_DATE_EDIT (selector->end_date_edit),
- end_tt.year,
- end_tt.month,
- end_tt.day);
+ i_cal_time_get_year (end_tt),
+ i_cal_time_get_month (end_tt),
+ i_cal_time_get_day (end_tt));
e_date_edit_set_time_of_day (
E_DATE_EDIT (selector->end_date_edit),
- end_tt.hour,
- end_tt.minute);
+ i_cal_time_get_hour (end_tt),
+ i_cal_time_get_minute (end_tt));
e_comp_editor_page_set_updating (page, FALSE);
g_clear_object (&comp_editor);
+ g_clear_object (&start_tt);
+ g_clear_object (&end_tt);
}
static gboolean
ecep_schedule_fill_component (ECompEditorPage *page,
- icalcomponent *component)
+ ICalComponent *component)
{
g_return_val_if_fail (E_IS_COMP_EDITOR_PAGE_SCHEDULE (page), FALSE);
- g_return_val_if_fail (component != NULL, FALSE);
+ g_return_val_if_fail (I_CAL_IS_COMPONENT (component), FALSE);
return E_COMP_EDITOR_PAGE_CLASS (e_comp_editor_page_schedule_parent_class)->fill_component (page,
component);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]