aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-07-03 12:21:37 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-07-03 12:21:37 +0800
commit642d32d63f226cd1ba049a9d979132e1a1cef94d (patch)
treebe4ef8fb72ca41391007554a6cbe97af41533555 /calendar/gui/dialogs
parentbacd3a85a434032316b3e63b95282175ce2b0659 (diff)
downloadgsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.gz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.bz2
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.lz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.xz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.zst
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.zip
cal-client/cal-client.[hc] cal-util/cal-component.c
2001-07-03 Damon Chaplin <damon@ximian.com> * cal-client/cal-client.[hc] * cal-util/cal-component.c * cal-util/cal-recur.[hc] * cal-util/test-recur.c * cal-util/timeutil.c * gui/calendar-config.c * gui/calendar-model.[hc] * gui/comp-util.[hc] * gui/e-calendar-table.c * gui/e-day-view-main-item.c * gui/e-day-view-top-item.c * gui/e-day-view.[hc] * gui/e-itip-control.c * gui/e-timezone-entry.[hc] * gui/e-week-view.[hc] * gui/gnome-cal.[hc] * gui/goto.c * gui/tag-calendar.[hc] * gui/dialogs/cal-prefs-dialog.c * gui/dialogs/comp-editor-page.[hc] * gui/dialogs/comp-editor-util.[hc] * gui/dialogs/comp-editor.c * gui/dialogs/e-timezone-dialog.[hc] * gui/dialogs/event-page.c * gui/dialogs/meeting-page.c * gui/dialogs/recurrence-page.c * gui/dialogs/task-details-page.c * gui/dialogs/task-details-page.glade * gui/dialogs/task-page.c * idl/evolution-calendar.idl * pcs/cal-backend-file.c * pcs/cal-backend.c * pcs/cal-backend.h * pcs/cal.c * pcs/query.c: timezone changes everywhere. There's still quite a few things to update, and its not working well at present. svn path=/trunk/; revision=10729
Diffstat (limited to 'calendar/gui/dialogs')
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.c12
-rw-r--r--calendar/gui/dialogs/comp-editor-page.c51
-rw-r--r--calendar/gui/dialogs/comp-editor-page.h14
-rw-r--r--calendar/gui/dialogs/comp-editor-util.c124
-rw-r--r--calendar/gui/dialogs/comp-editor-util.h2
-rw-r--r--calendar/gui/dialogs/comp-editor.c5
-rw-r--r--calendar/gui/dialogs/e-timezone-dialog.c45
-rw-r--r--calendar/gui/dialogs/e-timezone-dialog.h15
-rw-r--r--calendar/gui/dialogs/event-page.c346
-rw-r--r--calendar/gui/dialogs/meeting-page.c2
-rw-r--r--calendar/gui/dialogs/recurrence-page.c211
-rw-r--r--calendar/gui/dialogs/task-details-page.c97
-rw-r--r--calendar/gui/dialogs/task-details-page.glade38
-rw-r--r--calendar/gui/dialogs/task-page.c166
14 files changed, 809 insertions, 319 deletions
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c
index de3cbf2483..59acefc263 100644
--- a/calendar/gui/dialogs/cal-prefs-dialog.c
+++ b/calendar/gui/dialogs/cal-prefs-dialog.c
@@ -390,14 +390,16 @@ cal_prefs_dialog_show_config (CalPrefsDialog *prefs)
CalPrefsDialogPrivate *priv;
CalWeekdays working_days;
gint mask, day, week_start_day, time_divisions;
- char *zone;
+ char *zone_name;
+ icaltimezone *zone;
priv = prefs->priv;
/* Timezone. */
- zone = calendar_config_get_timezone ();
+ zone_name = calendar_config_get_timezone ();
+ zone = icaltimezone_get_builtin_timezone (zone_name);
e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->timezone),
- zone ? zone : "");
+ zone);
/* Working Days. */
working_days = calendar_config_get_working_days ();
@@ -482,13 +484,13 @@ cal_prefs_dialog_update_config (CalPrefsDialog *prefs)
CalPrefsDialogPrivate *priv;
CalWeekdays working_days;
gint mask, day, week_start_day, time_divisions, hour, minute;
- char *zone;
+ icaltimezone *zone;
priv = prefs->priv;
/* Timezone. */
zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->timezone));
- calendar_config_set_timezone (zone);
+ calendar_config_set_timezone (icaltimezone_get_location (zone));
/* Working Days. */
working_days = 0;
diff --git a/calendar/gui/dialogs/comp-editor-page.c b/calendar/gui/dialogs/comp-editor-page.c
index afa09177f5..85e7b8c9af 100644
--- a/calendar/gui/dialogs/comp-editor-page.c
+++ b/calendar/gui/dialogs/comp-editor-page.c
@@ -29,6 +29,8 @@
static void comp_editor_page_class_init (CompEditorPageClass *class);
+static void comp_editor_page_init (CompEditorPage *page);
+static void comp_editor_page_destroy (GtkObject *object);
/* Signal IDs */
@@ -65,7 +67,7 @@ comp_editor_page_get_type (void)
sizeof (CompEditorPage),
sizeof (CompEditorPageClass),
(GtkClassInitFunc) comp_editor_page_class_init,
- (GtkObjectInitFunc) NULL,
+ (GtkObjectInitFunc) comp_editor_page_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
@@ -136,10 +138,36 @@ comp_editor_page_class_init (CompEditorPageClass *class)
class->fill_component = NULL;
class->set_summary = NULL;
class->set_dates = NULL;
+
+ object_class->destroy = comp_editor_page_destroy;
}
+static void
+comp_editor_page_init (CompEditorPage *page)
+{
+ page->client = NULL;
+}
+
+
+static void
+comp_editor_page_destroy (GtkObject *object)
+{
+ CompEditorPage *page;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (IS_COMP_EDITOR_PAGE (object));
+
+ page = COMP_EDITOR_PAGE (object);
+
+ if (page->client) {
+ gtk_object_ref (GTK_OBJECT (page->client));
+ page->client = NULL;
+ }
+}
+
+
/**
* comp_editor_page_get_widget:
* @page: An editor page.
@@ -198,6 +226,27 @@ comp_editor_page_fill_component (CompEditorPage *page, CalComponent *comp)
}
/**
+ * comp_editor_page_set_cal_client:
+ * @page: An editor page
+ * @client: A #CalClient object
+ *
+ * Sets the #CalClient for the dialog page to use.
+ **/
+void
+comp_editor_page_set_cal_client (CompEditorPage *page, CalClient *client)
+{
+ g_return_if_fail (page != NULL);
+ g_return_if_fail (IS_COMP_EDITOR_PAGE (page));
+
+ if (page->client)
+ gtk_object_unref (GTK_OBJECT (client));
+
+ page->client = client;
+ if (page->client)
+ gtk_object_ref (GTK_OBJECT (client));
+}
+
+/**
* comp_editor_page_set_summary:
* @page: An editor page
* @summary: The text of the new summary value
diff --git a/calendar/gui/dialogs/comp-editor-page.h b/calendar/gui/dialogs/comp-editor-page.h
index b544200a76..08fe1d8508 100644
--- a/calendar/gui/dialogs/comp-editor-page.h
+++ b/calendar/gui/dialogs/comp-editor-page.h
@@ -26,6 +26,7 @@
#include <libgnome/gnome-defs.h>
#include <gtk/gtkwidget.h>
#include <cal-util/cal-component.h>
+#include "cal-client.h"
BEGIN_GNOME_DECLS
@@ -38,14 +39,17 @@ BEGIN_GNOME_DECLS
#define IS_COMP_EDITOR_PAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), TYPE_COMP_EDITOR_PAGE))
typedef struct {
- time_t start;
- time_t end;
- time_t due;
- time_t complete;
+ struct icaltimetype *start;
+ struct icaltimetype *end;
+ struct icaltimetype *due;
+ struct icaltimetype *complete;
} CompEditorPageDates;
typedef struct {
GtkObject object;
+
+ /* Some of the pages need the CalClient to access timezone data. */
+ CalClient *client;
} CompEditorPage;
typedef struct {
@@ -77,6 +81,8 @@ void comp_editor_page_fill_widgets (CompEditorPage *page,
CalComponent *comp);
void comp_editor_page_fill_component (CompEditorPage *page,
CalComponent *comp);
+void comp_editor_page_set_cal_client (CompEditorPage *page,
+ CalClient *client);
void comp_editor_page_set_summary (CompEditorPage *page,
const char *summary);
void comp_editor_page_set_dates (CompEditorPage *page,
diff --git a/calendar/gui/dialogs/comp-editor-util.c b/calendar/gui/dialogs/comp-editor-util.c
index b6c169f6ed..e3cf454e84 100644
--- a/calendar/gui/dialogs/comp-editor-util.c
+++ b/calendar/gui/dialogs/comp-editor-util.c
@@ -24,6 +24,7 @@
#endif
#include <string.h>
+#include <ical.h>
#include <glib.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
@@ -39,50 +40,77 @@
* @comp: The component to extract the dates from
*
* Extracts the dates from the calendar component into the
- * CompEditorPageDates structure
+ * CompEditorPageDates structure. Note that it returns pointers to static
+ * structs, so these will be overwritten in the next call.
**/
void
comp_editor_dates (CompEditorPageDates *dates, CalComponent *comp)
{
+ static struct icaltimetype start;
+ static struct icaltimetype end;
+ static struct icaltimetype due;
+ static struct icaltimetype complete;
+
CalComponentDateTime dt;
- struct icaltimetype *completed;
+ struct icaltimetype *comp_complete;
+
- dates->start = 0;
- dates->end = 0;
- dates->due = 0;
- dates->complete = 0;
+ dates->start = NULL;
+ dates->end = NULL;
+ dates->due = NULL;
+ dates->complete = NULL;
cal_component_get_dtstart (comp, &dt);
- if (dt.value)
- dates->start = icaltime_as_timet (*dt.value);
+ if (dt.value) {
+ start = *dt.value;
+ dates->start = &start;
+ }
+ cal_component_free_datetime (&dt);
cal_component_get_dtend (comp, &dt);
- if (dt.value)
- dates->end = icaltime_as_timet (*dt.value);
+ if (dt.value) {
+ end = *dt.value;
+ dates->end = &end;
+ }
+ cal_component_free_datetime (&dt);
cal_component_get_due (comp, &dt);
- if (dt.value)
- dates->due = icaltime_as_timet (*dt.value);
+ if (dt.value) {
+ due = *dt.value;
+ dates->due = &due;
+ }
+ cal_component_free_datetime (&dt);
- cal_component_get_completed (comp, &completed);
- if (completed) {
- dates->complete = icaltime_as_timet (*completed);
- cal_component_free_icaltimetype (completed);
+ cal_component_get_completed (comp, &comp_complete);
+ if (comp_complete) {
+ complete = *comp_complete;
+ dates->complete = &complete;
}
+ cal_component_free_icaltimetype (comp_complete);
}
static void
-write_label_piece (time_t t, char *buffer, int size, char *stext, char *etext)
+write_label_piece (struct icaltimetype *tt, char *buffer, int size,
+ char *stext, char *etext)
{
- struct tm *tmp_tm;
+ struct tm tmp_tm;
int len;
- tmp_tm = localtime (&t);
+ /* FIXME: May want to convert the time to an appropriate zone. */
+
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;
+ tmp_tm.tm_isdst = -1;
+
len = strlen (buffer);
- e_time_format_date_and_time (tmp_tm,
+ e_time_format_date_and_time (&tmp_tm,
calendar_config_get_24_hour_format (),
FALSE, FALSE,
&buffer[len], size - len);
@@ -101,25 +129,36 @@ write_label_piece (time_t t, char *buffer, int size, char *stext, char *etext)
void
comp_editor_date_label (CompEditorPageDates *dates, GtkWidget *label)
{
- static char buffer[1024];
+ char buffer[1024];
+ gboolean start_set = FALSE, end_set = FALSE;
+ gboolean complete_set = FALSE, due_set = FALSE;
buffer[0] = '\0';
- if (dates->start > 0)
+ if (dates->start && !icaltime_is_null_time (*dates->start))
+ start_set = TRUE;
+ if (dates->end && !icaltime_is_null_time (*dates->end))
+ end_set = TRUE;
+ if (dates->complete && !icaltime_is_null_time (*dates->complete))
+ complete_set = TRUE;
+ if (dates->due && !icaltime_is_null_time (*dates->due))
+ due_set = TRUE;
+
+ if (start_set)
write_label_piece (dates->start, buffer, 1024, NULL, NULL);
- if (dates->end > 0 && dates->start > 0)
+ if (start_set && end_set)
write_label_piece (dates->end, buffer, 1024, _(" to "), NULL);
- if (dates->complete > 0) {
- if (dates->start > 0)
+ if (complete_set) {
+ if (start_set)
write_label_piece (dates->complete, buffer, 1024, _(" (Completed "), ")");
else
write_label_piece (dates->complete, buffer, 1024, _("Completed "), NULL);
}
- if (dates->due > 0 && dates->complete == 0) {
- if (dates->start > 0)
+ if (due_set && dates->complete == NULL) {
+ if (start_set)
write_label_piece (dates->due, buffer, 1024, _(" (Due "), ")");
else
write_label_piece (dates->due, buffer, 1024, _("Due "), NULL);
@@ -151,3 +190,34 @@ comp_editor_new_date_edit (gboolean show_date, gboolean show_time)
return GTK_WIDGET (dedit);
}
+
+
+/* Returns the current time, for EDateEdit widgets and ECalendar items in the
+ dialogs.
+ FIXME: Should probably use the timezone from somewhere in the component
+ rather than the current timezone. */
+struct tm
+comp_editor_get_current_time (GtkObject *object, gpointer data)
+{
+ char *location;
+ icaltimezone *zone;
+ struct icaltimetype tt;
+ struct tm tmp_tm = { 0 };
+
+ /* Get the current timezone. */
+ location = calendar_config_get_timezone ();
+ zone = icaltimezone_get_builtin_timezone (location);
+
+ tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone);
+
+ /* Now copy it to the struct tm and return it. */
+ 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;
+ tmp_tm.tm_isdst = -1;
+
+ return tmp_tm;
+}
diff --git a/calendar/gui/dialogs/comp-editor-util.h b/calendar/gui/dialogs/comp-editor-util.h
index f2299e27c4..4e8e344731 100644
--- a/calendar/gui/dialogs/comp-editor-util.h
+++ b/calendar/gui/dialogs/comp-editor-util.h
@@ -30,4 +30,6 @@ void comp_editor_date_label (CompEditorPageDates *dates, GtkWidget *label);
GtkWidget *comp_editor_new_date_edit (gboolean show_date, gboolean show_time);
+struct tm comp_editor_get_current_time (GtkObject *object, gpointer data);
+
#endif
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 08677260e7..c001207783 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -364,6 +364,7 @@ void
comp_editor_set_cal_client (CompEditor *editor, CalClient *client)
{
CompEditorPrivate *priv;
+ GList *elem;
g_return_if_fail (editor != NULL);
g_return_if_fail (IS_COMP_EDITOR (editor));
@@ -388,6 +389,10 @@ comp_editor_set_cal_client (CompEditor *editor, CalClient *client)
priv->client = client;
+ /* Pass the client to any pages that need it. */
+ for (elem = priv->pages; elem; elem = elem->next)
+ comp_editor_page_set_cal_client (elem->data, client);
+
gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated",
GTK_SIGNAL_FUNC (obj_updated_cb), editor);
diff --git a/calendar/gui/dialogs/e-timezone-dialog.c b/calendar/gui/dialogs/e-timezone-dialog.c
index ad9acfb528..70061addd6 100644
--- a/calendar/gui/dialogs/e-timezone-dialog.c
+++ b/calendar/gui/dialogs/e-timezone-dialog.c
@@ -37,6 +37,11 @@
#define E_TIMEZONE_DIALOG_MAP_POINT_SELECTED_2_RGBA 0x000000ff
struct _ETimezoneDialogPrivate {
+ /* The TZID of the timezone. May be NULL for a 'local time' (i.e. when
+ the displayed name is "") or for builtin timezones which we haven't
+ loaded yet. */
+ char *tzid;
+
/* Glade XML data */
GladeXML *xml;
@@ -131,6 +136,7 @@ e_timezone_dialog_init (ETimezoneDialog *etd)
priv = g_new0 (ETimezoneDialogPrivate, 1);
etd->priv = priv;
+ priv->tzid = NULL;
priv->point_selected = NULL;
priv->point_hover = NULL;
priv->timeout_id = 0;
@@ -149,6 +155,9 @@ e_timezone_dialog_destroy (GtkObject *object)
etd = E_TIMEZONE_DIALOG (object);
priv = etd->priv;
+ g_free (priv->tzid);
+ priv->tzid = NULL;
+
if (priv->timeout_id) {
g_source_remove (priv->timeout_id);
priv->timeout_id = 0;
@@ -460,6 +469,9 @@ on_map_button_pressed (GtkWidget *w, GdkEventButton *event, gpointer data)
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry),
get_zone_from_point (etd, priv->point_selected));
+
+ g_free (priv->tzid);
+ priv->tzid = NULL;
}
return TRUE;
@@ -508,8 +520,13 @@ get_zone_from_point (ETimezoneDialog *etd,
}
+/* Returns the TZID of the timezone set, and optionally its displayed name.
+ The TZID may be NULL, in which case the builtin timezone with the city name
+ of display_name should be used. If display_name is also NULL or "", then it
+ is assumed to be a 'local time'. */
char*
-e_timezone_dialog_get_timezone (ETimezoneDialog *etd)
+e_timezone_dialog_get_timezone (ETimezoneDialog *etd,
+ char **display_name)
{
ETimezoneDialogPrivate *priv;
@@ -518,13 +535,21 @@ e_timezone_dialog_get_timezone (ETimezoneDialog *etd)
priv = etd->priv;
- return gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry));
+ if (display_name)
+ *display_name = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry));
+
+ return priv->tzid;
}
+/* Sets the TZID and displayed name of the timezone. The TZID may be NULL for
+ a 'local time' (i.e. display_name is NULL or "") or if it is a builtin
+ timezone which hasn't been loaded yet. (This is done so we don't load
+ timezones until we really need them.) */
void
e_timezone_dialog_set_timezone (ETimezoneDialog *etd,
- char *timezone)
+ char *tzid,
+ char *display_name)
{
ETimezoneDialogPrivate *priv;
@@ -533,8 +558,13 @@ e_timezone_dialog_set_timezone (ETimezoneDialog *etd,
priv = etd->priv;
+ if (priv->tzid)
+ g_free (priv->tzid);
+
+ priv->tzid = g_strdup (tzid);
+
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry),
- timezone);
+ display_name ? display_name : "");
find_selected_point (etd);
}
@@ -605,5 +635,12 @@ find_selected_point (ETimezoneDialog *etd)
static void
on_combo_changed (GtkEditable *entry, ETimezoneDialog *etd)
{
+ ETimezoneDialogPrivate *priv;
+
+ priv = etd->priv;
+
find_selected_point (etd);
+
+ g_free (priv->tzid);
+ priv->tzid = NULL;
}
diff --git a/calendar/gui/dialogs/e-timezone-dialog.h b/calendar/gui/dialogs/e-timezone-dialog.h
index 323375c5fc..4f6f9dd934 100644
--- a/calendar/gui/dialogs/e-timezone-dialog.h
+++ b/calendar/gui/dialogs/e-timezone-dialog.h
@@ -56,9 +56,20 @@ ETimezoneDialog* e_timezone_dialog_construct (ETimezoneDialog *etd);
ETimezoneDialog* e_timezone_dialog_new (void);
-char* e_timezone_dialog_get_timezone (ETimezoneDialog *etd);
+/* Returns the TZID of the timezone set, and optionally its displayed name.
+ The TZID may be NULL, in which case the builtin timezone with the city name
+ of display_name should be used. If display_name is also NULL or "", then it
+ is assumed to be a 'local time'. */
+char* e_timezone_dialog_get_timezone (ETimezoneDialog *etd,
+ char **display_name);
+
+/* Sets the TZID and displayed name of the timezone. The TZID may be NULL for
+ a 'local time' (i.e. display_name is NULL or "") or if it is a builtin
+ timezone which hasn't been loaded yet. (This is done so we don't load
+ timezones until we really need them.) */
void e_timezone_dialog_set_timezone (ETimezoneDialog *etd,
- char *timezone);
+ char *tzid,
+ char *display_name);
GtkWidget* e_timezone_dialog_get_toplevel (ETimezoneDialog *etd);
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index 89835ae4b3..c9f1891fdc 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -232,22 +232,20 @@ static void
check_all_day (EventPage *epage)
{
EventPagePrivate *priv;
- time_t ev_start, ev_end;
- gboolean all_day = FALSE;
+ gboolean all_day = FALSE, start_set, end_set;
+ gint start_hour, start_minute, end_hour, end_minute;
priv = epage->priv;
- /* Currently we just return if the date is not set or not valid.
- I'm not entirely sure this is the corrent thing to do. */
- ev_start = e_date_edit_get_time (E_DATE_EDIT (priv->start_time));
- g_assert (ev_start != -1);
+ start_set = e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_time),
+ &start_hour, &start_minute);
- ev_end = e_date_edit_get_time (E_DATE_EDIT (priv->end_time));
- g_assert (ev_end != -1);
+ end_set = e_date_edit_get_time_of_day (E_DATE_EDIT (priv->end_time),
+ &end_hour, &end_minute);
/* all day event checkbox */
- if (time_day_begin (ev_start) == ev_start
- && time_day_begin (ev_end) == ev_end)
+ if ((!start_set || (start_hour == 0 && start_minute == 0))
+ && (!end_set || (end_hour == 0 && end_minute == 0)))
all_day = TRUE;
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->all_day_event),
@@ -265,12 +263,9 @@ static void
clear_widgets (EventPage *epage)
{
EventPagePrivate *priv;
- time_t now;
priv = epage->priv;
- now = time (NULL);
-
/* Summary, description */
e_dialog_editable_set (priv->summary, NULL);
e_dialog_editable_set (priv->description, NULL);
@@ -280,8 +275,8 @@ clear_widgets (EventPage *epage)
epage);
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), epage);
- e_date_edit_set_time (E_DATE_EDIT (priv->start_time), now);
- e_date_edit_set_time (E_DATE_EDIT (priv->end_time), now);
+ e_date_edit_set_time (E_DATE_EDIT (priv->start_time), 0);
+ e_date_edit_set_time (E_DATE_EDIT (priv->end_time), 0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time),
epage);
@@ -306,10 +301,14 @@ event_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
EventPagePrivate *priv;
CalComponentText text;
CalComponentClassification cl;
- CalComponentDateTime d;
+ CalComponentDateTime start_date, end_date;
GSList *l;
- time_t dtstart, dtend;
const char *categories;
+ CalClientGetStatus status;
+ struct icaltimetype *start_tt, *end_tt;
+ icaltimezone *start_zone = NULL, *end_zone = NULL;
+
+ g_return_if_fail (page->client != NULL);
epage = EVENT_PAGE (page);
priv = epage->priv;
@@ -334,40 +333,63 @@ event_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
/* Start and end times */
+ cal_component_get_dtstart (comp, &start_date);
+ status = cal_client_get_timezone (page->client, start_date.tzid,
+ &start_zone);
+ /* FIXME: Handle error better. */
+ if (status != CAL_CLIENT_GET_SUCCESS)
+ g_warning ("Couldn't get timezone from server: %s",
+ start_date.tzid ? start_date.tzid : "");
+
+ cal_component_get_dtend (comp, &end_date);
+ status = cal_client_get_timezone (page->client, end_date.tzid, &end_zone);
+ /* FIXME: Handle error better. */
+ if (status != CAL_CLIENT_GET_SUCCESS)
+ g_warning ("Couldn't get timezone from server: %s",
+ end_date.tzid ? end_date.tzid : "");
+
/* All-day events are inclusive, i.e. if the end date shown is 2nd Feb
then the event includes all of the 2nd Feb. We would normally show
3rd Feb as the end date, since it really ends at midnight on 3rd,
so we have to subtract a day so we only show the 2nd. */
- cal_component_get_dtstart (comp, &d);
- dtstart = icaltime_as_timet (*d.value);
- cal_component_free_datetime (&d);
-
- cal_component_get_dtend (comp, &d);
- dtend = icaltime_as_timet (*d.value);
- cal_component_free_datetime (&d);
-
- if (time_day_begin (dtstart) == dtstart
- && time_day_begin (dtend) == dtend)
- dtend = time_add_day (dtend, -1);
+ start_tt = start_date.value;
+ end_tt = end_date.value;
+ if (start_tt->hour == 0 && start_tt->minute == 0 && start_tt->second == 0
+ && end_tt->hour == 0 && end_tt->minute == 0 && end_tt->second == 0)
+ icaltime_adjust (end_tt, 1, 0, 0, 0);
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time),
epage);
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), epage);
- e_date_edit_set_time (E_DATE_EDIT (priv->start_time), dtstart);
- e_date_edit_set_time (E_DATE_EDIT (priv->end_time), dtend);
+ e_date_edit_set_date (E_DATE_EDIT (priv->start_time), start_tt->year,
+ start_tt->month, start_tt->day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->start_time),
+ start_tt->hour, start_tt->minute);
+
+ e_date_edit_set_date (E_DATE_EDIT (priv->end_time), end_tt->year,
+ end_tt->month, end_tt->day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->end_time),
+ end_tt->hour, end_tt->minute);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time),
epage);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time),
epage);
+ cal_component_free_datetime (&start_date);
+ cal_component_free_datetime (&end_date);
+
check_all_day (epage);
- /* FIXME: Get the timezones from the event and put them in the
- widgets. Set sync_timezones to TRUE if both timezones are the same.
- */
- priv->sync_timezones = TRUE;
+ /* Set the timezones, and set sync_timezones to TRUE if both timezones
+ are the same. */
+ e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->start_timezone),
+ start_zone);
+ e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->end_timezone),
+ end_zone);
+ priv->sync_timezones = (start_zone == end_zone) ? TRUE : FALSE;
+
/* Classification */
@@ -413,10 +435,10 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp)
EventPagePrivate *priv;
CalComponentDateTime date;
struct icaltimetype icaltime;
- time_t t;
- gboolean all_day_event;
+ gboolean all_day_event, date_set;
char *cat, *str;
CalComponentClassification classif;
+ icaltimezone *zone;
epage = EVENT_PAGE (page);
priv = epage->priv;
@@ -463,28 +485,51 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp)
date.value = &icaltime;
date.tzid = NULL;
- t = e_date_edit_get_time (E_DATE_EDIT (priv->start_time));
- if (t != -1) {
- *date.value = icaltime_from_timet (t, FALSE);
- cal_component_set_dtstart (comp, &date);
- } else {
- /* FIXME: What do we do here? */
- }
+ icaltime.is_utc = 0;
+ /* FIXME: We should use is_date at some point. */
+ icaltime.is_date = 0;
+ icaltime.is_daylight = 0;
+ icaltime.second = 0;
+
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->start_time),
+ &icaltime.year,
+ &icaltime.month,
+ &icaltime.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_time),
+ &icaltime.hour,
+ &icaltime.minute);
+ g_assert (date_set);
+ zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->start_timezone));
+ if (zone)
+ date.tzid = icaltimezone_get_tzid (zone);
+ cal_component_set_dtstart (comp, &date);
/* If the all_day toggle is set, the end date is inclusive of the
entire day on which it points to. */
all_day_event = e_dialog_toggle_get (priv->all_day_event);
- t = e_date_edit_get_time (E_DATE_EDIT (priv->end_time));
- if (t != -1) {
- if (all_day_event)
- t = time_day_end (t);
- *date.value = icaltime_from_timet (t, FALSE);
- cal_component_set_dtend (comp, &date);
- } else {
- /* FIXME: What do we do here? */
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->end_time),
+ &icaltime.year,
+ &icaltime.month,
+ &icaltime.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->end_time),
+ &icaltime.hour,
+ &icaltime.minute);
+ g_assert (date_set);
+
+ if (all_day_event) {
+ icaltime.hour = 0;
+ icaltime.minute = 0;
+ icaltime.second = 0;
+ icaltime_adjust (&icaltime, 1, 0, 0, 0);
}
+ zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->end_timezone));
+ if (zone)
+ date.tzid = icaltimezone_get_tzid (zone);
+ cal_component_set_dtend (comp, &date);
+
+
/* Categories */
cat = e_dialog_editable_get (priv->categories);
@@ -606,9 +651,11 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
{
EventPage *epage;
EventPagePrivate *priv;
- time_t start, end;
- struct tm tm_start, tm_end;
CompEditorPageDates dates;
+ struct icaltimetype start_tt = icaltime_null_time();
+ struct icaltimetype end_tt = icaltime_null_time();
+ int cmp;
+ gboolean date_set;
epage = EVENT_PAGE (data);
priv = epage->priv;
@@ -617,49 +664,67 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
return;
/* Ensure that start < end */
- start = e_date_edit_get_time (E_DATE_EDIT (priv->start_time));
- g_assert (start != -1);
- end = e_date_edit_get_time (E_DATE_EDIT (priv->end_time));
- g_assert (end != -1);
-
- if (start >= end) {
- tm_start = *localtime (&start);
- tm_end = *localtime (&end);
-
- if (start == end && tm_start.tm_hour == 0
- && tm_start.tm_min == 0 && tm_start.tm_sec == 0) {
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->start_time),
+ &start_tt.year,
+ &start_tt.month,
+ &start_tt.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_time),
+ &start_tt.hour,
+ &start_tt.minute);
+ g_assert (date_set);
+
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->end_time),
+ &end_tt.year,
+ &end_tt.month,
+ &end_tt.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->end_time),
+ &end_tt.hour,
+ &end_tt.minute);
+ g_assert (date_set);
+
+ cmp = icaltime_compare (start_tt, end_tt);
+ if (cmp >= 0) {
+ if (cmp == 0 && start_tt.hour == 0
+ && start_tt.minute == 0
+ && start_tt.second == 0) {
/* If the start and end times are the same, but both
* are on day boundaries, then that is OK since it
* means we have an all-day event lasting 1 day. So
* we do nothing here.
*/
} else if (GTK_WIDGET (dedit) == priv->start_time) {
- /* Modify the end time */
+ /* Modify the end time, to be the start + 1 hour. */
- tm_end.tm_year = tm_start.tm_year;
- tm_end.tm_mon = tm_start.tm_mon;
- tm_end.tm_mday = tm_start.tm_mday;
- tm_end.tm_hour = tm_start.tm_hour + 1;
- tm_end.tm_min = tm_start.tm_min;
- tm_end.tm_sec = tm_start.tm_sec;
+ end_tt = start_tt;
+ icaltime_adjust (&end_tt, 0, 1, 0, 0);
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), epage);
- end = mktime (&tm_end);
- e_date_edit_set_time (E_DATE_EDIT (priv->end_time), end);
+
+ e_date_edit_set_date (E_DATE_EDIT (priv->end_time),
+ end_tt.year,
+ end_tt.month,
+ end_tt.day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->end_time),
+ end_tt.hour,
+ end_tt.minute);
+
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), epage);
} else if (GTK_WIDGET (dedit) == priv->end_time) {
- /* Modify the start time */
+ /* Modify the start time, to be the end - 1 hour. */
- tm_start.tm_year = tm_end.tm_year;
- tm_start.tm_mon = tm_end.tm_mon;
- tm_start.tm_mday = tm_end.tm_mday;
- tm_start.tm_hour = tm_end.tm_hour - 1;
- tm_start.tm_min = tm_end.tm_min;
- tm_start.tm_sec = tm_end.tm_sec;
+ start_tt = end_tt;
+ icaltime_adjust (&start_tt, 0, -1, 0, 0);
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), epage);
- start = mktime (&tm_start);
- e_date_edit_set_time (E_DATE_EDIT (priv->start_time), start);
+
+ e_date_edit_set_date (E_DATE_EDIT (priv->start_time),
+ start_tt.year,
+ start_tt.month,
+ start_tt.day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->start_time),
+ start_tt.hour,
+ start_tt.minute);
+
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), epage);
} else
g_assert_not_reached ();
@@ -669,10 +734,10 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
check_all_day (epage);
/* Notify upstream */
- dates.start = start;
- dates.end = end;
- dates.due = 0;
- dates.complete = 0;
+ dates.start = &start_tt;
+ dates.end = &end_tt;
+ dates.due = NULL;
+ dates.complete = NULL;
comp_editor_page_notify_dates_changed (COMP_EDITOR_PAGE (epage),
&dates);
}
@@ -686,7 +751,7 @@ start_timezone_changed_cb (GtkWidget *widget, gpointer data)
{
EventPage *epage;
EventPagePrivate *priv;
- char *zone;
+ icaltimezone *zone;
epage = EVENT_PAGE (data);
priv = epage->priv;
@@ -706,7 +771,7 @@ end_timezone_changed_cb (GtkWidget *widget, gpointer data)
{
EventPage *epage;
EventPagePrivate *priv;
- char *start_zone, *end_zone;
+ icaltimezone *start_zone, *end_zone;
epage = EVENT_PAGE (data);
priv = epage->priv;
@@ -714,7 +779,7 @@ end_timezone_changed_cb (GtkWidget *widget, gpointer data)
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));
- priv->sync_timezones = (strcmp (start_zone, end_zone)) ? FALSE : TRUE;
+ priv->sync_timezones = (start_zone == end_zone) ? TRUE : FALSE;
}
/* Callback: all day event button toggled.
@@ -727,11 +792,12 @@ all_day_event_toggled_cb (GtkWidget *toggle, gpointer data)
{
EventPage *epage;
EventPagePrivate *priv;
- struct tm start_tm, end_tm;
- time_t start_t, end_t;
gboolean all_day;
CompEditorPageDates dates;
-
+ struct icaltimetype start_tt = icaltime_null_time();
+ struct icaltimetype end_tt = icaltime_null_time();
+ gboolean date_set;
+
epage = EVENT_PAGE (data);
priv = epage->priv;
@@ -755,51 +821,58 @@ all_day_event_toggled_cb (GtkWidget *toggle, gpointer data)
/*
* Start time.
*/
- start_t = e_date_edit_get_time (E_DATE_EDIT (priv->start_time));
- g_assert (start_t != -1);
-
- start_tm = *localtime (&start_t);
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->start_time),
+ &start_tt.year,
+ &start_tt.month,
+ &start_tt.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_time),
+ &start_tt.hour,
+ &start_tt.minute);
+ g_assert (date_set);
if (all_day) {
/* Round down to the start of the day. */
- start_tm.tm_hour = 0;
- start_tm.tm_min = 0;
- start_tm.tm_sec = 0;
+ start_tt.hour = 0;
+ start_tt.minute = 0;
+ start_tt.second = 0;
} else {
/* Set to the start of the working day. */
- start_tm.tm_hour = calendar_config_get_day_start_hour ();
- start_tm.tm_min = calendar_config_get_day_start_minute ();
- start_tm.tm_sec = 0;
+ start_tt.hour = calendar_config_get_day_start_hour ();
+ start_tt.minute = calendar_config_get_day_start_minute ();
+ start_tt.second = 0;
}
/*
* End time.
*/
- end_t = e_date_edit_get_time (E_DATE_EDIT (priv->end_time));
- g_assert (end_t != -1);
-
- end_tm = *localtime (&end_t);
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->end_time),
+ &end_tt.year,
+ &end_tt.month,
+ &end_tt.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->end_time),
+ &end_tt.hour,
+ &end_tt.minute);
+ g_assert (date_set);
if (all_day) {
/* Round down to the start of the day. */
- end_tm.tm_hour = 0;
- end_tm.tm_min = 0;
- end_tm.tm_sec = 0;
+ end_tt.hour = 0;
+ end_tt.minute = 0;
+ end_tt.second = 0;
} else {
/* If the event end is now on or before the event start day,
- * make it end one hour after the start. mktime() will fix any
- * overflows.
- */
- if (end_tm.tm_year < start_tm.tm_year
- || (end_tm.tm_year == start_tm.tm_year
- && end_tm.tm_mon < start_tm.tm_mon)
- || (end_tm.tm_year == start_tm.tm_year
- && end_tm.tm_mon == start_tm.tm_mon
- && end_tm.tm_mday <= start_tm.tm_mday)) {
- end_tm.tm_year = start_tm.tm_year;
- end_tm.tm_mon = start_tm.tm_mon;
- end_tm.tm_mday = start_tm.tm_mday;
- end_tm.tm_hour = start_tm.tm_hour + 1;
+ * make it end one hour after the start. */
+ if (end_tt.year < start_tt.year
+ || (end_tt.year == start_tt.year
+ && end_tt.month < start_tt.month)
+ || (end_tt.year == start_tt.year
+ && end_tt.month == start_tt.month
+ && end_tt.day <= start_tt.day)) {
+ end_tt.year = start_tt.year;
+ end_tt.month = start_tt.month;
+ end_tt.day = start_tt.day;
+ end_tt.hour = start_tt.hour;
+ icaltime_adjust (&end_tt, 0, 1, 0, 0);
}
}
@@ -808,10 +881,15 @@ all_day_event_toggled_cb (GtkWidget *toggle, gpointer data)
gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time),
epage);
- start_t = mktime (&start_tm);
- end_t = mktime (&end_tm);
- e_date_edit_set_time (E_DATE_EDIT (priv->start_time), start_t);
- e_date_edit_set_time (E_DATE_EDIT (priv->end_time), end_t);
+ e_date_edit_set_date (E_DATE_EDIT (priv->start_time), start_tt.year,
+ start_tt.month, start_tt.day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->start_time),
+ start_tt.hour, start_tt.minute);
+
+ e_date_edit_set_date (E_DATE_EDIT (priv->end_time), end_tt.year,
+ end_tt.month, end_tt.day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->end_time),
+ end_tt.hour, end_tt.minute);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time),
epage);
@@ -822,9 +900,10 @@ all_day_event_toggled_cb (GtkWidget *toggle, gpointer data)
e_date_edit_set_show_time (E_DATE_EDIT (priv->end_time), !all_day);
/* Notify upstream */
- dates.start = start_t;
- dates.end = end_t;
- dates.due = 0;
+ dates.start = &start_tt;
+ dates.end = &end_tt;
+ dates.due = NULL;
+ dates.complete = NULL;
comp_editor_page_notify_dates_changed (COMP_EDITOR_PAGE (epage),
&dates);
}
@@ -868,6 +947,15 @@ init_widgets (EventPage *epage)
priv = epage->priv;
+ /* Make sure the EDateEdit widgets use our timezones to get the
+ current time. */
+ e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->start_time),
+ (EDateEditGetTimeCallback) comp_editor_get_current_time,
+ epage, NULL);
+ e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->end_time),
+ (EDateEditGetTimeCallback) comp_editor_get_current_time,
+ epage, NULL);
+
/* Summary */
gtk_signal_connect (GTK_OBJECT (priv->summary), "changed",
GTK_SIGNAL_FUNC (summary_changed_cb), epage);
diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c
index 2ef94bafff..566422aa9b 100644
--- a/calendar/gui/dialogs/meeting-page.c
+++ b/calendar/gui/dialogs/meeting-page.c
@@ -41,7 +41,7 @@
#include <widgets/misc/e-dateedit.h>
#include <widgets/meeting-time-sel/e-meeting-time-sel.h>
#include <e-util/e-dialog-widgets.h>
-#include "../Evolution-Addressbook-SelectNames.h"
+#include <addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.h>
#include "comp-editor-util.h"
#include "meeting-page.h"
diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c
index e1656ad83f..4023cd6b5a 100644
--- a/calendar/gui/dialogs/recurrence-page.c
+++ b/calendar/gui/dialogs/recurrence-page.c
@@ -43,6 +43,10 @@
+/* We set this as the TZID on all exceptions added. When we actually fill
+ the component, we replace it with the TZID from DTSTART. */
+static char *DUMMY_TZID = "DUMMY";
+
enum month_day_options {
MONTH_DAY_NTH,
MONTH_DAY_MON,
@@ -287,10 +291,11 @@ free_exception_clist_data (RecurrencePage *rpage)
GtkCList *clist = GTK_CLIST (priv->exception_list);
for (i = 0; i < clist->rows; i++) {
- gpointer data;
+ CalComponentDateTime *dt;
- data = gtk_clist_get_row_data (clist, i);
- g_free (data);
+ dt = gtk_clist_get_row_data (clist, i);
+ g_free (dt->value);
+ g_free (dt);
gtk_clist_set_row_data (clist, i, NULL);
}
@@ -391,42 +396,58 @@ clear_widgets (RecurrencePage *rpage)
/* Builds a static string out of an exception date */
static char *
-get_exception_string (time_t t)
+get_exception_string (CalComponentDateTime *dt)
{
static char buf[256];
+ struct tm tmp_tm;
+
+ tmp_tm.tm_year = dt->value->year - 1900;
+ tmp_tm.tm_mon = dt->value->month - 1;
+ tmp_tm.tm_mday = dt->value->day;
+ tmp_tm.tm_hour = dt->value->hour;
+ tmp_tm.tm_min = dt->value->minute;
+ tmp_tm.tm_sec = dt->value->second;
+ tmp_tm.tm_isdst = -1;
- strftime (buf, sizeof (buf), _("%a %b %d %Y"), localtime (&t));
+ strftime (buf, sizeof (buf), _("%a %b %d %Y"), &tmp_tm);
return buf;
}
/* Appends an exception date to the list */
static void
-append_exception (RecurrencePage *rpage, time_t t)
+append_exception (RecurrencePage *rpage, CalComponentDateTime *datetime)
{
RecurrencePagePrivate *priv;
- time_t *tt;
+ CalComponentDateTime *dt;
char *c[1];
int i;
GtkCList *clist;
+ struct icaltimetype *tt;
priv = rpage->priv;
- tt = g_new (time_t, 1);
- *tt = t;
+ dt = g_new (CalComponentDateTime, 1);
+ dt->value = g_new (struct icaltimetype, 1);
+ *dt->value = *datetime->value;
+ dt->tzid = datetime->tzid;
clist = GTK_CLIST (priv->exception_list);
gtk_signal_handler_block_by_data (GTK_OBJECT (clist), rpage);
- c[0] = get_exception_string (t);
+ c[0] = get_exception_string (dt);
i = gtk_clist_append (clist, c);
- gtk_clist_set_row_data (clist, i, tt);
+ gtk_clist_set_row_data (clist, i, dt);
gtk_clist_select_row (clist, i, 0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (clist), rpage);
- e_date_edit_set_time (E_DATE_EDIT (priv->exception_date), t);
+ tt = dt->value;
+ e_date_edit_set_date (E_DATE_EDIT (priv->exception_date),
+ tt->year, tt->month, tt->day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->exception_date),
+ tt->hour, tt->minute);
gtk_widget_set_sensitive (priv->exception_modify, TRUE);
gtk_widget_set_sensitive (priv->exception_delete, TRUE);
@@ -448,13 +469,11 @@ fill_exception_widgets (RecurrencePage *rpage, CalComponent *comp)
for (l = list; l; l = l->next) {
CalComponentDateTime *cdt;
- time_t ext;
added = TRUE;
cdt = l->data;
- ext = icaltime_as_timet (*cdt->value);
- append_exception (rpage, ext);
+ append_exception (rpage, cdt);
}
cal_component_free_exdate_list (list);
@@ -475,13 +494,10 @@ get_start_weekday_mask (CalComponent *comp)
cal_component_get_dtstart (comp, &dt);
if (dt.value) {
- time_t t;
- struct tm tm;
-
- t = icaltime_as_timet (*dt.value);
- tm = *localtime (&t);
+ short weekday;
- retval = 0x1 << tm.tm_wday;
+ weekday = icaltime_day_of_week (*dt.value);
+ retval = 0x1 << (weekday - 1);
} else
retval = 0;
@@ -575,6 +591,8 @@ simple_recur_to_comp (RecurrencePage *rpage, CalComponent *comp)
struct icalrecurrencetype r;
GSList l;
enum ending_type ending_type;
+ gboolean date_set;
+ struct icaltimetype icaltime = icaltime_null_time ();
priv = rpage->priv;
@@ -716,9 +734,21 @@ simple_recur_to_comp (RecurrencePage *rpage, CalComponent *comp)
g_assert (priv->ending_date_edit != NULL);
g_assert (E_IS_DATE_EDIT (priv->ending_date_edit));
- r.until = icaltime_from_timet (
- e_date_edit_get_time (E_DATE_EDIT (priv->ending_date_edit)),
- TRUE);
+ /* UNTIL must be in UTC, unless it is a date. So we probably
+ want to convert it to local time when showing. */
+ icaltime.is_utc = 0;
+ icaltime.is_date = 1;
+ icaltime.is_daylight = 0;
+
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->ending_date_edit),
+ &r.until.year,
+ &r.until.month,
+ &r.until.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->ending_date_edit),
+ &r.until.hour,
+ &r.until.minute);
+ g_assert (date_set);
+
break;
case ENDING_FOREVER:
@@ -744,9 +774,11 @@ static void
fill_component (RecurrencePage *rpage, CalComponent *comp)
{
RecurrencePagePrivate *priv;
+ CalComponentDateTime start_date;
enum recur_type recur_type;
GtkCList *exception_list;
GSList *list;
+ const char *tzid;
int i;
priv = rpage->priv;
@@ -776,19 +808,31 @@ fill_component (RecurrencePage *rpage, CalComponent *comp)
/* Set exceptions */
+ cal_component_get_dtstart (comp, &start_date);
+ tzid = start_date.tzid;
+ cal_component_free_datetime (&start_date);
+
list = NULL;
exception_list = GTK_CLIST (priv->exception_list);
for (i = 0; i < exception_list->rows; i++) {
- CalComponentDateTime *cdt;
- time_t *tim;
+ CalComponentDateTime *cdt, *dt;
cdt = g_new (CalComponentDateTime, 1);
cdt->value = g_new (struct icaltimetype, 1);
- cdt->tzid = NULL;
- tim = gtk_clist_get_row_data (exception_list, i);
- g_assert (tim != NULL);
- *cdt->value = icaltime_from_timet (*tim, FALSE);
+ dt = gtk_clist_get_row_data (exception_list, i);
+ g_assert (dt != NULL);
+
+ *cdt->value = *dt->value;
+
+ /* If the dummy TZID was used, we use the TZID from the
+ start date. We do this because we don't allow editing
+ of timezones for RDATEs, so we try to use the same timezone
+ as the DTSTART for all new exceptions added. */
+ if (dt->tzid == DUMMY_TZID)
+ cdt->tzid = tzid;
+ else
+ cdt->tzid = dt->tzid;
list = g_slist_prepend (list, cdt);
}
@@ -849,7 +893,8 @@ preview_recur (RecurrencePage *rpage)
fill_component (rpage, comp);
- tag_calendar_by_comp (E_CALENDAR (priv->preview_calendar), comp);
+ tag_calendar_by_comp (E_CALENDAR (priv->preview_calendar), comp,
+ COMP_EDITOR_PAGE (rpage)->client);
gtk_object_unref (GTK_OBJECT (comp));
}
@@ -1294,6 +1339,7 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r)
} else {
/* Ending date */
+ /* FIXME: UNTIL needs to be checked. */
priv->ending_date = icaltime_as_timet (r->until);
e_dialog_option_menu_set (priv->ending_menu,
ENDING_UNTIL,
@@ -1693,7 +1739,7 @@ recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates)
{
RecurrencePage *rpage;
RecurrencePagePrivate *priv;
- CalComponentDateTime dt;
+ CalComponentDateTime dt, old_dt;
struct icaltimetype icaltime;
guint8 mask;
@@ -1708,13 +1754,32 @@ recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates)
return;
dt.value = &icaltime;
- dt.tzid = NULL;
- *dt.value = icaltime_from_timet (dates->start, FALSE);
- cal_component_set_dtstart (priv->comp, &dt);
+ if (dates->start) {
+ icaltime = *dates->start;
+
+ /* Copy the TZID from the old property.
+ FIXME: Should get notified when the TZID changes.*/
+ cal_component_get_dtstart (priv->comp, &old_dt);
+ dt.tzid = NULL;
+ if (old_dt.tzid)
+ dt.tzid = old_dt.tzid;
+ cal_component_free_datetime (&old_dt);
+
+ cal_component_set_dtstart (priv->comp, &dt);
+ }
+
+ if (dates->end) {
+ icaltime = *dates->end;
+
+ /* Copy the TZID from the old property.
+ FIXME: Should get notified when the TZID changes.*/
+ cal_component_get_dtend (priv->comp, &old_dt);
+ dt.tzid = NULL;
+ if (old_dt.tzid)
+ dt.tzid = old_dt.tzid;
+ cal_component_free_datetime (&old_dt);
- if (dates->end != 0) {
- *dt.value = icaltime_from_timet (dates->end, FALSE);
cal_component_set_dtend (priv->comp, &dt);
}
@@ -1876,15 +1941,32 @@ exception_add_cb (GtkWidget *widget, gpointer data)
{
RecurrencePage *rpage;
RecurrencePagePrivate *priv;
- time_t t;
+ CalComponentDateTime dt;
+ struct icaltimetype icaltime = icaltime_null_time ();
+ gboolean date_set;
rpage = RECURRENCE_PAGE (data);
priv = rpage->priv;
field_changed (rpage);
- t = e_date_edit_get_time (E_DATE_EDIT (priv->exception_date));
- append_exception (rpage, t);
+ dt.value = &icaltime;
+ /* We set this to the dummy TZID for now. When we fill the component
+ we will replace it with the TZID from DTSTART. */
+ dt.tzid = DUMMY_TZID;
+
+ icaltime.is_date = 1;
+
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->exception_date),
+ &icaltime.year,
+ &icaltime.month,
+ &icaltime.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->exception_date),
+ &icaltime.hour,
+ &icaltime.minute);
+ g_assert (date_set);
+
+ append_exception (rpage, &dt);
preview_recur (rpage);
}
@@ -1895,7 +1977,8 @@ exception_modify_cb (GtkWidget *widget, gpointer data)
RecurrencePage *rpage;
RecurrencePagePrivate *priv;
GtkCList *clist;
- time_t *t;
+ CalComponentDateTime *dt;
+ struct icaltimetype *tt;
int sel;
rpage = RECURRENCE_PAGE (data);
@@ -1909,10 +1992,15 @@ exception_modify_cb (GtkWidget *widget, gpointer data)
sel = GPOINTER_TO_INT (clist->selection->data);
- t = gtk_clist_get_row_data (clist, sel);
- *t = e_date_edit_get_time (E_DATE_EDIT (priv->exception_date));
+ dt = gtk_clist_get_row_data (clist, sel);
+ tt = dt->value;
+ e_date_edit_get_date (E_DATE_EDIT (priv->exception_date),
+ &tt->year, &tt->month, &tt->day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->exception_date),
+ &tt->hour, &tt->minute);
+ tt->second = 0;
- gtk_clist_set_text (clist, sel, 0, get_exception_string (*t));
+ gtk_clist_set_text (clist, sel, 0, get_exception_string (dt));
preview_recur (rpage);
}
@@ -1925,7 +2013,7 @@ exception_delete_cb (GtkWidget *widget, gpointer data)
RecurrencePagePrivate *priv;
GtkCList *clist;
int sel;
- time_t *t;
+ CalComponentDateTime *dt;
rpage = RECURRENCE_PAGE (data);
priv = rpage->priv;
@@ -1938,9 +2026,10 @@ exception_delete_cb (GtkWidget *widget, gpointer data)
sel = GPOINTER_TO_INT (clist->selection->data);
- t = gtk_clist_get_row_data (clist, sel);
- g_assert (t != NULL);
- g_free (t);
+ dt = gtk_clist_get_row_data (clist, sel);
+ g_assert (dt != NULL);
+ g_free (dt->value);
+ g_free (dt);
gtk_clist_remove (clist, sel);
if (sel >= clist->rows)
@@ -1966,15 +2055,21 @@ exception_select_row_cb (GtkCList *clist, gint row, gint col,
{
RecurrencePage *rpage;
RecurrencePagePrivate *priv;
- time_t *t;
+ CalComponentDateTime *dt;
+ struct icaltimetype *t;
rpage = RECURRENCE_PAGE (data);
priv = rpage->priv;
- t = gtk_clist_get_row_data (clist, row);
- g_assert (t != NULL);
+ dt = gtk_clist_get_row_data (clist, row);
+ g_assert (dt != NULL);
- e_date_edit_set_time (E_DATE_EDIT (priv->exception_date), *t);
+ t = dt->value;
+
+ e_date_edit_set_date (E_DATE_EDIT (priv->exception_date),
+ t->year, t->month, t->day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->exception_date),
+ t->hour, t->minute);
}
/* This is called when any field is changed; it notifies upstream. */
@@ -2013,6 +2108,18 @@ init_widgets (RecurrencePage *rpage)
priv->preview_calendar);
gtk_widget_show (priv->preview_calendar);
+ /* Make sure the EDateEdit widgets and ECalendarItem use our timezones
+ to get the current time. */
+ e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->exception_date),
+ (EDateEditGetTimeCallback) comp_editor_get_current_time,
+ rpage, NULL);
+ e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->ending_date_edit),
+ (EDateEditGetTimeCallback) comp_editor_get_current_time,
+ rpage, NULL);
+ e_calendar_item_set_get_time_callback (ecal->calitem,
+ (ECalendarItemGetTimeCallback) comp_editor_get_current_time,
+ rpage, NULL);
+
/* Recurrence types */
gtk_signal_connect (GTK_OBJECT (priv->none), "toggled",
diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c
index 9a1a4b46c6..82d3e14b62 100644
--- a/calendar/gui/dialogs/task-details-page.c
+++ b/calendar/gui/dialogs/task-details-page.c
@@ -32,6 +32,7 @@
#include <gal/widgets/e-unicode.h>
#include <widgets/misc/e-dateedit.h>
#include "e-util/e-dialog-widgets.h"
+#include "../calendar-config.h"
#include "../e-timezone-entry.h"
#include "comp-editor-util.h"
#include "task-details-page.h"
@@ -50,7 +51,6 @@ struct _TaskDetailsPagePrivate {
GtkWidget *date_time;
GtkWidget *completed_date;
- GtkWidget *completed_timezone;
GtkWidget *url;
@@ -149,7 +149,6 @@ task_details_page_init (TaskDetailsPage *tdpage)
priv->summary = NULL;
priv->date_time = NULL;
priv->completed_date = NULL;
- priv->completed_timezone = NULL;
priv->url = NULL;
priv->updating = FALSE;
@@ -277,30 +276,46 @@ task_details_page_fill_component (CompEditorPage *page, CalComponent *comp)
{
TaskDetailsPage *tdpage;
TaskDetailsPagePrivate *priv;
+ struct icaltimetype icaltime;
GSList list;
CalComponentDateTime date;
CalComponentOrganizer organizer;
CalComponentAttendee attendee;
- time_t t;
char *url;
+ gboolean date_set;
tdpage = TASK_DETAILS_PAGE (page);
priv = tdpage->priv;
- /* Completed Date. */
- date.value = g_new (struct icaltimetype, 1);
- date.tzid = NULL;
+ /* COMPLETED must be in UTC. */
+ icaltime.is_utc = 1;
+ icaltime.is_date = 0;
+ icaltime.is_daylight = 0;
- t = e_date_edit_get_time (E_DATE_EDIT (priv->completed_date));
- if (t != -1) {
- *date.value = icaltime_from_timet (t, FALSE);
- cal_component_set_completed (comp, date.value);
+ /* Completed Date. */
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->completed_date),
+ &icaltime.year,
+ &icaltime.month,
+ &icaltime.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->completed_date),
+ &icaltime.hour,
+ &icaltime.minute);
+ if (date_set) {
+ /* COMPLETED must be in UTC, so we assume that the date in the
+ dialog is in the current timezone, and we now convert it
+ to UTC. FIXME: We should really use one timezone for the
+ entire time the dialog is shown. Otherwise if the user
+ changes the timezone, the COMPLETED date may get changed
+ as well. */
+ char *location = calendar_config_get_timezone ();
+ icaltimezone *zone = icaltimezone_get_builtin_timezone (location);
+ icaltimezone_convert_time (&icaltime, zone,
+ icaltimezone_get_utc_timezone ());
+ cal_component_set_completed (comp, &icaltime);
} else {
cal_component_set_completed (comp, NULL);
}
- g_free (date.value);
-
/* URL. */
url = e_dialog_editable_get (priv->url);
cal_component_set_url (comp, url);
@@ -359,9 +374,30 @@ task_details_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates)
priv = tdpage->priv;
comp_editor_date_label (dates, priv->date_time);
- if (dates->complete != 0)
- e_date_edit_set_time (E_DATE_EDIT (priv->completed_date),
- dates->complete);
+
+ if (dates->complete) {
+ if (icaltime_is_null_time (*dates->complete)) {
+ e_date_edit_set_time (E_DATE_EDIT (priv->completed_date), -1);
+ } else {
+ struct icaltimetype *tt = dates->complete;
+
+ /* Convert it from UTC to local time to display.
+ FIXME: We should really use one timezone for the
+ entire time the dialog is shown. Otherwise if the
+ user changes the timezone, the COMPLETED date may
+ get changed as well. */
+ char *location = calendar_config_get_timezone ();
+ icaltimezone *zone = icaltimezone_get_builtin_timezone (location);
+ icaltimezone_convert_time (tt,
+ icaltimezone_get_utc_timezone (),
+ zone);
+
+ e_date_edit_set_date (E_DATE_EDIT (priv->completed_date),
+ tt->year, tt->month, tt->day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->completed_date),
+ tt->hour, tt->minute);
+ }
+ }
}
@@ -387,7 +423,6 @@ get_widgets (TaskDetailsPage *tdpage)
priv->date_time = GW ("date-time");
priv->completed_date = GW ("completed-date");
- priv->completed_timezone = GW ("completed-timezone");
priv->url = GW ("url");
@@ -403,7 +438,6 @@ get_widgets (TaskDetailsPage *tdpage)
return (priv->summary
&& priv->date_time
&& priv->completed_date
- && priv->completed_timezone
&& priv->url
&& priv->organizer
&& priv->organizer_lbl
@@ -422,6 +456,8 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
TaskDetailsPage *tdpage;
TaskDetailsPagePrivate *priv;
CompEditorPageDates dates;
+ struct icaltimetype completed_tt = icaltime_null_time();
+ gboolean date_set;
tdpage = TASK_DETAILS_PAGE (data);
priv = tdpage->priv;
@@ -429,10 +465,20 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
if (priv->updating)
return;
- dates.start = 0;
- dates.end = 0;
- dates.due = 0;
- dates.complete = e_date_edit_get_time (E_DATE_EDIT (priv->completed_date));
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->completed_date),
+ &completed_tt.year,
+ &completed_tt.month,
+ &completed_tt.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->completed_date),
+ &completed_tt.hour,
+ &completed_tt.minute);
+ if (!date_set)
+ completed_tt = icaltime_null_time ();
+
+ dates.start = NULL;
+ dates.end = NULL;
+ dates.due = NULL;
+ dates.complete = &completed_tt;
/* Notify upstream */
comp_editor_page_notify_dates_changed (COMP_EDITOR_PAGE (tdpage), &dates);
@@ -460,13 +506,16 @@ init_widgets (TaskDetailsPage *tdpage)
priv = tdpage->priv;
+ /* Make sure the EDateEdit widgets use our timezones to get the
+ current time. */
+ e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->completed_date),
+ (EDateEditGetTimeCallback) comp_editor_get_current_time,
+ tdpage, NULL);
+
/* Completed Date */
gtk_signal_connect (GTK_OBJECT (priv->completed_date), "changed",
GTK_SIGNAL_FUNC (date_changed_cb), tdpage);
- gtk_signal_connect (GTK_OBJECT (priv->completed_timezone), "changed",
- GTK_SIGNAL_FUNC (field_changed_cb), tdpage);
-
/* URL */
gtk_signal_connect (GTK_OBJECT (priv->url), "changed",
GTK_SIGNAL_FUNC (field_changed_cb), tdpage);
diff --git a/calendar/gui/dialogs/task-details-page.glade b/calendar/gui/dialogs/task-details-page.glade
index 962906ebb4..c92bd52b8f 100644
--- a/calendar/gui/dialogs/task-details-page.glade
+++ b/calendar/gui/dialogs/task-details-page.glade
@@ -403,10 +403,12 @@
</widget>
<widget>
- <class>GtkHBox</class>
- <name>hbox1</name>
- <homogeneous>False</homogeneous>
- <spacing>0</spacing>
+ <class>Custom</class>
+ <name>completed-date</name>
+ <creation_function>task_details_page_create_date_edit</creation_function>
+ <int1>0</int1>
+ <int2>0</int2>
+ <last_modification_time>Fri, 01 Jun 2001 18:58:51 GMT</last_modification_time>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
@@ -421,34 +423,6 @@
<xfill>True</xfill>
<yfill>True</yfill>
</child>
-
- <widget>
- <class>Custom</class>
- <name>completed-date</name>
- <creation_function>task_details_page_create_date_edit</creation_function>
- <int1>0</int1>
- <int2>0</int2>
- <last_modification_time>Fri, 01 Jun 2001 18:58:51 GMT</last_modification_time>
- <child>
- <padding>0</padding>
- <expand>True</expand>
- <fill>True</fill>
- </child>
- </widget>
-
- <widget>
- <class>Custom</class>
- <name>completed-timezone</name>
- <creation_function>make_timezone_entry</creation_function>
- <int1>0</int1>
- <int2>0</int2>
- <last_modification_time>Tue, 19 Jun 2001 04:32:42 GMT</last_modification_time>
- <child>
- <padding>0</padding>
- <expand>True</expand>
- <fill>True</fill>
- </child>
- </widget>
</widget>
</widget>
</widget>
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index 705477f794..2fc7bbf23e 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -254,19 +254,16 @@ static void
clear_widgets (TaskPage *tpage)
{
TaskPagePrivate *priv;
- time_t now;
priv = tpage->priv;
- now = time (NULL);
-
/* Summary, description */
e_dialog_editable_set (priv->summary, NULL);
e_dialog_editable_set (priv->description, NULL);
/* Start, due times */
- e_date_edit_set_time (E_DATE_EDIT (priv->start_date), now);
- e_date_edit_set_time (E_DATE_EDIT (priv->due_date), now);
+ e_date_edit_set_time (E_DATE_EDIT (priv->start_date), 0);
+ e_date_edit_set_time (E_DATE_EDIT (priv->due_date), 0);
/* Classification */
e_dialog_radio_set (priv->classification_public,
@@ -341,12 +338,13 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
CalComponentText text;
CalComponentDateTime d;
CalComponentClassification cl;
+ CalClientGetStatus get_tz_status;
GSList *l;
- time_t t;
int *priority_value, *percent;
icalproperty_status status;
TaskEditorPriority priority;
const char *categories;
+ icaltimezone *zone;
tpage = TASK_PAGE (page);
priv = tpage->priv;
@@ -372,20 +370,50 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
/* Due Date. */
cal_component_get_due (comp, &d);
if (d.value) {
- t = icaltime_as_timet (*d.value);
+ struct icaltimetype *due_tt = d.value;
+ e_date_edit_set_date (E_DATE_EDIT (priv->due_date),
+ due_tt->year, due_tt->month,
+ due_tt->day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->due_date),
+ due_tt->hour, due_tt->minute);
} else {
- t = -1;
+ e_date_edit_set_time (E_DATE_EDIT (priv->due_date), -1);
}
- e_date_edit_set_time (E_DATE_EDIT (priv->due_date), t);
+
+ get_tz_status = cal_client_get_timezone (page->client, d.tzid, &zone);
+ /* FIXME: Handle error better. */
+ if (get_tz_status != CAL_CLIENT_GET_SUCCESS)
+ g_warning ("Couldn't get timezone from server: %s",
+ d.tzid ? d.tzid : "");
+ e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->due_timezone),
+ zone);
+
+ cal_component_free_datetime (&d);
+
/* Start Date. */
cal_component_get_dtstart (comp, &d);
if (d.value) {
- t = icaltime_as_timet (*d.value);
+ struct icaltimetype *start_tt = d.value;
+ e_date_edit_set_date (E_DATE_EDIT (priv->start_date),
+ start_tt->year, start_tt->month,
+ start_tt->day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->start_date),
+ start_tt->hour, start_tt->minute);
} else {
- t = -1;
+ e_date_edit_set_time (E_DATE_EDIT (priv->start_date), -1);
}
- e_date_edit_set_time (E_DATE_EDIT (priv->start_date), t);
+
+ get_tz_status = cal_client_get_timezone (page->client, d.tzid, &zone);
+ /* FIXME: Handle error better. */
+ if (get_tz_status != CAL_CLIENT_GET_SUCCESS)
+ g_warning ("Couldn't get timezone from server: %s",
+ d.tzid ? d.tzid : "");
+ e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->start_timezone),
+ zone);
+
+ cal_component_free_datetime (&d);
+
/* Percent Complete. */
cal_component_get_percent (comp, &percent);
@@ -460,12 +488,14 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp)
TaskPage *tpage;
TaskPagePrivate *priv;
CalComponentDateTime date;
- time_t t;
+ struct icaltimetype icaltime;
icalproperty_status status;
TaskEditorPriority priority;
int priority_value, percent;
char *cat;
char *str;
+ gboolean date_set;
+ icaltimezone *zone;
tpage = TASK_PAGE (page);
priv = tpage->priv;
@@ -509,22 +539,44 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp)
/* Dates */
- date.value = g_new (struct icaltimetype, 1);
+ date.value = &icaltime;
date.tzid = NULL;
+ icaltime.is_utc = 0;
+ /* FIXME: We should use is_date at some point. */
+ icaltime.is_date = 0;
+ icaltime.is_daylight = 0;
+ icaltime.second = 0;
+
/* Due Date. */
- t = e_date_edit_get_time (E_DATE_EDIT (priv->due_date));
- if (t != -1) {
- *date.value = icaltime_from_timet (t, FALSE);
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->due_date),
+ &icaltime.year,
+ &icaltime.month,
+ &icaltime.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->due_date),
+ &icaltime.hour,
+ &icaltime.minute);
+ if (date_set) {
+ zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->due_timezone));
+ if (zone)
+ date.tzid = icaltimezone_get_tzid (zone);
cal_component_set_due (comp, &date);
} else {
cal_component_set_due (comp, NULL);
}
/* Start Date. */
- t = e_date_edit_get_time (E_DATE_EDIT (priv->start_date));
- if (t != -1) {
- *date.value = icaltime_from_timet (t, FALSE);
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->start_date),
+ &icaltime.year,
+ &icaltime.month,
+ &icaltime.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_date),
+ &icaltime.hour,
+ &icaltime.minute);
+ if (date_set) {
+ zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->start_timezone));
+ if (zone)
+ date.tzid = icaltimezone_get_tzid (zone);
cal_component_set_dtstart (comp, &date);
} else {
cal_component_set_dtstart (comp, NULL);
@@ -583,8 +635,8 @@ task_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates)
priv->updating = TRUE;
- if (dates->complete != 0) {
- if (dates->complete == -1) {
+ if (dates->complete) {
+ if (icaltime_is_null_time (*dates->complete)) {
/* If the 'Completed Date' is set to 'None',
we set the status to 'Not Started' and the
percent-complete to 0. The task may
@@ -698,6 +750,9 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
TaskPage *tpage;
TaskPagePrivate *priv;
CompEditorPageDates dates;
+ gboolean date_set;
+ struct icaltimetype start_tt = icaltime_null_time();
+ struct icaltimetype due_tt = icaltime_null_time();
tpage = TASK_PAGE (data);
priv = tpage->priv;
@@ -705,10 +760,30 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
if (priv->updating)
return;
- dates.start = e_date_edit_get_time (E_DATE_EDIT (priv->start_date));
- dates.end = 0;
- dates.due = e_date_edit_get_time (E_DATE_EDIT (priv->due_date));
- dates.complete = 0;
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->start_date),
+ &start_tt.year,
+ &start_tt.month,
+ &start_tt.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_date),
+ &start_tt.hour,
+ &start_tt.minute);
+ if (!date_set)
+ start_tt = icaltime_null_time ();
+
+ date_set = e_date_edit_get_date (E_DATE_EDIT (priv->due_date),
+ &due_tt.year,
+ &due_tt.month,
+ &due_tt.day);
+ e_date_edit_get_time_of_day (E_DATE_EDIT (priv->due_date),
+ &due_tt.hour,
+ &due_tt.minute);
+ if (!date_set)
+ due_tt = icaltime_null_time ();
+
+ dates.start = &start_tt;
+ dates.end = NULL;
+ dates.due = &due_tt;
+ dates.complete = NULL;
/* Notify upstream */
comp_editor_page_notify_dates_changed (COMP_EDITOR_PAGE (tpage),
@@ -747,17 +822,24 @@ field_changed_cb (GtkWidget *widget, gpointer data)
}
static void
-complete_date_changed (TaskPage *tpage, time_t complete)
+complete_date_changed (TaskPage *tpage, gboolean complete)
{
TaskPagePrivate *priv;
CompEditorPageDates dates;
+ icaltimezone *zone;
+ struct icaltimetype completed_tt = icaltime_null_time();
priv = tpage->priv;
- dates.start = 0;
- dates.end = 0;
- dates.due = 0;
- dates.complete = complete;
+ /* Get the current time in UTC. */
+ zone = icaltimezone_get_utc_timezone ();
+ completed_tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone);
+ completed_tt.is_utc = TRUE;
+
+ dates.start = NULL;
+ dates.end = NULL;
+ dates.due = NULL;
+ dates.complete = &completed_tt;
/* Notify upstream */
comp_editor_page_notify_dates_changed (COMP_EDITOR_PAGE (tpage),
@@ -780,13 +862,13 @@ status_changed (GtkMenu *menu, TaskPage *tpage)
status = e_dialog_option_menu_get (priv->status, status_map);
if (status == ICAL_STATUS_NEEDSACTION) {
e_dialog_spin_set (priv->percent_complete, 0);
- complete_date_changed (tpage, -1);
+ complete_date_changed (tpage, FALSE);
} else if (status == ICAL_STATUS_INPROCESS) {
e_dialog_spin_set (priv->percent_complete, 50);
- complete_date_changed (tpage, -1);
+ complete_date_changed (tpage, FALSE);
} else if (status == ICAL_STATUS_COMPLETED) {
e_dialog_spin_set (priv->percent_complete, 100);
- complete_date_changed (tpage, time (NULL) - (time (NULL) % 60));
+ complete_date_changed (tpage, TRUE);
}
priv->updating = FALSE;
@@ -800,7 +882,7 @@ percent_complete_changed (GtkAdjustment *adj, TaskPage *tpage)
TaskPagePrivate *priv;
gint percent;
icalproperty_status status;
- time_t date_completed;
+ gboolean complete;
priv = tpage->priv;
@@ -811,10 +893,10 @@ percent_complete_changed (GtkAdjustment *adj, TaskPage *tpage)
percent = e_dialog_spin_get_int (priv->percent_complete);
if (percent == 100) {
- date_completed = time (NULL);
+ complete = TRUE;
status = ICAL_STATUS_COMPLETED;
} else {
- date_completed = -1;
+ complete = FALSE;
if (percent == 0)
status = ICAL_STATUS_NEEDSACTION;
@@ -823,7 +905,7 @@ percent_complete_changed (GtkAdjustment *adj, TaskPage *tpage)
}
e_dialog_option_menu_set (priv->status, status, status_map);
- complete_date_changed (tpage, date_completed);
+ complete_date_changed (tpage, complete);
priv->updating = FALSE;
@@ -839,6 +921,14 @@ init_widgets (TaskPage *tpage)
priv = tpage->priv;
+ /* Make sure the EDateEdit widgets use our timezones to get the
+ current time. */
+ e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->start_date),
+ (EDateEditGetTimeCallback) comp_editor_get_current_time,
+ tpage, NULL);
+ e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->due_date),
+ (EDateEditGetTimeCallback) comp_editor_get_current_time,
+ tpage, NULL);
/* Summary */
gtk_signal_connect (GTK_OBJECT (priv->summary), "changed",