gi-gtk-3.0.32: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.PrintOperation

Description

GtkPrintOperation is the high-level, portable printing API. It looks a bit different than other GTK+ dialogs such as the FileChooser, 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 printOperationNew when the user selects to print. Then you set some properties on it, e.g. the page size, any PrintSettings from previous print operations, the number of pages, the current page, etc.

Then you start the print operation by calling printOperationRun. 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 PrintOperation, the main one being drawPage, which you are supposed to catch and render the page on the provided PrintContext using Cairo.

The high-level printing API

C code

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 printOperationPreviewRenderPage, printOperationPreviewEndPreview and printOperationPreviewIsSelected are useful when implementing a print preview.

Synopsis

Exported types

class (GObject o, IsDescendantOf PrintOperation o) => IsPrintOperation o Source #

Type class for types which can be safely cast to PrintOperation, for instance with toPrintOperation.

Instances

Instances details
(GObject o, IsDescendantOf PrintOperation o) => IsPrintOperation o Source # 
Instance details

Defined in GI.Gtk.Objects.PrintOperation

toPrintOperation :: (MonadIO m, IsPrintOperation o) => o -> m PrintOperation Source #

Cast to PrintOperation, for types for which this is known to be safe. For general casts, use castTo.

Methods

Overloaded methods

cancel

printOperationCancel Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m () 

Cancels a running print operation. This function may be called from a beginPrint, paginate or drawPage signal handler to stop the currently running print operation.

Since: 2.10

drawPageFinish

printOperationDrawPageFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m () 

Signalize that drawing of particular page is complete.

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

Since: 2.16

getDefaultPageSetup

printOperationGetDefaultPageSetup Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m PageSetup

Returns: the default page setup

Returns the default page setup, see printOperationSetDefaultPageSetup.

Since: 2.10

getEmbedPageSetup

printOperationGetEmbedPageSetup Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m Bool

Returns: whether page setup selection combos are embedded

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

Since: 2.18

getError

printOperationGetError Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m ()

(Can throw GError)

Call this when the result of a print operation is PrintOperationResultError, either as returned by printOperationRun, or in the done signal handler. The returned GError will contain more details on what went wrong.

Since: 2.10

getHasSelection

printOperationGetHasSelection Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m Bool

Returns: whether there is a selection

Gets the value of PrintOperation:has-selection property.

Since: 2.18

getNPagesToPrint

printOperationGetNPagesToPrint Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m Int32

Returns: the number of pages that will be printed

Returns the number of pages that will be printed.

Note that this value is set during print preparation phase (PrintStatusPreparing), so this function should never be called before the data generation phase (PrintStatusGeneratingData). You can connect to the statusChanged signal and call printOperationGetNPagesToPrint when print status is PrintStatusGeneratingData. This is typically used to track the progress of print operation.

Since: 2.18

getPrintSettings

printOperationGetPrintSettings Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m PrintSettings

Returns: the current print settings of op.

Returns the current print settings.

Note that the return value is Nothing until either printOperationSetPrintSettings or printOperationRun have been called.

Since: 2.10

getStatus

printOperationGetStatus Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m PrintStatus

Returns: the status of the print operation

Returns the status of the print operation. Also see printOperationGetStatusString.

Since: 2.10

getStatusString

printOperationGetStatusString Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m Text

Returns: a string representation of 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 printOperationGetStatus to obtain a status value that is suitable for programmatic use.

Since: 2.10

getSupportSelection

printOperationGetSupportSelection Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m Bool

Returns: whether the application supports print of selection

Gets the value of PrintOperation:support-selection property.

Since: 2.18

isFinished

printOperationIsFinished Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m Bool

Returns: True, if the print operation is finished.

A convenience function to find out if the print operation is finished, either successfully (PrintStatusFinished) or unsuccessfully (PrintStatusFinishedAborted).

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.

Since: 2.10

new

printOperationNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m PrintOperation

Returns: a new PrintOperation

Creates a new PrintOperation.

Since: 2.10

run

printOperationRun Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a, IsWindow b) 
=> a

op: a PrintOperation

-> PrintOperationAction

action: the action to start

-> Maybe b

parent: Transient parent of the dialog

-> m PrintOperationResult

Returns: the result of the print operation. A return value of PrintOperationResultApply indicates that the printing was completed successfully. In this case, it is a good idea to obtain the used print settings with printOperationGetPrintSettings and store them for reuse with the next print operation. A value of PrintOperationResultInProgress means the operation is running asynchronously, and will emit the done signal when done. (Can throw GError)

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 statusChanged 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 printOperationSetAllowAsync or set the PrintOperation:allow-async property the operation will run asynchronously if this is supported on the platform. The 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 code

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 printOperationRun can only be called once on a given PrintOperation.

Since: 2.10

setAllowAsync

printOperationSetAllowAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Bool

allowAsync: True to allow asynchronous operation

-> m () 

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

Since: 2.10

setCurrentPage

printOperationSetCurrentPage Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Int32

currentPage: the current page, 0-based

-> m () 

Sets the current page.

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

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

Since: 2.10

setCustomTabLabel

printOperationSetCustomTabLabel Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Maybe Text

label: the label to use, or Nothing to use the default label

-> m () 

Sets the label for the tab holding custom widgets.

Since: 2.10

setDefaultPageSetup

printOperationSetDefaultPageSetup Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a, IsPageSetup b) 
=> a

op: a PrintOperation

-> Maybe b

defaultPageSetup: a PageSetup, or Nothing

-> m () 

Makes defaultPageSetup the default page setup for op.

This page setup will be used by printOperationRun, but it can be overridden on a per-page basis by connecting to the requestPageSetup signal.

Since: 2.10

setDeferDrawing

printOperationSetDeferDrawing Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> m () 

Sets up the PrintOperation to wait for calling of printOperationDrawPageFinish from application. It can be used for drawing page in another thread.

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

Since: 2.16

setEmbedPageSetup

printOperationSetEmbedPageSetup Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Bool

embed: True to embed page setup selection in the GtkPrintUnixDialog

-> m () 

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

Since: 2.18

setExportFilename

printOperationSetExportFilename Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> [Char]

filename: the filename for the exported file

-> m () 

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.

Since: 2.10

setHasSelection

printOperationSetHasSelection Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Bool

hasSelection: True indicates that a selection exists

-> m () 

Sets whether there is a selection to print.

Application has to set number of pages to which the selection will draw by printOperationSetNPages in a callback of beginPrint.

Since: 2.18

setJobName

printOperationSetJobName Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Text

jobName: a string that identifies the print job

-> m () 

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.

Since: 2.10

setNPages

printOperationSetNPages Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Int32

nPages: the number of pages

-> m () 

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

Note that the page numbers passed to the requestPageSetup and drawPage signals are 0-based, i.e. if the user chooses to print all pages, the last drawPage signal will be for page nPages - 1.

Since: 2.10

setPrintSettings

printOperationSetPrintSettings Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a, IsPrintSettings b) 
=> a

op: a PrintOperation

-> Maybe b

printSettings: PrintSettings

-> m () 

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

Since: 2.10

setShowProgress

printOperationSetShowProgress Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Bool

showProgress: True to show a progress dialog

-> m () 

If showProgress is True, the print operation will show a progress dialog during the print operation.

Since: 2.10

setSupportSelection

printOperationSetSupportSelection Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Bool

supportSelection: True to support selection

-> m () 

Sets whether selection is supported by PrintOperation.

Since: 2.18

setTrackPrintStatus

printOperationSetTrackPrintStatus Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Bool

trackStatus: True to track status after printing

-> m () 

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.

Since: 2.10

setUnit

printOperationSetUnit Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Unit

unit: the unit to use

-> m () 

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

Since: 2.10

setUseFullPage

printOperationSetUseFullPage Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) 
=> a

op: a PrintOperation

-> Bool

fullPage: True to set up the PrintContext for the full page

-> m () 

If fullPage is True, the transformation for the cairo context obtained from 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).

Since: 2.10

Properties

allowAsync

Determines whether the print operation may run asynchronously or not.

Some systems don't support asynchronous printing, but those that do will return PrintOperationResultInProgress as the status, and emit the 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 PrintOperationActionExport support asynchronous operation.

Since: 2.10

constructPrintOperationAllowAsync :: IsPrintOperation o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “allow-async” property. This is rarely needed directly, but it is used by new.

getPrintOperationAllowAsync :: (MonadIO m, IsPrintOperation o) => o -> m Bool Source #

Get the value of the “allow-async” property. When overloading is enabled, this is equivalent to

get printOperation #allowAsync

setPrintOperationAllowAsync :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m () Source #

Set the value of the “allow-async” property. When overloading is enabled, this is equivalent to

set printOperation [ #allowAsync := value ]

currentPage

The current page in the document.

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

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

Since: 2.10

constructPrintOperationCurrentPage :: IsPrintOperation o => Int32 -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “current-page” property. This is rarely needed directly, but it is used by new.

getPrintOperationCurrentPage :: (MonadIO m, IsPrintOperation o) => o -> m Int32 Source #

Get the value of the “current-page” property. When overloading is enabled, this is equivalent to

get printOperation #currentPage

setPrintOperationCurrentPage :: (MonadIO m, IsPrintOperation o) => o -> Int32 -> m () Source #

Set the value of the “current-page” property. When overloading is enabled, this is equivalent to

set printOperation [ #currentPage := value ]

customTabLabel

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

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

Since: 2.10

clearPrintOperationCustomTabLabel :: (MonadIO m, IsPrintOperation o) => o -> m () Source #

Set the value of the “custom-tab-label” property to Nothing. When overloading is enabled, this is equivalent to

clear #customTabLabel

constructPrintOperationCustomTabLabel :: IsPrintOperation o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “custom-tab-label” property. This is rarely needed directly, but it is used by new.

getPrintOperationCustomTabLabel :: (MonadIO m, IsPrintOperation o) => o -> m (Maybe Text) Source #

Get the value of the “custom-tab-label” property. When overloading is enabled, this is equivalent to

get printOperation #customTabLabel

setPrintOperationCustomTabLabel :: (MonadIO m, IsPrintOperation o) => o -> Text -> m () Source #

Set the value of the “custom-tab-label” property. When overloading is enabled, this is equivalent to

set printOperation [ #customTabLabel := value ]

defaultPageSetup

The PageSetup used by default.

This page setup will be used by printOperationRun, but it can be overridden on a per-page basis by connecting to the requestPageSetup signal.

Since: 2.10

clearPrintOperationDefaultPageSetup :: (MonadIO m, IsPrintOperation o) => o -> m () Source #

Set the value of the “default-page-setup” property to Nothing. When overloading is enabled, this is equivalent to

clear #defaultPageSetup

constructPrintOperationDefaultPageSetup :: (IsPrintOperation o, IsPageSetup a) => a -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “default-page-setup” property. This is rarely needed directly, but it is used by new.

getPrintOperationDefaultPageSetup :: (MonadIO m, IsPrintOperation o) => o -> m PageSetup Source #

Get the value of the “default-page-setup” property. When overloading is enabled, this is equivalent to

get printOperation #defaultPageSetup

setPrintOperationDefaultPageSetup :: (MonadIO m, IsPrintOperation o, IsPageSetup a) => o -> a -> m () Source #

Set the value of the “default-page-setup” property. When overloading is enabled, this is equivalent to

set printOperation [ #defaultPageSetup := value ]

embedPageSetup

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

Since: 2.18

constructPrintOperationEmbedPageSetup :: IsPrintOperation o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “embed-page-setup” property. This is rarely needed directly, but it is used by new.

getPrintOperationEmbedPageSetup :: (MonadIO m, IsPrintOperation o) => o -> m Bool Source #

Get the value of the “embed-page-setup” property. When overloading is enabled, this is equivalent to

get printOperation #embedPageSetup

setPrintOperationEmbedPageSetup :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m () Source #

Set the value of the “embed-page-setup” property. When overloading is enabled, this is equivalent to

set printOperation [ #embedPageSetup := value ]

exportFilename

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.

Since: 2.10

clearPrintOperationExportFilename :: (MonadIO m, IsPrintOperation o) => o -> m () Source #

Set the value of the “export-filename” property to Nothing. When overloading is enabled, this is equivalent to

clear #exportFilename

constructPrintOperationExportFilename :: IsPrintOperation o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “export-filename” property. This is rarely needed directly, but it is used by new.

getPrintOperationExportFilename :: (MonadIO m, IsPrintOperation o) => o -> m (Maybe Text) Source #

Get the value of the “export-filename” property. When overloading is enabled, this is equivalent to

get printOperation #exportFilename

setPrintOperationExportFilename :: (MonadIO m, IsPrintOperation o) => o -> Text -> m () Source #

Set the value of the “export-filename” property. When overloading is enabled, this is equivalent to

set printOperation [ #exportFilename := value ]

hasSelection

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.

Since: 2.18

constructPrintOperationHasSelection :: IsPrintOperation o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “has-selection” property. This is rarely needed directly, but it is used by new.

getPrintOperationHasSelection :: (MonadIO m, IsPrintOperation o) => o -> m Bool Source #

Get the value of the “has-selection” property. When overloading is enabled, this is equivalent to

get printOperation #hasSelection

setPrintOperationHasSelection :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m () Source #

Set the value of the “has-selection” property. When overloading is enabled, this is equivalent to

set printOperation [ #hasSelection := value ]

jobName

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.

Since: 2.10

constructPrintOperationJobName :: IsPrintOperation o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “job-name” property. This is rarely needed directly, but it is used by new.

getPrintOperationJobName :: (MonadIO m, IsPrintOperation o) => o -> m (Maybe Text) Source #

Get the value of the “job-name” property. When overloading is enabled, this is equivalent to

get printOperation #jobName

setPrintOperationJobName :: (MonadIO m, IsPrintOperation o) => o -> Text -> m () Source #

Set the value of the “job-name” property. When overloading is enabled, this is equivalent to

set printOperation [ #jobName := value ]

nPages

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

Note that the page numbers passed to the requestPageSetup and drawPage signals are 0-based, i.e. if the user chooses to print all pages, the last drawPage signal will be for page nPages - 1.

Since: 2.10

constructPrintOperationNPages :: IsPrintOperation o => Int32 -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “n-pages” property. This is rarely needed directly, but it is used by new.

getPrintOperationNPages :: (MonadIO m, IsPrintOperation o) => o -> m Int32 Source #

Get the value of the “n-pages” property. When overloading is enabled, this is equivalent to

get printOperation #nPages

setPrintOperationNPages :: (MonadIO m, IsPrintOperation o) => o -> Int32 -> m () Source #

Set the value of the “n-pages” property. When overloading is enabled, this is equivalent to

set printOperation [ #nPages := value ]

nPagesToPrint

The number of pages that will be printed.

Note that this value is set during print preparation phase (PrintStatusPreparing), so this value should never be get before the data generation phase (PrintStatusGeneratingData). You can connect to the statusChanged signal and call printOperationGetNPagesToPrint when print status is PrintStatusGeneratingData. This is typically used to track the progress of print operation.

Since: 2.18

getPrintOperationNPagesToPrint :: (MonadIO m, IsPrintOperation o) => o -> m Int32 Source #

Get the value of the “n-pages-to-print” property. When overloading is enabled, this is equivalent to

get printOperation #nPagesToPrint

printSettings

The PrintSettings used for initializing the dialog.

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

Since: 2.10

clearPrintOperationPrintSettings :: (MonadIO m, IsPrintOperation o) => o -> m () Source #

Set the value of the “print-settings” property to Nothing. When overloading is enabled, this is equivalent to

clear #printSettings

constructPrintOperationPrintSettings :: (IsPrintOperation o, IsPrintSettings a) => a -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “print-settings” property. This is rarely needed directly, but it is used by new.

getPrintOperationPrintSettings :: (MonadIO m, IsPrintOperation o) => o -> m PrintSettings Source #

Get the value of the “print-settings” property. When overloading is enabled, this is equivalent to

get printOperation #printSettings

setPrintOperationPrintSettings :: (MonadIO m, IsPrintOperation o, IsPrintSettings a) => o -> a -> m () Source #

Set the value of the “print-settings” property. When overloading is enabled, this is equivalent to

set printOperation [ #printSettings := value ]

showProgress

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

Since: 2.10

constructPrintOperationShowProgress :: IsPrintOperation o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “show-progress” property. This is rarely needed directly, but it is used by new.

getPrintOperationShowProgress :: (MonadIO m, IsPrintOperation o) => o -> m Bool Source #

Get the value of the “show-progress” property. When overloading is enabled, this is equivalent to

get printOperation #showProgress

setPrintOperationShowProgress :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m () Source #

Set the value of the “show-progress” property. When overloading is enabled, this is equivalent to

set printOperation [ #showProgress := value ]

status

The status of the print operation.

Since: 2.10

getPrintOperationStatus :: (MonadIO m, IsPrintOperation o) => o -> m PrintStatus Source #

Get the value of the “status” property. When overloading is enabled, this is equivalent to

get printOperation #status

statusString

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.

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

Since: 2.10

getPrintOperationStatusString :: (MonadIO m, IsPrintOperation o) => o -> m Text Source #

Get the value of the “status-string” property. When overloading is enabled, this is equivalent to

get printOperation #statusString

supportSelection

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

Since: 2.18

constructPrintOperationSupportSelection :: IsPrintOperation o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “support-selection” property. This is rarely needed directly, but it is used by new.

getPrintOperationSupportSelection :: (MonadIO m, IsPrintOperation o) => o -> m Bool Source #

Get the value of the “support-selection” property. When overloading is enabled, this is equivalent to

get printOperation #supportSelection

setPrintOperationSupportSelection :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m () Source #

Set the value of the “support-selection” property. When overloading is enabled, this is equivalent to

set printOperation [ #supportSelection := value ]

trackPrintStatus

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.

Since: 2.10

constructPrintOperationTrackPrintStatus :: IsPrintOperation o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “track-print-status” property. This is rarely needed directly, but it is used by new.

getPrintOperationTrackPrintStatus :: (MonadIO m, IsPrintOperation o) => o -> m Bool Source #

Get the value of the “track-print-status” property. When overloading is enabled, this is equivalent to

get printOperation #trackPrintStatus

setPrintOperationTrackPrintStatus :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m () Source #

Set the value of the “track-print-status” property. When overloading is enabled, this is equivalent to

set printOperation [ #trackPrintStatus := value ]

unit

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

Since: 2.10

constructPrintOperationUnit :: IsPrintOperation o => Unit -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “unit” property. This is rarely needed directly, but it is used by new.

getPrintOperationUnit :: (MonadIO m, IsPrintOperation o) => o -> m Unit Source #

Get the value of the “unit” property. When overloading is enabled, this is equivalent to

get printOperation #unit

setPrintOperationUnit :: (MonadIO m, IsPrintOperation o) => o -> Unit -> m () Source #

Set the value of the “unit” property. When overloading is enabled, this is equivalent to

set printOperation [ #unit := value ]

useFullPage

If True, the transformation for the cairo context obtained from 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).

Since: 2.10

constructPrintOperationUseFullPage :: IsPrintOperation o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “use-full-page” property. This is rarely needed directly, but it is used by new.

getPrintOperationUseFullPage :: (MonadIO m, IsPrintOperation o) => o -> m Bool Source #

Get the value of the “use-full-page” property. When overloading is enabled, this is equivalent to

get printOperation #useFullPage

setPrintOperationUseFullPage :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m () Source #

Set the value of the “use-full-page” property. When overloading is enabled, this is equivalent to

set printOperation [ #useFullPage := value ]

Signals

beginPrint

type C_PrintOperationBeginPrintCallback = Ptr () -> Ptr PrintContext -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationBeginPrintCallback Source #

Arguments

 = PrintContext

context: the PrintContext for the current operation

-> IO () 

Emitted after the user has finished changing print settings in the dialog, before the actual rendering starts.

A typical use for beginPrint is to use the parameters from the PrintContext and paginate the document accordingly, and then set the number of pages with printOperationSetNPages.

Since: 2.10

afterPrintOperationBeginPrint :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationBeginPrintCallback -> m SignalHandlerId Source #

Connect a signal handler for the beginPrint signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #beginPrint callback

onPrintOperationBeginPrint :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationBeginPrintCallback -> m SignalHandlerId Source #

Connect a signal handler for the beginPrint signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #beginPrint callback

createCustomWidget

type C_PrintOperationCreateCustomWidgetCallback = Ptr () -> Ptr () -> IO (Ptr Object) Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationCreateCustomWidgetCallback Source #

Arguments

 = IO Object

Returns: A custom widget that gets embedded in the print dialog, or Nothing

Emitted when displaying the print dialog. If you return a widget in a handler for this signal it will be added to a custom tab in the print dialog. You typically return a container widget with multiple widgets in it.

The print dialog owns the returned widget, and its lifetime is not controlled by the application. However, the widget is guaranteed to stay around until the customWidgetApply signal is emitted on the operation. Then you can read out any information you need from the widgets.

Since: 2.10

afterPrintOperationCreateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationCreateCustomWidgetCallback -> m SignalHandlerId Source #

Connect a signal handler for the createCustomWidget signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #createCustomWidget callback

onPrintOperationCreateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationCreateCustomWidgetCallback -> m SignalHandlerId Source #

Connect a signal handler for the createCustomWidget signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #createCustomWidget callback

customWidgetApply

type C_PrintOperationCustomWidgetApplyCallback = Ptr () -> Ptr Widget -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationCustomWidgetApplyCallback Source #

Arguments

 = Widget

widget: the custom widget added in create-custom-widget

-> IO () 

Emitted right before beginPrint if you added a custom widget in the createCustomWidget handler. When you get this signal you should read the information from the custom widgets, as the widgets are not guaraneed to be around at a later time.

Since: 2.10

afterPrintOperationCustomWidgetApply :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationCustomWidgetApplyCallback -> m SignalHandlerId Source #

Connect a signal handler for the customWidgetApply signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #customWidgetApply callback

onPrintOperationCustomWidgetApply :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationCustomWidgetApplyCallback -> m SignalHandlerId Source #

Connect a signal handler for the customWidgetApply signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #customWidgetApply callback

done

type C_PrintOperationDoneCallback = Ptr () -> CUInt -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationDoneCallback Source #

Arguments

 = PrintOperationResult

result: the result of the print operation

-> IO () 

Emitted when the print operation run has finished doing everything required for printing.

result gives you information about what happened during the run. If result is PrintOperationResultError then you can call printOperationGetError for more information.

If you enabled print status tracking then printOperationIsFinished may still return False after done was emitted.

Since: 2.10

afterPrintOperationDone :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationDoneCallback -> m SignalHandlerId Source #

Connect a signal handler for the done signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #done callback

onPrintOperationDone :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationDoneCallback -> m SignalHandlerId Source #

Connect a signal handler for the done signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #done callback

drawPage

type C_PrintOperationDrawPageCallback = Ptr () -> Ptr PrintContext -> Int32 -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationDrawPageCallback Source #

Arguments

 = PrintContext

context: the PrintContext for the current operation

-> Int32

pageNr: the number of the currently printed page (0-based)

-> IO () 

Emitted for every page that is printed. The signal handler must render the pageNr's page onto the cairo context obtained from context using printContextGetCairoContext.

C code

static void
draw_page (GtkPrintOperation *operation,
           GtkPrintContext   *context,
           gint               page_nr,
           gpointer           user_data)
{
  cairo_t *cr;
  PangoLayout *layout;
  gdouble width, text_height;
  gint layout_height;
  PangoFontDescription *desc;
  
  cr = gtk_print_context_get_cairo_context (context);
  width = gtk_print_context_get_width (context);
  
  cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);
  
  cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
  cairo_fill (cr);
  
  layout = gtk_print_context_create_pango_layout (context);
  
  desc = pango_font_description_from_string ("sans 14");
  pango_layout_set_font_description (layout, desc);
  pango_font_description_free (desc);
  
  pango_layout_set_text (layout, "some text", -1);
  pango_layout_set_width (layout, width * PANGO_SCALE);
  pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
     		      
  pango_layout_get_size (layout, NULL, &layout_height);
  text_height = (gdouble)layout_height / PANGO_SCALE;
  
  cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
  pango_cairo_show_layout (cr, layout);
  
  g_object_unref (layout);
}

Use printOperationSetUseFullPage and printOperationSetUnit before starting the print operation to set up the transformation of the cairo context according to your needs.

Since: 2.10

afterPrintOperationDrawPage :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationDrawPageCallback -> m SignalHandlerId Source #

Connect a signal handler for the drawPage signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #drawPage callback

onPrintOperationDrawPage :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationDrawPageCallback -> m SignalHandlerId Source #

Connect a signal handler for the drawPage signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #drawPage callback

endPrint

type C_PrintOperationEndPrintCallback = Ptr () -> Ptr PrintContext -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationEndPrintCallback Source #

Arguments

 = PrintContext

context: the PrintContext for the current operation

-> IO () 

Emitted after all pages have been rendered. A handler for this signal can clean up any resources that have been allocated in the beginPrint handler.

Since: 2.10

afterPrintOperationEndPrint :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationEndPrintCallback -> m SignalHandlerId Source #

Connect a signal handler for the endPrint signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #endPrint callback

onPrintOperationEndPrint :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationEndPrintCallback -> m SignalHandlerId Source #

Connect a signal handler for the endPrint signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #endPrint callback

paginate

type C_PrintOperationPaginateCallback = Ptr () -> Ptr PrintContext -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationPaginateCallback Source #

Arguments

 = PrintContext

context: the PrintContext for the current operation

-> IO Bool

Returns: True if pagination is complete

Emitted after the beginPrint signal, but before the actual rendering starts. It keeps getting emitted until a connected signal handler returns True.

The paginate signal is intended to be used for paginating a document in small chunks, to avoid blocking the user interface for a long time. The signal handler should update the number of pages using printOperationSetNPages, and return True if the document has been completely paginated.

If you don't need to do pagination in chunks, you can simply do it all in the beginPrint handler, and set the number of pages from there.

Since: 2.10

afterPrintOperationPaginate :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationPaginateCallback -> m SignalHandlerId Source #

Connect a signal handler for the paginate signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #paginate callback

onPrintOperationPaginate :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationPaginateCallback -> m SignalHandlerId Source #

Connect a signal handler for the paginate signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #paginate callback

preview

type C_PrintOperationPreviewCallback = Ptr () -> Ptr PrintOperationPreview -> Ptr PrintContext -> Ptr Window -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationPreviewCallback Source #

Arguments

 = PrintOperationPreview

preview: the PrintOperationPreview for the current operation

-> PrintContext

context: the PrintContext that will be used

-> Maybe Window

parent: the Window to use as window parent, or Nothing

-> IO Bool

Returns: True if the listener wants to take over control of the preview

Gets emitted when a preview is requested from the native dialog.

The default handler for this signal uses an external viewer application to preview.

To implement a custom print preview, an application must return True from its handler for this signal. In order to use the provided context for the preview implementation, it must be given a suitable cairo context with printContextSetCairoContext.

The custom preview implementation can use printOperationPreviewIsSelected and printOperationPreviewRenderPage to find pages which are selected for print and render them. The preview must be finished by calling printOperationPreviewEndPreview (typically in response to the user clicking a close button).

Since: 2.10

afterPrintOperationPreview :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationPreviewCallback -> m SignalHandlerId Source #

Connect a signal handler for the preview signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #preview callback

onPrintOperationPreview :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationPreviewCallback -> m SignalHandlerId Source #

Connect a signal handler for the preview signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #preview callback

requestPageSetup

type C_PrintOperationRequestPageSetupCallback = Ptr () -> Ptr PrintContext -> Int32 -> Ptr PageSetup -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationRequestPageSetupCallback Source #

Arguments

 = PrintContext

context: the PrintContext for the current operation

-> Int32

pageNr: the number of the currently printed page (0-based)

-> PageSetup

setup: the PageSetup

-> IO () 

Emitted once for every page that is printed, to give the application a chance to modify the page setup. Any changes done to setup will be in force only for printing this page.

Since: 2.10

afterPrintOperationRequestPageSetup :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationRequestPageSetupCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestPageSetup signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #requestPageSetup callback

onPrintOperationRequestPageSetup :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationRequestPageSetupCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestPageSetup signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #requestPageSetup callback

statusChanged

type C_PrintOperationStatusChangedCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationStatusChangedCallback = IO () Source #

Emitted at between the various phases of the print operation. See PrintStatus for the phases that are being discriminated. Use printOperationGetStatus to find out the current status.

Since: 2.10

afterPrintOperationStatusChanged :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationStatusChangedCallback -> m SignalHandlerId Source #

Connect a signal handler for the statusChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #statusChanged callback

onPrintOperationStatusChanged :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationStatusChangedCallback -> m SignalHandlerId Source #

Connect a signal handler for the statusChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #statusChanged callback

updateCustomWidget

type C_PrintOperationUpdateCustomWidgetCallback = Ptr () -> Ptr Widget -> Ptr PageSetup -> Ptr PrintSettings -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type PrintOperationUpdateCustomWidgetCallback Source #

Arguments

 = Widget

widget: the custom widget added in create-custom-widget

-> PageSetup

setup: actual page setup

-> PrintSettings

settings: actual print settings

-> IO () 

Emitted after change of selected printer. The actual page setup and print settings are passed to the custom widget, which can actualize itself according to this change.

Since: 2.18

afterPrintOperationUpdateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationUpdateCustomWidgetCallback -> m SignalHandlerId Source #

Connect a signal handler for the updateCustomWidget signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after printOperation #updateCustomWidget callback

onPrintOperationUpdateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> PrintOperationUpdateCustomWidgetCallback -> m SignalHandlerId Source #

Connect a signal handler for the updateCustomWidget signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on printOperation #updateCustomWidget callback