1 /* GTK - The GIMP Toolkit
2 * gtkprintoperationpreview.c: Abstract print preview interface
3 * Copyright (C) 2006, Red Hat, Inc.
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.
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.
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/>.
21 #include "gtkprintoperationpreview.h"
22 #include "gtkmarshalers.h"
26 static void gtk_print_operation_preview_base_init (gpointer g_iface);
29 gtk_print_operation_preview_get_type (void)
31 static GType print_operation_preview_type = 0;
33 if (!print_operation_preview_type)
35 const GTypeInfo print_operation_preview_info =
37 sizeof (GtkPrintOperationPreviewIface), /* class_size */
38 gtk_print_operation_preview_base_init, /* base_init */
39 NULL, /* base_finalize */
41 NULL, /* class_finalize */
42 NULL, /* class_data */
48 print_operation_preview_type =
49 g_type_register_static (G_TYPE_INTERFACE, I_("GtkPrintOperationPreview"),
50 &print_operation_preview_info, 0);
52 g_type_interface_add_prerequisite (print_operation_preview_type, G_TYPE_OBJECT);
55 return print_operation_preview_type;
59 gtk_print_operation_preview_base_init (gpointer g_iface)
61 static gboolean initialized = FALSE;
66 * GtkPrintOperationPreview::ready:
67 * @preview: the object on which the signal is emitted
68 * @context: the current #GtkPrintContext
70 * The ::ready signal gets emitted once per preview operation,
71 * before the first page is rendered.
73 * A handler for this signal can be used for setup tasks.
75 g_signal_new (I_("ready"),
76 GTK_TYPE_PRINT_OPERATION_PREVIEW,
78 G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, ready),
80 g_cclosure_marshal_VOID__OBJECT,
82 GTK_TYPE_PRINT_CONTEXT);
85 * GtkPrintOperationPreview::got-page-size:
86 * @preview: the object on which the signal is emitted
87 * @context: the current #GtkPrintContext
88 * @page_setup: the #GtkPageSetup for the current page
90 * The ::got-page-size signal is emitted once for each page
91 * that gets rendered to the preview.
93 * A handler for this signal should update the @context
94 * according to @page_setup and set up a suitable cairo
95 * context, using gtk_print_context_set_cairo_context().
97 g_signal_new (I_("got-page-size"),
98 GTK_TYPE_PRINT_OPERATION_PREVIEW,
100 G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, got_page_size),
102 _gtk_marshal_VOID__OBJECT_OBJECT,
104 GTK_TYPE_PRINT_CONTEXT,
105 GTK_TYPE_PAGE_SETUP);
112 * gtk_print_operation_preview_render_page:
113 * @preview: a #GtkPrintOperationPreview
114 * @page_nr: the page to render
116 * Renders a page to the preview, using the print context that
117 * was passed to the #GtkPrintOperation::preview handler together
120 * A custom iprint preview should use this function in its ::expose
121 * handler to render the currently selected page.
123 * Note that this function requires a suitable cairo context to
124 * be associated with the print context.
129 gtk_print_operation_preview_render_page (GtkPrintOperationPreview *preview,
132 g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
134 GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->render_page (preview,
139 * gtk_print_operation_preview_end_preview:
140 * @preview: a #GtkPrintOperationPreview
144 * This function must be called to finish a custom print preview.
149 gtk_print_operation_preview_end_preview (GtkPrintOperationPreview *preview)
151 g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
153 GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->end_preview (preview);
157 * gtk_print_operation_preview_is_selected:
158 * @preview: a #GtkPrintOperationPreview
159 * @page_nr: a page number
161 * Returns whether the given page is included in the set of pages that
162 * have been selected for printing.
164 * Returns: %TRUE if the page has been selected for printing
169 gtk_print_operation_preview_is_selected (GtkPrintOperationPreview *preview,
172 g_return_val_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview), FALSE);
174 return GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->is_selected (preview, page_nr);