diff options
author | Milan Crha <mcrha@redhat.com> | 2009-11-13 20:26:28 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-11-13 20:26:28 +0800 |
commit | d40a1d3e0dd793664e9bded6fcd5f8150c425a75 (patch) | |
tree | 3f69d46717ae36ade56c85bf47cefc7ae0c73d85 | |
parent | 1dcda8555ffe7923442296d176fc7ad6d6b0815d (diff) | |
download | gsoc2013-evolution-d40a1d3e0dd793664e9bded6fcd5f8150c425a75.tar gsoc2013-evolution-d40a1d3e0dd793664e9bded6fcd5f8150c425a75.tar.gz gsoc2013-evolution-d40a1d3e0dd793664e9bded6fcd5f8150c425a75.tar.bz2 gsoc2013-evolution-d40a1d3e0dd793664e9bded6fcd5f8150c425a75.tar.lz gsoc2013-evolution-d40a1d3e0dd793664e9bded6fcd5f8150c425a75.tar.xz gsoc2013-evolution-d40a1d3e0dd793664e9bded6fcd5f8150c425a75.tar.zst gsoc2013-evolution-d40a1d3e0dd793664e9bded6fcd5f8150c425a75.zip |
Bug #600133 - Crash on day view print preview without all day events
-rw-r--r-- | calendar/gui/print.c | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/calendar/gui/print.c b/calendar/gui/print.c index 6e395d8a71..eb18b48124 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -1312,44 +1312,50 @@ print_day_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, rows_in_top_display = MIN (MAX (rows_in_top_display, DAY_VIEW_MIN_ROWS_IN_TOP_DISPLAY), (bottom-top)*0.5/DAY_VIEW_ROW_HEIGHT); - - - for (i = 0; i < rows_in_top_display; i++) { - if (i < (rows_in_top_display - 1) || - rows_in_top_display >= pdi.long_events->len) { - event = &g_array_index (pdi.long_events, EDayViewEvent, i); - print_day_long_event (context, font, left, right, top, bottom, - DAY_VIEW_ROW_HEIGHT, event, &pdi, model); - } else { - /* too many events */ - cairo_t *cr = gtk_print_context_get_cairo_context (context); - gint x, y; - if (!pixbuf) { - const gchar **xpm = (const gchar **)jump_xpm; + if (rows_in_top_display > pdi.long_events->len) + rows_in_top_display = pdi.long_events->len; - /* this ugly thing is here only to get rid of compiler warning - about unused 'jump_xpm_focused' */ - if (pixbuf) - xpm = (const gchar **)jump_xpm_focused; + for (i = 0; i < rows_in_top_display && i < pdi.long_events->len; i++) { + event = &g_array_index (pdi.long_events, EDayViewEvent, i); + print_day_long_event (context, font, left, right, top, bottom, + DAY_VIEW_ROW_HEIGHT, event, &pdi, model); + } - pixbuf = gdk_pixbuf_new_from_xpm_data (xpm); - } + if (rows_in_top_display < pdi.long_events->len) { + /* too many events */ + cairo_t *cr = gtk_print_context_get_cairo_context (context); + gint x, y; - /* Right align - 10 comes from print_day_long_event too */ - x = right - gdk_pixbuf_get_width (pixbuf) * 0.5 - 10; - /* Placing '...' at mid height. 4 and 7 constant come from print_day_long_event - (offsets used to place events boxes in their respective cells) */ - y = top + DAY_VIEW_ROW_HEIGHT * i + (DAY_VIEW_ROW_HEIGHT - 4 - 7) * 0.5; + rows_in_top_display++; - cairo_save (cr); - cairo_scale (cr, 0.5, 0.5); - gdk_cairo_set_source_pixbuf (cr, pixbuf, x * 2.0, y * 2.0); - cairo_paint (cr); - cairo_restore (cr); + if (!pixbuf) { + const gchar **xpm = (const gchar **)jump_xpm; + + /* this ugly thing is here only to get rid of compiler warning + about unused 'jump_xpm_focused' */ + if (pixbuf) + xpm = (const gchar **)jump_xpm_focused; + + pixbuf = gdk_pixbuf_new_from_xpm_data (xpm); } + + /* Right align - 10 comes from print_day_long_event too */ + x = right - gdk_pixbuf_get_width (pixbuf) * 0.5 - 10; + /* Placing '...' at mid height. 4 and 7 constant come from print_day_long_event + (offsets used to place events boxes in their respective cells) */ + y = top + DAY_VIEW_ROW_HEIGHT * i + (DAY_VIEW_ROW_HEIGHT - 4 - 7) * 0.5; + + cairo_save (cr); + cairo_scale (cr, 0.5, 0.5); + gdk_cairo_set_source_pixbuf (cr, pixbuf, x * 2.0, y * 2.0); + cairo_paint (cr); + cairo_restore (cr); } + if (!rows_in_top_display) + rows_in_top_display++; + /* Draw the border around the long events. */ cr = gtk_print_context_get_cairo_context (context); |