viewer->print(viewer);
return;
} else {
- /* Force text rendering */
- mimeview_show_part_as_text(mimeview,
- mimeview_get_selected_part(mimeview));
+ /* Force text rendering if possible */
+ MimeInfo *mimepart;
+
+ mimepart = mimeview_get_selected_part(mimeview);
+ if (mimepart == NULL
+ || (mimepart->type != MIMETYPE_TEXT && mimepart->type != MIMETYPE_MESSAGE)) {
+ alertpanel_warning(_("Cannot print: the message doesn't "
+ "contain text."));
+ return;
+ }
+ mimeview_show_part_as_text(mimeview, mimepart);
}
}
if (sel_start != -1 && sel_end != -1) {
GdkPixbuf *pixbuf = gtk_image_get_pixbuf(print_data->avatar);
gdouble startx, starty;
- startx = gtk_print_context_get_width(context)/print_data->zoom;
+ if (pixbuf != NULL) {
+ startx = gtk_print_context_get_width(context)/print_data->zoom;
- startx -= ((double)gdk_pixbuf_get_width(pixbuf));
+ startx -= ((double)gdk_pixbuf_get_width(pixbuf));
- starty = start_pos;
+ starty = start_pos;
- surface = pixbuf_to_surface(pixbuf);
- cairo_set_source_surface (cr, surface, startx, starty);
- cairo_paint (cr);
- cairo_surface_destroy (surface);
+ surface = pixbuf_to_surface(pixbuf);
+ cairo_set_source_surface (cr, surface, startx, starty);
+ cairo_paint (cr);
+ cairo_surface_destroy (surface);
+ }
}
pango_layout_iter_free(iter);