aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog33
-rw-r--r--calendar/cal-util/timeutil.c2
-rw-r--r--calendar/gui/calendar-model.c3
-rw-r--r--calendar/gui/dialogs/comp-editor.c25
-rw-r--r--calendar/gui/e-itip-control.c111
-rw-r--r--calendar/gui/e-timezone-entry.c10
-rw-r--r--calendar/gui/print.c27
7 files changed, 160 insertions, 51 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index ee314f4445..68ae2e00a1 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,36 @@
+2001-10-27 Damon Chaplin <damon@ximian.com>
+
+ * gui/print.c (print_week_view):
+ (range_selector_new): when the week start day is set to Sunday, we
+ have to be careful to make sure we print the correct week, since
+ the previous Saturday is actually printed first. Fixes bug #13687.
+ (print_week_summary): always set compress_weekend to true if
+ multi_week_view is FALSE (i.e. we are printing the week view).
+ Fixes bug #13688.
+
+ * gui/e-itip-control.c (send_freebusy): use the timezones from the
+ DTSTART and DTEND.
+ (write_label_piece): output the date-time and the timezone after it.
+ Note that we may want to convert it to the current timezone and display
+ that as well. Also converted COMPLETED to the current timezone.
+ And fixed all uses of old timezone functions.
+
+ * gui/dialogs/comp-editor.c (commit_all_fields): added function to
+ set the focus in the window to NULL, so all fields lose their focus,
+ so they emit "changed" signals and update their values if needed.
+ We call this when most menu commands are used, e.g. 'Save and Close',
+ 'Print' etc. Fixes bug #11434. In future we should also check fields
+ are valid and show dialogs if they are not.
+
+ * gui/calendar-model.c (get_completed): use the completed value
+ properly. Fixes bug #13694.
+
+ * cal-util/timeutil.c (icaltimetype_to_tm_with_zone): don't check
+ from_zone and to_zone != NULL. A NULL zone is valid, it is for
+ floating times.
+
+2001-10-27 Federico Mena Quintero <federico@ximian.com>
+
2001-10-27 Federico Mena Quintero <federico@ximian.com>
* gui/e-day-view.c (e_day_view_on_text_item_event): Cancel editing
diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c
index c6f6e33bcf..3dcf8dc384 100644
--- a/calendar/cal-util/timeutil.c
+++ b/calendar/cal-util/timeutil.c
@@ -566,8 +566,6 @@ icaltimetype_to_tm_with_zone (struct icaltimetype *itt,
tm.tm_isdst = -1;
g_return_val_if_fail (itt != NULL, tm);
- g_return_val_if_fail (from_zone != NULL, tm);
- g_return_val_if_fail (to_zone != NULL, tm);
itt_copy = *itt;
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index 284940f525..7e8cc5665b 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -432,7 +432,6 @@ get_completed (CalendarModel *model,
int row)
{
CalendarModelPrivate *priv;
- CalComponentDateTime dt;
CalendarModelObjectData *object_data;
struct icaltimetype *completed;
@@ -446,7 +445,7 @@ get_completed (CalendarModel *model,
if (completed) {
object_data->completed = g_new (ECellDateEditValue, 1);
- object_data->completed->tt = *dt.value;
+ object_data->completed->tt = *completed;
object_data->completed->zone = icaltimezone_get_utc_timezone ();
cal_component_free_icaltimetype (completed);
} else {
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index dc7d01cbde..4f83b02dc4 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -1008,12 +1008,27 @@ comp_editor_focus (CompEditor *editor)
raise_and_focus (priv->window);
}
+/* This sets the focus to the toplevel, so any field being edited is committed.
+ FIXME: In future we may also want to check some of the fields are valid,
+ e.g. the EDateEdit fields. */
+static void
+commit_all_fields (CompEditor *editor)
+{
+ CompEditorPrivate *priv;
+
+ priv = editor->priv;
+
+ gtk_window_set_focus (GTK_WINDOW (priv->window), NULL);
+}
+
/* Menu Commands */
static void
save_cmd (GtkWidget *widget, gpointer data)
{
CompEditor *editor = COMP_EDITOR (data);
+ commit_all_fields (editor);
+
save_comp_with_send (editor);
}
@@ -1022,6 +1037,8 @@ save_close_cmd (GtkWidget *widget, gpointer data)
{
CompEditor *editor = COMP_EDITOR (data);
+ commit_all_fields (editor);
+
if (save_comp_with_send (editor))
close_dialog (editor);
}
@@ -1091,6 +1108,8 @@ save_as_cmd (GtkWidget *widget, gpointer data)
priv = editor->priv;
+ commit_all_fields (editor);
+
fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save As...")));
path = g_strdup_printf ("%s/", g_get_home_dir ());
gtk_file_selection_set_filename (fs, path);
@@ -1131,6 +1150,8 @@ print_cmd (GtkWidget *widget, gpointer data)
CompEditor *editor = COMP_EDITOR (data);
CalComponent *comp;
+ commit_all_fields (editor);
+
comp = comp_editor_get_current_comp (editor);
print_comp (comp, editor->priv->client, FALSE);
gtk_object_unref (GTK_OBJECT (comp));
@@ -1142,6 +1163,8 @@ print_preview_cmd (GtkWidget *widget, gpointer data)
CompEditor *editor = COMP_EDITOR (data);
CalComponent *comp;
+ commit_all_fields (editor);
+
comp = comp_editor_get_current_comp (editor);
print_comp (comp, editor->priv->client, TRUE);
gtk_object_unref (GTK_OBJECT (comp));
@@ -1163,6 +1186,8 @@ close_cmd (GtkWidget *widget, gpointer data)
{
CompEditor *editor = COMP_EDITOR (data);
+ commit_all_fields (editor);
+
if (prompt_to_save_changes (editor, TRUE))
close_dialog (editor);
}
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index 1b1ab423ba..3eac9366ab 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -36,10 +36,12 @@
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-dialog-util.h>
+#include <gal/widgets/e-unicode.h>
#include <gtkhtml/gtkhtml.h>
#include <gtkhtml/gtkhtml-stream.h>
#include <ical.h>
#include <cal-util/cal-component.h>
+#include <cal-util/timeutil.h>
#include <cal-client/cal-client.h>
#include <e-util/e-time-utils.h>
#include <e-util/e-dialog-widgets.h>
@@ -433,18 +435,32 @@ set_button_status (EItipControl *itip)
}
static void
-write_label_piece (time_t t, char *buffer, int size, const char *stext, const char *etext)
+write_label_piece (EItipControl *itip, CalComponentDateTime *dt,
+ char *buffer, int size,
+ const char *stext, const char *etext, gboolean is_utc)
{
- struct tm *tmp_tm;
- int len;
+ EItipControlPrivate *priv;
+ struct tm tmp_tm;
char time_buf[64], *time_utf8;
+ icaltimezone *zone = NULL;
+ char *display_name;
+
+ priv = itip->priv;
+
+ /* If we have been passed a UTC value, i.e. for the COMPLETED property,
+ we convert it to the current timezone to display. */
+ if (is_utc) {
+ char *location = calendar_config_get_timezone ();
+ zone = icaltimezone_get_builtin_timezone (location);
+ icaltimezone_convert_time (dt->value, icaltimezone_get_utc_timezone (), zone);
+ }
+
+ tmp_tm = icaltimetype_to_tm (dt->value);
- /* FIXME: Convert to an appropriate timezone. */
- tmp_tm = localtime (&t);
if (stext != NULL)
strcat (buffer, stext);
- e_time_format_date_and_time (tmp_tm,
+ e_time_format_date_and_time (&tmp_tm,
calendar_config_get_24_hour_format (),
FALSE, FALSE,
time_buf, sizeof (time_buf));
@@ -453,44 +469,59 @@ write_label_piece (time_t t, char *buffer, int size, const char *stext, const ch
strcat (buffer, time_utf8);
g_free (time_utf8);
+ if (!is_utc && dt->tzid) {
+ zone = icalcomponent_get_timezone (priv->top_level, dt->tzid);
+ }
+
+ /* Output timezone after time, e.g. " America/New_York". */
+ if (zone) {
+ display_name = icaltimezone_get_display_name (zone);
+ /* These are ASCII strings, so should be OK as UTF-8.*/
+ if (display_name) {
+ strcat (buffer, " ");
+ strcat (buffer, display_name);
+ }
+ }
+
if (etext != NULL)
strcat (buffer, etext);
}
static void
-set_date_label (GtkHTML *html, GtkHTMLStream *html_stream, CalComponent *comp)
+set_date_label (EItipControl *itip, GtkHTML *html, GtkHTMLStream *html_stream,
+ CalComponent *comp)
{
+ EItipControlPrivate *priv;
CalComponentDateTime datetime;
- time_t start = 0, end = 0, complete = 0, due = 0;
static char buffer[1024];
- gboolean wrote = FALSE;
+ gboolean wrote = FALSE, task_completed = FALSE;
CalComponentVType type;
+ priv = itip->priv;
+
type = cal_component_get_vtype (comp);
- /* FIXME: timezones. */
buffer[0] = '\0';
cal_component_get_dtstart (comp, &datetime);
if (datetime.value) {
- start = icaltime_as_timet (*datetime.value);
switch (type) {
case CAL_COMPONENT_EVENT:
- write_label_piece (start, buffer, 1024,
+ write_label_piece (itip, &datetime, buffer, 1024,
U_("Meeting begins: <b>"),
- "</b><br>");
+ "</b><br>", FALSE);
break;
case CAL_COMPONENT_TODO:
- write_label_piece (start, buffer, 1024,
+ write_label_piece (itip, &datetime, buffer, 1024,
U_("Task begins: <b>"),
- "</b><br>");
+ "</b><br>", FALSE);
break;
case CAL_COMPONENT_FREEBUSY:
- write_label_piece (start, buffer, 1024,
+ write_label_piece (itip, &datetime, buffer, 1024,
U_("Free/Busy info begins: <b>"),
- "</b><br>");
+ "</b><br>", FALSE);
break;
default:
- write_label_piece (start, buffer, 1024, U_("Begins: <b>"), "</b><br>");
+ write_label_piece (itip, &datetime, buffer, 1024, U_("Begins: <b>"), "</b><br>", FALSE);
}
gtk_html_write (html, html_stream, buffer, strlen(buffer));
wrote = TRUE;
@@ -500,17 +531,16 @@ set_date_label (GtkHTML *html, GtkHTMLStream *html_stream, CalComponent *comp)
buffer[0] = '\0';
cal_component_get_dtend (comp, &datetime);
if (datetime.value){
- end = icaltime_as_timet (*datetime.value);
switch (type) {
case CAL_COMPONENT_EVENT:
- write_label_piece (end, buffer, 1024, U_("Meeting ends: <b>"), "</b><br>");
+ write_label_piece (itip, &datetime, buffer, 1024, U_("Meeting ends: <b>"), "</b><br>", FALSE);
break;
case CAL_COMPONENT_FREEBUSY:
- write_label_piece (end, buffer, 1024, U_("Free/Busy info ends: <b>"),
- "</b><br>");
+ write_label_piece (itip, &datetime, buffer, 1024, U_("Free/Busy info ends: <b>"),
+ "</b><br>", FALSE);
break;
default:
- write_label_piece (end, buffer, 1024, U_("Ends: <b>"), "</b><br>");
+ write_label_piece (itip, &datetime, buffer, 1024, U_("Ends: <b>"), "</b><br>", FALSE);
}
gtk_html_write (html, html_stream, buffer, strlen (buffer));
wrote = TRUE;
@@ -521,18 +551,19 @@ set_date_label (GtkHTML *html, GtkHTMLStream *html_stream, CalComponent *comp)
datetime.tzid = NULL;
cal_component_get_completed (comp, &datetime.value);
if (type == CAL_COMPONENT_TODO && datetime.value) {
- complete = icaltime_as_timet (*datetime.value);
- write_label_piece (complete, buffer, 1024, U_("Task Completed: <b>"), "</b><br>");
+ /* Pass TRUE as is_utc, so it gets converted to the current
+ timezone. */
+ write_label_piece (itip, &datetime, buffer, 1024, U_("Task Completed: <b>"), "</b><br>", TRUE);
gtk_html_write (html, html_stream, buffer, strlen (buffer));
wrote = TRUE;
+ task_completed = TRUE;
}
cal_component_free_datetime (&datetime);
buffer[0] = '\0';
cal_component_get_due (comp, &datetime);
- if (type == CAL_COMPONENT_TODO && complete == 0 && datetime.value) {
- due = icaltime_as_timet (*datetime.value);
- write_label_piece (due, buffer, 1024, U_("Task Due: <b>"), "</b><br>");
+ if (type == CAL_COMPONENT_TODO && !task_completed && datetime.value) {
+ write_label_piece (itip, &datetime, buffer, 1024, U_("Task Due: <b>"), "</b><br>", FALSE);
gtk_html_write (html, html_stream, buffer, strlen (buffer));
wrote = TRUE;
}
@@ -683,7 +714,7 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title,
set_message (GTK_HTML (priv->html), html_stream, itip_title, FALSE);
/* Date information */
- set_date_label (GTK_HTML (priv->html), html_stream, priv->comp);
+ set_date_label (itip, GTK_HTML (priv->html), html_stream, priv->comp);
/* Summary */
cal_component_get_summary (priv->comp, &text);
@@ -1316,14 +1347,30 @@ send_freebusy (EItipControl *itip)
time_t start, end;
GtkWidget *dialog;
GList *comp_list;
+ icaltimezone *zone;
priv = itip->priv;
- /* FIXME: timezones and free these. */
cal_component_get_dtstart (priv->comp, &datetime);
- start = icaltime_as_timet (*datetime.value);
+ if (datetime.tzid) {
+ zone = icalcomponent_get_timezone (priv->top_level,
+ datetime.tzid);
+ } else {
+ zone = NULL;
+ }
+ start = icaltime_as_timet_with_zone (*datetime.value, zone);
+ cal_component_free_datetime (&datetime);
+
cal_component_get_dtend (priv->comp, &datetime);
- end = icaltime_as_timet (*datetime.value);
+ if (datetime.tzid) {
+ zone = icalcomponent_get_timezone (priv->top_level,
+ datetime.tzid);
+ } else {
+ zone = NULL;
+ }
+ end = icaltime_as_timet_with_zone (*datetime.value, zone);
+ cal_component_free_datetime (&datetime);
+
comp_list = cal_client_get_free_busy (priv->event_client, NULL, start, end);
if (comp_list) {
diff --git a/calendar/gui/e-timezone-entry.c b/calendar/gui/e-timezone-entry.c
index 32739f5d5a..eb8ebe8df4 100644
--- a/calendar/gui/e-timezone-entry.c
+++ b/calendar/gui/e-timezone-entry.c
@@ -319,15 +319,7 @@ e_timezone_entry_set_timezone (ETimezoneEntry *tentry,
static char*
e_timezone_entry_get_display_name (icaltimezone *zone)
{
- char *display_name;
-
- display_name = icaltimezone_get_location (zone);
- if (!display_name)
- display_name = icaltimezone_get_tznames (zone);
- if (!display_name)
- display_name = icaltimezone_get_tzid (zone);
-
- return display_name;
+ return icaltimezone_get_display_name (zone);
}
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index c9cca5667b..ba96781ccf 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -1495,7 +1495,10 @@ print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal,
psi.month = month;
/* Get a few config settings. */
- psi.compress_weekend = calendar_config_get_compress_weekend ();
+ if (multi_week_view)
+ psi.compress_weekend = calendar_config_get_compress_weekend ();
+ else
+ psi.compress_weekend = TRUE;
psi.use_24_hour_format = calendar_config_get_24_hour_format ();
/* We convert this from (0 = Sun, 6 = Sat) to (0 = Mon, 6 = Sun). */
@@ -1837,9 +1840,15 @@ range_selector_new (GtkWidget *dialog, time_t at, int *view)
week_start_day = calendar_config_get_week_start_day ();
week_begin = time_week_begin_with_zone (at, week_start_day, zone);
/* If the week starts on a Sunday, we have to show the Saturday first,
- since the weekend is compressed. */
- if (week_start_day == 0)
- week_begin = time_add_day_with_zone (week_begin, -1, zone);
+ since the weekend is compressed. If the original date passed in was
+ a Saturday, we need to move on to the next Saturday, else we move
+ back to the last one. */
+ if (week_start_day == 0) {
+ if (tm.tm_wday == 6)
+ week_begin = time_add_day_with_zone (week_begin, 6, zone);
+ else
+ week_begin = time_add_day_with_zone (week_begin, -1, zone);
+ }
week_end = time_add_day_with_zone (week_begin, 6, zone);
week_begin_tm = *convert_timet_to_struct_tm (week_begin, zone);
@@ -1955,18 +1964,24 @@ print_week_view (GnomePrintContext *pc, GnomeCalendar *gcal, time_t date,
char buf[100];
time_t when;
gint week_start_day;
+ struct tm tm;
header = top - HEADER_HEIGHT;
/* FIXME: What is the name supposed to be for? */
gnome_print_beginpage (pc, "Calendar Week View");
+ tm = *convert_timet_to_struct_tm (date, zone);
week_start_day = calendar_config_get_week_start_day ();
when = time_week_begin_with_zone (date, week_start_day, zone);
/* If the week starts on a Sunday, we have to show the Saturday first,
since the weekend is compressed. */
- if (week_start_day == 0)
- when = time_add_day_with_zone (when, -1, zone);
+ if (week_start_day == 0) {
+ if (tm.tm_wday == 6)
+ when = time_add_day_with_zone (when, 6, zone);
+ else
+ when = time_add_day_with_zone (when, -1, zone);
+ }
/* Print the main week view. */
print_week_summary (pc, gcal, when, FALSE, 1, 0,