diff options
author | Milan Crha <mcrha@redhat.com> | 2009-11-13 20:22:46 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-11-13 20:22:46 +0800 |
commit | ba89f0b2c4993c562a1bdb0f5ce90b654c3b68b5 (patch) | |
tree | a31c4aafd1713719d5596c482d8dd879e43c8ee0 /calendar | |
parent | b38769dab892fee77ab19c1092d2f29d774e0014 (diff) | |
download | gsoc2013-evolution-ba89f0b2c4993c562a1bdb0f5ce90b654c3b68b5.tar gsoc2013-evolution-ba89f0b2c4993c562a1bdb0f5ce90b654c3b68b5.tar.gz gsoc2013-evolution-ba89f0b2c4993c562a1bdb0f5ce90b654c3b68b5.tar.bz2 gsoc2013-evolution-ba89f0b2c4993c562a1bdb0f5ce90b654c3b68b5.tar.lz gsoc2013-evolution-ba89f0b2c4993c562a1bdb0f5ce90b654c3b68b5.tar.xz gsoc2013-evolution-ba89f0b2c4993c562a1bdb0f5ce90b654c3b68b5.tar.zst gsoc2013-evolution-ba89f0b2c4993c562a1bdb0f5ce90b654c3b68b5.zip |
Bug #600133 - Crash on day view print preview without all day events
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gui/print.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/calendar/gui/print.c b/calendar/gui/print.c index 829dde34bd..7b0c794a58 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -1312,42 +1312,49 @@ print_day_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, 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 (rows_in_top_display > pdi.long_events->len) + rows_in_top_display = pdi.long_events->len; - if (!pixbuf) { - const gchar **xpm = (const gchar **)jump_xpm; + 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); + } - /* 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; + 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; - pixbuf = gdk_pixbuf_new_from_xpm_data (xpm); - } + rows_in_top_display++; - /* 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; + if (!pixbuf) { + const gchar **xpm = (const gchar **)jump_xpm; - 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); + /* 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); |