gtkPrintOperationNew()
gtkPrintOperationSetAllowAsync(object, allow.async)
gtkPrintOperationGetError(object, .errwarn = TRUE)
gtkPrintOperationSetDefaultPageSetup(object, default.page.setup = NULL)
gtkPrintOperationGetDefaultPageSetup(object)
gtkPrintOperationSetPrintSettings(object, print.settings = NULL)
gtkPrintOperationGetPrintSettings(object)
gtkPrintOperationSetJobName(object, job.name)
gtkPrintOperationSetNPages(object, n.pages)
gtkPrintOperationGetNPagesToPrint(object)
gtkPrintOperationSetCurrentPage(object, current.page)
gtkPrintOperationSetUseFullPage(object, full.page)
gtkPrintOperationSetUnit(object, unit)
gtkPrintOperationSetExportFilename(object, filename)
gtkPrintOperationSetShowProgress(object, show.progress)
gtkPrintOperationSetTrackPrintStatus(object, track.status)
gtkPrintOperationSetCustomTabLabel(object, label)
gtkPrintOperationRun(object, action, parent = NULL, .errwarn = TRUE)
gtkPrintOperationCancel(object)
gtkPrintOperationDrawPageFinish(object)
gtkPrintOperationSetDeferDrawing(object)
gtkPrintOperationGetStatus(object)
gtkPrintOperationGetStatusString(object)
gtkPrintOperationIsFinished(object)
gtkPrintOperationSetSupportSelection(object, support.selection)
gtkPrintOperationGetSupportSelection(object)
gtkPrintOperationSetHasSelection(object, has.selection)
gtkPrintOperationGetHasSelection(object)
gtkPrintOperationSetEmbedPageSetup(object, embed)
gtkPrintOperationGetEmbedPageSetup(object)
gtkPrintRunPageSetupDialog(parent, page.setup = NULL, settings)
gtkPrintRunPageSetupDialogAsync(parent, page.setup, settings, done.cb, data)
gtkPrintOperationPreviewEndPreview(object)
gtkPrintOperationPreviewIsSelected(object, page.nr)
gtkPrintOperationPreviewRenderPage(object, page.nr)
gtkPrintOperation()
GObject +----GtkPrintOperation GInterface +----GtkPrintOperationPreview
GtkPrintOperation
.GtkPrintOperationPreview
.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 GtkPrintUnixDialog
. The typical way to use the high-level printing API is to create a
GtkPrintOperation
object with gtkPrintOperationNew
when the user
selects to print. Then you set some properties on it, e.g. the page size,
any GtkPrintSettings
from previous print operations, the number of pages,
the current page, etc. Then you start the print operation by calling gtkPrintOperationRun
.
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 ::draw-page, which you are supposed
to catch and render the page on the provided GtkPrintContext
using Cairo. The high-level printing API
settings <- NULL print_something <- { op <- gtkPrintOperation() if (!is.null(settings)) op$setPrintSettings(settings) gSignalConnect(op, "begin_print", begin_print) gSignalConnect(op, "draw_page", draw_page) res <- op$run("print-dialog", main_window)[[1]] if (res == "apply") settings <- op$getPrintSettings() }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
gtkPrintOperationPrintPreviewRenderPage()
,
gtkPrintOperationPreviewEndPreview
and
gtkPrintOperationPreviewIsSelected
are useful
when implementing a print preview. Printing support was added in GTK+ 2.10.GtkPrintOperation
GtkPrintOperationPreview
gtkPrintOperation
is the equivalent of gtkPrintOperationNew
.GtkPrintStatus
initial
preparing
generating-data
sending-data
pending
pending-issue
printing
finished
finished-aborted
GtkPrintOperationAction
action
parameter to gtkPrintOperationRun
determines what action the print operation should perform. print-dialog
print
preview
export
GtkPrintOperationResult
gtkPrintOperationRun
. error
apply
cancel
in-progress
GtkPrintError
general
internal-error
nomem
begin-print(operation, context, user.data)
GtkPrintContext
and paginate the document accordingly, and then
set the number of pages with gtkPrintOperationSetNPages
.
Since 2.10 operation
GtkPrintOperation
on which the signal was emittedcontext
GtkPrintContext
for the current operationuser.data
create-custom-widget(operation, user.data)
"custom-widget-apply"
signal is emitted on the operation. Then you can read out any
information you need from the widgets.
Since 2.10 operation
GtkPrintOperation
on which the signal was emitteduser.data
GObject
] A custom widget that gets embedded in the print dialog,
or NULL
custom-widget-apply(operation, widget, user.data)
"begin-print"
if you added
a custom widget in the "create-custom-widget"
handler.
When you get this signal you should read the information from the
custom widgets, as the widgets are not guaraneed to be around at a
later time.
Since 2.10 operation
GtkPrintOperation
on which the signal was emittedwidget
user.data
done(operation, result, user.data)
result
gives you information about what happened during the run.
If result
is GTK_PRINT_OPERATION_RESULT_ERROR
then you can call
gtkPrintOperationGetError
for more information. If you enabled print status tracking then
gtkPrintOperationIsFinished
may still return FALSE
after "done"
was emitted.
Since 2.10 operation
GtkPrintOperation
on which the signal was emittedresult
user.data
draw-page(operation, context, page.nr, user.data)
page.nr
's page onto the cairo context obtained
from context
using gtkPrintContextGetCairoContext
.
draw_page <- (operation, context, page_nr, user_data) { cr <- context$getCairoContext() width <- context$getWidth() cr$rectangle(0, 0, width, HEADER_HEIGHT) cr$setSourceRgb(0.8, 0.8, 0.8) cr$fill() layout <- context$createPangoLayout() desc <- pangoFontDescriptionFromString("sans 14") layout$setFontDescription(desc) layout$setText("some text") layout$setWidth(width) layout$setAlignment(layout, "center") layout_height <- layout$getSize()$height text_height <- layout_height / PANGO_SCALE cr$moveTo(width / 2, (HEADER_HEIGHT - text_height) / 2) pangoCairoShowLayout(cr, layout) }Use
gtkPrintOperationSetUseFullPage
and
gtkPrintOperationSetUnit
before starting the print operation
to set up the transformation of the cairo context according to your
needs.
Since 2.10 operation
GtkPrintOperation
on which the signal was emittedcontext
GtkPrintContext
for the current operationpage.nr
user.data
end-print(operation, context, user.data)
"begin-print"
handler.
Since 2.10 operation
GtkPrintOperation
on which the signal was emittedcontext
GtkPrintContext
for the current operationuser.data
paginate(operation, context, user.data)
"begin-print"
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
gtkPrintOperationSetNPages
, 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 ::begin-print handler, and set the number of pages
from there.
Since 2.10 operation
GtkPrintOperation
on which the signal was emittedcontext
GtkPrintContext
for the current operationuser.data
TRUE
if pagination is complete preview(operation, preview, context, parent, user.data)
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 gtkPrintContextSetCairoContext
. The custom preview implementation can use
gtkPrintOperationPreviewIsSelected
and
gtkPrintOperationPreviewRenderPage
to find pages which
are selected for print and render them. The preview must be
finished by calling gtkPrintOperationPreviewEndPreview
(typically in response to the user clicking a close button).
Since 2.10 operation
GtkPrintOperation
on which the signal was emittedpreview
GtkPrintPreviewOperation
for the current operationcontext
GtkPrintContext
that will be usedparent
GtkWindow
to use as window parent, or NULL
. [ allow-none ]user.data
TRUE
if the listener wants to take over control of the preview request-page-setup(operation, context, page.nr, setup, user.data)
setup
will be in force only for printing this page.
Since 2.10 operation
GtkPrintOperation
on which the signal was emittedcontext
GtkPrintContext
for the current operationpage.nr
setup
GtkPageSetup
user.data
status-changed(operation, user.data)
GtkPrintStatus
for the phases that are being discriminated.
Use gtkPrintOperationGetStatus
to find out the current
status.
Since 2.10 operation
GtkPrintOperation
on which the signal was emitteduser.data
update-custom-widget(operation, widget, setup, settings, user.data)
operation
GtkPrintOperation
on which the signal was emittedwidget
setup
settings
user.data
got-page-size(preview, context, page.setup, user.data)
context
according to page.setup
and set up a suitable cairo
context, using gtkPrintContextSetCairoContext
. preview
context
GtkPrintContext
page.setup
GtkPageSetup
for the current pageuser.data
ready(preview, context, user.data)
preview
context
GtkPrintContext
user.data
allow-async
[logical : Read / Write]GTK_PRINT_OPERATION_RESULT_IN_PROGRESS
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
GTK_PRINT_OPERATION_ACTION_EXPORT
support asynchronous operation.
Default value: FALSE Since 2.10 current-page
[integer : Read / Write]gtkPrintOperationRun
,
the user will be able to select to print only the current page. Note that this only makes sense for pre-paginated documents.
Allowed values: >= -1 Default value: -1 Since 2.10 custom-tab-label
[character : * : Read / Write]NULL
, GTK+ uses a default label.
Default value: NULL Since 2.10 default-page-setup
[GtkPageSetup
: * : Read / Write]GtkPageSetup
used by default. This page setup will be used by gtkPrintOperationRun
,
but it can be overridden on a per-page basis by connecting
to the "request-page-setup"
signal.
Since 2.10 embed-page-setup
[logical : Read / Write]TRUE
, page size combo box and orientation combo box are embedded into page setup page.
Default value: FALSE Since 2.18 export-filename
[character : * : Read / Write]has-selection
[logical : Read / Write]job-name
[character : * : Read / Write]n-pages
[integer : Read / Write]"begin-print"
signal hander. Note that the page numbers passed to the
"request-page-setup"
and
"draw-page"
signals are 0-based, i.e. if
the user chooses to print all pages, the last ::draw-page signal
will be for page n.pages
- 1.
Allowed values: >= -1 Default value: -1 Since 2.10 n-pages-to-print
[integer : Read]GTK_PRINT_STATUS_PREPARING
), so this value should never be
get before the data generation phase (GTK_PRINT_STATUS_GENERATING_DATA
).
You can connect to the "status-changed"
signal
and call gtkPrintOperationGetNPagesToPrint
when
print status is GTK_PRINT_STATUS_GENERATING_DATA
.
This is typically used to track the progress of print operation.
Allowed values: >= -1 Default value: -1 Since 2.18 print-settings
[GtkPrintSettings
: * : Read / Write]GtkPrintSettings
used for initializing the dialog. Setting this property is typically used to re-establish
print settings from a previous print operation, see
gtkPrintOperationRun
.
Since 2.10 show-progress
[logical : Read / Write]status
[GtkPrintStatus
: Read]status-string
[character : * : Read]GtkStatusbar
. See the "status"
property for a status value that
is suitable for programmatic use.
Default value: "" Since 2.10 support-selection
[logical : Read / Write]TRUE
, the print operation will support print of selection.
This allows the print dialog to show a "Selection" button.
Default value: FALSE Since 2.18 track-print-status
[logical : Read / Write]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.
Default value: FALSE Since 2.10 unit
[GtkUnit
: Read / Write]GtkPrintContext
is set up in such a way that distances
are measured in units of unit
.
Default value: GTK_UNIT_PIXEL Since 2.10 use-full-page
[logical : Read / Write]TRUE
, the transformation for the cairo context obtained
from GtkPrintContext
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).
Default value: FALSE Since 2.10 GtkPrintContext