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 <!-- ##### SIGNAL GtkPrintOperation::update-custom-widget ##### -->
186 @printoperation: the object which received the signal.
191 <!-- ##### ARG GtkPrintOperation:allow-async ##### -->
196 <!-- ##### ARG GtkPrintOperation:current-page ##### -->
201 <!-- ##### ARG GtkPrintOperation:custom-tab-label ##### -->
206 <!-- ##### ARG GtkPrintOperation:default-page-setup ##### -->
211 <!-- ##### ARG GtkPrintOperation:embed-page-setup ##### -->
216 <!-- ##### ARG GtkPrintOperation:export-filename ##### -->
221 <!-- ##### ARG GtkPrintOperation:has-selection ##### -->
226 <!-- ##### ARG GtkPrintOperation:job-name ##### -->
231 <!-- ##### ARG GtkPrintOperation:n-pages ##### -->
236 <!-- ##### ARG GtkPrintOperation:n-pages-to-print ##### -->
241 <!-- ##### ARG GtkPrintOperation:print-settings ##### -->
246 <!-- ##### ARG GtkPrintOperation:show-progress ##### -->
251 <!-- ##### ARG GtkPrintOperation:status ##### -->
256 <!-- ##### ARG GtkPrintOperation:status-string ##### -->
261 <!-- ##### ARG GtkPrintOperation:support-selection ##### -->
266 <!-- ##### ARG GtkPrintOperation:track-print-status ##### -->
271 <!-- ##### ARG GtkPrintOperation:unit ##### -->
276 <!-- ##### ARG GtkPrintOperation:use-full-page ##### -->
281 <!-- ##### ENUM GtkPrintStatus ##### -->
283 The status gives a rough indication of the completion
284 of a running print operation.
287 @GTK_PRINT_STATUS_INITIAL: The printing has not started yet; this
288 status is set initially, and while the print dialog is shown.
289 @GTK_PRINT_STATUS_PREPARING: This status is set while the begin-print
290 signal is emitted and during pagination.
291 @GTK_PRINT_STATUS_GENERATING_DATA: This status is set while the
292 pages are being rendered.
293 @GTK_PRINT_STATUS_SENDING_DATA: The print job is being sent off to the
295 @GTK_PRINT_STATUS_PENDING: The print job has been sent to the printer,
296 but is not printed for some reason, e.g. the printer may be stopped.
297 @GTK_PRINT_STATUS_PENDING_ISSUE: Some problem has occurred during
298 printing, e.g. a paper jam.
299 @GTK_PRINT_STATUS_PRINTING: The printer is processing the print job.
300 @GTK_PRINT_STATUS_FINISHED: The printing has been completed successfully.
301 @GTK_PRINT_STATUS_FINISHED_ABORTED: The printing has been aborted.
303 <!-- ##### ENUM GtkPrintOperationAction ##### -->
305 The @action parameter to gtk_print_operation_run()
306 determines what action the print operation should perform.
309 @GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG: Show the print dialog.
310 @GTK_PRINT_OPERATION_ACTION_PRINT: Start to print without showing
311 the print dialog, based on the current print settings.
312 @GTK_PRINT_OPERATION_ACTION_PREVIEW: Show the print preview.
313 @GTK_PRINT_OPERATION_ACTION_EXPORT: Export to a file. This requires
314 the export-filename property to be set.
316 <!-- ##### ENUM GtkPrintOperationResult ##### -->
318 A value of this type is returned by gtk_print_operation_run().
321 @GTK_PRINT_OPERATION_RESULT_ERROR: An error has occured.
322 @GTK_PRINT_OPERATION_RESULT_APPLY: The print settings should be stored.
323 @GTK_PRINT_OPERATION_RESULT_CANCEL: The print operation has been canceled,
324 the print settings should not be stored.
325 @GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: The print operation is not complete
326 yet. This value will only be returned when running asynchronously.
328 <!-- ##### ENUM GtkPrintError ##### -->
330 Error codes that identify various errors that can occur while
331 using the GTK+ printing support.
334 @GTK_PRINT_ERROR_GENERAL: An unspecified error occurred.
335 @GTK_PRINT_ERROR_INTERNAL_ERROR: An internal error occurred.
336 @GTK_PRINT_ERROR_NOMEM: A memory allocation failed.
337 @GTK_PRINT_ERROR_INVALID_FILE: An error occurred while loading a page setup
338 or paper size from a key file.
340 <!-- ##### MACRO GTK_PRINT_ERROR ##### -->
342 The #GQuark used for #GtkPrintError errors.
347 <!-- ##### FUNCTION gtk_print_operation_new ##### -->
355 <!-- ##### FUNCTION gtk_print_operation_set_allow_async ##### -->
364 <!-- ##### FUNCTION gtk_print_operation_get_error ##### -->
373 <!-- ##### FUNCTION gtk_print_operation_set_default_page_setup ##### -->
382 <!-- ##### FUNCTION gtk_print_operation_get_default_page_setup ##### -->
391 <!-- ##### FUNCTION gtk_print_operation_set_print_settings ##### -->
400 <!-- ##### FUNCTION gtk_print_operation_get_print_settings ##### -->
409 <!-- ##### FUNCTION gtk_print_operation_set_job_name ##### -->
418 <!-- ##### FUNCTION gtk_print_operation_set_n_pages ##### -->
427 <!-- ##### FUNCTION gtk_print_operation_get_n_pages_to_print ##### -->
436 <!-- ##### FUNCTION gtk_print_operation_set_current_page ##### -->
445 <!-- ##### FUNCTION gtk_print_operation_set_use_full_page ##### -->
454 <!-- ##### FUNCTION gtk_print_operation_set_unit ##### -->
463 <!-- ##### FUNCTION gtk_print_operation_set_export_filename ##### -->
472 <!-- ##### FUNCTION gtk_print_operation_set_show_progress ##### -->
481 <!-- ##### FUNCTION gtk_print_operation_set_track_print_status ##### -->
490 <!-- ##### FUNCTION gtk_print_operation_set_custom_tab_label ##### -->
499 <!-- ##### FUNCTION gtk_print_operation_run ##### -->
511 <!-- ##### FUNCTION gtk_print_operation_cancel ##### -->
519 <!-- ##### FUNCTION gtk_print_operation_draw_page_finish ##### -->
527 <!-- ##### FUNCTION gtk_print_operation_set_defer_drawing ##### -->
535 <!-- ##### FUNCTION gtk_print_operation_get_status ##### -->
544 <!-- ##### FUNCTION gtk_print_operation_get_status_string ##### -->
553 <!-- ##### FUNCTION gtk_print_operation_is_finished ##### -->
562 <!-- ##### FUNCTION gtk_print_operation_set_support_selection ##### -->
571 <!-- ##### FUNCTION gtk_print_operation_get_support_selection ##### -->
580 <!-- ##### FUNCTION gtk_print_operation_set_has_selection ##### -->
589 <!-- ##### FUNCTION gtk_print_operation_get_has_selection ##### -->
598 <!-- ##### FUNCTION gtk_print_operation_set_embed_page_setup ##### -->
607 <!-- ##### FUNCTION gtk_print_operation_get_embed_page_setup ##### -->
616 <!-- ##### FUNCTION gtk_print_run_page_setup_dialog ##### -->
627 <!-- ##### USER_FUNCTION GtkPageSetupDoneFunc ##### -->
629 The type of function that is passed to gtk_print_run_page_setup_dialog_async().
630 This function will be called when the page setup dialog is dismissed, and
631 also serves as destroy notify for @data.
634 @page_setup: the #GtkPageSetup that has been
635 @data: user data that has been passed to
636 gtk_print_run_page_setup_dialog_async().
639 <!-- ##### FUNCTION gtk_print_run_page_setup_dialog_async ##### -->
651 <!-- ##### STRUCT GtkPrintOperationPreview ##### -->
657 <!-- ##### SIGNAL GtkPrintOperationPreview::got-page-size ##### -->
662 @printoperationpreview: the object which received the signal.
666 <!-- ##### SIGNAL GtkPrintOperationPreview::ready ##### -->
671 @printoperationpreview: the object which received the signal.
674 <!-- ##### FUNCTION gtk_print_operation_preview_end_preview ##### -->
682 <!-- ##### FUNCTION gtk_print_operation_preview_is_selected ##### -->
692 <!-- ##### FUNCTION gtk_print_operation_preview_render_page ##### -->