PrintOperation
open class PrintOperation : GLibObject.Object, PrintOperationProtocol
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 [classGtk.PrintUnixDialog
].
The typical way to use the high-level printing API is to create
a GtkPrintOperation
object with [ctorGtk.PrintOperation.new
]
when the user selects to print. Then you set some properties on it,
e.g. the page size, any [classGtk.PrintSettings
] from previous print
operations, the number of pages, the current page, etc.
Then you start the print operation by calling [methodGtk.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
[signalGtk.PrintOperation::draw-page
], which you are supposed to handle
and render the page on the provided [classGtk.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
[methodGtk.PrintOperationPreview.render_page
],
[methodGtk.PrintOperationPreview.end_preview
] and
[methodGtk.PrintOperationPreview.is_selected
]
are useful when implementing a print preview.
The PrintOperation
type acts as a reference-counted owner of an underlying GtkPrintOperation
instance.
It provides the methods that can operate on this data type through PrintOperationProtocol
conformance.
Use PrintOperation
as a strong reference or owner of a GtkPrintOperation
instance.
-
Designated initialiser from the underlying `C` data type.
This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
PrintOperation
instance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkPrintOperation>)
Parameters
op
pointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to thePrintOperation
instance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkPrintOperation>)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a non-mutating
gpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to thePrintOperation
instance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)
Parameters
op
gpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to thePrintOperation
instance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to thePrintOperation
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkPrintOperation>?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to thePrintOperation
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkPrintOperation>?)
Parameters
op
pointer to the underlying object
-
Designated initialiser from the underlying
C
data type. Will retainGtkPrintOperation
. i.e., ownership is transferred to thePrintOperation
instance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkPrintOperation>)
Parameters
op
pointer to the underlying object
-
Reference intialiser for a related type that implements
PrintOperationProtocol
Will retainGtkPrintOperation
.Declaration
Swift
@inlinable public init<T>(printOperation other: T) where T : PrintOperationProtocol
Parameters
other
an instance of a related type that implements
PrintOperationProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PrintOperationProtocol
.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PrintOperationProtocol
.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PrintOperationProtocol
.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)
Parameters
p
raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PrintOperationProtocol
.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PrintOperationProtocol
.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)
Parameters
p
mutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PrintOperationProtocol
.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)
Parameters
raw
mutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PrintOperationProtocol
.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PrintOperationProtocol
.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Creates a new
GtkPrintOperation
.Declaration
Swift
@inlinable public init()