From ab00f5b08adb1d74a0c70d935a32ffd982e86f34 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 21 Jan 2009 02:52:05 +0000 Subject: Merge revisions 37075:37107 from trunk. svn path=/branches/kill-bonobo/; revision=37112 --- calendar/gui/print.c | 59 +++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'calendar/gui/print.c') diff --git a/calendar/gui/print.c b/calendar/gui/print.c index dcd9672ec7..f448b4704d 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -1062,13 +1062,33 @@ print_attendees (GtkPrintContext *context, PangoFontDescription *font, cairo_t * return top; } +static char * +get_summary_with_location (icalcomponent *icalcomp) +{ + const gchar *summary, *location; + char *text; + + g_return_val_if_fail (icalcomp != NULL, NULL); + + summary = icalcomponent_get_summary (icalcomp); + text = summary ? (char*) summary : ""; + + location = icalcomponent_get_location (icalcomp); + if (location && *location) { + text = g_strdup_printf ("%s (%s)", text, location); + } else { + text = g_strdup (text); + } + + return text; +} + static void print_day_long_event (GtkPrintContext *context, PangoFontDescription *font, double left, double right, double top, double bottom, double row_height, EDayViewEvent *event, struct pdinfo *pdi, ECalModel *model) { - const gchar *summary; double x1, x2, y1, y2; double left_triangle_width = -1.0, right_triangle_width = -1.0; char *text; @@ -1134,12 +1154,13 @@ print_day_long_event (GtkPrintContext *context, PangoFontDescription *font, } /* Print the text. */ - summary = icalcomponent_get_summary (event->comp_data->icalcomp); - text = summary ? (char*) summary : ""; + text = get_summary_with_location (event->comp_data->icalcomp); x1 += 4; x2 -= 4; print_text (context, font, text, PANGO_ALIGN_CENTER, x1, x2, y1, y2); + + g_free (text); } @@ -1148,11 +1169,10 @@ print_day_event (GtkPrintContext *context, PangoFontDescription *font, double left, double right, double top, double bottom, EDayViewEvent *event, struct pdinfo *pdi, ECalModel *model) { - const gchar *summary, *location; double x1, x2, y1, y2, col_width, row_height; int start_offset, end_offset, start_row, end_row; char *text, start_buffer[32], end_buffer[32]; - gboolean display_times = FALSE, free_text = FALSE; + gboolean display_times = FALSE; struct tm date_tm; double red, green, blue; @@ -1188,14 +1208,7 @@ print_day_event (GtkPrintContext *context, PangoFontDescription *font, e_cal_model_get_rgb_color_for_component (model, event->comp_data, &red, &green, &blue); print_border_rgb (context, x1, x2, y1, y2, 1.0, red, green, blue); - summary = icalcomponent_get_summary (event->comp_data->icalcomp); - text = summary ? (char*) summary : ""; - - location = icalcomponent_get_location (event->comp_data->icalcomp); - if (location && *location) { - text = g_strdup_printf ("%s (%s)", text, location); - free_text = TRUE; - } + text = get_summary_with_location (event->comp_data->icalcomp); if (display_times) { gchar *t = NULL; @@ -1217,22 +1230,16 @@ print_day_event (GtkPrintContext *context, PangoFontDescription *font, e_time_format_time (&date_tm, pdi->use_24_hour_format, FALSE, end_buffer, sizeof (end_buffer)); - if (free_text) - t = text; - + t = text; text = g_strdup_printf ("%s - %s %s ", start_buffer, end_buffer, text); - free_text = TRUE; - - if (t) - g_free (t); + g_free (t); } bound_text (context, font, text, -1, x1 + 2, y1, x2 - 2, y2, FALSE, NULL, NULL); - if (free_text) - g_free (text); + g_free (text); } @@ -1337,7 +1344,7 @@ print_day_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, /* lay out the short events, within the day. */ e_day_view_layout_day_events (pdi.events[0], DAY_VIEW_ROWS, - DAY_VIEW_MINS_PER_ROW, pdi.cols_per_row); + DAY_VIEW_MINS_PER_ROW, pdi.cols_per_row, -1); /* print the short events. */ if (top > bottom ) @@ -1497,15 +1504,13 @@ print_week_event (GtkPrintContext *context, PangoFontDescription *font, { EWeekViewEventSpan *span; gint span_num; - const gchar *summary; char *text; int num_days, start_x, start_y, start_h, end_x, end_y, end_h; double x1, x2, y1, y2; double red, green, blue; GdkPixbuf *pixbuf = NULL; - summary = icalcomponent_get_summary (event->comp_data->icalcomp); - text = summary ? (char*) summary : ""; + text = get_summary_with_location (event->comp_data->icalcomp); for (span_num = 0; span_num < event->num_spans; span_num++) { span = &g_array_index (spans, EWeekViewEventSpan, @@ -1610,6 +1615,8 @@ print_week_event (GtkPrintContext *context, PangoFontDescription *font, if (pixbuf) g_object_unref (pixbuf); + + g_free (text); } -- cgit v1.2.3