1/* GTK - The GIMP Toolkit
2 * gtkprintoperation.h: Print Operation
3 * Copyright (C) 2006, Red Hat, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __GTK_PRINT_OPERATION_H__
20#define __GTK_PRINT_OPERATION_H__
21
22
23#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
24#error "Only <gtk/gtk.h> can be included directly."
25#endif
26
27#include <cairo.h>
28#include <gtk/gtkmain.h>
29#include <gtk/gtkwindow.h>
30#include <gtk/gtkpagesetup.h>
31#include <gtk/gtkprintsettings.h>
32#include <gtk/gtkprintcontext.h>
33#include <gtk/gtkprintoperationpreview.h>
34
35
36G_BEGIN_DECLS
37
38#define GTK_TYPE_PRINT_OPERATION (gtk_print_operation_get_type ())
39#define GTK_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperation))
40#define GTK_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationClass))
41#define GTK_IS_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_OPERATION))
42#define GTK_IS_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_OPERATION))
43#define GTK_PRINT_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationClass))
44
45typedef struct _GtkPrintOperationClass GtkPrintOperationClass;
46typedef struct _GtkPrintOperationPrivate GtkPrintOperationPrivate;
47typedef struct _GtkPrintOperation GtkPrintOperation;
48
49/**
50 * GtkPrintStatus:
51 * @GTK_PRINT_STATUS_INITIAL: The printing has not started yet; this
52 * status is set initially, and while the print dialog is shown.
53 * @GTK_PRINT_STATUS_PREPARING: This status is set while the begin-print
54 * signal is emitted and during pagination.
55 * @GTK_PRINT_STATUS_GENERATING_DATA: This status is set while the
56 * pages are being rendered.
57 * @GTK_PRINT_STATUS_SENDING_DATA: The print job is being sent off to the
58 * printer.
59 * @GTK_PRINT_STATUS_PENDING: The print job has been sent to the printer,
60 * but is not printed for some reason, e.g. the printer may be stopped.
61 * @GTK_PRINT_STATUS_PENDING_ISSUE: Some problem has occurred during
62 * printing, e.g. a paper jam.
63 * @GTK_PRINT_STATUS_PRINTING: The printer is processing the print job.
64 * @GTK_PRINT_STATUS_FINISHED: The printing has been completed successfully.
65 * @GTK_PRINT_STATUS_FINISHED_ABORTED: The printing has been aborted.
66 *
67 * The status gives a rough indication of the completion of a running
68 * print operation.
69 */
70typedef enum {
71 GTK_PRINT_STATUS_INITIAL,
72 GTK_PRINT_STATUS_PREPARING,
73 GTK_PRINT_STATUS_GENERATING_DATA,
74 GTK_PRINT_STATUS_SENDING_DATA,
75 GTK_PRINT_STATUS_PENDING,
76 GTK_PRINT_STATUS_PENDING_ISSUE,
77 GTK_PRINT_STATUS_PRINTING,
78 GTK_PRINT_STATUS_FINISHED,
79 GTK_PRINT_STATUS_FINISHED_ABORTED
80} GtkPrintStatus;
81
82/**
83 * GtkPrintOperationResult:
84 * @GTK_PRINT_OPERATION_RESULT_ERROR: An error has occurred.
85 * @GTK_PRINT_OPERATION_RESULT_APPLY: The print settings should be stored.
86 * @GTK_PRINT_OPERATION_RESULT_CANCEL: The print operation has been canceled,
87 * the print settings should not be stored.
88 * @GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: The print operation is not complete
89 * yet. This value will only be returned when running asynchronously.
90 *
91 * A value of this type is returned by gtk_print_operation_run().
92 */
93typedef enum {
94 GTK_PRINT_OPERATION_RESULT_ERROR,
95 GTK_PRINT_OPERATION_RESULT_APPLY,
96 GTK_PRINT_OPERATION_RESULT_CANCEL,
97 GTK_PRINT_OPERATION_RESULT_IN_PROGRESS
98} GtkPrintOperationResult;
99
100/**
101 * GtkPrintOperationAction:
102 * @GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG: Show the print dialog.
103 * @GTK_PRINT_OPERATION_ACTION_PRINT: Start to print without showing
104 * the print dialog, based on the current print settings.
105 * @GTK_PRINT_OPERATION_ACTION_PREVIEW: Show the print preview.
106 * @GTK_PRINT_OPERATION_ACTION_EXPORT: Export to a file. This requires
107 * the export-filename property to be set.
108 *
109 * The @action parameter to gtk_print_operation_run()
110 * determines what action the print operation should perform.
111 */
112typedef enum {
113 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
114 GTK_PRINT_OPERATION_ACTION_PRINT,
115 GTK_PRINT_OPERATION_ACTION_PREVIEW,
116 GTK_PRINT_OPERATION_ACTION_EXPORT
117} GtkPrintOperationAction;
118
119
120struct _GtkPrintOperation
121{
122 GObject parent_instance;
123
124 /*< private >*/
125 GtkPrintOperationPrivate *priv;
126};
127
128/**
129 * GtkPrintOperationClass:
130 * @parent_class: The parent class.
131 * @done: Signal emitted when the print operation run has finished
132 * doing everything required for printing.
133 * @begin_print: Signal emitted after the user has finished changing
134 * print settings in the dialog, before the actual rendering starts.
135 * @paginate: Signal emitted after the “begin-print” signal, but
136 * before the actual rendering starts.
137 * @request_page_setup: Emitted once for every page that is printed,
138 * to give the application a chance to modify the page setup.
139 * @draw_page: Signal emitted for every page that is printed.
140 * @end_print: Signal emitted after all pages have been rendered.
141 * @status_changed: Emitted at between the various phases of the print
142 * operation.
143 * @create_custom_widget: Signal emitted when displaying the print dialog.
144 * @custom_widget_apply: Signal emitted right before “begin-print” if
145 * you added a custom widget in the “create-custom-widget” handler.
146 * @preview: Signal emitted when a preview is requested from the
147 * native dialog.
148 * @update_custom_widget: Emitted after change of selected printer.
149 */
150struct _GtkPrintOperationClass
151{
152 GObjectClass parent_class;
153
154 /*< public >*/
155
156 void (*done) (GtkPrintOperation *operation,
157 GtkPrintOperationResult result);
158 void (*begin_print) (GtkPrintOperation *operation,
159 GtkPrintContext *context);
160 gboolean (*paginate) (GtkPrintOperation *operation,
161 GtkPrintContext *context);
162 void (*request_page_setup) (GtkPrintOperation *operation,
163 GtkPrintContext *context,
164 gint page_nr,
165 GtkPageSetup *setup);
166 void (*draw_page) (GtkPrintOperation *operation,
167 GtkPrintContext *context,
168 gint page_nr);
169 void (*end_print) (GtkPrintOperation *operation,
170 GtkPrintContext *context);
171 void (*status_changed) (GtkPrintOperation *operation);
172
173 GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
174 void (*custom_widget_apply) (GtkPrintOperation *operation,
175 GtkWidget *widget);
176
177 gboolean (*preview) (GtkPrintOperation *operation,
178 GtkPrintOperationPreview *preview,
179 GtkPrintContext *context,
180 GtkWindow *parent);
181
182 void (*update_custom_widget) (GtkPrintOperation *operation,
183 GtkWidget *widget,
184 GtkPageSetup *setup,
185 GtkPrintSettings *settings);
186
187 /*< private >*/
188
189 /* Padding for future expansion */
190 void (*_gtk_reserved1) (void);
191 void (*_gtk_reserved2) (void);
192 void (*_gtk_reserved3) (void);
193 void (*_gtk_reserved4) (void);
194 void (*_gtk_reserved5) (void);
195 void (*_gtk_reserved6) (void);
196 void (*_gtk_reserved7) (void);
197 void (*_gtk_reserved8) (void);
198};
199
200/**
201 * GTK_PRINT_ERROR:
202 *
203 * The error domain for #GtkPrintError errors.
204 */
205#define GTK_PRINT_ERROR gtk_print_error_quark ()
206
207/**
208 * GtkPrintError:
209 * @GTK_PRINT_ERROR_GENERAL: An unspecified error occurred.
210 * @GTK_PRINT_ERROR_INTERNAL_ERROR: An internal error occurred.
211 * @GTK_PRINT_ERROR_NOMEM: A memory allocation failed.
212 * @GTK_PRINT_ERROR_INVALID_FILE: An error occurred while loading a page setup
213 * or paper size from a key file.
214 *
215 * Error codes that identify various errors that can occur while
216 * using the GTK+ printing support.
217 */
218typedef enum
219{
220 GTK_PRINT_ERROR_GENERAL,
221 GTK_PRINT_ERROR_INTERNAL_ERROR,
222 GTK_PRINT_ERROR_NOMEM,
223 GTK_PRINT_ERROR_INVALID_FILE
224} GtkPrintError;
225
226GDK_AVAILABLE_IN_ALL
227GQuark gtk_print_error_quark (void);
228
229GDK_AVAILABLE_IN_ALL
230GType gtk_print_operation_get_type (void) G_GNUC_CONST;
231GDK_AVAILABLE_IN_ALL
232GtkPrintOperation * gtk_print_operation_new (void);
233GDK_AVAILABLE_IN_ALL
234void gtk_print_operation_set_default_page_setup (GtkPrintOperation *op,
235 GtkPageSetup *default_page_setup);
236GDK_AVAILABLE_IN_ALL
237GtkPageSetup * gtk_print_operation_get_default_page_setup (GtkPrintOperation *op);
238GDK_AVAILABLE_IN_ALL
239void gtk_print_operation_set_print_settings (GtkPrintOperation *op,
240 GtkPrintSettings *print_settings);
241GDK_AVAILABLE_IN_ALL
242GtkPrintSettings * gtk_print_operation_get_print_settings (GtkPrintOperation *op);
243GDK_AVAILABLE_IN_ALL
244void gtk_print_operation_set_job_name (GtkPrintOperation *op,
245 const gchar *job_name);
246GDK_AVAILABLE_IN_ALL
247void gtk_print_operation_set_n_pages (GtkPrintOperation *op,
248 gint n_pages);
249GDK_AVAILABLE_IN_ALL
250void gtk_print_operation_set_current_page (GtkPrintOperation *op,
251 gint current_page);
252GDK_AVAILABLE_IN_ALL
253void gtk_print_operation_set_use_full_page (GtkPrintOperation *op,
254 gboolean full_page);
255GDK_AVAILABLE_IN_ALL
256void gtk_print_operation_set_unit (GtkPrintOperation *op,
257 GtkUnit unit);
258GDK_AVAILABLE_IN_ALL
259void gtk_print_operation_set_export_filename (GtkPrintOperation *op,
260 const gchar *filename);
261GDK_AVAILABLE_IN_ALL
262void gtk_print_operation_set_track_print_status (GtkPrintOperation *op,
263 gboolean track_status);
264GDK_AVAILABLE_IN_ALL
265void gtk_print_operation_set_show_progress (GtkPrintOperation *op,
266 gboolean show_progress);
267GDK_AVAILABLE_IN_ALL
268void gtk_print_operation_set_allow_async (GtkPrintOperation *op,
269 gboolean allow_async);
270GDK_AVAILABLE_IN_ALL
271void gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op,
272 const gchar *label);
273GDK_AVAILABLE_IN_ALL
274GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
275 GtkPrintOperationAction action,
276 GtkWindow *parent,
277 GError **error);
278GDK_AVAILABLE_IN_ALL
279void gtk_print_operation_get_error (GtkPrintOperation *op,
280 GError **error);
281GDK_AVAILABLE_IN_ALL
282GtkPrintStatus gtk_print_operation_get_status (GtkPrintOperation *op);
283GDK_AVAILABLE_IN_ALL
284const gchar * gtk_print_operation_get_status_string (GtkPrintOperation *op);
285GDK_AVAILABLE_IN_ALL
286gboolean gtk_print_operation_is_finished (GtkPrintOperation *op);
287GDK_AVAILABLE_IN_ALL
288void gtk_print_operation_cancel (GtkPrintOperation *op);
289GDK_AVAILABLE_IN_ALL
290void gtk_print_operation_draw_page_finish (GtkPrintOperation *op);
291GDK_AVAILABLE_IN_ALL
292void gtk_print_operation_set_defer_drawing (GtkPrintOperation *op);
293GDK_AVAILABLE_IN_ALL
294void gtk_print_operation_set_support_selection (GtkPrintOperation *op,
295 gboolean support_selection);
296GDK_AVAILABLE_IN_ALL
297gboolean gtk_print_operation_get_support_selection (GtkPrintOperation *op);
298GDK_AVAILABLE_IN_ALL
299void gtk_print_operation_set_has_selection (GtkPrintOperation *op,
300 gboolean has_selection);
301GDK_AVAILABLE_IN_ALL
302gboolean gtk_print_operation_get_has_selection (GtkPrintOperation *op);
303GDK_AVAILABLE_IN_ALL
304void gtk_print_operation_set_embed_page_setup (GtkPrintOperation *op,
305 gboolean embed);
306GDK_AVAILABLE_IN_ALL
307gboolean gtk_print_operation_get_embed_page_setup (GtkPrintOperation *op);
308GDK_AVAILABLE_IN_ALL
309gint gtk_print_operation_get_n_pages_to_print (GtkPrintOperation *op);
310
311GDK_AVAILABLE_IN_ALL
312GtkPageSetup *gtk_print_run_page_setup_dialog (GtkWindow *parent,
313 GtkPageSetup *page_setup,
314 GtkPrintSettings *settings);
315
316/**
317 * GtkPageSetupDoneFunc:
318 * @page_setup: the #GtkPageSetup that has been
319 * @data: (closure): user data that has been passed to
320 * gtk_print_run_page_setup_dialog_async()
321 *
322 * The type of function that is passed to
323 * gtk_print_run_page_setup_dialog_async().
324 *
325 * This function will be called when the page setup dialog
326 * is dismissed, and also serves as destroy notify for @data.
327 */
328typedef void (* GtkPageSetupDoneFunc) (GtkPageSetup *page_setup,
329 gpointer data);
330
331GDK_AVAILABLE_IN_ALL
332void gtk_print_run_page_setup_dialog_async (GtkWindow *parent,
333 GtkPageSetup *page_setup,
334 GtkPrintSettings *settings,
335 GtkPageSetupDoneFunc done_cb,
336 gpointer data);
337
338G_END_DECLS
339
340#endif /* __GTK_PRINT_OPERATION_H__ */
341

source code of include/gtk-3.0/gtk/gtkprintoperation.h