PrintOperation

open class PrintOperation(pointer: <Error class: unknown class><<Error class: unknown class>>) : PrintOperationPreview

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 getter

  • method current-page: Property has no getter

  • method custom-tab-label: Property has no getter

  • method default-page-setup: Property TypeInfo of getter and setter do not match

  • method export-filename: Property has no getter

  • method job-name: Property has no getter

  • method n-pages: Property has no getter

  • method show-progress: Property has no getter

  • method track-print-status: Property has no getter

  • method unit: Property has no getter

  • method use-full-page: Property has no getter

Constructors

Link copied to clipboard
constructor()

Creates a new GtkPrintOperation.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

If true, page size combo box and orientation combo box are embedded into page setup page.

Link copied to clipboard
val gtkPrintOperationPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open override val gtkPrintOperationPreviewPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

Determines whether there is a selection in your application.

Link copied to clipboard
open val nPagesToPrint: Int

The number of pages that will be printed.

Link copied to clipboard

The GtkPrintSettings used for initializing the dialog.

Link copied to clipboard

The status of the print operation.

Link copied to clipboard

A string representation of the status of the print operation.

Link copied to clipboard

If true, the print operation will support print of selection.

Functions

Link copied to clipboard
open fun cancel()

Cancels a running print operation.

Link copied to clipboard
fun connectBeginPrint(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (context: PrintContext) -> Unit): <Error class: unknown class>

Emitted after the user has finished changing print settings in the dialog, before the actual rendering starts.

Link copied to clipboard
fun connectCreateCustomWidget(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> <Error class: unknown class>?): <Error class: unknown class>

Emitted when displaying the print dialog.

Link copied to clipboard
fun connectCustomWidgetApply(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (widget: Widget) -> Unit): <Error class: unknown class>

Emitted right before ::begin-print if you added a custom widget in the ::create-custom-widget handler.

Link copied to clipboard
fun connectDone(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (result: PrintOperationResult) -> Unit): <Error class: unknown class>

Emitted when the print operation run has finished doing everything required for printing.

Link copied to clipboard
fun connectDrawPage(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (context: PrintContext, pageNr: Int) -> Unit): <Error class: unknown class>

Emitted for every page that is printed.

Link copied to clipboard
fun connectEndPrint(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (context: PrintContext) -> Unit): <Error class: unknown class>

Emitted after all pages have been rendered.

Link copied to clipboard
open fun connectGotPageSize(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (context: PrintContext, pageSetup: PageSetup) -> Unit): <Error class: unknown class>

Emitted once for each page that gets rendered to the preview.

Link copied to clipboard
fun connectPaginate(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (context: PrintContext) -> Boolean): <Error class: unknown class>

Emitted after the ::begin-print signal, but before the actual rendering starts.

Link copied to clipboard
fun connectPreview(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (preview: PrintOperationPreview, context: PrintContext, parent: Window?) -> Boolean): <Error class: unknown class>

Gets emitted when a preview is requested from the native dialog.

Link copied to clipboard
open fun connectReady(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (context: PrintContext) -> Unit): <Error class: unknown class>

The ::ready signal gets emitted once per preview operation, before the first page is rendered.

Link copied to clipboard
fun connectRequestPageSetup(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (context: PrintContext, pageNr: Int, setup: PageSetup) -> Unit): <Error class: unknown class>

Emitted once for every page that is printed.

Link copied to clipboard
fun connectStatusChanged(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> Unit): <Error class: unknown class>

Emitted at between the various phases of the print operation.

Link copied to clipboard
fun connectUpdateCustomWidget(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (widget: Widget, setup: PageSetup, settings: PrintSettings) -> Unit): <Error class: unknown class>

Emitted after change of selected printer.

Link copied to clipboard
open fun drawPageFinish()

Signal that drawing of particular page is complete.

Link copied to clipboard
open fun endPreview()

Ends a preview.

Link copied to clipboard

Returns the default page setup.

Link copied to clipboard

Gets whether page setup selection combos are embedded

Link copied to clipboard
open fun getError(): <Error class: unknown class><Unit>

Call this when the result of a print operation is %GTK_PRINT_OPERATION_RESULT_ERROR.

Link copied to clipboard

Gets whether there is a selection.

Link copied to clipboard
open fun getNPagesToPrint(): Int

Returns the number of pages that will be printed.

Link copied to clipboard

Returns the current print settings.

Link copied to clipboard

Returns the status of the print operation.

Link copied to clipboard

Returns a string representation of the status of the print operation.

Link copied to clipboard

Gets whether the application supports print of selection

Link copied to clipboard
open fun isFinished(): Boolean

A convenience function to find out if the print operation is finished.

Link copied to clipboard
open fun isSelected(pageNr: Int): Boolean

Returns whether the given page is included in the set of pages that have been selected for printing.

Link copied to clipboard
open fun renderPage(pageNr: Int)

Renders a page to the preview.

Link copied to clipboard
open fun run(action: PrintOperationAction, parent: Window? = null): <Error class: unknown class><PrintOperationResult>

Runs the print operation.

Link copied to clipboard
open fun setAllowAsync(allowAsync: Boolean)

Sets whether gtk_print_operation_run() may return before the print operation is completed.

Link copied to clipboard
open fun setCurrentPage(currentPage: Int)

Sets the current page.

Link copied to clipboard
open fun setCustomTabLabel(label: String? = null)

Sets the label for the tab holding custom widgets.

Link copied to clipboard
open fun setDefaultPageSetup(defaultPageSetup: PageSetup? = null)

Makes @default_page_setup the default page setup for @op.

Link copied to clipboard
open fun setDeferDrawing()

Sets up the GtkPrintOperation to wait for calling of [method@Gtk.PrintOperation.draw_page_finish from application.

Link copied to clipboard
open fun setEmbedPageSetup(embed: Boolean)

Embed page size combo box and orientation combo box into page setup page.

Link copied to clipboard
open fun setExportFilename(filename: String)

Sets up the GtkPrintOperation to generate a file instead of showing the print dialog.

Link copied to clipboard
open fun setHasSelection(hasSelection: Boolean)

Sets whether there is a selection to print.

Link copied to clipboard
open fun setJobName(jobName: String)

Sets the name of the print job.

Link copied to clipboard
open fun setNPages(nPages: Int)

Sets the number of pages in the document.

Link copied to clipboard
open fun setPrintSettings(printSettings: PrintSettings? = null)

Sets the print settings for @op.

Link copied to clipboard
open fun setShowProgress(showProgress: Boolean)

If @show_progress is true, the print operation will show a progress dialog during the print operation.

Link copied to clipboard
open fun setSupportSelection(supportSelection: Boolean)

Sets whether selection is supported by GtkPrintOperation.

Link copied to clipboard
open fun setTrackPrintStatus(trackStatus: Boolean)

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.

Link copied to clipboard
open fun setUnit(unit: Unit)

Sets up the transformation for the cairo context obtained from GtkPrintContext in such a way that distances are measured in units of @unit.

Link copied to clipboard
open fun setUseFullPage(fullPage: Boolean)

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.