Gjsify LogoGjsify Logo

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 #GtkPrintOperation::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_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 gtk_print_operation_preview_render_page(), gtk_print_operation_preview_end_preview() and gtk_print_operation_preview_is_selected() are useful when implementing a print preview.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

Properties

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_PRINT_OPERATION_RESULT_IN_PROGRESS as the status, and emit the #GtkPrintOperation::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_PRINT_OPERATION_ACTION_EXPORT support asynchronous operation.

current_page: number

The current page in the document.

If this is set before gtk_print_operation_run(), the user will be able to select to print only the current page.

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

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.

default_page_setup: Gtk.PageSetup

The #GtkPageSetup used by default.

This page setup will be used by gtk_print_operation_run(), but it can be overridden on a per-page basis by connecting to the #GtkPrintOperation::request-page-setup signal.

embed_page_setup: boolean

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

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.

g_type_instance: TypeInstance
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.

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.

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 #GtkPrintOperation::begin-print signal hander.

Note that the page numbers passed to the #GtkPrintOperation::request-page-setup and #GtkPrintOperation::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.

n_pages_to_print: number

The number of pages that will be printed.

Note that this value is set during print preparation phase (%GTK_PRINT_STATUS_PREPARING), so this value should never be get before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA). You can connect to the #GtkPrintOperation::status-changed signal and call gtk_print_operation_get_n_pages_to_print() when print status is %GTK_PRINT_STATUS_GENERATING_DATA. This is typically used to track the progress of print operation.

parent_instance: GObject.Object
print_settings: Gtk.PrintSettings

The #GtkPrintSettings used for initializing the dialog.

Setting this property is typically used to re-establish print settings from a previous print operation, see gtk_print_operation_run().

show_progress: boolean

Determines whether to show a progress dialog during the print operation.

The status of the print operation.

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 #GtkStatusbar.

See the #GtkPrintOperation:status property for a status value that is suitable for programmatic use.

support_selection: boolean

If %TRUE, the print operation will support print of selection. This allows the print dialog to show a "Selection" button.

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.

unit: Gtk.Unit

The transformation for the cairo context obtained from #GtkPrintContext is set up in such a way that distances are measured in units of unit.

use_full_page: boolean

If %TRUE, the transformation for the cairo context obtained from #GtkPrintContext puts the origin at the top left corner of the page (which 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).

name: string

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 instance to be updated with the same value of the "active" property of the action #GObject instance.

    If flags contains %G_BINDING_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 #GBinding 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 can have multiple bindings.

    Parameters

    • source_property: string

      the property on source to bind

    • target: GObject.Object

      the target #GObject

    • target_property: string

      the property on target to bind

    • flags: BindingFlags

      flags to pass to #GBinding

    Returns Binding

  • 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

    • source_property: string

      the property on source to bind

    • target: GObject.Object

      the target #GObject

    • target_property: string

      the property on target to bind

    • flags: BindingFlags

      flags to pass to #GBinding

    • transform_to: TClosure<any, any>

      a #GClosure wrapping the transformation function from the source to the target, or %NULL to use the default

    • transform_from: TClosure<any, any>

      a #GClosure wrapping the transformation function from the target to the source, or %NULL to use the default

    Returns Binding

  • cancel(): void
  • Cancels a running print operation. This function may be called from a #GtkPrintOperation::begin-print, #GtkPrintOperation::paginate or #GtkPrintOperation::draw-page signal handler to stop the currently running print operation.

    Returns void

  • disconnect(id: number): void
  • draw_page_finish(): void
  • Signalize that drawing of particular page is complete.

    It is called after completion of page drawing (e.g. drawing in another thread). If gtk_print_operation_set_defer_drawing() was called before, then this function has to be called by application. In another case it is called by the library itself.

    Returns void

  • emit(sigName: "begin-print", context: Gtk.PrintContext, ...args: any[]): void
  • emit(sigName: "create-custom-widget", ...args: any[]): void
  • emit(sigName: "custom-widget-apply", widget: Gtk.Widget, ...args: any[]): void
  • emit(sigName: "done", result: Gtk.PrintOperationResult, ...args: any[]): void
  • emit(sigName: "draw-page", context: Gtk.PrintContext, page_nr: number, ...args: any[]): void
  • emit(sigName: "end-print", context: Gtk.PrintContext, ...args: any[]): void
  • emit(sigName: "paginate", context: Gtk.PrintContext, ...args: any[]): void
  • emit(sigName: "preview", preview: Gtk.PrintOperationPreview, context: Gtk.PrintContext, parent: Gtk.Window, ...args: any[]): void
  • emit(sigName: "request-page-setup", context: Gtk.PrintContext, page_nr: number, setup: Gtk.PageSetup, ...args: any[]): void
  • emit(sigName: "status-changed", ...args: any[]): void
  • emit(sigName: "update-custom-widget", widget: Gtk.Widget, setup: Gtk.PageSetup, settings: Gtk.PrintSettings, ...args: any[]): void
  • emit(sigName: "notify::allow-async", ...args: any[]): void
  • emit(sigName: "notify::current-page", ...args: any[]): void
  • emit(sigName: "notify::custom-tab-label", ...args: any[]): void
  • emit(sigName: "notify::default-page-setup", ...args: any[]): void
  • emit(sigName: "notify::embed-page-setup", ...args: any[]): void
  • emit(sigName: "notify::export-filename", ...args: any[]): void
  • emit(sigName: "notify::has-selection", ...args: any[]): void
  • emit(sigName: "notify::job-name", ...args: any[]): void
  • emit(sigName: "notify::n-pages", ...args: any[]): void
  • emit(sigName: "notify::n-pages-to-print", ...args: any[]): void
  • emit(sigName: "notify::print-settings", ...args: any[]): void
  • emit(sigName: "notify::show-progress", ...args: any[]): void
  • emit(sigName: "notify::status", ...args: any[]): void
  • emit(sigName: "notify::status-string", ...args: any[]): void
  • emit(sigName: "notify::support-selection", ...args: any[]): void
  • emit(sigName: "notify::track-print-status", ...args: any[]): void
  • emit(sigName: "notify::unit", ...args: any[]): void
  • emit(sigName: "notify::use-full-page", ...args: any[]): void
  • emit(sigName: string, ...args: any[]): void
  • end_preview(): void
  • force_floating(): void
  • This function is intended for #GObject implementations to re-enforce a [floating][floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling g_object_ref_sink().

    Returns void

  • freeze_notify(): 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::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

  • get_data(key?: string): object
  • Gets a named field from the objects table of associations (see g_object_set_data()).

    Parameters

    • Optional key: string

      name of the key for that association

    Returns object

  • get_embed_page_setup(): boolean
  • get_error(): void
  • Call this when the result of a print operation is %GTK_PRINT_OPERATION_RESULT_ERROR, either as returned by gtk_print_operation_run(), or in the #GtkPrintOperation::done signal handler. The returned #GError will contain more details on what went wrong.

    Returns void

  • get_has_selection(): boolean
  • get_n_pages_to_print(): number
  • Returns the number of pages that will be printed.

    Note that this value is set during print preparation phase (%GTK_PRINT_STATUS_PREPARING), so this function should never be called before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA). You can connect to the #GtkPrintOperation::status-changed signal and call gtk_print_operation_get_n_pages_to_print() when print status is %GTK_PRINT_STATUS_GENERATING_DATA. This is typically used to track the progress of print operation.

    Returns number

  • Returns the current print settings.

    Note that the return value is %NULL until either gtk_print_operation_set_print_settings() or gtk_print_operation_run() have been called.

    Returns Gtk.PrintSettings

  • get_property(property_name?: string, value?: any): void
  • Gets a property of an object.

    The value can be:

    • an empty #GValue initialized by %G_VALUE_INIT, which will be automatically initialized with the expected type of the property (since GLib 2.60)
    • a #GValue initialized with the expected type of the property
    • a #GValue 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 g_value_unset().

    Note that g_object_get_property() is really intended for language bindings, g_object_get() is much more convenient for C programming.

    Parameters

    • Optional property_name: string

      the name of the property to get

    • Optional value: any

      return location for the property value

    Returns void

  • get_qdata(quark: number): object
  • get_status_string(): string
  • 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 #GtkStatusbar.

    Use gtk_print_operation_get_status() to obtain a status value that is suitable for programmatic use.

    Returns string

  • get_support_selection(): boolean
  • getv(names: string[], values: any[]): void
  • 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

  • is_finished(): boolean
  • A convenience function to find out if the print operation is finished, either successfully (%GTK_PRINT_STATUS_FINISHED) or unsuccessfully (%GTK_PRINT_STATUS_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

  • is_floating(): boolean
  • is_selected(page_nr: number): boolean
  • notify(property_name: string): 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

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

      enum
    {
    PROP_0,
    PROP_FOO,
    PROP_LAST
    };

    static GParamSpec *properties[PROP_LAST];

    static void
    my_object_class_init (MyObjectClass *klass)
    {
    properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
    0, 100,
    50,
    G_PARAM_READWRITE);
    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

    • pspec: ParamSpec

      the #GParamSpec of a property installed on the class of object.

    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

  • 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

  • render_page(page_nr: number): void
  • Renders a page to the preview, using the print context that was passed to the #GtkPrintOperation::preview handler together with preview.

    A custom iprint preview should use this function in its ::expose handler 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, by first letting the user modify print settings in the print dialog, and then print the document.

    Normally that this function does not return until the rendering of all pages is complete. You can connect to the #GtkPrintOperation::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 call gtk_print_operation_set_allow_async() or set the #GtkPrintOperation:allow-async property the operation will run asynchronously if this is supported on the platform. The #GtkPrintOperation::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_widget_destroy), NULL);
    gtk_widget_show (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 #GtkPrintOperation.

    Parameters

    Returns Gtk.PrintOperationResult

  • run_dispose(): void
  • Releases all references to other objects. This can be used to break reference cycles.

    This function should only be called from object system implementations.

    Returns void

  • set_allow_async(allow_async: boolean): void
  • Sets whether the 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

  • set_current_page(current_page: number): void
  • Sets the current page.

    If this is called before gtk_print_operation_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

  • set_custom_tab_label(label: string): void
  • Sets the label for the tab holding custom widgets.

    Parameters

    • label: string

      the label to use, or %NULL to use the default label

    Returns void

  • set_data(key: string, data?: object): 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 #GQuark 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 #GQuark storage growing unbounded.

    Parameters

    • key: string

      name of the key

    • Optional data: object

      data to associate with that key

    Returns void

  • set_default_page_setup(default_page_setup: Gtk.PageSetup): void
  • Makes default_page_setup the default page setup for op.

    This page setup will be used by gtk_print_operation_run(), but it can be overridden on a per-page basis by connecting to the #GtkPrintOperation::request-page-setup signal.

    Parameters

    • default_page_setup: Gtk.PageSetup

      a #GtkPageSetup, or %NULL

    Returns void

  • set_defer_drawing(): void
  • Sets up the #GtkPrintOperation to wait for calling of gtk_print_operation_draw_page_finish() from application. It can be used for drawing page in another thread.

    This function must be called in the callback of “draw-page” signal.

    Returns void

  • set_embed_page_setup(embed: boolean): void
  • Embed page size combo box and orientation combo box into page setup page. Selected page setup is stored as default page setup in #GtkPrintOperation.

    Parameters

    • embed: boolean

      %TRUE to embed page setup selection in the #GtkPrintUnixDialog

    Returns void

  • set_export_filename(filename: string): void
  • Sets up the #GtkPrintOperation to generate a file instead of showing the print dialog. The indended 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

  • set_has_selection(has_selection: boolean): void
  • Sets whether there is a selection to print.

    Application has to set number of pages to which the selection will draw by gtk_print_operation_set_n_pages() in a callback of #GtkPrintOperation::begin-print.

    Parameters

    • has_selection: boolean

      %TRUE indicates that a selection exists

    Returns void

  • set_job_name(job_name: string): 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

  • set_n_pages(n_pages: number): 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 #GtkPrintOperation::begin-print signal hander.

    Note that the page numbers passed to the #GtkPrintOperation::request-page-setup and #GtkPrintOperation::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

  • Sets the print settings for op. This is typically used to re-establish print settings from a previous print operation, see gtk_print_operation_run().

    Parameters

    Returns void

  • set_property(property_name: string, value?: any): void
  • set_show_progress(show_progress: boolean): 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

  • set_support_selection(support_selection: boolean): void
  • Sets whether selection is supported by #GtkPrintOperation.

    Parameters

    • support_selection: boolean

      %TRUE to support selection

    Returns void

  • set_track_print_status(track_status: boolean): 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

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

    Parameters

    Returns void

  • set_use_full_page(full_page: boolean): void
  • 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 (which 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

    • full_page: boolean

      %TRUE to set up the #GtkPrintContext for the full page

    Returns void

  • steal_data(key?: string): object
  • Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

    Parameters

    • Optional key: string

      name of the key

    Returns object

  • steal_qdata(quark: number): object
  • 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 #GQuark, naming the user data pointer

    Returns object

  • thaw_notify(): void
  • 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::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

  • unref(): 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 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 instance. Use g_clear_object() for this.

    Returns void

  • vfunc_constructed(): void
  • vfunc_custom_widget_apply(widget: Gtk.Widget): void
  • vfunc_dispatch_properties_changed(n_pspecs: number, pspecs: ParamSpec): void
  • vfunc_dispose(): void
  • vfunc_end_preview(): void
  • vfunc_finalize(): void
  • vfunc_get_property(property_id: number, value?: any, pspec?: ParamSpec): void
  • vfunc_is_selected(page_nr: number): boolean
  • 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.

    virtual

    Parameters

    Returns void

  • vfunc_render_page(page_nr: number): void
  • Renders a page to the preview, using the print context that was passed to the #GtkPrintOperation::preview handler together with preview.

    A custom iprint preview should use this function in its ::expose handler to render the currently selected page.

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

    virtual

    Parameters

    • page_nr: number

      the page to render

    Returns void

  • vfunc_set_property(property_id: number, value?: any, pspec?: ParamSpec): void
  • vfunc_status_changed(): void
  • watch_closure(closure: TClosure<any, any>): 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

    • closure: TClosure<any, any>

      #GClosure to watch

    Returns void

  • compat_control(what: number, data: object): number
  • Find the #GParamSpec with the given name for an interface. Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().

    Parameters

    • g_iface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface

    • property_name: string

      name of a property to look up.

    Returns ParamSpec

  • 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 #GParamSpec, 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 #GTypeInfo.) 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

    • g_iface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface.

    • pspec: ParamSpec

      the #GParamSpec for the new property

    Returns void

  • Lists the properties of an interface.Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().

    Parameters

    • g_iface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface

    Returns ParamSpec[]

  • Creates a new instance of a #GObject subtype and sets its properties.

    Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY) which are not explicitly specified are set to their default values.

    Parameters

    • object_type: GType<unknown>

      the type id of the #GObject subtype to instantiate

    • parameters: GObject.Parameter[]

      an array of #GParameter

    Returns GObject.Object

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method