gtkprintoperation.h 15.5 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
2 3 4 5 6 7 8 9 10 11 12 13 14 15
 * gtkprintoperation.h: Print Operation
 * Copyright (C) 2006, Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
16
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 18 19 20 21
 */

#ifndef __GTK_PRINT_OPERATION_H__
#define __GTK_PRINT_OPERATION_H__

22

23 24 25 26
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif

27
#include <cairo.h>
28 29 30 31 32 33
#include <gtk/gtkmain.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtkpagesetup.h>
#include <gtk/gtkprintsettings.h>
#include <gtk/gtkprintcontext.h>
#include <gtk/gtkprintoperationpreview.h>
34

35

36 37
G_BEGIN_DECLS

Matthias Clasen's avatar
Matthias Clasen committed
38 39 40 41 42 43
#define GTK_TYPE_PRINT_OPERATION                (gtk_print_operation_get_type ())
#define GTK_PRINT_OPERATION(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperation))
#define GTK_PRINT_OPERATION_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationClass))
#define GTK_IS_PRINT_OPERATION(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_OPERATION))
#define GTK_IS_PRINT_OPERATION_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_OPERATION))
#define GTK_PRINT_OPERATION_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationClass))
44 45 46 47 48

typedef struct _GtkPrintOperationClass   GtkPrintOperationClass;
typedef struct _GtkPrintOperationPrivate GtkPrintOperationPrivate;
typedef struct _GtkPrintOperation        GtkPrintOperation;

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
/**
 * GtkPrintStatus:
 * @GTK_PRINT_STATUS_INITIAL: The printing has not started yet; this
 *     status is set initially, and while the print dialog is shown.
 * @GTK_PRINT_STATUS_PREPARING: This status is set while the begin-print
 *     signal is emitted and during pagination.
 * @GTK_PRINT_STATUS_GENERATING_DATA: This status is set while the
 *     pages are being rendered.
 * @GTK_PRINT_STATUS_SENDING_DATA: The print job is being sent off to the
 *     printer.
 * @GTK_PRINT_STATUS_PENDING: The print job has been sent to the printer,
 *     but is not printed for some reason, e.g. the printer may be stopped.
 * @GTK_PRINT_STATUS_PENDING_ISSUE: Some problem has occurred during
 *     printing, e.g. a paper jam.
 * @GTK_PRINT_STATUS_PRINTING: The printer is processing the print job.
 * @GTK_PRINT_STATUS_FINISHED: The printing has been completed successfully.
 * @GTK_PRINT_STATUS_FINISHED_ABORTED: The printing has been aborted.
 *
 * The status gives a rough indication of the completion of a running
 * print operation.
 */
70 71 72 73 74 75 76 77 78 79 80 81
typedef enum {
  GTK_PRINT_STATUS_INITIAL,
  GTK_PRINT_STATUS_PREPARING,
  GTK_PRINT_STATUS_GENERATING_DATA,
  GTK_PRINT_STATUS_SENDING_DATA,
  GTK_PRINT_STATUS_PENDING,
  GTK_PRINT_STATUS_PENDING_ISSUE,
  GTK_PRINT_STATUS_PRINTING,
  GTK_PRINT_STATUS_FINISHED,
  GTK_PRINT_STATUS_FINISHED_ABORTED
} GtkPrintStatus;

82 83 84 85 86 87 88 89 90 91 92
/**
 * GtkPrintOperationResult:
 * @GTK_PRINT_OPERATION_RESULT_ERROR: An error has occured.
 * @GTK_PRINT_OPERATION_RESULT_APPLY: The print settings should be stored.
 * @GTK_PRINT_OPERATION_RESULT_CANCEL: The print operation has been canceled,
 *     the print settings should not be stored.
 * @GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: The print operation is not complete
 *     yet. This value will only be returned when running asynchronously.
 *
 * A value of this type is returned by gtk_print_operation_run().
 */
93 94 95 96 97 98 99
typedef enum {
  GTK_PRINT_OPERATION_RESULT_ERROR,
  GTK_PRINT_OPERATION_RESULT_APPLY,
  GTK_PRINT_OPERATION_RESULT_CANCEL,
  GTK_PRINT_OPERATION_RESULT_IN_PROGRESS
} GtkPrintOperationResult;

100 101 102 103 104 105 106 107 108 109 110 111
/**
 * GtkPrintOperationAction:
 * @GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG: Show the print dialog.
 * @GTK_PRINT_OPERATION_ACTION_PRINT: Start to print without showing
 *     the print dialog, based on the current print settings.
 * @GTK_PRINT_OPERATION_ACTION_PREVIEW: Show the print preview.
 * @GTK_PRINT_OPERATION_ACTION_EXPORT: Export to a file. This requires
 *     the export-filename property to be set.
 *
 * The @action parameter to gtk_print_operation_run()
 * determines what action the print operation should perform.
 */
112 113 114 115
typedef enum {
  GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
  GTK_PRINT_OPERATION_ACTION_PRINT,
  GTK_PRINT_OPERATION_ACTION_PREVIEW,
Matthias Clasen's avatar
Matthias Clasen committed
116
  GTK_PRINT_OPERATION_ACTION_EXPORT
117 118 119
} GtkPrintOperationAction;


120 121 122
struct _GtkPrintOperation
{
  GObject parent_instance;
123

124
  /*< private >*/
125
  GtkPrintOperationPrivate *priv;
126 127
};

128 129 130 131 132 133 134
/**
 * GtkPrintOperationClass:
 * @parent_class: The parent class.
 * @done: Signal emitted when the print operation run has finished
 *    doing everything required for printing.
 * @begin_print: Signal emitted after the user has finished changing
 *    print settings in the dialog, before the actual rendering starts.
135
 * @paginate: Signal emitted after the “begin-print” signal, but
136 137 138 139 140 141 142 143
 *    before the actual rendering starts.
 * @request_page_setup: Emitted once for every page that is printed,
 *    to give the application a chance to modify the page setup.
 * @draw_page: Signal emitted for every page that is printed.
 * @end_print: Signal emitted after all pages have been rendered.
 * @status_changed: Emitted at between the various phases of the print
 *    operation.
 * @create_custom_widget: Signal emitted when displaying the print dialog.
144 145
 * @custom_widget_apply: Signal emitted right before “begin-print” if
 *    you added a custom widget in the “create-custom-widget” handler.
146 147 148 149
 * @preview: Signal emitted when a preview is requested from the
 *    native dialog.
 * @update_custom_widget: Emitted after change of selected printer.
 */
150 151 152
struct _GtkPrintOperationClass
{
  GObjectClass parent_class;
153

154 155
  /*< public >*/

156
  void     (*done)               (GtkPrintOperation *operation,
Matthias Clasen's avatar
Matthias Clasen committed
157
                                  GtkPrintOperationResult result);
158
  void     (*begin_print)        (GtkPrintOperation *operation,
Matthias Clasen's avatar
Matthias Clasen committed
159
                                  GtkPrintContext   *context);
160
  gboolean (*paginate)           (GtkPrintOperation *operation,
Matthias Clasen's avatar
Matthias Clasen committed
161
                                  GtkPrintContext   *context);
162
  void     (*request_page_setup) (GtkPrintOperation *operation,
Matthias Clasen's avatar
Matthias Clasen committed
163 164 165
                                  GtkPrintContext   *context,
                                  gint               page_nr,
                                  GtkPageSetup      *setup);
166
  void     (*draw_page)          (GtkPrintOperation *operation,
Matthias Clasen's avatar
Matthias Clasen committed
167 168
                                  GtkPrintContext   *context,
                                  gint               page_nr);
169
  void     (*end_print)          (GtkPrintOperation *operation,
Matthias Clasen's avatar
Matthias Clasen committed
170
                                  GtkPrintContext   *context);
171
  void     (*status_changed)     (GtkPrintOperation *operation);
172 173 174

  GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
  void       (*custom_widget_apply)  (GtkPrintOperation *operation,
Matthias Clasen's avatar
Matthias Clasen committed
175
                                      GtkWidget         *widget);
176

Matthias Clasen's avatar
Matthias Clasen committed
177 178 179 180
  gboolean (*preview)        (GtkPrintOperation        *operation,
                              GtkPrintOperationPreview *preview,
                              GtkPrintContext          *context,
                              GtkWindow                *parent);
181

182 183 184 185 186
  void     (*update_custom_widget) (GtkPrintOperation *operation,
                                    GtkWidget         *widget,
                                    GtkPageSetup      *setup,
                                    GtkPrintSettings  *settings);

187 188
  /*< private >*/

189 190 191 192 193 194 195
  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
  void (*_gtk_reserved5) (void);
  void (*_gtk_reserved6) (void);
196 197
  void (*_gtk_reserved7) (void);
  void (*_gtk_reserved8) (void);
198 199
};

200 201 202 203 204
/**
 * GTK_PRINT_ERROR:
 *
 * The error domain for #GtkPrintError errors.
 */
205 206
#define GTK_PRINT_ERROR gtk_print_error_quark ()

207 208 209 210 211 212 213 214 215 216 217
/**
 * GtkPrintError:
 * @GTK_PRINT_ERROR_GENERAL: An unspecified error occurred.
 * @GTK_PRINT_ERROR_INTERNAL_ERROR: An internal error occurred.
 * @GTK_PRINT_ERROR_NOMEM: A memory allocation failed.
 * @GTK_PRINT_ERROR_INVALID_FILE: An error occurred while loading a page setup
 *     or paper size from a key file.
 *
 * Error codes that identify various errors that can occur while
 * using the GTK+ printing support.
 */
218 219 220 221
typedef enum
{
  GTK_PRINT_ERROR_GENERAL,
  GTK_PRINT_ERROR_INTERNAL_ERROR,
Matthias Clasen's avatar
Matthias Clasen committed
222 223
  GTK_PRINT_ERROR_NOMEM,
  GTK_PRINT_ERROR_INVALID_FILE
224 225
} GtkPrintError;

226
GDK_AVAILABLE_IN_ALL
227 228
GQuark gtk_print_error_quark (void);

229
GDK_AVAILABLE_IN_ALL
230
GType                   gtk_print_operation_get_type               (void) G_GNUC_CONST;
231
GDK_AVAILABLE_IN_ALL
232
GtkPrintOperation *     gtk_print_operation_new                    (void);
233
GDK_AVAILABLE_IN_ALL
234
void                    gtk_print_operation_set_default_page_setup (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
235
                                                                    GtkPageSetup       *default_page_setup);
236
GDK_AVAILABLE_IN_ALL
237
GtkPageSetup *          gtk_print_operation_get_default_page_setup (GtkPrintOperation  *op);
238
GDK_AVAILABLE_IN_ALL
239
void                    gtk_print_operation_set_print_settings     (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
240
                                                                    GtkPrintSettings   *print_settings);
241
GDK_AVAILABLE_IN_ALL
242
GtkPrintSettings *      gtk_print_operation_get_print_settings     (GtkPrintOperation  *op);
243
GDK_AVAILABLE_IN_ALL
244
void                    gtk_print_operation_set_job_name           (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
245
                                                                    const gchar        *job_name);
246
GDK_AVAILABLE_IN_ALL
Alexander Larsson's avatar
Alexander Larsson committed
247
void                    gtk_print_operation_set_n_pages            (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
248
                                                                    gint                n_pages);
249
GDK_AVAILABLE_IN_ALL
250
void                    gtk_print_operation_set_current_page       (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
251
                                                                    gint                current_page);
252
GDK_AVAILABLE_IN_ALL
253
void                    gtk_print_operation_set_use_full_page      (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
254
                                                                    gboolean            full_page);
255
GDK_AVAILABLE_IN_ALL
256
void                    gtk_print_operation_set_unit               (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
257
                                                                    GtkUnit             unit);
258
GDK_AVAILABLE_IN_ALL
259
void                    gtk_print_operation_set_export_filename    (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
260
                                                                    const gchar        *filename);
261
GDK_AVAILABLE_IN_ALL
262
void                    gtk_print_operation_set_track_print_status (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
263
                                                                    gboolean            track_status);
264
GDK_AVAILABLE_IN_ALL
265
void                    gtk_print_operation_set_show_progress      (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
266
                                                                    gboolean            show_progress);
267
GDK_AVAILABLE_IN_ALL
268
void                    gtk_print_operation_set_allow_async        (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
269
                                                                    gboolean            allow_async);
270
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
271
void                    gtk_print_operation_set_custom_tab_label   (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
272
                                                                    const gchar        *label);
273
GDK_AVAILABLE_IN_ALL
274
GtkPrintOperationResult gtk_print_operation_run                    (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
275 276 277
                                                                    GtkPrintOperationAction action,
                                                                    GtkWindow          *parent,
                                                                    GError            **error);
278
GDK_AVAILABLE_IN_ALL
279
void                    gtk_print_operation_get_error              (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
280
                                                                    GError            **error);
281
GDK_AVAILABLE_IN_ALL
282
GtkPrintStatus          gtk_print_operation_get_status             (GtkPrintOperation  *op);
283
GDK_AVAILABLE_IN_ALL
284
const gchar *           gtk_print_operation_get_status_string      (GtkPrintOperation  *op);
285
GDK_AVAILABLE_IN_ALL
286
gboolean                gtk_print_operation_is_finished            (GtkPrintOperation  *op);
287
GDK_AVAILABLE_IN_ALL
288
void                    gtk_print_operation_cancel                 (GtkPrintOperation  *op);
289
GDK_AVAILABLE_IN_ALL
290
void                    gtk_print_operation_draw_page_finish       (GtkPrintOperation  *op);
291
GDK_AVAILABLE_IN_ALL
292
void                    gtk_print_operation_set_defer_drawing      (GtkPrintOperation  *op);
293
GDK_AVAILABLE_IN_ALL
294 295
void                    gtk_print_operation_set_support_selection  (GtkPrintOperation  *op,
                                                                    gboolean            support_selection);
296
GDK_AVAILABLE_IN_ALL
297
gboolean                gtk_print_operation_get_support_selection  (GtkPrintOperation  *op);
298
GDK_AVAILABLE_IN_ALL
299 300
void                    gtk_print_operation_set_has_selection      (GtkPrintOperation  *op,
                                                                    gboolean            has_selection);
301
GDK_AVAILABLE_IN_ALL
302
gboolean                gtk_print_operation_get_has_selection      (GtkPrintOperation  *op);
303
GDK_AVAILABLE_IN_ALL
304
void                    gtk_print_operation_set_embed_page_setup   (GtkPrintOperation  *op,
Matthias Clasen's avatar
Matthias Clasen committed
305
                                                                    gboolean            embed);
306
GDK_AVAILABLE_IN_ALL
307
gboolean                gtk_print_operation_get_embed_page_setup   (GtkPrintOperation  *op);
308
GDK_AVAILABLE_IN_ALL
309
gint                    gtk_print_operation_get_n_pages_to_print   (GtkPrintOperation  *op);
310

311
GDK_AVAILABLE_IN_ALL
312
GtkPageSetup           *gtk_print_run_page_setup_dialog            (GtkWindow          *parent,
Matthias Clasen's avatar
Matthias Clasen committed
313 314
                                                                    GtkPageSetup       *page_setup,
                                                                    GtkPrintSettings   *settings);
315

316 317 318
/**
 * GtkPageSetupDoneFunc:
 * @page_setup: the #GtkPageSetup that has been
Matthias Clasen's avatar
Matthias Clasen committed
319 320
 * @data: (closure): user data that has been passed to
 *     gtk_print_run_page_setup_dialog_async()
321 322
 *
 * The type of function that is passed to
Matthias Clasen's avatar
Matthias Clasen committed
323 324 325 326
 * gtk_print_run_page_setup_dialog_async().
 *
 * This function will be called when the page setup dialog
 * is dismissed, and also serves as destroy notify for @data.
327
 */
328
typedef void  (* GtkPageSetupDoneFunc) (GtkPageSetup *page_setup,
Matthias Clasen's avatar
Matthias Clasen committed
329
                                        gpointer      data);
Matthias Clasen's avatar
Matthias Clasen committed
330

331
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
332
void                    gtk_print_run_page_setup_dialog_async      (GtkWindow            *parent,
Matthias Clasen's avatar
Matthias Clasen committed
333 334
                                                                    GtkPageSetup         *page_setup,
                                                                    GtkPrintSettings     *settings,
Matthias Clasen's avatar
Matthias Clasen committed
335 336 337
                                                                    GtkPageSetupDoneFunc  done_cb,
                                                                    gpointer              data);

338 339 340
G_END_DECLS

#endif /* __GTK_PRINT_OPERATION_H__ */