package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gtk/Ocgtk_gtk/Gtk/Wrappers/Print_operation/index.html

Module Wrappers.Print_operation

type t = [ `print_operation | `object_ ] Gobject.obj
val new_ : unit -> t

Create a new PrintOperation

val set_use_full_page : t -> bool -> unit

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.

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

val set_unit : t -> Gtk_enums.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.

val set_track_print_status : t -> bool -> unit

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.

val set_support_selection : t -> bool -> unit

Sets whether selection is supported by `GtkPrintOperation`.

val set_show_progress : t -> bool -> unit

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

val set_print_settings : t -> [ `print_settings | `object_ ] Gobject.obj option -> unit

Sets the print settings for @op.

This is typically used to re-establish print settings from a previous print operation, see method@Gtk.PrintOperation.run.

val set_n_pages : t -> int -> unit

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 signal@Gtk.PrintOperation::begin-print signal handler.

Note that the page numbers passed to the signal@Gtk.PrintOperation::request-page-setup and signal@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.

val set_job_name : t -> string -> unit

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.

val set_has_selection : t -> bool -> unit

Sets whether there is a selection to print.

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

val set_export_filename : t -> string -> unit

Sets up the `GtkPrintOperation` 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.

val set_embed_page_setup : t -> bool -> unit

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

Selected page setup is stored as default page setup in `GtkPrintOperation`.

val set_defer_drawing : t -> unit

Sets up the `GtkPrintOperation` 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 [signal@Gtk.PrintOperation::draw-page] signal.

val set_default_page_setup : t -> [ `page_setup | `object_ ] Gobject.obj option -> unit

Makes @default_page_setup the default page setup for @op.

This page setup will be used by method@Gtk.PrintOperation.run, but it can be overridden on a per-page basis by connecting to the signal@Gtk.PrintOperation::request-page-setup signal.

val set_custom_tab_label : t -> string option -> unit

Sets the label for the tab holding custom widgets.

val set_current_page : t -> int -> unit

Sets the current page.

If this is called before method@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.

val set_allow_async : t -> bool -> unit

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

Note that some platforms may not allow asynchronous operation.

val run : t -> Gtk_enums.printoperationaction -> [ `window | `widget | `initially_unowned | `object_ ] Gobject.obj option -> (Gtk_enums.printoperationresult, GError.t) result

Runs the print operation.

Normally that this function does not return until the rendering of all pages is complete. You can connect to the signal@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 signal@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).

```c 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 `GtkPrintOperation`.

val is_finished : t -> bool

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

a print operation is finished if its status is either %GTK_PRINT_STATUS_FINISHED or %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.

val get_support_selection : t -> bool

Gets whether the application supports print of selection

val get_status_string : t -> 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 method@Gtk.PrintOperation.get_status to obtain a status value that is suitable for programmatic use.

val get_status : t -> Gtk_enums.printstatus

Returns the status of the print operation.

Also see method@Gtk.PrintOperation.get_status_string.

val get_print_settings : t -> [ `print_settings | `object_ ] Gobject.obj option

Returns the current print settings.

Note that the return value is %NULL until either method@Gtk.PrintOperation.set_print_settings or method@Gtk.PrintOperation.run have been called.

val get_n_pages_to_print : t -> int

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 signal@Gtk.PrintOperation::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.

val get_has_selection : t -> bool

Gets whether there is a selection.

val get_error : t -> (unit, GError.t) result

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

It can be called either after method@Gtk.PrintOperation.run returns, or in the signal@Gtk.PrintOperation::done signal handler.

The returned `GError` will contain more details on what went wrong.

val get_embed_page_setup : t -> bool

Gets whether page setup selection combos are embedded

val get_default_page_setup : t -> [ `page_setup | `object_ ] Gobject.obj

Returns the default page setup.

val draw_page_finish : t -> unit

Signal that drawing of particular page is complete.

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

val cancel : t -> unit

Cancels a running print operation.

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

val on_begin_print : ?after:bool -> t -> callback:(context:[ `print_context | `object_ ] Gobject.obj -> unit) -> Gobject.Signal.handler_id
val on_custom_widget_apply : ?after:bool -> t -> callback: (widget:[ `widget | `initially_unowned | `object_ ] Gobject.obj -> unit) -> Gobject.Signal.handler_id
val on_done_ : ?after:bool -> t -> callback:(result:Gtk_enums.printoperationresult -> unit) -> Gobject.Signal.handler_id
val on_draw_page : ?after:bool -> t -> callback: (context:[ `print_context | `object_ ] Gobject.obj -> page_nr:int -> unit) -> Gobject.Signal.handler_id
val on_end_print : ?after:bool -> t -> callback:(context:[ `print_context | `object_ ] Gobject.obj -> unit) -> Gobject.Signal.handler_id
val on_paginate : ?after:bool -> t -> callback:(context:[ `print_context | `object_ ] Gobject.obj -> bool) -> Gobject.Signal.handler_id
val on_preview : ?after:bool -> t -> callback: (preview:[ `print_operation_preview ] Gobject.obj -> context:[ `print_context | `object_ ] Gobject.obj -> parent: [ `window | `widget | `initially_unowned | `object_ ] Gobject.obj option -> bool) -> Gobject.Signal.handler_id
val on_request_page_setup : ?after:bool -> t -> callback: (context:[ `print_context | `object_ ] Gobject.obj -> page_nr:int -> setup:[ `page_setup | `object_ ] Gobject.obj -> unit) -> Gobject.Signal.handler_id
val on_status_changed : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_update_custom_widget : ?after:bool -> t -> callback: (widget:[ `widget | `initially_unowned | `object_ ] Gobject.obj -> setup:[ `page_setup | `object_ ] Gobject.obj -> settings:[ `print_settings | `object_ ] Gobject.obj -> unit) -> Gobject.Signal.handler_id