Class (GI Class)

Gtk-4.0GtkPrintOperation

High-level, portable printing API.

It looks a bit different than other GTK dialogs such as the Gtk.FileChooser, since some platforms don’t expose enough infrastructure to implement a good print dialog. On such platforms, Gtk.PrintOperation uses the native print dialog. On platforms which do not provide a native print dialog, GTK uses its own, see Gtk.PrintUnixDialog.

The typical way to use the high-level printing API is to create a Gtk.PrintOperation object with Gtk.PrintOperation.new when the user selects to print. Then you set some properties on it, e.g. the page size, any Gtk.PrintSettings from previous print operations, the number of pages, the current page, etc.

Then you start the print operation by calling 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 Gtk.PrintOperation, the main one being Gtk.PrintOperation::draw-page, which you are supposed to handle and render the page on the provided 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 Gtk.PrintOperation uses an external application to do print preview. To implement a custom print preview, an application must connect to the preview signal. The functions Gtk.PrintOperationPreview.render_page, Gtk.PrintOperationPreview.end_preview and Gtk.PrintOperationPreview.is_selected are useful when implementing a print preview.

Hierarchy (View Summary)

Implements

Index

Constructors

Properties

Accessors

Methods

Methods - Inherited from GObject

Constructors

Properties

Compile-time signal type information.

This instance property is generated only for TypeScript type checking. It is not defined at runtime and should not be accessed in JS code.

Accessors

  • get allow_async(): boolean

    Determines whether the print operation may run asynchronously or not.

    Some systems don't support asynchronous printing, but those that do will return Gtk.PrintOperationResult.IN_PROGRESS as the status, and emit the Gtk.PrintOperation::done signal when the operation is actually done.

    The Windows port does not support asynchronous operation at all (this is unlikely to change). On other platforms, all actions except for Gtk.PrintOperationAction.EXPORT support asynchronous operation.

    Returns boolean

  • set allow_async(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get allowAsync(): boolean

    Determines whether the print operation may run asynchronously or not.

    Some systems don't support asynchronous printing, but those that do will return Gtk.PrintOperationResult.IN_PROGRESS as the status, and emit the Gtk.PrintOperation::done signal when the operation is actually done.

    The Windows port does not support asynchronous operation at all (this is unlikely to change). On other platforms, all actions except for Gtk.PrintOperationAction.EXPORT support asynchronous operation.

    Returns boolean

  • set allowAsync(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get current_page(): number

    The current page in the document.

    If this is set before Gtk.PrintOperation.run, the user will be able to select to print only the current page.

    Note that this only makes sense for pre-paginated documents.

    Returns number

  • set current_page(val: number): void

    Parameters

    • val: number

    Returns void

  • get currentPage(): number

    The current page in the document.

    If this is set before Gtk.PrintOperation.run, the user will be able to select to print only the current page.

    Note that this only makes sense for pre-paginated documents.

    Returns number

  • set currentPage(val: number): void

    Parameters

    • val: number

    Returns void

  • get custom_tab_label(): string

    Used as the label of the tab containing custom widgets.

    Note that this property may be ignored on some platforms.

    If this is null, GTK uses a default label.

    Returns string

  • set custom_tab_label(val: string): void

    Parameters

    • val: string

    Returns void

  • get customTabLabel(): string

    Used as the label of the tab containing custom widgets.

    Note that this property may be ignored on some platforms.

    If this is null, GTK uses a default label.

    Returns string

  • set customTabLabel(val: string): void

    Parameters

    • val: string

    Returns void

  • get embed_page_setup(): boolean

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

    Returns boolean

  • set embed_page_setup(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get embedPageSetup(): boolean

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

    Returns boolean

  • set embedPageSetup(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get export_filename(): string

    The name of a file to generate instead of showing the print dialog.

    Currently, PDF is the only supported format.

    The intended use of this property is for implementing “Export to PDF” actions.

    “Print to PDF” support is independent of this and is done by letting the user pick the “Print to PDF” item from the list of printers in the print dialog.

    Returns string

  • set export_filename(val: string): void

    Parameters

    • val: string

    Returns void

  • get exportFilename(): string

    The name of a file to generate instead of showing the print dialog.

    Currently, PDF is the only supported format.

    The intended use of this property is for implementing “Export to PDF” actions.

    “Print to PDF” support is independent of this and is done by letting the user pick the “Print to PDF” item from the list of printers in the print dialog.

    Returns string

  • set exportFilename(val: string): void

    Parameters

    • val: string

    Returns void

  • get has_selection(): boolean

    Determines whether there is a selection in your application.

    This can allow your application to print the selection. This is typically used to make a "Selection" button sensitive.

    Returns boolean

  • set has_selection(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get hasSelection(): boolean

    Determines whether there is a selection in your application.

    This can allow your application to print the selection. This is typically used to make a "Selection" button sensitive.

    Returns boolean

  • set hasSelection(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get job_name(): string

    A string used to identify the job (e.g. in monitoring applications like eggcups).

    If you don't set a job name, GTK picks a default one by numbering successive print jobs.

    Returns string

  • set job_name(val: string): void

    Parameters

    • val: string

    Returns void

  • get jobName(): string

    A string used to identify the job (e.g. in monitoring applications like eggcups).

    If you don't set a job name, GTK picks a default one by numbering successive print jobs.

    Returns string

  • set jobName(val: string): void

    Parameters

    • val: string

    Returns void

  • get n_pages(): number

    The number of pages in the document.

    This must be set to a positive number before the rendering starts. It may be set in a Gtk.PrintOperation::begin-print signal handler.

    Note that the page numbers passed to the Gtk.PrintOperation::request-page-setup and Gtk.PrintOperation::draw-page signals are 0-based, i.e. if the user chooses to print all pages, the last ::draw-page signal will be for page n_pages - 1.

    Returns number

  • set n_pages(val: number): void

    Parameters

    • val: number

    Returns void

  • get nPages(): number

    The number of pages in the document.

    This must be set to a positive number before the rendering starts. It may be set in a Gtk.PrintOperation::begin-print signal handler.

    Note that the page numbers passed to the Gtk.PrintOperation::request-page-setup and Gtk.PrintOperation::draw-page signals are 0-based, i.e. if the user chooses to print all pages, the last ::draw-page signal will be for page n_pages - 1.

    Returns number

  • set nPages(val: number): void

    Parameters

    • val: number

    Returns void

  • get status_string(): string

    A string representation of the status of the print operation.

    The string is translated and suitable for displaying the print status e.g. in a Gtk.Statusbar.

    See the Gtk.PrintOperation.status property for a status value that is suitable for programmatic use.

    Returns string

  • get statusString(): string

    A string representation of the status of the print operation.

    The string is translated and suitable for displaying the print status e.g. in a Gtk.Statusbar.

    See the Gtk.PrintOperation.status property for a status value that is suitable for programmatic use.

    Returns string

  • get support_selection(): boolean

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

    This allows the print dialog to show a "Selection" button.

    Returns boolean

  • set support_selection(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get supportSelection(): boolean

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

    This allows the print dialog to show a "Selection" button.

    Returns boolean

  • set supportSelection(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get track_print_status(): boolean

    If true, the print operation will try to continue report on the status of the print job in the printer queues and printer.

    This can allow your application to show things like “out of paper” issues, and when the print job actually reaches the printer. However, this is often implemented using polling, and should not be enabled unless needed.

    Returns boolean

  • set track_print_status(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get trackPrintStatus(): boolean

    If true, the print operation will try to continue report on the status of the print job in the printer queues and printer.

    This can allow your application to show things like “out of paper” issues, and when the print job actually reaches the printer. However, this is often implemented using polling, and should not be enabled unless needed.

    Returns boolean

  • set trackPrintStatus(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get use_full_page(): boolean

    If true, the transformation for the cairo context obtained from Gtk.PrintContext puts the origin at the top left corner of the page.

    This may not be the top left corner of the sheet, depending on page orientation and the number of pages per sheet. Otherwise, the origin is at the top left corner of the imageable area (i.e. inside the margins).

    Returns boolean

  • set use_full_page(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get useFullPage(): boolean

    If true, the transformation for the cairo context obtained from Gtk.PrintContext puts the origin at the top left corner of the page.

    This may not be the top left corner of the sheet, depending on page orientation and the number of pages per sheet. Otherwise, the origin is at the top left corner of the imageable area (i.e. inside the margins).

    Returns boolean

  • set useFullPage(val: boolean): void

    Parameters

    • val: boolean

    Returns void

Methods

  • Creates a binding between source_property on source and target_property on target.

    Whenever the source_property is changed the target_property is updated using the same value. For instance:

      g_object_bind_property (action, "active", widget, "sensitive", 0);
    

    Will result in the "sensitive" property of the widget GObject.Object instance to be updated with the same value of the "active" property of the action GObject.Object instance.

    If flags contains GObject.BindingFlags.BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well.

    The binding will automatically be removed when either the source or the target instances are finalized. To remove the binding without affecting the source and the target you can just call g_object_unref() on the returned GObject.Binding instance.

    Removing the binding by calling g_object_unref() on it must only be done if the binding, source and target are only used from a single thread and it is clear that both source and target outlive the binding. Especially it is not safe to rely on this if the binding, source or target can be finalized from different threads. Keep another reference to the binding and use g_binding_unbind() instead to be on the safe side.

    A GObject.Object can have multiple bindings.

    Parameters

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Complete version of g_object_bind_property().

    Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    If flags contains GObject.BindingFlags.BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well. The transform_from function is only used in case of bidirectional bindings, otherwise it will be ignored

    The binding will automatically be removed when either the source or the target instances are finalized. This will release the reference that is being held on the GObject.Binding instance; if you want to hold on to the GObject.Binding instance, you will need to hold a reference to it.

    To remove the binding, call g_binding_unbind().

    A GObject.Object can have multiple bindings.

    The same user_data parameter will be used for both transform_to and transform_from transformation functions; the notify function will be called once, when the binding is removed. If you need different data for each transformation function, please use g_object_bind_property_with_closures() instead.

    Parameters

    • source_property: string

      the property on source to bind

    • target: GObject.Object

      the target GObject.Object

    • target_property: string

      the property on target to bind

    • flags: GObject.BindingFlags

      flags to pass to GObject.Binding

    • Optionaltransform_to: BindingTransformFunc

      the transformation function from the source to the target, or null to use the default

    • Optionaltransform_from: BindingTransformFunc

      the transformation function from the target to the source, or null to use the default

    • Optionalnotify: DestroyNotify

      a function to call when disposing the binding, to free resources used by the transformation functions, or null if not required

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    This function is the language bindings friendly version of g_object_bind_property_full(), using GClosures instead of function pointers.

    Parameters

    • ...args: never[]

      the property on source to bind

    Returns any

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Cancels a running print operation.

    This function may be called from a Gtk.PrintOperation::begin-print, Gtk.PrintOperation::paginate or Gtk.PrintOperation::draw-page signal handler to stop the currently running print operation.

    Returns void

  • Disconnects a handler from an instance so it will not be called during any future or currently ongoing emissions of the signal it has been connected to.

    Parameters

    • id: number

      Handler ID of the handler to be disconnected

    Returns void

  • Signal that drawing of particular page is complete.

    It is called after completion of page drawing (e.g. drawing in another thread). If Gtk.PrintOperation.set_defer_drawing was called before, then this function has to be called by application. Otherwise it is called by GTK itself.

    Returns void

  • Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one GObject.Object::notify signal is emitted for each property modified while the object is frozen.

    This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.

    Returns void

  • Gets whether page setup selection combos are embedded

    Returns boolean

    whether page setup selection combos are embedded

  • Gets whether there is a selection.

    Returns boolean

    whether there is a selection

  • Returns the number of pages that will be printed.

    Note that this value is set during print preparation phase (Gtk.PrintStatus.PREPARING), so this function should never be called before the data generation phase (Gtk.PrintStatus.GENERATING_DATA). You can connect to the Gtk.PrintOperation::status-changed signal and call gtk_print_operation_get_n_pages_to_print() when print status is Gtk.PrintStatus.GENERATING_DATA.

    This is typically used to track the progress of print operation.

    Returns number

    the number of pages that will be printed

  • Gets a property of an object.

    The value can be:

    • an empty GObject.Value initialized by G_VALUE_INIT, which will be automatically initialized with the expected type of the property (since GLib 2.60)
    • a GObject.Value initialized with the expected type of the property
    • a GObject.Value initialized with a type to which the expected type of the property can be transformed

    In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling GObject.Value.unset.

    Note that GObject.Object.get_property is really intended for language bindings, GObject.Object.get is much more convenient for C programming.

    Parameters

    • property_name: string

      The name of the property to get

    • value: any

      Return location for the property value. Can be an empty GObject.Value initialized by G_VALUE_INIT (auto-initialized with expected type since GLib 2.60), a GObject.Value initialized with the expected property type, or a GObject.Value initialized with a transformable type

    Returns any

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

    The string is translated and suitable for displaying the print status e.g. in a Gtk.Statusbar.

    Use Gtk.PrintOperation.get_status to obtain a status value that is suitable for programmatic use.

    Returns string

    a string representation of the status of the print operation

  • Gets whether the application supports print of selection

    Returns boolean

    whether the application supports print of selection

  • Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

    Parameters

    • names: string[]

      the names of each property to get

    • values: any[]

      the values of each property to get

    Returns void

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

    a print operation is finished if its status is either Gtk.PrintStatus.FINISHED or Gtk.PrintStatus.FINISHED_ABORTED.

    Note: when you enable print status tracking the print operation can be in a non-finished state even after done has been called, as the operation status then tracks the print job status on the printer.

    Returns boolean

    true, if the print operation is finished.

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

    Parameters

    • page_nr: number

      a page number

    Returns boolean

    true if the page has been selected for printing

  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    • property_name: string

      the name of a property installed on the class of object.

    Returns void

  • Emits a "notify" signal for the property specified by pspec on object.

    This function omits the property name lookup, hence it is faster than g_object_notify().

    One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:

      typedef enum
    {
    PROP_FOO = 1,
    PROP_LAST
    } MyObjectProperty;

    static GParamSpec *properties[PROP_LAST];

    static void
    my_object_class_init (MyObjectClass *klass)
    {
    properties[PROP_FOO] = g_param_spec_int ("foo", NULL, NULL,
    0, 100,
    50,
    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
    g_object_class_install_property (gobject_class,
    PROP_FOO,
    properties[PROP_FOO]);
    }

    and then notify a change on the "foo" property with:

      g_object_notify_by_pspec (self, properties[PROP_FOO]);
    

    Parameters

    Returns void

  • Increases the reference count of object.

    Since GLib 2.56, if GLIB_VERSION_MAX_ALLOWED is 2.56 or greater, the type of object will be propagated to the return type (using the GCC typeof() extension), so any casting the caller needs to do on the return type must be explicit.

    Returns GObject.Object

    the same object

  • Increase the reference count of object, and possibly remove the [floating][floating-ref] reference, if object has a floating reference.

    In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.

    Since GLib 2.56, the type of object will be propagated to the return type under the same conditions as for g_object_ref().

    Returns GObject.Object

    object

  • Renders a page to the preview.

    This is using the print context that was passed to the Gtk.PrintOperation::preview handler together with preview.

    A custom print preview should use this function to render the currently selected page.

    Note that this function requires a suitable cairo context to be associated with the print context.

    Parameters

    • page_nr: number

      the page to render

    Returns void

  • Runs the print operation.

    Normally that this function does not return until the rendering of all pages is complete. You can connect to the Gtk.PrintOperation::status-changed signal on op to obtain some information about the progress of the print operation.

    Furthermore, it may use a recursive mainloop to show the print dialog.

    If you set the [Gtk.PrintOperation:allow-async] property, the operation will run asynchronously if this is supported on the platform. The Gtk.PrintOperation::done signal will be emitted with the result of the operation when the it is done (i.e. when the dialog is canceled, or when the print succeeds or fails).

    if (settings != NULL)
    gtk_print_operation_set_print_settings (print, settings);

    if (page_setup != NULL)
    gtk_print_operation_set_default_page_setup (print, page_setup);

    g_signal_connect (print, "begin-print",
    G_CALLBACK (begin_print), &data);
    g_signal_connect (print, "draw-page",
    G_CALLBACK (draw_page), &data);

    res = gtk_print_operation_run (print,
    GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
    parent,
    &error);

    if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
    {
    error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
    GTK_DIALOG_DESTROY_WITH_PARENT,
    GTK_MESSAGE_ERROR,
    GTK_BUTTONS_CLOSE,
    "Error printing file:\n%s",
    error->message);
    g_signal_connect (error_dialog, "response",
    G_CALLBACK (gtk_window_destroy), NULL);
    gtk_window_present (GTK_WINDOW (error_dialog));
    g_error_free (error);
    }
    else 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));
    }

    Note that gtk_print_operation_run() can only be called once on a given Gtk.PrintOperation.

    Parameters

    Returns Gtk.PrintOperationResult

    the result of the print operation. A return value of Gtk.PrintOperationResult.APPLY indicates that the printing was completed successfully. In this case, it is a good idea to obtain the used print settings with Gtk.PrintOperation.get_print_settings and store them for reuse with the next print operation. A value of Gtk.PrintOperationResult.IN_PROGRESS means the operation is running asynchronously, and will emit the Gtk.PrintOperation::done signal when done.

  • Sets multiple properties of an object at once. The properties argument should be a dictionary mapping property names to values.

    Parameters

    • properties: { [key: string]: any }

      Object containing the properties to set

    Returns void

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

    Note that some platforms may not allow asynchronous operation.

    Parameters

    • allow_async: boolean

      true to allow asynchronous operation

    Returns void

  • Sets the current page.

    If this is called before Gtk.PrintOperation.run, the user will be able to select to print only the current page.

    Note that this only makes sense for pre-paginated documents.

    Parameters

    • current_page: number

      the current page, 0-based

    Returns void

  • Sets the label for the tab holding custom widgets.

    Parameters

    • Optionallabel: string

      the label to use, or null to use the default label

    Returns void

  • Each object carries around a table of associations from strings to pointers. This function lets you set an association.

    If the object already had an association with that name, the old association will be destroyed.

    Internally, the key is converted to a GLib.Quark using g_quark_from_string(). This means a copy of key is kept permanently (even after object has been finalized) — so it is recommended to only use a small, bounded set of values for key in your program, to avoid the GLib.Quark storage growing unbounded.

    Parameters

    • key: string

      name of the key

    • Optionaldata: any

      data to associate with that key

    Returns void

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

    This can be used for drawing page in another thread.

    This function must be called in the callback of the Gtk.PrintOperation::draw-page signal.

    Returns void

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

    Selected page setup is stored as default page setup in Gtk.PrintOperation.

    Parameters

    Returns void

  • Sets up the Gtk.PrintOperation to generate a file instead of showing the print dialog.

    The intended use of this function is for implementing “Export to PDF” actions. Currently, PDF is the only supported format.

    “Print to PDF” support is independent of this and is done by letting the user pick the “Print to PDF” item from the list of printers in the print dialog.

    Parameters

    • filename: string

      the filename for the exported file

    Returns void

  • Sets whether there is a selection to print.

    Application has to set number of pages to which the selection will draw by Gtk.PrintOperation.set_n_pages in a handler for the Gtk.PrintOperation::begin-print signal.

    Parameters

    • has_selection: boolean

      true indicates that a selection exists

    Returns void

  • Sets the name of the print job.

    The name is used to identify the job (e.g. in monitoring applications like eggcups).

    If you don’t set a job name, GTK picks a default one by numbering successive print jobs.

    Parameters

    • job_name: string

      a string that identifies the print job

    Returns void

  • Sets the number of pages in the document.

    This must be set to a positive number before the rendering starts. It may be set in a Gtk.PrintOperation::begin-print signal handler.

    Note that the page numbers passed to the Gtk.PrintOperation::request-page-setup and Gtk.PrintOperation::draw-page signals are 0-based, i.e. if the user chooses to print all pages, the last ::draw-page signal will be for page n_pages - 1.

    Parameters

    • n_pages: number

      the number of pages

    Returns void

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

    Parameters

    • show_progress: boolean

      true to show a progress dialog

    Returns void

  • Sets whether selection is supported by Gtk.PrintOperation.

    Parameters

    • support_selection: boolean

      true to support selection

    Returns void

  • 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.

    This can allow your application to show things like “out of paper” issues, and when the print job actually reaches the printer.

    This function is often implemented using some form of polling, so it should not be enabled unless needed.

    Parameters

    • track_status: boolean

      true to track status after printing

    Returns void

  • If full_page is true, the transformation for the cairo context obtained from Gtk.PrintContext puts the origin at the top left corner of the page.

    This may not be the top left corner of the sheet, depending on page orientation and the number of pages per sheet). Otherwise, the origin is at the top left corner of the imageable area (i.e. inside the margins).

    Parameters

    Returns void

  • This function gets back user data pointers stored via g_object_set_qdata() and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

    void
    object_add_to_user_list (GObject *object,
    const gchar *new_string)
    {
    // the quark, naming the object data
    GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
    // retrieve the old string list
    GList *list = g_object_steal_qdata (object, quark_string_list);

    // prepend new string
    list = g_list_prepend (list, g_strdup (new_string));
    // this changed 'list', so we need to set it again
    g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
    }
    static void
    free_string_list (gpointer data)
    {
    GList *node, *list = data;

    for (node = list; node; node = node->next)
    g_free (node->data);
    g_list_free (list);
    }

    Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().

    Parameters

    • quark: number

      A GLib.Quark, naming the user data pointer

    Returns any

    The user data pointer set, or null

  • Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

    Duplicate notifications for each property are squashed so that at most one GObject.Object::notify signal is emitted for each property, in the reverse order in which they have been queued.

    It is an error to call this function when the freeze count is zero.

    Returns void

  • Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

    If the pointer to the GObject.Object may be reused in future (for example, if it is an instance variable of another object), it is recommended to clear the pointer to null rather than retain a dangling pointer to a potentially invalid GObject.Object instance. Use g_clear_object() for this.

    Returns void

  • the constructed function is called by g_object_new() as the final step of the object creation process. At the point of the call, all construction properties have been set on the object. The purpose of this call is to allow for object initialisation steps that can only be performed after construction properties have been set. constructed implementors should chain up to the constructed call of their parent class to allow it to complete its initialisation.

    Returns void

  • Signal emitted right before “begin-print” if you added a custom widget in the “create-custom-widget” handler.

    Parameters

    Returns void

  • the dispose function is supposed to drop all references to other objects, but keep the instance otherwise intact, so that client method invocations still work. It may be run multiple times (due to reference loops). Before returning, dispose should chain up to the dispose method of the parent class.

    Returns void

  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    Returns void

  • Renders a page to the preview.

    This is using the print context that was passed to the Gtk.PrintOperation::preview handler together with preview.

    A custom print preview should use this function to render the currently selected page.

    Note that this function requires a suitable cairo context to be associated with the print context.

    Parameters

    • page_nr: number

      the page to render

    Returns void

  • the generic setter for all properties of this type. Should be overridden for every type with properties. If implementations of set_property don't emit property change notification explicitly, this will be done implicitly by the type system. However, if the notify signal is emitted explicitly, the type system will not emit it a second time.

    Parameters

    Returns void

  • Emitted at between the various phases of the print operation.

    Returns void

  • This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling g_closure_invalidate() on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, g_object_ref() and g_object_unref() are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

    Parameters

    Returns void

Methods - Inherited from GObject

  • Add a property to an interface; this is only useful for interfaces that are added to GObject-derived types. Adding a property to an interface forces all objects classes with that interface to have a compatible property. The compatible property could be a newly created GObject.ParamSpec, but normally g_object_class_override_property() will be used so that the object class only needs to provide an implementation and inherits the property description, default value, bounds, and so forth from the interface property.

    This function is meant to be called from the interface's default vtable initialization function (the class_init member of GObject.TypeInfo.) It must not be called after after class_init has been called for any object types implementing this interface.

    If pspec is a floating reference, it will be consumed.

    Parameters

    Returns void

  • Parameters

    • property_id: number

      the new property ID

    • name: string

      the name of a property registered in a parent class or in an interface of this class.

    Returns void

Interfaces

ConstructorProps
SignalSignatures