]> Pileus Git - ~andy/gtk/blob - gtk/gtkprintoperation.h
Whitespace fixes
[~andy/gtk] / gtk / gtkprintoperation.h
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, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 #error "Only <gtk/gtk.h> can be included directly."
23 #endif
24
25 #ifndef __GTK_PRINT_OPERATION_H__
26 #define __GTK_PRINT_OPERATION_H__
27
28
29 #include <cairo.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>
36
37
38 G_BEGIN_DECLS
39
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))
46
47 typedef struct _GtkPrintOperationClass   GtkPrintOperationClass;
48 typedef struct _GtkPrintOperationPrivate GtkPrintOperationPrivate;
49 typedef struct _GtkPrintOperation        GtkPrintOperation;
50
51 /**
52  * GtkPrintStatus:
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
60  *     printer.
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.
68  *
69  * The status gives a rough indication of the completion of a running
70  * print operation.
71  */
72 typedef enum {
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
82 } GtkPrintStatus;
83
84 /**
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.
92  *
93  * A value of this type is returned by gtk_print_operation_run().
94  */
95 typedef enum {
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;
101
102 /**
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.
110  *
111  * The @action parameter to gtk_print_operation_run()
112  * determines what action the print operation should perform.
113  */
114 typedef enum {
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;
120
121
122 struct _GtkPrintOperation
123 {
124   GObject parent_instance;
125
126   /*< private >*/
127   GtkPrintOperationPrivate *priv;
128 };
129
130 struct _GtkPrintOperationClass
131 {
132   GObjectClass parent_class;
133
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,
142                                   gint               page_nr,
143                                   GtkPageSetup      *setup);
144   void     (*draw_page)          (GtkPrintOperation *operation,
145                                   GtkPrintContext   *context,
146                                   gint               page_nr);
147   void     (*end_print)          (GtkPrintOperation *operation,
148                                   GtkPrintContext   *context);
149   void     (*status_changed)     (GtkPrintOperation *operation);
150
151   GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
152   void       (*custom_widget_apply)  (GtkPrintOperation *operation,
153                                       GtkWidget         *widget);
154
155   gboolean (*preview)        (GtkPrintOperation        *operation,
156                               GtkPrintOperationPreview *preview,
157                               GtkPrintContext          *context,
158                               GtkWindow                *parent);
159
160   void     (*update_custom_widget) (GtkPrintOperation *operation,
161                                     GtkWidget         *widget,
162                                     GtkPageSetup      *setup,
163                                     GtkPrintSettings  *settings);
164
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);
174 };
175
176 /**
177  * GTK_PRINT_ERROR:
178  *
179  * The error domain for #GtkPrintError errors.
180  */
181 #define GTK_PRINT_ERROR gtk_print_error_quark ()
182
183 /**
184  * GtkPrintError:
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.
190  *
191  * Error codes that identify various errors that can occur while
192  * using the GTK+ printing support.
193  */
194 typedef enum
195 {
196   GTK_PRINT_ERROR_GENERAL,
197   GTK_PRINT_ERROR_INTERNAL_ERROR,
198   GTK_PRINT_ERROR_NOMEM,
199   GTK_PRINT_ERROR_INVALID_FILE
200 } GtkPrintError;
201
202 GQuark gtk_print_error_quark (void);
203
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,
215                                                                     gint                n_pages);
216 void                    gtk_print_operation_set_current_page       (GtkPrintOperation  *op,
217                                                                     gint                current_page);
218 void                    gtk_print_operation_set_use_full_page      (GtkPrintOperation  *op,
219                                                                     gboolean            full_page);
220 void                    gtk_print_operation_set_unit               (GtkPrintOperation  *op,
221                                                                     GtkUnit             unit);
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,
231                                                                     const gchar        *label);
232 GtkPrintOperationResult gtk_print_operation_run                    (GtkPrintOperation  *op,
233                                                                     GtkPrintOperationAction action,
234                                                                     GtkWindow          *parent,
235                                                                     GError            **error);
236 void                    gtk_print_operation_get_error              (GtkPrintOperation  *op,
237                                                                     GError            **error);
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,
251                                                                     gboolean            embed);
252 gboolean                gtk_print_operation_get_embed_page_setup   (GtkPrintOperation  *op);
253 gint                    gtk_print_operation_get_n_pages_to_print   (GtkPrintOperation  *op);
254
255 GtkPageSetup           *gtk_print_run_page_setup_dialog            (GtkWindow          *parent,
256                                                                     GtkPageSetup       *page_setup,
257                                                                     GtkPrintSettings   *settings);
258
259 /**
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()
264  *
265  * The type of function that is passed to
266  * gtk_print_run_page_setup_dialog_async().
267  *
268  * This function will be called when the page setup dialog
269  * is dismissed, and also serves as destroy notify for @data.
270  */
271 typedef void  (* GtkPageSetupDoneFunc) (GtkPageSetup *page_setup,
272                                         gpointer      data);
273
274 void                    gtk_print_run_page_setup_dialog_async      (GtkWindow            *parent,
275                                                                     GtkPageSetup         *page_setup,
276                                                                     GtkPrintSettings     *settings,
277                                                                     GtkPageSetupDoneFunc  done_cb,
278                                                                     gpointer              data);
279
280 G_END_DECLS
281
282 #endif /* __GTK_PRINT_OPERATION_H__ */