From: Holger Berndt Date: Tue, 27 Nov 2007 12:20:10 +0000 (+0000) Subject: 2007-11-27 [holger] 3.1.0cvs36 X-Git-Tag: rel_3_2_0~44 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=384cd2e28ec50981a4fef9896d3d7733e86380a9;ds=sidebyside 2007-11-27 [holger] 3.1.0cvs36 * src/printing.c Add a line separating header and body in the printout --- diff --git a/ChangeLog b/ChangeLog index c7905be4c..2f5018ce8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-11-27 [holger] 3.1.0cvs36 + + * src/printing.c + Add a line separating header and body + in the printout + 2007-11-27 [wwp] 3.1.0cvs35 * src/addressbook.c diff --git a/PATCHSETS b/PATCHSETS index aa8a4f270..66303a710 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -3093,3 +3093,4 @@ ( cvs diff -u -r 1.155.2.80 -r 1.155.2.81 src/Makefile.am; diff -u /dev/null src/addrcustomattr.c; diff -u /dev/null src/addrcustomattr.h; cvs diff -u -r 1.60.2.107 -r 1.60.2.108 src/addressbook.c; cvs diff -u -r 1.14.2.45 -r 1.14.2.46 src/editaddress.c; cvs diff -u -r 1.3.2.7 -r 1.3.2.8 src/editaddress.h; cvs diff -u -r 1.204.2.155 -r 1.204.2.156 src/prefs_common.c; cvs diff -u -r 1.103.2.100 -r 1.103.2.101 src/prefs_common.h; cvs diff -u -r 1.9.2.43 -r 1.9.2.44 src/common/defs.h; ) > 3.1.0cvs33.patchset ( cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/printing.c; ) > 3.1.0cvs34.patchset ( cvs diff -u -r 1.60.2.108 -r 1.60.2.109 src/addressbook.c; ) > 3.1.0cvs35.patchset +( cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/printing.c; ) > 3.1.0cvs36.patchset diff --git a/configure.ac b/configure.ac index ea5c7ed8c..2aabf2430 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=1 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=35 +EXTRA_VERSION=36 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/printing.c b/src/printing.c index 8843a75be..c4c8f0897 100644 --- a/src/printing.c +++ b/src/printing.c @@ -50,6 +50,7 @@ struct _PrintData { GHashTable *images; gint img_cnt; gdouble zoom; + gdouble ypos_line; }; typedef struct { @@ -762,6 +763,9 @@ static void printing_textview_cb_begin_print(GtkPrintOperation *op, GtkPrintCont int start, ii; PangoLayoutIter *iter; double start_pos; + gint num_header_lines; + gboolean header_done; + const gchar *text; double line_height =0.; print_data = (PrintData*) user_data; @@ -796,6 +800,23 @@ static void printing_textview_cb_begin_print(GtkPrintOperation *op, GtkPrintCont ii = 0; start_pos = 0.; iter = pango_layout_get_iter(print_data->layout); + + /* count number of header lines */ + num_header_lines = 0; + header_done = FALSE; + text = pango_layout_get_text(print_data->layout); + if(text && *text && *text != '\n') { + do { + if(text[0] == '\n' && (text[1] != '\0')) { + num_header_lines++; + if(text[1] == '\n') { + header_done = TRUE; + } + } + text++; + } while(*text && !header_done); + } + do { PangoRectangle logical_rect; PangoLayoutLine *line; @@ -819,6 +840,12 @@ static void printing_textview_cb_begin_print(GtkPrintOperation *op, GtkPrintCont page_height = 0; } + if(ii == num_header_lines) { + int y0, y1; + pango_layout_iter_get_line_yrange(iter,&y0,&y1); + print_data->ypos_line = (double)y0 + 1./3.*((double)(y1 - y0))/2.; + } + page_height += line_height; ii++; } while(ii < num_lines && pango_layout_iter_next_line(iter)); @@ -958,7 +985,26 @@ static void printing_textview_cb_draw_page(GtkPrintOperation *op, GtkPrintContex if(ii == start) start_pos = ((double)logical_rect.y) / PANGO_SCALE; - + + /* Draw header separator line */ + if(ii == 0) { + cairo_surface_t *surface; + surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + gtk_print_context_get_width(context)/print_data->zoom, + gtk_print_context_get_height(context)/print_data->zoom); + cairo_set_line_width(cr, .5); + cairo_set_source_surface(cr, surface, + ((double)logical_rect.x) / PANGO_SCALE, + ((double)baseline) / PANGO_SCALE - start_pos); + cairo_move_to(cr, + ((double)logical_rect.x) / PANGO_SCALE, + (double)print_data->ypos_line / PANGO_SCALE); + cairo_rel_line_to(cr, gtk_print_context_get_width(context)/print_data->zoom, 0); + cairo_set_source_rgb(cr, 0., 0., 0.); + cairo_stroke(cr); + cairo_surface_destroy(surface); + } + cairo_move_to(cr, ((double)logical_rect.x) / PANGO_SCALE, ((double)baseline) / PANGO_SCALE - start_pos);