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#ifndef __GTK_PRINT_OPERATION_H__
22#define __GTK_PRINT_OPERATION_H__
23
24
25#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
26#error "Only <gtk/gtk.h> can be included directly."
27#endif
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
38G_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
47typedef struct _GtkPrintOperationClass GtkPrintOperationClass;
48typedef struct _GtkPrintOperationPrivate GtkPrintOperationPrivate;
49typedef struct _GtkPrintOperation GtkPrintOperation;
50
51typedef enum {
52 GTK_PRINT_STATUS_INITIAL,
53 GTK_PRINT_STATUS_PREPARING,
54 GTK_PRINT_STATUS_GENERATING_DATA,
55 GTK_PRINT_STATUS_SENDING_DATA,
56 GTK_PRINT_STATUS_PENDING,
57 GTK_PRINT_STATUS_PENDING_ISSUE,
58 GTK_PRINT_STATUS_PRINTING,
59 GTK_PRINT_STATUS_FINISHED,
60 GTK_PRINT_STATUS_FINISHED_ABORTED
61} GtkPrintStatus;
62
63typedef enum {
64 GTK_PRINT_OPERATION_RESULT_ERROR,
65 GTK_PRINT_OPERATION_RESULT_APPLY,
66 GTK_PRINT_OPERATION_RESULT_CANCEL,
67 GTK_PRINT_OPERATION_RESULT_IN_PROGRESS
68} GtkPrintOperationResult;
69
70typedef enum {
71 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
72 GTK_PRINT_OPERATION_ACTION_PRINT,
73 GTK_PRINT_OPERATION_ACTION_PREVIEW,
74 GTK_PRINT_OPERATION_ACTION_EXPORT
75} GtkPrintOperationAction;
76
77
78struct _GtkPrintOperation
79{
80 GObject parent_instance;
81
82 GtkPrintOperationPrivate *GSEAL (priv);
83};
84
85struct _GtkPrintOperationClass
86{
87 GObjectClass parent_class;
88
89 void (*done) (GtkPrintOperation *operation,
90 GtkPrintOperationResult result);
91 void (*begin_print) (GtkPrintOperation *operation,
92 GtkPrintContext *context);
93 gboolean (*paginate) (GtkPrintOperation *operation,
94 GtkPrintContext *context);
95 void (*request_page_setup) (GtkPrintOperation *operation,
96 GtkPrintContext *context,
97 gint page_nr,
98 GtkPageSetup *setup);
99 void (*draw_page) (GtkPrintOperation *operation,
100 GtkPrintContext *context,
101 gint page_nr);
102 void (*end_print) (GtkPrintOperation *operation,
103 GtkPrintContext *context);
104 void (*status_changed) (GtkPrintOperation *operation);
105
106 GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
107 void (*custom_widget_apply) (GtkPrintOperation *operation,
108 GtkWidget *widget);
109
110 gboolean (*preview) (GtkPrintOperation *operation,
111 GtkPrintOperationPreview *preview,
112 GtkPrintContext *context,
113 GtkWindow *parent);
114
115 void (*update_custom_widget) (GtkPrintOperation *operation,
116 GtkWidget *widget,
117 GtkPageSetup *setup,
118 GtkPrintSettings *settings);
119
120 /* Padding for future expansion */
121 void (*_gtk_reserved1) (void);
122 void (*_gtk_reserved2) (void);
123 void (*_gtk_reserved3) (void);
124 void (*_gtk_reserved4) (void);
125 void (*_gtk_reserved5) (void);
126 void (*_gtk_reserved6) (void);
127};
128
129#define GTK_PRINT_ERROR gtk_print_error_quark ()
130
131typedef enum
132{
133 GTK_PRINT_ERROR_GENERAL,
134 GTK_PRINT_ERROR_INTERNAL_ERROR,
135 GTK_PRINT_ERROR_NOMEM,
136 GTK_PRINT_ERROR_INVALID_FILE
137} GtkPrintError;
138
139GQuark gtk_print_error_quark (void);
140
141GType gtk_print_operation_get_type (void) G_GNUC_CONST;
142GtkPrintOperation * gtk_print_operation_new (void);
143void gtk_print_operation_set_default_page_setup (GtkPrintOperation *op,
144 GtkPageSetup *default_page_setup);
145GtkPageSetup * gtk_print_operation_get_default_page_setup (GtkPrintOperation *op);
146void gtk_print_operation_set_print_settings (GtkPrintOperation *op,
147 GtkPrintSettings *print_settings);
148GtkPrintSettings * gtk_print_operation_get_print_settings (GtkPrintOperation *op);
149void gtk_print_operation_set_job_name (GtkPrintOperation *op,
150 const gchar *job_name);
151void gtk_print_operation_set_n_pages (GtkPrintOperation *op,
152 gint n_pages);
153void gtk_print_operation_set_current_page (GtkPrintOperation *op,
154 gint current_page);
155void gtk_print_operation_set_use_full_page (GtkPrintOperation *op,
156 gboolean full_page);
157void gtk_print_operation_set_unit (GtkPrintOperation *op,
158 GtkUnit unit);
159void gtk_print_operation_set_export_filename (GtkPrintOperation *op,
160 const gchar *filename);
161void gtk_print_operation_set_track_print_status (GtkPrintOperation *op,
162 gboolean track_status);
163void gtk_print_operation_set_show_progress (GtkPrintOperation *op,
164 gboolean show_progress);
165void gtk_print_operation_set_allow_async (GtkPrintOperation *op,
166 gboolean allow_async);
167void gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op,
168 const gchar *label);
169GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
170 GtkPrintOperationAction action,
171 GtkWindow *parent,
172 GError **error);
173void gtk_print_operation_get_error (GtkPrintOperation *op,
174 GError **error);
175GtkPrintStatus gtk_print_operation_get_status (GtkPrintOperation *op);
176const gchar * gtk_print_operation_get_status_string (GtkPrintOperation *op);
177gboolean gtk_print_operation_is_finished (GtkPrintOperation *op);
178void gtk_print_operation_cancel (GtkPrintOperation *op);
179void gtk_print_operation_draw_page_finish (GtkPrintOperation *op);
180void gtk_print_operation_set_defer_drawing (GtkPrintOperation *op);
181void gtk_print_operation_set_support_selection (GtkPrintOperation *op,
182 gboolean support_selection);
183gboolean gtk_print_operation_get_support_selection (GtkPrintOperation *op);
184void gtk_print_operation_set_has_selection (GtkPrintOperation *op,
185 gboolean has_selection);
186gboolean gtk_print_operation_get_has_selection (GtkPrintOperation *op);
187void gtk_print_operation_set_embed_page_setup (GtkPrintOperation *op,
188 gboolean embed);
189gboolean gtk_print_operation_get_embed_page_setup (GtkPrintOperation *op);
190gint gtk_print_operation_get_n_pages_to_print (GtkPrintOperation *op);
191
192GtkPageSetup *gtk_print_run_page_setup_dialog (GtkWindow *parent,
193 GtkPageSetup *page_setup,
194 GtkPrintSettings *settings);
195
196typedef void (* GtkPageSetupDoneFunc) (GtkPageSetup *page_setup,
197 gpointer data);
198
199void gtk_print_run_page_setup_dialog_async (GtkWindow *parent,
200 GtkPageSetup *page_setup,
201 GtkPrintSettings *settings,
202 GtkPageSetupDoneFunc done_cb,
203 gpointer data);
204
205G_END_DECLS
206
207#endif /* __GTK_PRINT_OPERATION_H__ */
208