Class: Gtk::PrintOperation

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#allow_async=(allow_async) ⇒ TrueClass

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 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_PRINT_OPERATION_ACTION_EXPORT support asynchronous operation.

Parameters:

  • allow_async (TrueClass)

Returns:

  • (TrueClass)

    allow-async

  • (TrueClass)

    allow-async

#allow_async?TrueClass

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 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_PRINT_OPERATION_ACTION_EXPORT support asynchronous operation.

Returns:

  • (TrueClass)

    allow-async

#cancelnil

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

Returns:

  • (nil)

#current_pageInteger

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.

Returns:

  • (Integer)

    current-page

#current_page=(current_page) ⇒ Integer

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.

Parameters:

  • current_page (Integer)

Returns:

  • (Integer)

    current-page

  • (Integer)

    current-page

#custom_tab_labelString

Used as the label of the tab containing custom widgets. Note that this property may be ignored on some platforms.

If this is nil, GTK+ uses a default label.

Returns:

  • (String)

    custom-tab-label

#custom_tab_label=(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 nil, GTK+ uses a default label.

Parameters:

  • custom_tab_label (String)

Returns:

  • (String)

    custom-tab-label

  • (String)

    custom-tab-label

#default_page_setupGtk::PageSetup

The Gtk::PageSetup 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 Gtk::PrintOperation::request-page-setup signal.

Returns:

#default_page_setup=(default_page_setup) ⇒ Gtk::PageSetup

The Gtk::PageSetup 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 Gtk::PrintOperation::request-page-setup signal.

Parameters:

Returns:

#draw_page_finishnil

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:

  • (nil)

#embed_page_setupTrueClass

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

Returns:

  • (TrueClass)

    whether page setup selection combos are embedded

#embed_page_setup=(embed_page_setup) ⇒ TrueClass

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

Parameters:

  • embed_page_setup (TrueClass)

Returns:

  • (TrueClass)

    embed-page-setup

  • (TrueClass)

    embed-page-setup

#embed_page_setup?TrueClass

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

Returns:

  • (TrueClass)

    embed-page-setup

#errornil

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 Gtk::PrintOperation::done signal handler. The returned #GError will contain more details on what went wrong.

Returns:

  • (nil)

#export_filenameString

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)

    export-filename

#export_filename=(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.

Parameters:

  • export_filename (String)

Returns:

  • (String)

    export-filename

  • (String)

    export-filename

#has_selectionTrueClass

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

Returns:

  • (TrueClass)

    whether there is a selection

#has_selection=(has_selection) ⇒ TrueClass

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.

Parameters:

  • has_selection (TrueClass)

Returns:

  • (TrueClass)

    has-selection

  • (TrueClass)

    has-selection

#has_selection?TrueClass

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:

  • (TrueClass)

    has-selection

#is_finishedTrueClass

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:

  • (TrueClass)

    true, if the print operation is finished.

#job_nameString

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)

    job-name

#job_name=(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.

Parameters:

  • job_name (String)

Returns:

  • (String)

    job-name

  • (String)

    job-name

#n_pagesInteger

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

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:

  • (Integer)

    n-pages

#n_pages=(n_pages) ⇒ Integer

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

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 (Integer)

Returns:

  • (Integer)

    n-pages

  • (Integer)

    n-pages

#n_pages_to_printInteger

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

Returns:

  • (Integer)

    n-pages-to-print

#n_pages_to_print=(n_pages_to_print) ⇒ Integer

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

Parameters:

  • n_pages_to_print (Integer)

Returns:

  • (Integer)

    n-pages-to-print

  • (Integer)

    n-pages-to-print

#newGtk::PrintOperation

Creates a new Gtk::PrintOperation.

Returns:

The Gtk::PrintSettings 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().

Returns:

The Gtk::PrintSettings 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().

Parameters:

Returns:

#run(action, parent) ⇒ Gtk::PrintOperationResult

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 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 call gtk_print_operation_set_allow_async() or 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_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 Gtk::PrintOperation.

Parameters:

Returns:

  • (Gtk::PrintOperationResult)

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

#set_defer_drawingnil

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

  • (nil)

#show_progress=(show_progress) ⇒ TrueClass

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

Parameters:

  • show_progress (TrueClass)

Returns:

  • (TrueClass)

    show-progress

  • (TrueClass)

    show-progress

#show_progress?TrueClass

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

Returns:

  • (TrueClass)

    show-progress

#statusGtk::PrintStatus

The status of the print operation.

Returns:

#status=(status) ⇒ Gtk::PrintStatus

The status of the print operation.

Parameters:

Returns:

#status_stringString

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)

    status-string

#status_string=(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.

Parameters:

  • status_string (String)

Returns:

  • (String)

    status-string

  • (String)

    status-string

#support_selectionTrueClass

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

Returns:

  • (TrueClass)

    whether the application supports print of selection

#support_selection=(support_selection) ⇒ TrueClass

If true, the print operation will support print of selection. This allows the print dialog to show a “Selection” button.

Parameters:

  • support_selection (TrueClass)

Returns:

  • (TrueClass)

    support-selection

  • (TrueClass)

    support-selection

#support_selection?TrueClass

If true, the print operation will support print of selection. This allows the print dialog to show a “Selection” button.

Returns:

  • (TrueClass)

    support-selection

#track_print_status=(track_print_status) ⇒ TrueClass

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.

Parameters:

  • track_print_status (TrueClass)

Returns:

  • (TrueClass)

    track-print-status

  • (TrueClass)

    track-print-status

#track_print_status?TrueClass

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:

  • (TrueClass)

    track-print-status

#unitGtk::Unit

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

Returns:

#unit=(unit) ⇒ Gtk::Unit

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

Parameters:

Returns:

#use_full_page=(use_full_page) ⇒ TrueClass

If true, the transformation for the cairo context obtained from Gtk::PrintContext 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:

  • use_full_page (TrueClass)

Returns:

  • (TrueClass)

    use-full-page

  • (TrueClass)

    use-full-page

#use_full_page?TrueClass

If true, the transformation for the cairo context obtained from Gtk::PrintContext 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).

Returns:

  • (TrueClass)

    use-full-page