GtkPrintOperation
High-level Printing API
GtkPrintOperation is the high-level, portable printing API. It looks
a bit different than other GTK+ dialogs such as the #GtkFileChooser,
since some platforms don't expose enough infrastructure to implement
a good print dialog. On such platforms, GtkPrintOperation uses the
native print dialog. On platforms which do not provide a native
print dialog, GTK+ uses its own, see #GtkPrintUnixDialog.
The typical way to use the high-level printing API is to create a
#GtkPrintOperation object with gtk_print_operation_new() when the user
selects to print. Then you set some properties on it, e.g. the page size,
any #GtkPrintSettings from previous print operations, the number of pages,
the current page, etc.
Then you start the print operation by calling gtk_print_operation_run().
It will then show a dialog, let the user select a printer and options.
When the user finished the dialog various signals will be emitted on the
#GtkPrintOperation, the main one being ::draw-page, which you are supposed
to catch and render the page on the provided #GtkPrintContext using Cairo.
The high-level printing API
static GtkPrintSettings *settings = NULL;
static void
do_print (void)
{
GtkPrintOperation *print;
GtkPrintOperationResult res;
print = gtk_print_operation_new ();
if (settings != NULL)
gtk_print_operation_set_print_settings (print, settings);
g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
res = gtk_print_operation_run (print, GTK_WINDOW (main_window), NULL);
if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
{
if (settings != NULL)
g_object_unref (settings);
settings = g_object_ref (gtk_print_operation_get_print_settings (print));
}
g_object_unref (print);
}
Printing support was added in GTK+ 2.10.
#GtkPrintContext, #GtkPrintUnixDialog
@printoperation: the object which received the signal.
@arg1:
@printoperation: the object which received the signal.
@arg1:
@arg2:
@printoperation: the object which received the signal.
@arg1:
@printoperation: the object which received the signal.
@arg1:
@arg2:
@arg3:
@printoperation: the object which received the signal.
@GTK_PRINT_STATUS_INITIAL:
@GTK_PRINT_STATUS_PREPARING:
@GTK_PRINT_STATUS_GENERATING_DATA:
@GTK_PRINT_STATUS_SENDING_DATA:
@GTK_PRINT_STATUS_PENDING:
@GTK_PRINT_STATUS_PENDING_ISSUE:
@GTK_PRINT_STATUS_PRINTING:
@GTK_PRINT_STATUS_FINISHED:
@GTK_PRINT_STATUS_FINISHED_ABORTED:
@GTK_PRINT_OPERATION_RESULT_ERROR:
@GTK_PRINT_OPERATION_RESULT_APPLY:
@GTK_PRINT_OPERATION_RESULT_CANCEL:
@GTK_PRINT_ERROR_GENERAL:
@GTK_PRINT_ERROR_INTERNAL_ERROR:
@GTK_PRINT_ERROR_NOMEM:
The #GQuark used for #GtkPrintError errors.
@Returns:
@op:
@default_page_setup:
@op:
@Returns:
@op:
@print_settings:
@op:
@Returns:
@op:
@job_name:
@op:
@current_page:
@op:
@full_page:
@op:
@unit:
@op:
@show_dialog:
@op:
@filename:
@op:
@parent:
@error:
@Returns:
@op:
@parent:
@op:
@Returns:
@op:
@Returns:
@op:
@Returns:
@parent:
@page_setup:
@settings:
@Returns:
@page_setup:
@data:
@parent:
@page_setup:
@settings:
@done_cb:
@data: