diff options
author | Damon Chaplin <damon@ximian.com> | 2001-10-30 20:59:28 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2001-10-30 20:59:28 +0800 |
commit | 6cc1ca709616dafc050dc29e10f26686ac3e4caa (patch) | |
tree | e593984309d8f2ff05b729fd0fc1fb789b473ee3 /calendar/gui/dialogs | |
parent | 6d9d0b02aab0c899742a43002116bc0caf05324f (diff) | |
download | gsoc2013-evolution-6cc1ca709616dafc050dc29e10f26686ac3e4caa.tar.gz gsoc2013-evolution-6cc1ca709616dafc050dc29e10f26686ac3e4caa.tar.zst gsoc2013-evolution-6cc1ca709616dafc050dc29e10f26686ac3e4caa.zip |
updated code to handle DATE values.
2001-10-30 Damon Chaplin <damon@ximian.com>
* gui/dialogs/schedule-page.c:
* gui/dialogs/event-page.c:
* gui/dialogs/comp-editor-util.c: updated code to handle DATE values.
* gui/gnome-cal.c (gnome_calendar_new_appointment_for):
* gui/e-day-view.c (e_day_view_key_press): updated DATE code.
* gui/e-cell-date-edit-text.c:
* gui/calendar-model.c: updated to support DATE values.
* cal-util/cal-recur.c (cal_recur_generate_instances_of_rule): updated
to use DATE values in same way as Outlook - i.e. the DTEND date is
not included entirely. Though I did make it so that if the DTSTART
and DTEND used the same DATE value, it includes the entire day.
So 1-day events should be the same. Long All-Day events will be
1 day shorter.
* cal-util/cal-component.c (cal_component_get_start_plus_duration):
don't subtract a day from the end date.
* gui/tasks-control.c: updated the EPixmap paths for Cut/Copy etc.
Removed Print & Print Preview paths, since we don't have menu commands
for these any more.
svn path=/trunk/; revision=14456
Diffstat (limited to 'calendar/gui/dialogs')
-rw-r--r-- | calendar/gui/dialogs/comp-editor-util.c | 40 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 21 | ||||
-rw-r--r-- | calendar/gui/dialogs/schedule-page.c | 14 |
3 files changed, 52 insertions, 23 deletions
diff --git a/calendar/gui/dialogs/comp-editor-util.c b/calendar/gui/dialogs/comp-editor-util.c index 751e23dbcf..34d4e71e81 100644 --- a/calendar/gui/dialogs/comp-editor-util.c +++ b/calendar/gui/dialogs/comp-editor-util.c @@ -112,11 +112,13 @@ comp_editor_free_dates (CompEditorPageDates *dates) } +/* dtstart is only passed in if tt is the dtend. */ static void write_label_piece (struct icaltimetype *tt, char *buffer, int size, - char *stext, char *etext) + char *stext, char *etext, struct icaltimetype *dtstart) { struct tm tmp_tm = { 0 }; + struct icaltimetype tt_copy = *tt; int len; /* FIXME: May want to convert the time to an appropriate zone. */ @@ -124,20 +126,28 @@ write_label_piece (struct icaltimetype *tt, char *buffer, int size, if (stext != NULL) strcat (buffer, stext); - tmp_tm.tm_year = tt->year - 1900; - tmp_tm.tm_mon = tt->month - 1; - tmp_tm.tm_mday = tt->day; - tmp_tm.tm_hour = tt->hour; - tmp_tm.tm_min = tt->minute; - tmp_tm.tm_sec = tt->second; + /* If we are writing the DTEND (i.e. DTSTART is set), and + DTEND > DTSTART, subtract 1 day. The DTEND date is not inclusive. */ + if (tt_copy.is_date && dtstart + && icaltime_compare_date_only (tt_copy, *dtstart) > 0) { + icaltime_adjust (&tt_copy, -1, 0, 0, 0); + } + + tmp_tm.tm_year = tt_copy.year - 1900; + tmp_tm.tm_mon = tt_copy.month - 1; + tmp_tm.tm_mday = tt_copy.day; + tmp_tm.tm_hour = tt_copy.hour; + tmp_tm.tm_min = tt_copy.minute; + tmp_tm.tm_sec = tt_copy.second; tmp_tm.tm_isdst = -1; - tmp_tm.tm_wday = time_day_of_week (tt->day, tt->month - 1, tt->year); + tmp_tm.tm_wday = time_day_of_week (tt_copy.day, tt_copy.month - 1, + tt_copy.year); len = strlen (buffer); e_time_format_date_and_time (&tmp_tm, calendar_config_get_24_hour_format (), - FALSE, FALSE, + !tt_copy.is_date, FALSE, &buffer[len], size - len); if (etext != NULL) strcat (buffer, etext); @@ -171,24 +181,24 @@ comp_editor_date_label (CompEditorPageDates *dates, GtkWidget *label) if (start_set) write_label_piece (dates->start->value, buffer, 1024, - NULL, NULL); + NULL, NULL, NULL); if (start_set && end_set) write_label_piece (dates->end->value, buffer, 1024, - _(" to "), NULL); + _(" to "), NULL, dates->start->value); if (complete_set) { if (start_set) - write_label_piece (dates->complete, buffer, 1024, _(" (Completed "), ")"); + write_label_piece (dates->complete, buffer, 1024, _(" (Completed "), ")", NULL); else - write_label_piece (dates->complete, buffer, 1024, _("Completed "), NULL); + write_label_piece (dates->complete, buffer, 1024, _("Completed "), NULL, NULL); } if (due_set && dates->complete == NULL) { if (start_set) - write_label_piece (dates->due->value, buffer, 1024, _(" (Due "), ")"); + write_label_piece (dates->due->value, buffer, 1024, _(" (Due "), ")", NULL); else - write_label_piece (dates->due->value, buffer, 1024, _("Due "), NULL); + write_label_piece (dates->due->value, buffer, 1024, _("Due "), NULL, NULL); } gtk_label_set_text (GTK_LABEL (label), buffer); diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 72b6fe9871..191f87e306 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -332,15 +332,15 @@ update_time (EventPage *epage, CalComponentDateTime *start_date, CalComponentDat } /* If both times are DATE values, we set the 'All Day Event' checkbox. - If not, if the end time is a DATE we convert it to the end of the - day. */ + Also, if DTEND is after DTSTART, we subtract 1 day from it. */ all_day_event = FALSE; start_tt = start_date->value; end_tt = end_date->value; if (start_tt->is_date && end_tt->is_date) { all_day_event = TRUE; - } else if (end_tt->is_date) { - icaltime_adjust (end_tt, 1, 0, 0, 0); + if (icaltime_compare_date_only (*end_tt, *start_tt) > 0) { + icaltime_adjust (end_tt, -1, 0, 0, 0); + } } set_all_day (epage, all_day_event); @@ -647,6 +647,9 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) if (all_day_event) { start_tt.is_date = TRUE; end_tt.is_date = TRUE; + + /* We have to add 1 day to DTEND, as it is not inclusive. */ + icaltime_adjust (&end_tt, 1, 0, 0, 0); } else { icaltimezone *start_zone, *end_zone; @@ -805,6 +808,9 @@ summary_changed_cb (GtkEditable *editable, gpointer data) } +/* Note that this assumes that the start_tt and end_tt passed to it are the + dates visible to the user. For DATE values, we have to add 1 day to the + end_tt before emitting the signal. */ static void notify_dates_changed (EventPage *epage, struct icaltimetype *start_tt, struct icaltimetype *end_tt) @@ -822,7 +828,11 @@ notify_dates_changed (EventPage *epage, struct icaltimetype *start_tt, start_dt.value = start_tt; end_dt.value = end_tt; - if (!all_day_event) { + if (all_day_event) { + /* The actual DTEND is 1 day after the displayed date for + DATE values. */ + icaltime_adjust (end_tt, 1, 0, 0, 0); + } else { start_zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->start_timezone)); end_zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->end_timezone)); } @@ -835,6 +845,7 @@ notify_dates_changed (EventPage *epage, struct icaltimetype *start_tt, dates.due = NULL; dates.complete = NULL; + comp_editor_page_notify_dates_changed (COMP_EDITOR_PAGE (epage), &dates); } diff --git a/calendar/gui/dialogs/schedule-page.c b/calendar/gui/dialogs/schedule-page.c index 08cc57e48b..df7ca0c702 100644 --- a/calendar/gui/dialogs/schedule-page.c +++ b/calendar/gui/dialogs/schedule-page.c @@ -268,7 +268,14 @@ update_time (SchedulePage *spage, CalComponentDateTime *start_date, CalComponent all_day = (start_tt.is_date && end_tt.is_date) ? TRUE : FALSE; - /* For All-Day events, we set the time field to empty. */ + /* For All Day Events, if DTEND is after DTSTART, we subtract 1 day + from it. */ + if (all_day) { + if (icaltime_compare_date_only (end_tt, start_tt) > 0) { + icaltime_adjust (&end_tt, -1, 0, 0, 0); + } + } + e_date_edit_set_date (E_DATE_EDIT (priv->sel->start_date_edit), start_tt.year, start_tt.month, start_tt.day); e_date_edit_set_time_of_day (E_DATE_EDIT (priv->sel->start_date_edit), @@ -484,7 +491,6 @@ time_changed_cb (GtkWidget *widget, gpointer data) CalComponentDateTime start_dt, end_dt; struct icaltimetype start_tt = icaltime_null_time (); struct icaltimetype end_tt = icaltime_null_time (); - gboolean start_time_set, end_time_set; priv = spage->priv; @@ -514,10 +520,12 @@ time_changed_cb (GtkWidget *widget, gpointer data) start_dt.tzid = icaltimezone_get_tzid (priv->zone); end_dt.tzid = start_dt.tzid; } else { - /* For All-Day Events, we set the timezone to NULL. */ + /* For All-Day Events, we set the timezone to NULL, and add + 1 day to DTEND. */ start_dt.value->is_date = TRUE; start_dt.tzid = NULL; end_dt.value->is_date = TRUE; + icaltime_adjust (&end_tt, 1, 0, 0, 0); end_dt.tzid = NULL; } |