]> Pileus Git - ~andy/gtk/blob - gtk/gtkprintoperationpreview.c
Don't use old toolbar API in toolbar stress test
[~andy/gtk] / gtk / gtkprintoperationpreview.c
1 /* GTK - The GIMP Toolkit
2  * gtkprintoperationpreview.c: Abstract print preview interface
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 #include "config.h"
22
23 #include "gtkprintoperationpreview.h"
24 #include "gtkmarshalers.h"
25 #include "gtkintl.h"
26 #include "gtkalias.h"
27
28
29 static void gtk_print_operation_preview_base_init (gpointer g_iface);
30
31 GType
32 gtk_print_operation_preview_get_type (void)
33 {
34   static GType print_operation_preview_type = 0;
35
36   if (!print_operation_preview_type)
37     {
38       const GTypeInfo print_operation_preview_info =
39       {
40         sizeof (GtkPrintOperationPreviewIface), /* class_size */
41         gtk_print_operation_preview_base_init,   /* base_init */
42         NULL,           /* base_finalize */
43         NULL,
44         NULL,           /* class_finalize */
45         NULL,           /* class_data */
46         0,
47         0,              /* n_preallocs */
48         NULL
49       };
50
51       print_operation_preview_type =
52         g_type_register_static (G_TYPE_INTERFACE, I_("GtkPrintOperationPreview"),
53                                 &print_operation_preview_info, 0);
54
55       g_type_interface_add_prerequisite (print_operation_preview_type, G_TYPE_OBJECT);
56     }
57
58   return print_operation_preview_type;
59 }
60
61 static void
62 gtk_print_operation_preview_base_init (gpointer g_iface)
63 {
64   static gboolean initialized = FALSE;
65
66   if (!initialized)
67     {
68       /**
69        * GtkPrintOperationPreview::ready:
70        * @preview: the object on which the signal is emitted
71        * @context: the current #GtkPrintContext
72        *
73        * The ::ready signal gets emitted once per preview operation,
74        * before the first page is rendered.
75        * 
76        * A handler for this signal can be used for setup tasks.
77        */
78       g_signal_new (I_("ready"),
79                     GTK_TYPE_PRINT_OPERATION_PREVIEW,
80                     G_SIGNAL_RUN_LAST,
81                     G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, ready),
82                     NULL, NULL,
83                     g_cclosure_marshal_VOID__OBJECT,
84                     G_TYPE_NONE, 1,
85                     GTK_TYPE_PRINT_CONTEXT);
86
87       /**
88        * GtkPrintOperationPreview::got-page-size:
89        * @preview: the object on which the signal is emitted
90        * @context: the current #GtkPrintContext
91        * @page_setup: the #GtkPageSetup for the current page
92        *
93        * The ::got-page-size signal is emitted once for each page
94        * that gets rendered to the preview. 
95        *
96        * A handler for this signal should update the @context
97        * according to @page_setup and set up a suitable cairo
98        * context, using gtk_print_context_set_cairo_context().
99        */
100       g_signal_new (I_("got-page-size"),
101                     GTK_TYPE_PRINT_OPERATION_PREVIEW,
102                     G_SIGNAL_RUN_LAST,
103                     G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, got_page_size),
104                     NULL, NULL,
105                     _gtk_marshal_VOID__OBJECT_OBJECT,
106                     G_TYPE_NONE, 2,
107                     GTK_TYPE_PRINT_CONTEXT,
108                     GTK_TYPE_PAGE_SETUP);
109
110       initialized = TRUE;
111     }
112 }
113
114 /**
115  * gtk_print_operation_preview_render_page:
116  * @preview: a #GtkPrintOperationPreview
117  * @page_nr: the page to render
118  *
119  * Renders a page to the preview, using the print context that
120  * was passed to the #GtkPrintOperation::preview handler together
121  * with @preview.
122  *
123  * A custom iprint preview should use this function in its ::expose
124  * handler to render the currently selected page.
125  * 
126  * Note that this function requires a suitable cairo context to 
127  * be associated with the print context. 
128  *
129  * Since: 2.10 
130  */
131 void    
132 gtk_print_operation_preview_render_page (GtkPrintOperationPreview *preview,
133                                          gint                      page_nr)
134 {
135   g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
136
137   GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->render_page (preview,
138                                                                 page_nr);
139 }
140
141 /**
142  * gtk_print_operation_preview_end_preview:
143  * @preview: a #GtkPrintOperationPreview
144  *
145  * Ends a preview. 
146  *
147  * This function must be called to finish a custom print preview.
148  *
149  * Since: 2.10
150  */
151 void
152 gtk_print_operation_preview_end_preview (GtkPrintOperationPreview *preview)
153 {
154   g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
155
156   GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->end_preview (preview);
157 }
158
159 /**
160  * gtk_print_operation_preview_is_selected:
161  * @preview: a #GtkPrintOperationPreview
162  * @page_nr: a page number
163  *
164  * Returns whether the given page is included in the set of pages that
165  * have been selected for printing.
166  * 
167  * Returns: %TRUE if the page has been selected for printing
168  *
169  * Since: 2.10
170  */
171 gboolean
172 gtk_print_operation_preview_is_selected (GtkPrintOperationPreview *preview,
173                                          gint                      page_nr)
174 {
175   g_return_val_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview), FALSE);
176
177   return GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->is_selected (preview, page_nr);
178 }
179
180
181 #define __GTK_PRINT_OPERATION_PREVIEW_C__
182 #include "gtkaliasdef.c"