gi-gtk-4.0.4: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
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

newtype PrintOperation Source #

Memory-managed wrapper type.

Constructors

PrintOperation (ManagedPtr PrintOperation) 

Instances

Instances details
Eq PrintOperation Source # 
Instance details

Defined in GI.Gtk.Objects.PrintOperation

GObject PrintOperation Source # 
Instance details

Defined in GI.Gtk.Objects.PrintOperation

ManagedPtrNewtype PrintOperation Source # 
Instance details

Defined in GI.Gtk.Objects.PrintOperation

TypedObject PrintOperation Source # 
Instance details

Defined in GI.Gtk.Objects.PrintOperation

Methods

glibType :: IO GType

HasParentTypes PrintOperation Source # 
Instance details

Defined in GI.Gtk.Objects.PrintOperation

IsGValue (Maybe PrintOperation) Source #

Convert PrintOperation to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.PrintOperation

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe PrintOperation -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe PrintOperation)

type ParentTypes PrintOperation Source # 
Instance details

Defined in GI.Gtk.Objects.PrintOperation

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

new

printOperationNew Source #

Arguments

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

Returns: a new PrintOperation

Creates a new PrintOperation.

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

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.

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.

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.

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.

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.

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.

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

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.

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.

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

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.

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.

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.

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.

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.

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.

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

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.

constructPrintOperationAllowAsync :: (IsPrintOperation o, MonadIO m) => Bool -> m (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.

constructPrintOperationCurrentPage :: (IsPrintOperation o, MonadIO m) => Int32 -> m (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.

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, MonadIO m) => Text -> m (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.

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, MonadIO m, IsPageSetup a) => a -> m (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.

constructPrintOperationEmbedPageSetup :: (IsPrintOperation o, MonadIO m) => Bool -> m (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.

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, MonadIO m) => Text -> m (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.

constructPrintOperationHasSelection :: (IsPrintOperation o, MonadIO m) => Bool -> m (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.

constructPrintOperationJobName :: (IsPrintOperation o, MonadIO m) => Text -> m (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 handler.

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.

constructPrintOperationNPages :: (IsPrintOperation o, MonadIO m) => Int32 -> m (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.

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.

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, MonadIO m, IsPrintSettings a) => a -> m (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.

constructPrintOperationShowProgress :: (IsPrintOperation o, MonadIO m) => Bool -> m (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.

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.

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.

constructPrintOperationSupportSelection :: (IsPrintOperation o, MonadIO m) => Bool -> m (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.

constructPrintOperationTrackPrintStatus :: (IsPrintOperation o, MonadIO m) => Bool -> m (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.

constructPrintOperationUnit :: (IsPrintOperation o, MonadIO m) => Unit -> m (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).

constructPrintOperationUseFullPage :: (IsPrintOperation o, MonadIO m) => Bool -> m (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.

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.

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.

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.

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,
           int                page_nr,
           gpointer           user_data)
{
  cairo_t *cr;
  PangoLayout *layout;
  double width, text_height;
  int 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 = (double)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.

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.

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.

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

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.

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.

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.

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