1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 High-level Printing API
7 <!-- ##### SECTION Long_Description ##### -->
9 GtkPrintOperation is the high-level, portable printing API. It looks
10 a bit different than other GTK+ dialogs such as the #GtkFileChooser,
11 since some platforms don't expose enough infrastructure to implement
12 a good print dialog. On such platforms, GtkPrintOperation uses the
13 native print dialog. On platforms which do not provide a native
14 print dialog, GTK+ uses its own, see #GtkPrintUnixDialog.
18 The typical way to use the high-level printing API is to create a
19 #GtkPrintOperation object with gtk_print_operation_new() when the user
20 selects to print. Then you set some properties on it, e.g. the page size,
21 any #GtkPrintSettings from previous print operations, the number of pages,
22 the current page, etc.
25 Then you start the print operation by calling gtk_print_operation_run().
26 It will then show a dialog, let the user select a printer and options.
27 When the user finished the dialog various signals will be emitted on the
28 #GtkPrintOperation, the main one being ::draw-page, which you are supposed
29 to catch and render the page on the provided #GtkPrintContext using Cairo.
33 <title>The high-level printing API</title>
35 static GtkPrintSettings *settings = NULL;
40 GtkPrintOperation *print;
41 GtkPrintOperationResult res;
43 print = gtk_print_operation_new (<!-- -->);
46 gtk_print_operation_set_print_settings (print, settings);
48 g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
49 g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
51 res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
52 GTK_WINDOW (main_window), NULL);
54 if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
57 g_object_unref (settings);
58 settings = g_object_ref (gtk_print_operation_get_print_settings (print));
61 g_object_unref (print);
68 By default GtkPrintOperation uses an external application to do
69 print preview. To implement a custom print preview, an application
70 must connect to the preview signal. The functions
71 gtk_print_operation_print_preview_render_page(),
72 gtk_print_operation_preview_end_preview() and
73 gtk_print_operation_preview_is_selected() are useful
74 when implementing a print preview.
78 Printing support was added in GTK+ 2.10.
81 <!-- ##### SECTION See_Also ##### -->
83 #GtkPrintContext, #GtkPrintUnixDialog
86 <!-- ##### SECTION Stability_Level ##### -->
89 <!-- ##### STRUCT GtkPrintOperation ##### -->
95 <!-- ##### SIGNAL GtkPrintOperation::begin-print ##### -->
103 <!-- ##### SIGNAL GtkPrintOperation::create-custom-widget ##### -->
111 <!-- ##### SIGNAL GtkPrintOperation::custom-widget-apply ##### -->
119 <!-- ##### SIGNAL GtkPrintOperation::done ##### -->
124 @printoperation: the object which received the signal.
127 <!-- ##### SIGNAL GtkPrintOperation::draw-page ##### -->
132 @printoperation: the object which received the signal.
136 <!-- ##### SIGNAL GtkPrintOperation::end-print ##### -->
141 @printoperation: the object which received the signal.
144 <!-- ##### SIGNAL GtkPrintOperation::paginate ##### -->
149 @printoperation: the object which received the signal.
153 <!-- ##### SIGNAL GtkPrintOperation::preview ##### -->
158 @printoperation: the object which received the signal.
164 <!-- ##### SIGNAL GtkPrintOperation::request-page-setup ##### -->
169 @printoperation: the object which received the signal.
174 <!-- ##### SIGNAL GtkPrintOperation::status-changed ##### -->
179 @printoperation: the object which received the signal.
181 <!-- ##### ARG GtkPrintOperation:allow-async ##### -->
186 <!-- ##### ARG GtkPrintOperation:current-page ##### -->
191 <!-- ##### ARG GtkPrintOperation:custom-tab-label ##### -->
196 <!-- ##### ARG GtkPrintOperation:default-page-setup ##### -->
201 <!-- ##### ARG GtkPrintOperation:export-filename ##### -->
206 <!-- ##### ARG GtkPrintOperation:job-name ##### -->
211 <!-- ##### ARG GtkPrintOperation:n-pages ##### -->
216 <!-- ##### ARG GtkPrintOperation:print-settings ##### -->
221 <!-- ##### ARG GtkPrintOperation:show-progress ##### -->
226 <!-- ##### ARG GtkPrintOperation:status ##### -->
231 <!-- ##### ARG GtkPrintOperation:status-string ##### -->
236 <!-- ##### ARG GtkPrintOperation:track-print-status ##### -->
241 <!-- ##### ARG GtkPrintOperation:unit ##### -->
246 <!-- ##### ARG GtkPrintOperation:use-full-page ##### -->
251 <!-- ##### ENUM GtkPrintStatus ##### -->
253 The status gives a rough indication of the completion
254 of a running print operation.
257 @GTK_PRINT_STATUS_INITIAL: The printing has not started yet; this
258 status is set initially, and while the print dialog is shown.
259 @GTK_PRINT_STATUS_PREPARING: This status is set while the begin-print
260 signal is emitted and during pagination.
261 @GTK_PRINT_STATUS_GENERATING_DATA: This status is set while the
262 pages are being rendered.
263 @GTK_PRINT_STATUS_SENDING_DATA: The print job is being sent off to the
265 @GTK_PRINT_STATUS_PENDING: The print job has been sent to the printer,
266 but is not printed for some reason, e.g. the printer may be stopped.
267 @GTK_PRINT_STATUS_PENDING_ISSUE: Some problem has occurred during
268 printing, e.g. a paper jam.
269 @GTK_PRINT_STATUS_PRINTING: The printer is processing the print job.
270 @GTK_PRINT_STATUS_FINISHED: The printing has been completed successfully.
271 @GTK_PRINT_STATUS_FINISHED_ABORTED: The printing has been aborted.
273 <!-- ##### ENUM GtkPrintOperationAction ##### -->
275 The @action parameter to gtk_print_operation_run()
276 determines what action the print operation should perform.
279 @GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG: Show the print dialog.
280 @GTK_PRINT_OPERATION_ACTION_PRINT: Start to print without showing
281 the print dialog, based on the current print settings.
282 @GTK_PRINT_OPERATION_ACTION_PREVIEW: Show the print preview.
283 @GTK_PRINT_OPERATION_ACTION_EXPORT: Export to a file. This requires
284 the export-filename property to be set.
286 <!-- ##### ENUM GtkPrintOperationResult ##### -->
288 A value of this type is returned by gtk_print_operation_run().
291 @GTK_PRINT_OPERATION_RESULT_ERROR: An error has occured.
292 @GTK_PRINT_OPERATION_RESULT_APPLY: The print settings should be stored.
293 @GTK_PRINT_OPERATION_RESULT_CANCEL: The print operation has been canceled,
294 the print settings should not be stored.
295 @GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: The print operation is complete
296 yet. This value will only be returned when running asynchronously.
298 <!-- ##### ENUM GtkPrintError ##### -->
303 @GTK_PRINT_ERROR_GENERAL:
304 @GTK_PRINT_ERROR_INTERNAL_ERROR:
305 @GTK_PRINT_ERROR_NOMEM:
306 @GTK_PRINT_ERROR_INVALID_FILE:
308 <!-- ##### MACRO GTK_PRINT_ERROR ##### -->
310 The #GQuark used for #GtkPrintError errors.
315 <!-- ##### FUNCTION gtk_print_operation_new ##### -->
323 <!-- ##### FUNCTION gtk_print_operation_set_allow_async ##### -->
332 <!-- ##### FUNCTION gtk_print_operation_get_error ##### -->
341 <!-- ##### FUNCTION gtk_print_operation_set_default_page_setup ##### -->
350 <!-- ##### FUNCTION gtk_print_operation_get_default_page_setup ##### -->
359 <!-- ##### FUNCTION gtk_print_operation_set_print_settings ##### -->
368 <!-- ##### FUNCTION gtk_print_operation_get_print_settings ##### -->
377 <!-- ##### FUNCTION gtk_print_operation_set_job_name ##### -->
386 <!-- ##### FUNCTION gtk_print_operation_set_n_pages ##### -->
395 <!-- ##### FUNCTION gtk_print_operation_set_current_page ##### -->
404 <!-- ##### FUNCTION gtk_print_operation_set_use_full_page ##### -->
413 <!-- ##### FUNCTION gtk_print_operation_set_unit ##### -->
422 <!-- ##### FUNCTION gtk_print_operation_set_export_filename ##### -->
431 <!-- ##### FUNCTION gtk_print_operation_set_show_progress ##### -->
440 <!-- ##### FUNCTION gtk_print_operation_set_track_print_status ##### -->
449 <!-- ##### FUNCTION gtk_print_operation_set_custom_tab_label ##### -->
458 <!-- ##### FUNCTION gtk_print_operation_run ##### -->
470 <!-- ##### FUNCTION gtk_print_operation_cancel ##### -->
478 <!-- ##### FUNCTION gtk_print_operation_get_status ##### -->
487 <!-- ##### FUNCTION gtk_print_operation_get_status_string ##### -->
496 <!-- ##### FUNCTION gtk_print_operation_is_finished ##### -->
505 <!-- ##### FUNCTION gtk_print_run_page_setup_dialog ##### -->
516 <!-- ##### USER_FUNCTION GtkPageSetupDoneFunc ##### -->
518 The type of function that is passed to gtk_print_run_page_setup_dialog_async().
519 This function will be called when the page setup dialog is dismissed, and
520 also serves as destroy notify for @data.
523 @page_setup: the #GtkPageSetup that has been
524 @data: user data that has been passed to
525 gtk_print_run_page_setup_dialog_async().
528 <!-- ##### FUNCTION gtk_print_run_page_setup_dialog_async ##### -->
540 <!-- ##### STRUCT GtkPrintOperationPreview ##### -->
546 <!-- ##### FUNCTION gtk_print_operation_preview_end_preview ##### -->
554 <!-- ##### FUNCTION gtk_print_operation_preview_is_selected ##### -->
564 <!-- ##### FUNCTION gtk_print_operation_preview_render_page ##### -->