gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.PrintOperation

Contents

- Exported types
- Methods
  - cancel
  - drawPageFinish
  - getDefaultPageSetup
  - getEmbedPageSetup
  - getError
  - getHasSelection
  - getNPagesToPrint
  - getPrintSettings
  - getStatus
  - getStatusString
  - getSupportSelection
  - isFinished
  - new
  - run
  - setAllowAsync
  - setCurrentPage
  - setCustomTabLabel
  - setDefaultPageSetup
  - setDeferDrawing
  - setEmbedPageSetup
  - setExportFilename
  - setHasSelection
  - setJobName
  - setNPages
  - setPrintSettings
  - setShowProgress
  - setSupportSelection
  - setTrackPrintStatus
  - setUnit
  - setUseFullPage
- Properties
  - allowAsync
  - currentPage
  - customTabLabel
  - defaultPageSetup
  - embedPageSetup
  - exportFilename
  - hasSelection
  - jobName
  - nPages
  - nPagesToPrint
  - printSettings
  - showProgress
  - status
  - statusString
  - supportSelection
  - trackPrintStatus
  - unit
  - useFullPage
- Signals
  - beginPrint
  - createCustomWidget
  - customWidgetApply
  - done
  - drawPage
  - endPrint
  - paginate
  - preview
  - requestPageSetup
  - statusChanged
  - updateCustomWidget

Description

High-level, portable printing API.

It looks a bit different than other GTK dialogs such as the `GtkFileChooser`, 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 `PrintUnixDialog`.

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 `GtkPrintOperation`, the main one being PrintOperation::drawPage, which you are supposed to handle 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

- newtype PrintOperation = PrintOperation (ManagedPtr PrintOperation)
- class (GObject o, IsDescendantOf PrintOperation o) => IsPrintOperation o
- toPrintOperation :: (MonadIO m, IsPrintOperation o) => o -> m PrintOperation
- printOperationCancel :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m ()
- printOperationDrawPageFinish :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m ()
- printOperationGetDefaultPageSetup :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m (Maybe PageSetup)
- printOperationGetEmbedPageSetup :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m Bool
- printOperationGetError :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m ()
- printOperationGetHasSelection :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m Bool
- printOperationGetNPagesToPrint :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m Int32
- printOperationGetPrintSettings :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m (Maybe PrintSettings)
- printOperationGetStatus :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m PrintStatus
- printOperationGetStatusString :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m Text
- printOperationGetSupportSelection :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m Bool
- printOperationIsFinished :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m Bool
- printOperationNew :: (HasCallStack, MonadIO m) => m PrintOperation
- printOperationRun :: (HasCallStack, MonadIO m, IsPrintOperation a, IsWindow b) => a -> PrintOperationAction -> Maybe b -> m PrintOperationResult
- printOperationSetAllowAsync :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Bool -> m ()
- printOperationSetCurrentPage :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Int32 -> m ()
- printOperationSetCustomTabLabel :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Maybe Text -> m ()
- printOperationSetDefaultPageSetup :: (HasCallStack, MonadIO m, IsPrintOperation a, IsPageSetup b) => a -> Maybe b -> m ()
- printOperationSetDeferDrawing :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> m ()
- printOperationSetEmbedPageSetup :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Bool -> m ()
- printOperationSetExportFilename :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> [Char] -> m ()
- printOperationSetHasSelection :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Bool -> m ()
- printOperationSetJobName :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Text -> m ()
- printOperationSetNPages :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Int32 -> m ()
- printOperationSetPrintSettings :: (HasCallStack, MonadIO m, IsPrintOperation a, IsPrintSettings b) => a -> Maybe b -> m ()
- printOperationSetShowProgress :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Bool -> m ()
- printOperationSetSupportSelection :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Bool -> m ()
- printOperationSetTrackPrintStatus :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Bool -> m ()
- printOperationSetUnit :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Unit -> m ()
- printOperationSetUseFullPage :: (HasCallStack, MonadIO m, IsPrintOperation a) => a -> Bool -> m ()
- constructPrintOperationAllowAsync :: (IsPrintOperation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPrintOperationAllowAsync :: (MonadIO m, IsPrintOperation o) => o -> m Bool
- setPrintOperationAllowAsync :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m ()
- constructPrintOperationCurrentPage :: (IsPrintOperation o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getPrintOperationCurrentPage :: (MonadIO m, IsPrintOperation o) => o -> m Int32
- setPrintOperationCurrentPage :: (MonadIO m, IsPrintOperation o) => o -> Int32 -> m ()
- clearPrintOperationCustomTabLabel :: (MonadIO m, IsPrintOperation o) => o -> m ()
- constructPrintOperationCustomTabLabel :: (IsPrintOperation o, MonadIO m) => Text -> m (GValueConstruct o)
- getPrintOperationCustomTabLabel :: (MonadIO m, IsPrintOperation o) => o -> m (Maybe Text)
- setPrintOperationCustomTabLabel :: (MonadIO m, IsPrintOperation o) => o -> Text -> m ()
- clearPrintOperationDefaultPageSetup :: (MonadIO m, IsPrintOperation o) => o -> m ()
- constructPrintOperationDefaultPageSetup :: (IsPrintOperation o, MonadIO m, IsPageSetup a) => a -> m (GValueConstruct o)
- getPrintOperationDefaultPageSetup :: (MonadIO m, IsPrintOperation o) => o -> m (Maybe PageSetup)
- setPrintOperationDefaultPageSetup :: (MonadIO m, IsPrintOperation o, IsPageSetup a) => o -> a -> m ()
- constructPrintOperationEmbedPageSetup :: (IsPrintOperation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPrintOperationEmbedPageSetup :: (MonadIO m, IsPrintOperation o) => o -> m Bool
- setPrintOperationEmbedPageSetup :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m ()
- clearPrintOperationExportFilename :: (MonadIO m, IsPrintOperation o) => o -> m ()
- constructPrintOperationExportFilename :: (IsPrintOperation o, MonadIO m) => Text -> m (GValueConstruct o)
- getPrintOperationExportFilename :: (MonadIO m, IsPrintOperation o) => o -> m (Maybe Text)
- setPrintOperationExportFilename :: (MonadIO m, IsPrintOperation o) => o -> Text -> m ()
- constructPrintOperationHasSelection :: (IsPrintOperation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPrintOperationHasSelection :: (MonadIO m, IsPrintOperation o) => o -> m Bool
- setPrintOperationHasSelection :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m ()
- constructPrintOperationJobName :: (IsPrintOperation o, MonadIO m) => Text -> m (GValueConstruct o)
- getPrintOperationJobName :: (MonadIO m, IsPrintOperation o) => o -> m (Maybe Text)
- setPrintOperationJobName :: (MonadIO m, IsPrintOperation o) => o -> Text -> m ()
- constructPrintOperationNPages :: (IsPrintOperation o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getPrintOperationNPages :: (MonadIO m, IsPrintOperation o) => o -> m Int32
- setPrintOperationNPages :: (MonadIO m, IsPrintOperation o) => o -> Int32 -> m ()
- getPrintOperationNPagesToPrint :: (MonadIO m, IsPrintOperation o) => o -> m Int32
- clearPrintOperationPrintSettings :: (MonadIO m, IsPrintOperation o) => o -> m ()
- constructPrintOperationPrintSettings :: (IsPrintOperation o, MonadIO m, IsPrintSettings a) => a -> m (GValueConstruct o)
- getPrintOperationPrintSettings :: (MonadIO m, IsPrintOperation o) => o -> m (Maybe PrintSettings)
- setPrintOperationPrintSettings :: (MonadIO m, IsPrintOperation o, IsPrintSettings a) => o -> a -> m ()
- constructPrintOperationShowProgress :: (IsPrintOperation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPrintOperationShowProgress :: (MonadIO m, IsPrintOperation o) => o -> m Bool
- setPrintOperationShowProgress :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m ()
- getPrintOperationStatus :: (MonadIO m, IsPrintOperation o) => o -> m PrintStatus
- getPrintOperationStatusString :: (MonadIO m, IsPrintOperation o) => o -> m Text
- constructPrintOperationSupportSelection :: (IsPrintOperation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPrintOperationSupportSelection :: (MonadIO m, IsPrintOperation o) => o -> m Bool
- setPrintOperationSupportSelection :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m ()
- constructPrintOperationTrackPrintStatus :: (IsPrintOperation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPrintOperationTrackPrintStatus :: (MonadIO m, IsPrintOperation o) => o -> m Bool
- setPrintOperationTrackPrintStatus :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m ()
- constructPrintOperationUnit :: (IsPrintOperation o, MonadIO m) => Unit -> m (GValueConstruct o)
- getPrintOperationUnit :: (MonadIO m, IsPrintOperation o) => o -> m Unit
- setPrintOperationUnit :: (MonadIO m, IsPrintOperation o) => o -> Unit -> m ()
- constructPrintOperationUseFullPage :: (IsPrintOperation o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPrintOperationUseFullPage :: (MonadIO m, IsPrintOperation o) => o -> m Bool
- setPrintOperationUseFullPage :: (MonadIO m, IsPrintOperation o) => o -> Bool -> m ()
- type PrintOperationBeginPrintCallback = PrintContext -> IO ()
- afterPrintOperationBeginPrint :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationBeginPrintCallback) -> m SignalHandlerId
- onPrintOperationBeginPrint :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationBeginPrintCallback) -> m SignalHandlerId
- type PrintOperationCreateCustomWidgetCallback = IO (Maybe Object)
- afterPrintOperationCreateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationCreateCustomWidgetCallback) -> m SignalHandlerId
- onPrintOperationCreateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationCreateCustomWidgetCallback) -> m SignalHandlerId
- type PrintOperationCustomWidgetApplyCallback = Widget -> IO ()
- afterPrintOperationCustomWidgetApply :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationCustomWidgetApplyCallback) -> m SignalHandlerId
- onPrintOperationCustomWidgetApply :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationCustomWidgetApplyCallback) -> m SignalHandlerId
- type PrintOperationDoneCallback = PrintOperationResult -> IO ()
- afterPrintOperationDone :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationDoneCallback) -> m SignalHandlerId
- onPrintOperationDone :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationDoneCallback) -> m SignalHandlerId
- type PrintOperationDrawPageCallback = PrintContext -> Int32 -> IO ()
- afterPrintOperationDrawPage :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationDrawPageCallback) -> m SignalHandlerId
- onPrintOperationDrawPage :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationDrawPageCallback) -> m SignalHandlerId
- type PrintOperationEndPrintCallback = PrintContext -> IO ()
- afterPrintOperationEndPrint :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationEndPrintCallback) -> m SignalHandlerId
- onPrintOperationEndPrint :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationEndPrintCallback) -> m SignalHandlerId
- type PrintOperationPaginateCallback = PrintContext -> IO Bool
- afterPrintOperationPaginate :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationPaginateCallback) -> m SignalHandlerId
- onPrintOperationPaginate :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationPaginateCallback) -> m SignalHandlerId
- type PrintOperationPreviewCallback = PrintOperationPreview -> PrintContext -> Maybe Window -> IO Bool
- afterPrintOperationPreview :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationPreviewCallback) -> m SignalHandlerId
- onPrintOperationPreview :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationPreviewCallback) -> m SignalHandlerId
- type PrintOperationRequestPageSetupCallback = PrintContext -> Int32 -> PageSetup -> IO ()
- afterPrintOperationRequestPageSetup :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationRequestPageSetupCallback) -> m SignalHandlerId
- onPrintOperationRequestPageSetup :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationRequestPageSetupCallback) -> m SignalHandlerId
- type PrintOperationStatusChangedCallback = IO ()
- afterPrintOperationStatusChanged :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationStatusChangedCallback) -> m SignalHandlerId
- onPrintOperationStatusChanged :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationStatusChangedCallback) -> m SignalHandlerId
- type PrintOperationUpdateCustomWidgetCallback = Widget -> PageSetup -> PrintSettings -> IO ()
- afterPrintOperationUpdateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationUpdateCustomWidgetCallback) -> m SignalHandlerId
- onPrintOperationUpdateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: a) => PrintOperationUpdateCustomWidgetCallback) -> m SignalHandlerId

# 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 Methods (==) :: PrintOperation -> PrintOperation -> Bool Source # (/=) :: PrintOperation -> PrintOperation -> Bool Source #
GObject PrintOperation Source # |
Instance details Defined in GI.Gtk.Objects.PrintOperation
ManagedPtrNewtype PrintOperation Source # |
Instance details Defined in GI.Gtk.Objects.PrintOperation Methods toManagedPtr :: PrintOperation -> ManagedPtr PrintOperation Source #
TypedObject PrintOperation Source # |
Instance details Defined in GI.Gtk.Objects.PrintOperation Methods glibType :: IO GType Source #
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 Source # gvalueSet_ :: Ptr GValue -> Maybe PrintOperation -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe PrintOperation) Source #
type ParentTypes PrintOperation Source # |
Instance details Defined in GI.Gtk.Objects.PrintOperation type ParentTypes PrintOperation = '[Object, PrintOperationPreview]

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

### Click to display all available methods, including inherited ones

Expand

#### Methods

bindProperty, bindPropertyFull, cancel, drawPageFinish, endPreview, forceFloating, freezeNotify, getv, isFinished, isFloating, isSelected, notify, notifyByPspec, ref, refSink, renderPage, run, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getData, getDefaultPageSetup, getEmbedPageSetup, getError, getHasSelection, getNPagesToPrint, getPrintSettings, getProperty, getQdata, getStatus, getStatusString, getSupportSelection.

#### Setters

setAllowAsync, setCurrentPage, setCustomTabLabel, setData, setDataFull, setDefaultPageSetup, setDeferDrawing, setEmbedPageSetup, setExportFilename, setHasSelection, setJobName, setNPages, setPrintSettings, setProperty, setShowProgress, setSupportSelection, setTrackPrintStatus, setUnit, setUseFullPage.

## cancel

printOperationCancel Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> m () |

Cancels a running print operation.

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

## drawPageFinish

printOperationDrawPageFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> m () |

Signal 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. Otherwise it is called by GTK itself.

## getDefaultPageSetup

printOperationGetDefaultPageSetup Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> m (Maybe PageSetup) | Returns: the default page setup

Returns the default page setup.

## getEmbedPageSetup

printOperationGetEmbedPageSetup Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> m Bool | Returns: whether page setup selection combos are embedded

Gets whether page setup selection combos are embedded

## getError

printOperationGetError Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> m () | (Can throw `GError`)

Call this when the result of a print operation is `PrintOperationResultError`.

It can be called either after `printOperationRun` returns, or in the PrintOperation::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 `GtkPrintOperation`
-> m Bool | Returns: whether there is a selection

Gets whether there is a selection.

## getNPagesToPrint

printOperationGetNPagesToPrint Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> 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 PrintOperation::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 `GtkPrintOperation`
-> m (Maybe 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 `GtkPrintOperation`
-> 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 `GtkPrintOperation`
-> 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 `GtkStatusbar`.

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 `GtkPrintOperation`
-> m Bool | Returns: whether the application supports print of selection

Gets whether the application supports print of selection

## isFinished

printOperationIsFinished Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> m Bool | Returns: `True`, if the print operation is finished.

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

a print operation is finished if its status is either `PrintStatusFinished` or `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 `GtkPrintOperation`

Creates a new `GtkPrintOperation`.

## run

printOperationRun Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a, IsWindow b) |
=> a | `op`: a `GtkPrintOperation`
-> 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 PrintOperation::done signal when done. (Can throw `GError`)

Runs the print operation.

Normally that this function does not return until the rendering of all pages is complete. You can connect to the PrintOperation::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 set the [Gtk.PrintOperation:allow-async] property, the operation will run asynchronously if this is supported on the platform. The PrintOperation::done signal will be emitted with the result of the operation when the it is done (i.e. when the dialog is canceled, or when the print succeeds or fails).

### c 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_window_present (GTK_WINDOW (error_dialog));
       g_error_free (error);
     }
    else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
     {
       if (settings != NULL)
    g_object_unref (settings);
       settings = g_object_ref (gtk_print_operation_get_print_settings (print));
     }

Note that `printOperationRun` can only be called once on a given `GtkPrintOperation`.

## setAllowAsync

printOperationSetAllowAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> Bool | `allowAsync`: `True` to allow asynchronous operation
-> m () |

Sets whether `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 `GtkPrintOperation`
-> 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 `GtkPrintOperation`
-> 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 `GtkPrintOperation`
-> Maybe b | `defaultPageSetup`: a `GtkPageSetup`
-> 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 PrintOperation::requestPageSetup signal.

## setDeferDrawing

printOperationSetDeferDrawing Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> m () |

Sets up the `GtkPrintOperation` to wait for calling of [method`gtk`.PrintOperation.draw_page_finish from application.

This can be used for drawing page in another thread.

This function must be called in the callback of the PrintOperation::drawPage signal.

## setEmbedPageSetup

printOperationSetEmbedPageSetup Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> 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 `GtkPrintOperation`.

## setExportFilename

printOperationSetExportFilename Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> [Char] | `filename`: the filename for the exported file
-> m () |

Sets up the `GtkPrintOperation` to generate a file instead of showing the print dialog.

The intended use of this function is for implementing “Export to PDF” actions. Currently, PDF is the only supported format.

“Print to PDF” support is independent of this and is done by letting the user pick the “Print to PDF” item from the list of printers in the print dialog.

## setHasSelection

printOperationSetHasSelection Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> 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 handler for the PrintOperation::beginPrint signal.

## setJobName

printOperationSetJobName Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> 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 `GtkPrintOperation`
-> 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 PrintOperation::beginPrint signal handler.

Note that the page numbers passed to the PrintOperation::requestPageSetup and PrintOperation::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 `GtkPrintOperation`
-> Maybe b | `printSettings`: `GtkPrintSettings`
-> 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 `GtkPrintOperation`
-> 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 `GtkPrintOperation`
-> Bool | `supportSelection`: `True` to support selection
-> m () |

Sets whether selection is supported by `GtkPrintOperation`.

## setTrackPrintStatus

printOperationSetTrackPrintStatus Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> 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 `GtkPrintOperation`
-> Unit | `unit`: the unit to use
-> m () |

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

## setUseFullPage

printOperationSetUseFullPage Source #

Arguments

:: (HasCallStack, MonadIO m, IsPrintOperation a) |
=> a | `op`: a `GtkPrintOperation`
-> Bool | `fullPage`: `True` to set up the `GtkPrintContext` for the full page
-> m () |

If `fullPage` is `True`, the transformation for the cairo context obtained from `GtkPrintContext` puts the origin at the top left corner of the page.

This may not be the top left corner of the sheet, depending on page orientation and the number of pages per sheet). Otherwise, the origin is at the top left corner of the imageable area (i.e. inside the margins).

# 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 PrintOperation::done signal when the operation is actually done.

The Windows port does not support asynchronous operation at all (this is unlikely to change). On other platforms, all actions except for `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 `GtkPageSetup` 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 PrintOperation::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 (Maybe 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 PrintOperation::beginPrint signal handler.

Note that the page numbers passed to the PrintOperation::requestPageSetup and PrintOperation::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 PrintOperation::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 `GtkPrintSettings` 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 (Maybe 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 `GtkStatusbar`.

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 `GtkPrintContext` 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 `GtkPrintContext` puts the origin at the top left corner of the page.

This may not be the top left corner of the sheet, depending on page orientation and the number of pages per sheet. Otherwise, the origin is at the top left corner of the imageable area (i.e. inside the margins).

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 PrintOperationBeginPrintCallback Source #

Arguments

= PrintContext | `context`: the `GtkPrintContext` 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 -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationBeginPrint :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 PrintOperationCreateCustomWidgetCallback Source #

Arguments

= IO (Maybe Object) | Returns: A custom widget that gets embedded in the print dialog

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 PrintOperation::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 -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationCreateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 PrintOperationCustomWidgetApplyCallback Source #

Arguments

= Widget | `widget`: the custom widget added in createCustomWidget
-> 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 guaranteed to be around at a later time.

afterPrintOperationCustomWidgetApply :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationCustomWidgetApply :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 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 the done signal was emitted.

afterPrintOperationDone :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationDone :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 PrintOperationDrawPageCallback Source #

Arguments

= PrintContext | `context`: the `GtkPrintContext` 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 -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationDrawPage :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 PrintOperationEndPrintCallback Source #

Arguments

= PrintContext | `context`: the `GtkPrintContext` 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 PrintOperation::beginPrint handler.

afterPrintOperationEndPrint :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationEndPrint :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 PrintOperationPaginateCallback Source #

Arguments

= PrintContext | `context`: the `GtkPrintContext` 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 -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationPaginate :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 PrintOperationPreviewCallback Source #

Arguments

= PrintOperationPreview | `preview`: the `GtkPrintOperationPreview` for the current operation
-> PrintContext | `context`: the `GtkPrintContext` that will be used
-> Maybe Window | `parent`: the `GtkWindow` to use as window parent
-> 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 -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationPreview :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 PrintOperationRequestPageSetupCallback Source #

Arguments

= PrintContext | `context`: the `GtkPrintContext` for the current operation
-> Int32 | `pageNr`: the number of the currently printed page (0-based)
-> PageSetup | `setup`: the `GtkPageSetup`
-> IO () |

Emitted once for every page that is printed.

This gives 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 -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationRequestPageSetup :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 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 -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationStatusChanged :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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 PrintOperationUpdateCustomWidgetCallback Source #

Arguments

= Widget | `widget`: the custom widget added in createCustomWidget
-> 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 -> ((?self :: 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

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onPrintOperationUpdateCustomWidget :: (IsPrintOperation a, MonadIO m) => a -> ((?self :: 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