[PATCH 1/3] Table print: Only show a table header when not 'paginating'

Lubomir I. Ivanov neolit123 at gmail.com
Sun Mar 10 05:50:00 PDT 2013


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

Strangely on Linux everything looks fine, but Windows shows the header
two times on the first page, which is due to the pango_cairo_show_layout()
function being called both for the 'paginating' and 'regular' stages
in show_table_header().

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 print.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/print.c b/print.c
index d7b6d44..a04725d 100644
--- a/print.c
+++ b/print.c
@@ -495,7 +495,7 @@ static void show_dive_tanks(struct dive *dive, cairo_t *cr, double w,
 	g_object_unref (layout);
 }
 
-static void show_table_header(cairo_t *cr, PangoLayout *layout, double w)
+static void show_table_header(cairo_t *cr, PangoLayout *layout, double w, gboolean paginate)
 {
 	int i;
 	double maxwidth, colwidth, curwidth;
@@ -514,7 +514,8 @@ static void show_table_header(cairo_t *cr, PangoLayout *layout, double w)
 		curwidth = curwidth + (colwidth * rel_width[i]);
 		pango_layout_set_text(layout, _(headers[i]), -1);
 		pango_layout_set_justify(layout, 0);
-		pango_cairo_show_layout(cr, layout);
+		if (!paginate)
+			pango_cairo_show_layout(cr, layout);
 	}
 	cairo_move_to(cr, 0, 0);
 }
@@ -788,7 +789,7 @@ static void draw_table(GtkPrintOperation *operation, GtkPrintContext *context, g
 	pango_layout_get_extents(layout, NULL, &logic_ext);
 	cairo_translate (cr, w/10, 2.0 * logic_ext.height / PANGO_SCALE);
 	y = 2.0 * logic_ext.height / PANGO_SCALE;
-	show_table_header(cr, layout, w*2);
+	show_table_header(cr, layout, w*2, paginate);
 	set_font(layout, font, FONT_NORMAL*1.2, PANGO_ALIGN_LEFT);
 	/* We wanted the header ellipsized but not the data */
 	pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list