PrintOperation.connectDrawPage

gulong connectDrawPage(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.print_context.PrintContext))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == int))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.print_operation.PrintOperation))) && Parameters!T.length < 4)

Connect to DrawPage signal.

Emitted for every page that is printed. The signal handler must render the page_nr's page onto the cairo context obtained from context using [gtk.print_context.PrintContext.getCairoContext].

static void
 draw_page (GtkPrintOperation *operation,
            GtkPrintContext   *context,
            gint               page_nr,
            gpointer           user_data)
 {
   cairo_t *cr;
   PangoLayout *layout;
   gdouble width, text_height;
   gint layout_height;
   PangoFontDescription *desc;

   cr = gtk_print_context_get_cairo_context (context);
   width = gtk_print_context_get_width (context);

   cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);

   cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
   cairo_fill (cr);

   layout = gtk_print_context_create_pango_layout (context);

   desc = pango_font_description_from_string ("sans 14");
   pango_layout_set_font_description (layout, desc);
   pango_font_description_free (desc);

   pango_layout_set_text (layout, "some text", -1);
   pango_layout_set_width (layout, width * PANGO_SCALE);
   pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);

   pango_layout_get_size (layout, NULL, &layout_height);
   text_height = (gdouble)layout_height / PANGO_SCALE;

   cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
   pango_cairo_show_layout (cr, layout);

   g_object_unref (layout);
 }

Use [gtk.print_operation.PrintOperation.setUseFullPage] and [gtk.print_operation.PrintOperation.setUnit] before starting the print operation to set up the transformation of the cairo context according to your needs.

Parameters

callbacksignal callback delegate or function to connect void callback(gtk.print_context.PrintContext context, int pageNr, gtk.print_operation.PrintOperation printOperation) context the #GtkPrintContext for the current operation (optional) pageNr the number of the currently printed page (0-based) (optional) printOperation the instance the signal is connected to (optional)
afterYes.After to execute callback after default handler, No.After to execute before (default)

Returns

Signal ID