pub trait PrintOperationExt: 'static {
Show 67 methods fn cancel(&self); fn draw_page_finish(&self); fn default_page_setup(&self) -> Option<PageSetup>; fn embeds_page_setup(&self) -> bool; fn has_selection(&self) -> bool; fn n_pages_to_print(&self) -> i32; fn print_settings(&self) -> Option<PrintSettings>; fn status(&self) -> PrintStatus; fn status_string(&self) -> Option<GString>; fn supports_selection(&self) -> bool; fn is_finished(&self) -> bool; fn run(
        &self,
        action: PrintOperationAction,
        parent: Option<&impl IsA<Window>>
    ) -> Result<PrintOperationResult, Error>; fn set_allow_async(&self, allow_async: bool); fn set_current_page(&self, current_page: i32); fn set_custom_tab_label(&self, label: Option<&str>); fn set_default_page_setup(&self, default_page_setup: Option<&PageSetup>); fn set_defer_drawing(&self); fn set_embed_page_setup(&self, embed: bool); fn set_export_filename(&self, filename: impl AsRef<Path>); fn set_has_selection(&self, has_selection: bool); fn set_job_name(&self, job_name: &str); fn set_n_pages(&self, n_pages: i32); fn set_print_settings(&self, print_settings: Option<&PrintSettings>); fn set_show_progress(&self, show_progress: bool); fn set_support_selection(&self, support_selection: bool); fn set_track_print_status(&self, track_status: bool); fn set_unit(&self, unit: Unit); fn set_use_full_page(&self, full_page: bool); fn allows_async(&self) -> bool; fn current_page(&self) -> i32; fn custom_tab_label(&self) -> Option<GString>; fn export_filename(&self) -> Option<GString>; fn job_name(&self) -> Option<GString>; fn n_pages(&self) -> i32; fn shows_progress(&self) -> bool; fn tracks_print_status(&self) -> bool; fn unit(&self) -> Unit; fn uses_full_page(&self) -> bool; fn connect_begin_print<F: Fn(&Self, &PrintContext) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_create_custom_widget<F: Fn(&Self) -> Object + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_custom_widget_apply<F: Fn(&Self, &Widget) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_done<F: Fn(&Self, PrintOperationResult) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_draw_page<F: Fn(&Self, &PrintContext, i32) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_end_print<F: Fn(&Self, &PrintContext) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_paginate<F: Fn(&Self, &PrintContext) -> bool + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_preview<F: Fn(&Self, &PrintOperationPreview, &PrintContext, Option<&Window>) -> bool + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_request_page_setup<F: Fn(&Self, &PrintContext, i32, &PageSetup) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_status_changed<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_update_custom_widget<F: Fn(&Self, &Widget, &PageSetup, &PrintSettings) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_allow_async_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_current_page_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_custom_tab_label_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_default_page_setup_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_embed_page_setup_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_export_filename_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_has_selection_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_job_name_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_n_pages_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_n_pages_to_print_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_print_settings_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_show_progress_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_status_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_status_string_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_support_selection_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_track_print_status_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_unit_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_use_full_page_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Trait containing all PrintOperation methods.

Implementors

PrintOperation

Required Methods

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

Signalize that drawing of particular page is complete.

It is called after completion of page drawing (e.g. drawing in another thread). If 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 the default page setup, see set_default_page_setup().

Returns

the default page setup

Gets the value of property::PrintOperation::embed-page-setup property.

Returns

whether page setup selection combos are embedded

Gets the value of property::PrintOperation::has-selection property.

Returns

whether there is a selection

Returns the number of pages that will be printed.

Note that this value is set during print preparation phase (PrintStatus::Preparing), so this function should never be called before the data generation phase (PrintStatus::GeneratingData). You can connect to the signal::PrintOperation::status-changed signal and call n_pages_to_print() when print status is PrintStatus::GeneratingData. This is typically used to track the progress of print operation.

Returns

the number of pages that will be printed

Returns the current print settings.

Note that the return value is None until either set_print_settings() or run() have been called.

Returns

the current print settings of self.

Returns the status of the print operation. Also see status_string().

Returns

the status of the print operation

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

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

Returns

a string representation of the status of the print operation

Gets the value of property::PrintOperation::support-selection property.

Returns

whether the application supports print of selection

A convenience function to find out if the print operation is finished, either successfully (PrintStatus::Finished) or unsuccessfully (PrintStatus::FinishedAborted).

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

true, if the print operation is finished.

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 signal::PrintOperation::status-changed signal on self 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 set_allow_async() or set the property::PrintOperation::allow-async property the operation will run asynchronously if this is supported on the platform. The signal::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).

⚠️ The following code is in 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_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 run() can only be called once on a given PrintOperation.

action

the action to start

parent

Transient parent of the dialog

Returns

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

Sets whether the run() may return before the print operation is completed. Note that some platforms may not allow asynchronous operation.

allow_async

true to allow asynchronous operation

Sets the current page.

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

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

current_page

the current page, 0-based

Sets the label for the tab holding custom widgets.

label

the label to use, or None to use the default label

Makes default_page_setup the default page setup for self.

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

default_page_setup

a PageSetup, or None

Sets up the PrintOperation to wait for calling of 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.

Embed page size combo box and orientation combo box into page setup page. Selected page setup is stored as default page setup in PrintOperation.

embed

true to embed page setup selection in the GtkPrintUnixDialog

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

filename

the filename for the exported file

Implementors