aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog24
-rw-r--r--calendar/cal-util/cal-recur.c2
-rw-r--r--calendar/gui/calendar-config.c2
-rw-r--r--calendar/gui/calendar-model.c6
-rw-r--r--calendar/gui/dialogs/comp-editor-util.c30
-rw-r--r--calendar/gui/dialogs/comp-editor.c4
-rw-r--r--calendar/gui/dialogs/event-page.c3
-rw-r--r--calendar/gui/dialogs/recurrence-page.c2
-rw-r--r--calendar/gui/dialogs/task-editor.c9
-rw-r--r--calendar/gui/dialogs/task-page.c1
-rw-r--r--calendar/gui/e-calendar-table.c3
-rw-r--r--calendar/gui/e-day-view.c6
-rw-r--r--calendar/gui/e-itip-control.c9
-rw-r--r--calendar/gui/e-meeting-time-sel.c8
-rw-r--r--calendar/gui/e-week-view-event-item.c6
-rw-r--r--calendar/gui/e-week-view.c4
-rw-r--r--calendar/gui/gnome-cal.c6
-rw-r--r--calendar/gui/print.c243
-rw-r--r--calendar/gui/print.h2
19 files changed, 286 insertions, 84 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index d74283dee1..218ae600b6 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,27 @@
+2001-10-26 Damon Chaplin <damon@ximian.com>
+
+ * gui/e-itip-control.c (write_label_piece): convert the formatted
+ date to UTF-8.
+
+ * cal-util/cal-recur.c (CAL_OBJ_DEBUG): turn off debug functions.
+
+ * gui/dialogs/comp-editor-util.c (parse_contact_string): handle UTF8
+ correctly. Bug #4450. Good enough for 1.0.
+
+ * gui/e-week-view-event-item.c (e_week_view_draw_time): set the gc
+ color before drawing. Should fix bug #11469.
+
+ * gui/dialogs/task-editor.c (task_editor_edit_comp): show or hide the
+ meeting page as appropriate. Note this may be called more than once,
+ if the task gets updated somewhere else and the user clicks 'Update
+ the object'. Hopefully fixes bug #12930.
+
+ * gui/print.c (print_comp_item): printed more fields and made a little
+ prettier. Fixes bug #9352.
+ (print_date_label): used the correct timezones for each date field.
+
+ * *.c: removed several debug messages.
+
2001-10-26 JP Rosevear <jpr@ximian.com>
* conduits/calendar/calendar-conduit.c (check_for_slow_setting):
diff --git a/calendar/cal-util/cal-recur.c b/calendar/cal-util/cal-recur.c
index 1f11e89c0f..ca7c720222 100644
--- a/calendar/cal-util/cal-recur.c
+++ b/calendar/cal-util/cal-recur.c
@@ -110,7 +110,7 @@
#define MAX_YEAR 2037
/* Define this for some debugging output. */
-#if 1
+#if 0
#define CAL_OBJ_DEBUG 1
#endif
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index c4a3e12510..15006a28a5 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -836,8 +836,6 @@ on_timezone_set (GnomeDialog *dialog,
e_timezone_dialog_get_timezone (etd, &display_name);
- g_print ("Location: %s\n", display_name ? display_name : "");
-
if (display_name && display_name[0]) {
calendar_config_set_timezone (display_name);
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index bb57586767..5a56227207 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -1160,8 +1160,6 @@ set_transparency (CalComponent *comp, const char *value)
static void
set_url (CalComponent *comp, const char *value)
{
- g_print ("In calendar model set_url\n");
-
if (string_is_empty (value)) {
cal_component_set_url (comp, NULL);
return;
@@ -1191,8 +1189,6 @@ set_status (CalComponent *comp, const char *value)
icalproperty_status status;
int percent;
- g_print ("In calendar model set_status: %s\n", value);
-
/* An empty string is the same as 'None'. */
if (!value[0] || !g_strcasecmp (value, _("None")))
status = ICAL_STATUS_NONE;
@@ -1248,7 +1244,7 @@ calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *val
comp = g_array_index (priv->objects, CalComponent *, row);
g_assert (comp != NULL);
-#if 1
+#if 0
g_print ("In calendar_model_set_value_at: %i\n", col);
#endif
diff --git a/calendar/gui/dialogs/comp-editor-util.c b/calendar/gui/dialogs/comp-editor-util.c
index 77939beee8..f031f35556 100644
--- a/calendar/gui/dialogs/comp-editor-util.c
+++ b/calendar/gui/dialogs/comp-editor-util.c
@@ -32,6 +32,7 @@
#include <liboaf/liboaf.h>
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-widget.h>
+#include <gal/unicode/gunicode.h>
#include <e-destination.h>
#include <e-util/e-time-utils.h>
#include <cal-util/timeutil.h>
@@ -359,8 +360,7 @@ comp_editor_show_contacts_dialog (GNOME_Evolution_Addressbook_SelectNames corba_
/* A simple 'name <email>' parser. Input should be UTF8.
- FIXME: Should probably use camel functions or something.
- Also note that this is broken wrt UTF8 - can't use strchr etc. */
+ FIXME: Should probably use camel functions or something. */
static void
parse_contact_string (const char *value, char **name, char **email)
{
@@ -372,8 +372,8 @@ parse_contact_string (const char *value, char **name, char **email)
return;
}
- lbracket = strchr (value, '<');
- rbracket = strchr (value, '>');
+ lbracket = g_utf8_strchr (value, '<');
+ rbracket = g_utf8_strchr (value, '>');
if (!lbracket || !rbracket || rbracket < lbracket) {
*name = g_strdup (value);
@@ -381,9 +381,9 @@ parse_contact_string (const char *value, char **name, char **email)
return;
}
- name_end = lbracket - 1;
- while (name_end > value && isspace (*name_end))
- name_end--;
+ name_end = g_utf8_prev_char (lbracket);
+ while (name_end > value && g_unichar_isspace (g_utf8_get_char (name_end)))
+ name_end = g_utf8_prev_char (name_end);
tmp_name = g_malloc (name_end - value + 2);
strncpy (tmp_name, value, name_end - value + 1);
@@ -395,8 +395,10 @@ parse_contact_string (const char *value, char **name, char **email)
tmp_email[rbracket - lbracket - 1] = '\0';
*email = tmp_email;
+#if 0
g_print ("Parsed: %s\n Name:'%s'\nEmail:'%s'\n",
value, *name, *email);
+#endif
}
@@ -431,7 +433,9 @@ comp_editor_contacts_to_widget (GtkWidget *contacts_entry,
g_ptr_array_add (dest_array, NULL);
contacts_string = e_destination_exportv ((EDestination**) dest_array->pdata);
+#if 0
g_print ("Destinations: %s\n", contacts_string ? contacts_string : "");
+#endif
bonobo_widget_set_property (BONOBO_WIDGET (contacts_entry),
"destinations", contacts_string, NULL);
@@ -460,7 +464,9 @@ comp_editor_contacts_to_component (GtkWidget *contacts_entry,
bonobo_widget_get_property (BONOBO_WIDGET (contacts_entry),
"destinations", &contacts_string, NULL);
+#if 0
g_print ("Contacts string: %s\n", contacts_string ? contacts_string : "");
+#endif
contact_destv = e_destination_importv (contacts_string);
if (contact_destv) {
@@ -472,16 +478,18 @@ comp_editor_contacts_to_component (GtkWidget *contacts_entry,
t->altrep = NULL;
/* If both name and email are given, use the standard
- 'name <email>' form, otherwise use just the name
+ '"name" <email>' form, otherwise use just the name
or the email address.
FIXME: I'm not sure this is correct syntax etc. */
if (name && name[0] && email && email[0])
- t->value = g_strdup_printf ("%s <%s>",
+ t->value = g_strdup_printf ("\"%s\" <%s>",
name, email);
else if (name && name[0])
- t->value = g_strdup (name);
+ t->value = g_strdup_printf ("\"%s\"",
+ name);
else
- t->value = g_strdup (email);
+ t->value = g_strdup_printf ("<%s>",
+ email);
contact_list = g_slist_prepend (contact_list, t);
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 077bff879c..6b5b78252c 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -1133,7 +1133,7 @@ print_cmd (GtkWidget *widget, gpointer data)
CalComponent *comp;
comp = comp_editor_get_current_comp (editor);
- print_comp (comp, FALSE);
+ print_comp (comp, editor->priv->client, FALSE);
gtk_object_unref (GTK_OBJECT (comp));
}
@@ -1144,7 +1144,7 @@ print_preview_cmd (GtkWidget *widget, gpointer data)
CalComponent *comp;
comp = comp_editor_get_current_comp (editor);
- print_comp (comp, TRUE);
+ print_comp (comp, editor->priv->client, TRUE);
gtk_object_unref (GTK_OBJECT (comp));
}
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index 9c89fbdf53..57fd3ac0ef 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -445,7 +445,9 @@ contacts_changed_cb (BonoboListener *listener,
epage = EVENT_PAGE (data);
priv = epage->priv;
+#if 0
g_print ("In contacts_changed_cb\n");
+#endif
if (!priv->updating)
comp_editor_page_notify_changed (COMP_EDITOR_PAGE (epage));
@@ -1171,7 +1173,6 @@ contacts_clicked_cb (GtkWidget *button, gpointer data)
epage = EVENT_PAGE (data);
priv = epage->priv;
- g_print ("In contacts_clicked_cb\n");
comp_editor_show_contacts_dialog (priv->corba_select_names);
/* FIXME: Currently we aren't getting the changed event from the
diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c
index c76b6dd970..02ce2ed064 100644
--- a/calendar/gui/dialogs/recurrence-page.c
+++ b/calendar/gui/dialogs/recurrence-page.c
@@ -831,7 +831,9 @@ fill_component (RecurrencePage *rpage, CalComponent *comp)
*cdt->value = *dt->value;
cdt->tzid = g_strdup (dt->tzid);
+#if 0
g_print ("Adding exception is_date: %i\n", cdt->value->is_date);
+#endif
list = g_slist_prepend (list, cdt);
}
diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c
index 5db5597e65..863977192c 100644
--- a/calendar/gui/dialogs/task-editor.c
+++ b/calendar/gui/dialogs/task-editor.c
@@ -218,12 +218,17 @@ task_editor_edit_comp (CompEditor *editor, CalComponent *comp)
cal_component_get_attendee_list (comp, &attendees);
if (attendees == NULL) {
- comp_editor_remove_page (editor, COMP_EDITOR_PAGE (priv->meet_page));
+ if (priv->meeting_shown)
+ comp_editor_remove_page (editor, COMP_EDITOR_PAGE (priv->meet_page));
priv->meeting_shown = FALSE;
- set_menu_sens (te);
} else {
GSList *l;
+ if (!priv->meeting_shown)
+ comp_editor_append_page (COMP_EDITOR (te),
+ COMP_EDITOR_PAGE (priv->meet_page),
+ _("Assignment"));
+
for (l = attendees; l != NULL; l = l->next) {
CalComponentAttendee *ca = l->data;
EMeetingAttendee *ia = E_MEETING_ATTENDEE (e_meeting_attendee_new_from_cal_component_attendee (ca));
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index d60ca5ba5b..084bbcbde8 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -754,7 +754,6 @@ contacts_clicked_cb (GtkWidget *button, gpointer data)
tpage = TASK_PAGE (data);
priv = tpage->priv;
- g_print ("In contacts_clicked_cb\n");
comp_editor_show_contacts_dialog (priv->corba_select_names);
/* FIXME: Currently we aren't getting the changed event from the
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 80a8e817c1..3451d20a33 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -204,8 +204,6 @@ task_compare_cb (gconstpointer a, gconstpointer b)
int *prio_a, *prio_b;
int retval;
- g_print ("In task_compare_cb\n");
-
ca = CAL_COMPONENT (a);
cb = CAL_COMPONENT (b);
@@ -894,7 +892,6 @@ e_calendar_table_on_double_click (ETable *table,
GdkEvent *event,
ECalendarTable *cal_table)
{
- g_print ("In e_calendar_table_on_double_click\n");
open_task_by_row (cal_table, row);
}
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 26597071ed..001c56aad0 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -3000,7 +3000,9 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget,
gint event_x, event_y, scroll_x, scroll_y, row, day, event_num;
EDayViewPosition pos;
+#if 0
g_print ("In e_day_view_on_main_canvas_button_press\n");
+#endif
/* Handle scroll wheel events */
if (event->button == 4) {
@@ -3864,7 +3866,9 @@ e_day_view_on_main_canvas_button_release (GtkWidget *widget,
GdkEventButton *event,
EDayView *day_view)
{
+#if 0
g_print ("In e_day_view_on_main_canvas_button_release\n");
+#endif
if (day_view->selection_is_being_dragged) {
gdk_pointer_ungrab (event->time);
@@ -5538,7 +5542,9 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item,
}
break;
case GDK_2BUTTON_PRESS:
+#if 0
g_print ("Item got double-click\n");
+#endif
break;
case GDK_BUTTON_PRESS:
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index 5170a162be..9b3707f3d7 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -438,17 +438,22 @@ write_label_piece (time_t t, char *buffer, int size, const char *stext, const ch
{
struct tm *tmp_tm;
int len;
+ char time_buf[64], *time_utf8;
/* FIXME: Convert to an appropriate timezone. */
tmp_tm = localtime (&t);
if (stext != NULL)
strcat (buffer, stext);
- len = strlen (buffer);
e_time_format_date_and_time (tmp_tm,
calendar_config_get_24_hour_format (),
FALSE, FALSE,
- &buffer[len], size - len);
+ time_buf, sizeof (time_buf));
+
+ time_utf8 = e_utf8_from_locale_string (time_buf);
+ strcat (buffer, time_utf8);
+ g_free (time_utf8);
+
if (etext != NULL)
strcat (buffer, etext);
}
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index ebfb05857b..5457458620 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -2023,9 +2023,11 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
%B = full month name, %d = month day, %Y = full year. */
g_date_strftime (buffer, sizeof (buffer), _("%A, %B %d, %Y"), &date);
+#if 0
g_print ("longest_month: %i longest_weekday: %i date: %s\n",
longest_month, longest_weekday, buffer);
-
+#endif
+
if (gdk_string_width (font, buffer) < max_date_width) {
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_FULL;
return;
@@ -2051,9 +2053,11 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
%m = month number, %d = month day, %Y = full year. */
g_date_strftime (buffer, sizeof (buffer), _("%a %m/%d/%Y"), &date);
+#if 0
g_print ("longest_month: %i longest_weekday: %i date: %s\n",
longest_month, longest_weekday, buffer);
-
+#endif
+
if (gdk_string_width (font, buffer) < max_date_width)
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY;
else
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index 09bacec50a..8aec196c51 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -249,7 +249,7 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
EWeekViewEvent *event;
EWeekViewEventSpan *span;
GtkStyle *style;
- GdkGC *fg_gc, *gc;
+ GdkGC *gc;
gint x1, y1, x2, y2, time_x, time_y;
gint icon_x, icon_y, time_width, min_end_time_x, max_icon_x;
gint rect_x, rect_w, rect_x2;
@@ -277,7 +277,6 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
event->spans_index + wveitem->span_num);
style = GTK_WIDGET (week_view)->style;
- fg_gc = style->fg_gc[GTK_STATE_NORMAL];
gc = week_view->main_gc;
x1 = canvas_item->x1 - x;
@@ -495,6 +494,7 @@ e_week_view_draw_time (EWeekView *week_view,
small_font = week_view->small_font;
gc = week_view->main_gc;
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT]);
time_y_normal_font = time_y_small_font = time_y + font->ascent;
if (small_font)
@@ -816,7 +816,7 @@ e_week_view_event_item_button_release (EWeekViewEventItem *wveitem,
week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent);
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);
-#if 1
+#if 0
g_print ("In e_week_view_event_item_button_release\n");
#endif
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 70b1ebee5a..bf145c16d5 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -2091,7 +2091,7 @@ e_week_view_on_button_press (GtkWidget *widget,
{
gint x, y, day;
-#if 1
+#if 0
g_print ("In e_week_view_on_button_press\n");
if (event->type == GDK_2BUTTON_PRESS)
g_print (" is a double-click\n");
@@ -2127,8 +2127,6 @@ e_week_view_on_button_press (GtkWidget *widget,
if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
time_t dtstart, dtend;
- g_print (" got double-click\n");
-
dtstart = week_view->day_starts[day];
dtend = week_view->day_starts[day + 1];
gnome_calendar_new_appointment_for (week_view->calendar,
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 728efba451..d7e9a67658 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -590,8 +590,6 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const char *category,
static void
view_selection_changed_cb (GtkWidget *view, GnomeCalendar *gcal)
{
- g_print ("In view_selection_changed_cb\n");
-
gtk_signal_emit (GTK_OBJECT (gcal),
gnome_calendar_signals[SELECTION_CHANGED]);
}
@@ -2094,8 +2092,6 @@ gnome_calendar_new_task (GnomeCalendar *gcal)
TaskEditor *tedit;
CalComponent *comp;
- g_print ("In gnome_calendar_new_task\n");
-
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
@@ -2262,7 +2258,6 @@ gnome_calendar_update_date_navigator (GnomeCalendar *gcal)
end_date = start_date;
g_date_add_days (&end_date, days_shown - 1);
- g_print ("Updating date navigator selection\n");
e_calendar_item_set_selection (priv->date_navigator->calitem,
&start_date, &end_date);
}
@@ -2355,7 +2350,6 @@ static void
gnome_calendar_on_date_navigator_date_range_changed (ECalendarItem *calitem,
GnomeCalendar *gcal)
{
- g_print ("In gnome_calendar_on_date_navigator_date_range_changed\n");
update_query (gcal);
}
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index f5b0dad825..111e5a19cf 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -2093,33 +2093,65 @@ write_label_piece (time_t t, char *buffer, int size, char *stext, char *etext)
strcat (buffer, etext);
}
+static icaltimezone*
+get_zone_from_tzid (CalClient *client, const char *tzid)
+{
+ icaltimezone *zone;
+
+ /* Note that the timezones may not be on the server, so we try to get
+ the builtin timezone with the TZID first. */
+ zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+ if (!zone) {
+ CalClientGetStatus status;
+
+ status = cal_client_get_timezone (client, tzid, &zone);
+ /* FIXME: Handle error better. */
+ if (status != CAL_CLIENT_GET_SUCCESS)
+ g_warning ("Couldn't get timezone from server: %s",
+ tzid ? tzid : "");
+ }
+
+ return zone;
+}
+
static void
-print_date_label (GnomePrintContext *pc, CalComponent *comp,
+print_date_label (GnomePrintContext *pc, CalComponent *comp, CalClient *client,
double left, double right, double top, double bottom)
{
- icaltimezone *zone = get_timezone ();
+ icaltimezone *start_zone, *end_zone, *due_zone, *completed_zone;
CalComponentDateTime datetime;
time_t start = 0, end = 0, complete = 0, due = 0;
static char buffer[1024], *utf_text;
cal_component_get_dtstart (comp, &datetime);
- if (datetime.value)
- start = icaltime_as_timet_with_zone (*datetime.value, zone);
+ if (datetime.value) {
+ start_zone = get_zone_from_tzid (client, datetime.tzid);
+ start = icaltime_as_timet_with_zone (*datetime.value,
+ start_zone);
+ }
cal_component_free_datetime (&datetime);
cal_component_get_dtend (comp, &datetime);
- if (datetime.value)
- end = icaltime_as_timet_with_zone (*datetime.value, zone);
+ if (datetime.value) {
+ end_zone = get_zone_from_tzid (client, datetime.tzid);
+ end = icaltime_as_timet_with_zone (*datetime.value,
+ end_zone);
+ }
cal_component_free_datetime (&datetime);
cal_component_get_due (comp, &datetime);
- if (datetime.value)
- due = icaltime_as_timet_with_zone (*datetime.value, zone);
+ if (datetime.value) {
+ due_zone = get_zone_from_tzid (client, datetime.tzid);
+ due = icaltime_as_timet_with_zone (*datetime.value,
+ due_zone);
+ }
cal_component_free_datetime (&datetime);
cal_component_get_completed (comp, &datetime.value);
if (datetime.value) {
- complete = icaltime_as_timet_with_zone (*datetime.value, zone);
+ completed_zone = icaltimezone_get_utc_timezone ();
+ complete = icaltime_as_timet_with_zone (*datetime.value,
+ completed_zone);
cal_component_free_icaltimetype (datetime.value);
}
@@ -2152,47 +2184,180 @@ print_date_label (GnomePrintContext *pc, CalComponent *comp,
}
static void
-print_comp_item (GnomePrintContext *pc, CalComponent *comp,
+print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client,
double left, double right, double top, double bottom)
{
GnomeFont *font;
CalComponentVType vtype;
CalComponentText text;
GSList *desc, *l;
+ const char *title, *categories;
+ char *categories_string;
+ GSList *contact_list, *elem;
+ gint header_size;
vtype = cal_component_get_vtype (comp);
- switch (vtype) {
- case CAL_COMPONENT_EVENT:
- case CAL_COMPONENT_TODO:
- /* Summary */
- font = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, FALSE,
- 18);
- cal_component_get_summary (comp, &text);
- top = bound_text (pc, font, text.value, left, right,
- top - 3, bottom, 0);
- gtk_object_unref (GTK_OBJECT (font));
-
- /* Date information */
- print_date_label (pc, comp, left, right, top-3, top - 15);
- top -= 30;
-
- /* Description */
- font = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, FALSE, 12);
- cal_component_get_description_list (comp, &desc);
- for (l = desc; l != NULL; l = l->next) {
- CalComponentText *text = l->data;
-
- if (text->value != NULL)
- top = bound_text (pc, font, text->value, left, right, top-3, bottom, 0);
+ /* We should only be asked to print VEVENTs or VTODOs. */
+ if (vtype == CAL_COMPONENT_EVENT)
+ title = U_("Appointment");
+ else if (vtype == CAL_COMPONENT_TODO)
+ title = U_("Task");
+ else
+ return;
+
+ /* Print the title in a box at the top of the page. */
+ font = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, FALSE, 18);
+ header_size = 50;
+ print_border (pc, left, right, top, top - header_size,
+ 1.0, 0.9);
+ print_text (pc, font, title, ALIGN_CENTER, left, right,
+ top - header_size * 0.1, top - header_size);
+ gtk_object_unref (GTK_OBJECT (font));
+
+ top -= header_size + 10;
+
+ /* Summary */
+ font = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, FALSE, 18);
+ cal_component_get_summary (comp, &text);
+ top = bound_text (pc, font, text.value, left, right,
+ top - 3, bottom, 0);
+ gtk_object_unref (GTK_OBJECT (font));
+
+ /* Date information */
+ print_date_label (pc, comp, client, left, right, top-3, top - 15);
+ top -= 20;
+
+ font = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, FALSE, 12);
+
+ /* For a VTODO we print the Status, Priority, % Complete and URL. */
+ if (vtype == CAL_COMPONENT_TODO) {
+ icalproperty_status status;
+ const char *status_string = NULL;
+ int *percent;
+ int *priority;
+ const char *url;
+
+ /* Status */
+ cal_component_get_status (comp, &status);
+ if (status != ICAL_STATUS_NONE) {
+ switch (status) {
+ case ICAL_STATUS_NEEDSACTION:
+ status_string = U_("Not Started");
+ break;
+ case ICAL_STATUS_INPROCESS:
+ status_string = U_("In Progress");
+ break;
+ case ICAL_STATUS_COMPLETED:
+ status_string = U_("Completed");
+ break;
+ case ICAL_STATUS_CANCELLED:
+ status_string = U_("Cancelled");
+ break;
+ default:
+ break;
+ }
+
+ if (status_string) {
+ char *text = g_strdup_printf (U_("Status: %s"),
+ status_string);
+ top = bound_text (pc, font, text,
+ left, right, top, bottom, 0);
+ top += gnome_font_get_size (font) - 6;
+ g_free (text);
+ }
}
- cal_component_free_text_list (desc);
- gtk_object_unref (GTK_OBJECT (font));
- break;
- default:
+ /* Priority */
+ cal_component_get_priority (comp, &priority);
+ if (priority && *priority >= 0) {
+ char *priority_string, *priority_utf8, *text;
+
+ priority_string = cal_util_priority_to_string (*priority);
+ cal_component_free_priority (priority);
+
+ priority_utf8 = e_utf8_from_locale_string (priority_string);
+ text = g_strdup_printf (U_("Priority: %s"),
+ priority_utf8);
+ top = bound_text (pc, font, text,
+ left, right, top, bottom, 0);
+ top += gnome_font_get_size (font) - 6;
+ g_free (text);
+ g_free (priority_utf8);
+ }
+
+ /* Percent Complete */
+ cal_component_get_percent (comp, &percent);
+ if (percent) {
+ char *percent_string;
+
+ percent_string = g_strdup_printf (U_("Percent Complete: %i"), *percent);
+ cal_component_free_percent (percent);
+
+ top = bound_text (pc, font, percent_string,
+ left, right, top, bottom, 0);
+ top += gnome_font_get_size (font) - 6;
+ }
+
+
+ /* URL */
+ cal_component_get_url (comp, &url);
+ if (url && url[0]) {
+ char *url_string = g_strdup_printf (U_("URL: %s"),
+ url);
+
+ top = bound_text (pc, font, url_string,
+ left, right, top, bottom, 0);
+ top += gnome_font_get_size (font) - 6;
+
+ g_free (url_string);
+ }
}
+ /* Categories */
+ cal_component_get_categories (comp, &categories);
+ if (categories && categories[0]) {
+ categories_string = g_strdup_printf (U_("Categories: %s"),
+ categories);
+ top = bound_text (pc, font, categories_string,
+ left, right, top, bottom, 0);
+ top += gnome_font_get_size (font) - 6;
+ g_free (categories_string);
+ }
+
+ /* Contacts */
+ cal_component_get_contact_list (comp, &contact_list);
+ if (contact_list) {
+ GString *contacts = g_string_new (U_("Contacts: "));
+ for (elem = contact_list; elem; elem = elem->next) {
+ CalComponentText *t = elem->data;
+ /* Put a comma between contacts. */
+ if (elem != contact_list)
+ g_string_append (contacts, ", ");
+ g_string_append (contacts, t->value);
+ }
+ cal_component_free_text_list (contact_list);
+
+ top = bound_text (pc, font, contacts->str,
+ left, right, top, bottom, 0);
+ top += gnome_font_get_size (font) - 6;
+
+ g_string_free (contacts, TRUE);
+ }
+
+ top -= 16;
+
+ /* Description */
+ cal_component_get_description_list (comp, &desc);
+ for (l = desc; l != NULL; l = l->next) {
+ CalComponentText *text = l->data;
+
+ if (text->value != NULL)
+ top = bound_text (pc, font, text->value, left, right, top-3, bottom, 0);
+ }
+ cal_component_free_text_list (desc);
+ gtk_object_unref (GTK_OBJECT (font));
+
gnome_print_showpage (pc);
}
@@ -2320,7 +2485,7 @@ print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date,
void
-print_comp (CalComponent *comp, gboolean preview)
+print_comp (CalComponent *comp, CalClient *client, gboolean preview)
{
GnomePrinter *printer;
GnomePrintMaster *gpm;
@@ -2393,7 +2558,7 @@ print_comp (CalComponent *comp, gboolean preview)
- gnome_paper_tmargin (paper_info);
b = gnome_paper_bmargin (paper_info);
- print_comp_item (pc, comp, l, r, t, b);
+ print_comp_item (pc, comp, client, l, r, t, b);
gnome_print_master_close (gpm);
diff --git a/calendar/gui/print.h b/calendar/gui/print.h
index b2b537b063..74ce37f61a 100644
--- a/calendar/gui/print.h
+++ b/calendar/gui/print.h
@@ -35,7 +35,7 @@ typedef enum {
} PrintView;
void print_calendar (GnomeCalendar *gcal, gboolean preview, time_t at, PrintView default_view);
-void print_comp (CalComponent *comp, gboolean preview);
+void print_comp (CalComponent *comp, CalClient *client, gboolean preview);
void print_setup (void);