1 /* GTK - The GIMP Toolkit
2 * gtkprintoperation.h: Print Operation
3 * Copyright (C) 2006, Red Hat, Inc.
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.
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.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 #error "Only <gtk/gtk.h> can be included directly."
25 #ifndef __GTK_PRINT_OPERATION_H__
26 #define __GTK_PRINT_OPERATION_H__
30 #include <gtk/gtkmain.h>
31 #include <gtk/gtkwindow.h>
32 #include <gtk/gtkpagesetup.h>
33 #include <gtk/gtkprintsettings.h>
34 #include <gtk/gtkprintcontext.h>
35 #include <gtk/gtkprintoperationpreview.h>
40 #define GTK_TYPE_PRINT_OPERATION (gtk_print_operation_get_type ())
41 #define GTK_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperation))
42 #define GTK_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationClass))
43 #define GTK_IS_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_OPERATION))
44 #define GTK_IS_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_OPERATION))
45 #define GTK_PRINT_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationClass))
47 typedef struct _GtkPrintOperationClass GtkPrintOperationClass;
48 typedef struct _GtkPrintOperationPrivate GtkPrintOperationPrivate;
49 typedef struct _GtkPrintOperation GtkPrintOperation;
53 * @GTK_PRINT_STATUS_INITIAL: The printing has not started yet; this
54 * status is set initially, and while the print dialog is shown.
55 * @GTK_PRINT_STATUS_PREPARING: This status is set while the begin-print
56 * signal is emitted and during pagination.
57 * @GTK_PRINT_STATUS_GENERATING_DATA: This status is set while the
58 * pages are being rendered.
59 * @GTK_PRINT_STATUS_SENDING_DATA: The print job is being sent off to the
61 * @GTK_PRINT_STATUS_PENDING: The print job has been sent to the printer,
62 * but is not printed for some reason, e.g. the printer may be stopped.
63 * @GTK_PRINT_STATUS_PENDING_ISSUE: Some problem has occurred during
64 * printing, e.g. a paper jam.
65 * @GTK_PRINT_STATUS_PRINTING: The printer is processing the print job.
66 * @GTK_PRINT_STATUS_FINISHED: The printing has been completed successfully.
67 * @GTK_PRINT_STATUS_FINISHED_ABORTED: The printing has been aborted.
69 * The status gives a rough indication of the completion of a running
73 GTK_PRINT_STATUS_INITIAL,
74 GTK_PRINT_STATUS_PREPARING,
75 GTK_PRINT_STATUS_GENERATING_DATA,
76 GTK_PRINT_STATUS_SENDING_DATA,
77 GTK_PRINT_STATUS_PENDING,
78 GTK_PRINT_STATUS_PENDING_ISSUE,
79 GTK_PRINT_STATUS_PRINTING,
80 GTK_PRINT_STATUS_FINISHED,
81 GTK_PRINT_STATUS_FINISHED_ABORTED
85 * GtkPrintOperationResult:
86 * @GTK_PRINT_OPERATION_RESULT_ERROR: An error has occured.
87 * @GTK_PRINT_OPERATION_RESULT_APPLY: The print settings should be stored.
88 * @GTK_PRINT_OPERATION_RESULT_CANCEL: The print operation has been canceled,
89 * the print settings should not be stored.
90 * @GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: The print operation is not complete
91 * yet. This value will only be returned when running asynchronously.
93 * A value of this type is returned by gtk_print_operation_run().
96 GTK_PRINT_OPERATION_RESULT_ERROR,
97 GTK_PRINT_OPERATION_RESULT_APPLY,
98 GTK_PRINT_OPERATION_RESULT_CANCEL,
99 GTK_PRINT_OPERATION_RESULT_IN_PROGRESS
100 } GtkPrintOperationResult;
103 * GtkPrintOperationAction:
104 * @GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG: Show the print dialog.
105 * @GTK_PRINT_OPERATION_ACTION_PRINT: Start to print without showing
106 * the print dialog, based on the current print settings.
107 * @GTK_PRINT_OPERATION_ACTION_PREVIEW: Show the print preview.
108 * @GTK_PRINT_OPERATION_ACTION_EXPORT: Export to a file. This requires
109 * the export-filename property to be set.
111 * The @action parameter to gtk_print_operation_run()
112 * determines what action the print operation should perform.
115 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
116 GTK_PRINT_OPERATION_ACTION_PRINT,
117 GTK_PRINT_OPERATION_ACTION_PREVIEW,
118 GTK_PRINT_OPERATION_ACTION_EXPORT
119 } GtkPrintOperationAction;
122 struct _GtkPrintOperation
124 GObject parent_instance;
127 GtkPrintOperationPrivate *priv;
130 struct _GtkPrintOperationClass
132 GObjectClass parent_class;
134 void (*done) (GtkPrintOperation *operation,
135 GtkPrintOperationResult result);
136 void (*begin_print) (GtkPrintOperation *operation,
137 GtkPrintContext *context);
138 gboolean (*paginate) (GtkPrintOperation *operation,
139 GtkPrintContext *context);
140 void (*request_page_setup) (GtkPrintOperation *operation,
141 GtkPrintContext *context,
143 GtkPageSetup *setup);
144 void (*draw_page) (GtkPrintOperation *operation,
145 GtkPrintContext *context,
147 void (*end_print) (GtkPrintOperation *operation,
148 GtkPrintContext *context);
149 void (*status_changed) (GtkPrintOperation *operation);
151 GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
152 void (*custom_widget_apply) (GtkPrintOperation *operation,
155 gboolean (*preview) (GtkPrintOperation *operation,
156 GtkPrintOperationPreview *preview,
157 GtkPrintContext *context,
160 void (*update_custom_widget) (GtkPrintOperation *operation,
163 GtkPrintSettings *settings);
165 /* Padding for future expansion */
166 void (*_gtk_reserved1) (void);
167 void (*_gtk_reserved2) (void);
168 void (*_gtk_reserved3) (void);
169 void (*_gtk_reserved4) (void);
170 void (*_gtk_reserved5) (void);
171 void (*_gtk_reserved6) (void);
172 void (*_gtk_reserved7) (void);
173 void (*_gtk_reserved8) (void);
179 * The error domain for #GtkPrintError errors.
181 #define GTK_PRINT_ERROR gtk_print_error_quark ()
185 * @GTK_PRINT_ERROR_GENERAL: An unspecified error occurred.
186 * @GTK_PRINT_ERROR_INTERNAL_ERROR: An internal error occurred.
187 * @GTK_PRINT_ERROR_NOMEM: A memory allocation failed.
188 * @GTK_PRINT_ERROR_INVALID_FILE: An error occurred while loading a page setup
189 * or paper size from a key file.
191 * Error codes that identify various errors that can occur while
192 * using the GTK+ printing support.
196 GTK_PRINT_ERROR_GENERAL,
197 GTK_PRINT_ERROR_INTERNAL_ERROR,
198 GTK_PRINT_ERROR_NOMEM,
199 GTK_PRINT_ERROR_INVALID_FILE
202 GQuark gtk_print_error_quark (void);
204 GType gtk_print_operation_get_type (void) G_GNUC_CONST;
205 GtkPrintOperation * gtk_print_operation_new (void);
206 void gtk_print_operation_set_default_page_setup (GtkPrintOperation *op,
207 GtkPageSetup *default_page_setup);
208 GtkPageSetup * gtk_print_operation_get_default_page_setup (GtkPrintOperation *op);
209 void gtk_print_operation_set_print_settings (GtkPrintOperation *op,
210 GtkPrintSettings *print_settings);
211 GtkPrintSettings * gtk_print_operation_get_print_settings (GtkPrintOperation *op);
212 void gtk_print_operation_set_job_name (GtkPrintOperation *op,
213 const gchar *job_name);
214 void gtk_print_operation_set_n_pages (GtkPrintOperation *op,
216 void gtk_print_operation_set_current_page (GtkPrintOperation *op,
218 void gtk_print_operation_set_use_full_page (GtkPrintOperation *op,
220 void gtk_print_operation_set_unit (GtkPrintOperation *op,
222 void gtk_print_operation_set_export_filename (GtkPrintOperation *op,
223 const gchar *filename);
224 void gtk_print_operation_set_track_print_status (GtkPrintOperation *op,
225 gboolean track_status);
226 void gtk_print_operation_set_show_progress (GtkPrintOperation *op,
227 gboolean show_progress);
228 void gtk_print_operation_set_allow_async (GtkPrintOperation *op,
229 gboolean allow_async);
230 void gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op,
232 GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
233 GtkPrintOperationAction action,
236 void gtk_print_operation_get_error (GtkPrintOperation *op,
238 GtkPrintStatus gtk_print_operation_get_status (GtkPrintOperation *op);
239 G_CONST_RETURN gchar * gtk_print_operation_get_status_string (GtkPrintOperation *op);
240 gboolean gtk_print_operation_is_finished (GtkPrintOperation *op);
241 void gtk_print_operation_cancel (GtkPrintOperation *op);
242 void gtk_print_operation_draw_page_finish (GtkPrintOperation *op);
243 void gtk_print_operation_set_defer_drawing (GtkPrintOperation *op);
244 void gtk_print_operation_set_support_selection (GtkPrintOperation *op,
245 gboolean support_selection);
246 gboolean gtk_print_operation_get_support_selection (GtkPrintOperation *op);
247 void gtk_print_operation_set_has_selection (GtkPrintOperation *op,
248 gboolean has_selection);
249 gboolean gtk_print_operation_get_has_selection (GtkPrintOperation *op);
250 void gtk_print_operation_set_embed_page_setup (GtkPrintOperation *op,
252 gboolean gtk_print_operation_get_embed_page_setup (GtkPrintOperation *op);
253 gint gtk_print_operation_get_n_pages_to_print (GtkPrintOperation *op);
255 GtkPageSetup *gtk_print_run_page_setup_dialog (GtkWindow *parent,
256 GtkPageSetup *page_setup,
257 GtkPrintSettings *settings);
260 * GtkPageSetupDoneFunc:
261 * @page_setup: the #GtkPageSetup that has been
262 * @data: (closure): user data that has been passed to
263 * gtk_print_run_page_setup_dialog_async()
265 * The type of function that is passed to
266 * gtk_print_run_page_setup_dialog_async().
268 * This function will be called when the page setup dialog
269 * is dismissed, and also serves as destroy notify for @data.
271 typedef void (* GtkPageSetupDoneFunc) (GtkPageSetup *page_setup,
274 void gtk_print_run_page_setup_dialog_async (GtkWindow *parent,
275 GtkPageSetup *page_setup,
276 GtkPrintSettings *settings,
277 GtkPageSetupDoneFunc done_cb,
282 #endif /* __GTK_PRINT_OPERATION_H__ */