]> Pileus Git - ~andy/gtk/blob - gtk/gtkprintoperation.h
stylecontext: Do invalidation on first resize container
[~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, 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
36 G_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
45 typedef struct _GtkPrintOperationClass   GtkPrintOperationClass;
46 typedef struct _GtkPrintOperationPrivate GtkPrintOperationPrivate;
47 typedef 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  */
70 typedef 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 occured.
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  */
93 typedef 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  */
112 typedef 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
120 struct _GtkPrintOperation
121 {
122   GObject parent_instance;
123
124   /*< private >*/
125   GtkPrintOperationPrivate *priv;
126 };
127
128 struct _GtkPrintOperationClass
129 {
130   GObjectClass parent_class;
131
132   void     (*done)               (GtkPrintOperation *operation,
133                                   GtkPrintOperationResult result);
134   void     (*begin_print)        (GtkPrintOperation *operation,
135                                   GtkPrintContext   *context);
136   gboolean (*paginate)           (GtkPrintOperation *operation,
137                                   GtkPrintContext   *context);
138   void     (*request_page_setup) (GtkPrintOperation *operation,
139                                   GtkPrintContext   *context,
140                                   gint               page_nr,
141                                   GtkPageSetup      *setup);
142   void     (*draw_page)          (GtkPrintOperation *operation,
143                                   GtkPrintContext   *context,
144                                   gint               page_nr);
145   void     (*end_print)          (GtkPrintOperation *operation,
146                                   GtkPrintContext   *context);
147   void     (*status_changed)     (GtkPrintOperation *operation);
148
149   GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
150   void       (*custom_widget_apply)  (GtkPrintOperation *operation,
151                                       GtkWidget         *widget);
152
153   gboolean (*preview)        (GtkPrintOperation        *operation,
154                               GtkPrintOperationPreview *preview,
155                               GtkPrintContext          *context,
156                               GtkWindow                *parent);
157
158   void     (*update_custom_widget) (GtkPrintOperation *operation,
159                                     GtkWidget         *widget,
160                                     GtkPageSetup      *setup,
161                                     GtkPrintSettings  *settings);
162
163   /* Padding for future expansion */
164   void (*_gtk_reserved1) (void);
165   void (*_gtk_reserved2) (void);
166   void (*_gtk_reserved3) (void);
167   void (*_gtk_reserved4) (void);
168   void (*_gtk_reserved5) (void);
169   void (*_gtk_reserved6) (void);
170   void (*_gtk_reserved7) (void);
171   void (*_gtk_reserved8) (void);
172 };
173
174 /**
175  * GTK_PRINT_ERROR:
176  *
177  * The error domain for #GtkPrintError errors.
178  */
179 #define GTK_PRINT_ERROR gtk_print_error_quark ()
180
181 /**
182  * GtkPrintError:
183  * @GTK_PRINT_ERROR_GENERAL: An unspecified error occurred.
184  * @GTK_PRINT_ERROR_INTERNAL_ERROR: An internal error occurred.
185  * @GTK_PRINT_ERROR_NOMEM: A memory allocation failed.
186  * @GTK_PRINT_ERROR_INVALID_FILE: An error occurred while loading a page setup
187  *     or paper size from a key file.
188  *
189  * Error codes that identify various errors that can occur while
190  * using the GTK+ printing support.
191  */
192 typedef enum
193 {
194   GTK_PRINT_ERROR_GENERAL,
195   GTK_PRINT_ERROR_INTERNAL_ERROR,
196   GTK_PRINT_ERROR_NOMEM,
197   GTK_PRINT_ERROR_INVALID_FILE
198 } GtkPrintError;
199
200 GQuark gtk_print_error_quark (void);
201
202 GType                   gtk_print_operation_get_type               (void) G_GNUC_CONST;
203 GtkPrintOperation *     gtk_print_operation_new                    (void);
204 void                    gtk_print_operation_set_default_page_setup (GtkPrintOperation  *op,
205                                                                     GtkPageSetup       *default_page_setup);
206 GtkPageSetup *          gtk_print_operation_get_default_page_setup (GtkPrintOperation  *op);
207 void                    gtk_print_operation_set_print_settings     (GtkPrintOperation  *op,
208                                                                     GtkPrintSettings   *print_settings);
209 GtkPrintSettings *      gtk_print_operation_get_print_settings     (GtkPrintOperation  *op);
210 void                    gtk_print_operation_set_job_name           (GtkPrintOperation  *op,
211                                                                     const gchar        *job_name);
212 void                    gtk_print_operation_set_n_pages            (GtkPrintOperation  *op,
213                                                                     gint                n_pages);
214 void                    gtk_print_operation_set_current_page       (GtkPrintOperation  *op,
215                                                                     gint                current_page);
216 void                    gtk_print_operation_set_use_full_page      (GtkPrintOperation  *op,
217                                                                     gboolean            full_page);
218 void                    gtk_print_operation_set_unit               (GtkPrintOperation  *op,
219                                                                     GtkUnit             unit);
220 void                    gtk_print_operation_set_export_filename    (GtkPrintOperation  *op,
221                                                                     const gchar        *filename);
222 void                    gtk_print_operation_set_track_print_status (GtkPrintOperation  *op,
223                                                                     gboolean            track_status);
224 void                    gtk_print_operation_set_show_progress      (GtkPrintOperation  *op,
225                                                                     gboolean            show_progress);
226 void                    gtk_print_operation_set_allow_async        (GtkPrintOperation  *op,
227                                                                     gboolean            allow_async);
228 void                    gtk_print_operation_set_custom_tab_label   (GtkPrintOperation  *op,
229                                                                     const gchar        *label);
230 GtkPrintOperationResult gtk_print_operation_run                    (GtkPrintOperation  *op,
231                                                                     GtkPrintOperationAction action,
232                                                                     GtkWindow          *parent,
233                                                                     GError            **error);
234 void                    gtk_print_operation_get_error              (GtkPrintOperation  *op,
235                                                                     GError            **error);
236 GtkPrintStatus          gtk_print_operation_get_status             (GtkPrintOperation  *op);
237 const gchar *           gtk_print_operation_get_status_string      (GtkPrintOperation  *op);
238 gboolean                gtk_print_operation_is_finished            (GtkPrintOperation  *op);
239 void                    gtk_print_operation_cancel                 (GtkPrintOperation  *op);
240 void                    gtk_print_operation_draw_page_finish       (GtkPrintOperation  *op);
241 void                    gtk_print_operation_set_defer_drawing      (GtkPrintOperation  *op);
242 void                    gtk_print_operation_set_support_selection  (GtkPrintOperation  *op,
243                                                                     gboolean            support_selection);
244 gboolean                gtk_print_operation_get_support_selection  (GtkPrintOperation  *op);
245 void                    gtk_print_operation_set_has_selection      (GtkPrintOperation  *op,
246                                                                     gboolean            has_selection);
247 gboolean                gtk_print_operation_get_has_selection      (GtkPrintOperation  *op);
248 void                    gtk_print_operation_set_embed_page_setup   (GtkPrintOperation  *op,
249                                                                     gboolean            embed);
250 gboolean                gtk_print_operation_get_embed_page_setup   (GtkPrintOperation  *op);
251 gint                    gtk_print_operation_get_n_pages_to_print   (GtkPrintOperation  *op);
252
253 GtkPageSetup           *gtk_print_run_page_setup_dialog            (GtkWindow          *parent,
254                                                                     GtkPageSetup       *page_setup,
255                                                                     GtkPrintSettings   *settings);
256
257 /**
258  * GtkPageSetupDoneFunc:
259  * @page_setup: the #GtkPageSetup that has been
260  * @data: (closure): user data that has been passed to
261  *     gtk_print_run_page_setup_dialog_async()
262  *
263  * The type of function that is passed to
264  * gtk_print_run_page_setup_dialog_async().
265  *
266  * This function will be called when the page setup dialog
267  * is dismissed, and also serves as destroy notify for @data.
268  */
269 typedef void  (* GtkPageSetupDoneFunc) (GtkPageSetup *page_setup,
270                                         gpointer      data);
271
272 void                    gtk_print_run_page_setup_dialog_async      (GtkWindow            *parent,
273                                                                     GtkPageSetup         *page_setup,
274                                                                     GtkPrintSettings     *settings,
275                                                                     GtkPageSetupDoneFunc  done_cb,
276                                                                     gpointer              data);
277
278 G_END_DECLS
279
280 #endif /* __GTK_PRINT_OPERATION_H__ */