GHashTable *images;
gint img_cnt;
gdouble zoom;
+ gdouble ypos_line;
};
typedef struct {
if(res == GTK_PRINT_OPERATION_RESULT_ERROR) {
GError *error = NULL;
gtk_print_operation_get_error(op, &error);
- debug_print("Error printing message: %s",
+ debug_print("Error printing message: %s\n",
error ? error->message : "no details");
}
else if(res == GTK_PRINT_OPERATION_RESULT_APPLY) {
GtkToolItem *separator;
static GdkGeometry geometry;
GtkWidget *dialog = NULL;
- GtkTooltips *toolbar_tips = gtk_tooltips_new();
GtkWidget *statusbar = gtk_hbox_new(2, FALSE);
+ CLAWS_TIP_DECL();
+
debug_print("Creating internal print preview\n");
print_data = (PrintData*) data;
gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
+#if !(GTK_CHECK_VERSION(2,12,0))
+#define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
+ gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(widget), GTK_TOOLTIPS(tips), \
+ tip, NULL); \
+}
+#else
+#define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
+ gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), tip); \
+}
+#endif
+
#define TOOLBAR_ITEM(item,text,tooltip,cb,cbdata) { \
item = GTK_WIDGET(gtk_tool_button_new_from_stock(text)); \
gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE); \
gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE); \
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1); \
g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(cb), cbdata); \
- gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(item), GTK_TOOLTIPS(toolbar_tips), \
- tooltip, NULL); \
+ CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), \
+ tooltip); \
}
TOOLBAR_ITEM(preview_data->first, GTK_STOCK_GOTO_FIRST, _("First page"), cb_preview_go_first, preview_data);
int start, ii;
PangoLayoutIter *iter;
double start_pos;
+ gint header_end_pos;
+ gint num_header_lines;
+ gint dummy;
+ gboolean header_done;
+ const gchar *text;
double line_height =0.;
print_data = (PrintData*) user_data;
ii = 0;
start_pos = 0.;
iter = pango_layout_get_iter(print_data->layout);
+
+ /* find the last character of the header */
+ header_end_pos = 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') && (text[1] == '\n'))
+ header_done = TRUE;
+ else
+ header_end_pos++;
+ text++;
+ } while(*text && !header_done);
+ }
+ /* find line number for header end */
+ pango_layout_index_to_line_x(print_data->layout, header_end_pos, 1,
+ &num_header_lines, &dummy);
+ /* line count is zero-based */
+ num_header_lines++;
+
do {
PangoRectangle logical_rect;
PangoLayoutLine *line;
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));
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);