PrintOperation
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 class@Gtk.PrintUnixDialog.
The typical way to use the high-level printing API is to create a GtkPrintOperation
object with ctor@Gtk.PrintOperation.new when the user selects to print. Then you set some properties on it, e.g. the page size, any class@Gtk.PrintSettings from previous print operations, the number of pages, the current page, etc.
Then you start the print operation by calling method@Gtk.PrintOperation.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 signal@Gtk.PrintOperation::draw-page, which you are supposed to handle and render the page on the provided class@Gtk.PrintContext 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_PRINT_OPERATION_ACTION_PRINT_DIALOG,
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);
}
By default GtkPrintOperation
uses an external application to do print preview. To implement a custom print preview, an application must connect to the preview signal. The functions method@Gtk.PrintOperationPreview.render_page, method@Gtk.PrintOperationPreview.end_preview and method@Gtk.PrintOperationPreview.is_selected are useful when implementing a print preview.
Skipped during bindings generation
method
allow-async
: Property has no gettermethod
current-page
: Property has no gettermethod
custom-tab-label
: Property has no gettermethod
default-page-setup
: Property TypeInfo of getter and setter do not matchmethod
export-filename
: Property has no gettermethod
job-name
: Property has no gettermethod
n-pages
: Property has no gettermethod
show-progress
: Property has no gettermethod
track-print-status
: Property has no gettermethod
unit
: Property has no gettermethod
use-full-page
: Property has no getter
Constructors
Properties
If true, page size combo box and orientation combo box are embedded into page setup page.
Determines whether there is a selection in your application.
The number of pages that will be printed.
The GtkPrintSettings
used for initializing the dialog.
The status of the print operation.
A string representation of the status of the print operation.
If true, the print operation will support print of selection.
Functions
Emitted after the user has finished changing print settings in the dialog, before the actual rendering starts.
Emitted when displaying the print dialog.
Emitted right before ::begin-print if you added a custom widget in the ::create-custom-widget handler.
Emitted when the print operation run has finished doing everything required for printing.
Emitted for every page that is printed.
Emitted after all pages have been rendered.
Emitted once for each page that gets rendered to the preview.
Emitted after the ::begin-print signal, but before the actual rendering starts.
Gets emitted when a preview is requested from the native dialog.
The ::ready signal gets emitted once per preview operation, before the first page is rendered.
Emitted once for every page that is printed.
Emitted at between the various phases of the print operation.
Emitted after change of selected printer.
Signal that drawing of particular page is complete.
Ends a preview.
Returns the default page setup.
Gets whether page setup selection combos are embedded
Gets whether there is a selection.
Returns the number of pages that will be printed.
Returns the current print settings.
Returns the status of the print operation.
Returns a string representation of the status of the print operation.
Gets whether the application supports print of selection
A convenience function to find out if the print operation is finished.
Returns whether the given page is included in the set of pages that have been selected for printing.
Renders a page to the preview.
Runs the print operation.
Sets whether gtk_print_operation_run() may return before the print operation is completed.
Sets the current page.
Sets the label for the tab holding custom widgets.
Makes @default_page_setup the default page setup for @op.
Sets up the GtkPrintOperation
to wait for calling of [method@Gtk.PrintOperation.draw_page_finish from application.
Embed page size combo box and orientation combo box into page setup page.
Sets up the GtkPrintOperation
to generate a file instead of showing the print dialog.
Sets whether there is a selection to print.
Sets the name of the print job.
Sets the print settings for @op.
If @show_progress is true, the print operation will show a progress dialog during the print operation.
Sets whether selection is supported by GtkPrintOperation
.
If track_status is true, the print operation will try to continue report on the status of the print job in the printer queues and printer.
If @full_page is true, the transformation for the cairo context obtained from GtkPrintContext
puts the origin at the top left corner of the page.