]> Pileus Git - ~andy/gtk/blob - gtk/gtkprintoperationpreview.c
Practically everything changed.
[~andy/gtk] / gtk / gtkprintoperationpreview.c
1 /* GTK - The GTK+ 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       g_signal_new (I_("ready"),
69                     GTK_TYPE_PRINT_OPERATION_PREVIEW,
70                     G_SIGNAL_RUN_LAST,
71                     G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, ready),
72                     NULL, NULL,
73                     g_cclosure_marshal_VOID__OBJECT,
74                     G_TYPE_NONE, 1,
75                     GTK_TYPE_PRINT_CONTEXT);
76
77       g_signal_new (I_("got-page-size"),
78                     GTK_TYPE_PRINT_OPERATION_PREVIEW,
79                     G_SIGNAL_RUN_LAST,
80                     G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, got_page_size),
81                     NULL, NULL,
82                     _gtk_marshal_VOID__OBJECT_OBJECT,
83                     G_TYPE_NONE, 2,
84                     GTK_TYPE_PRINT_CONTEXT,
85                     GTK_TYPE_PAGE_SETUP);
86
87       initialized = TRUE;
88     }
89 }
90
91 /**
92  * gtk_print_operation_preview_render_page:
93  * @preview: a #GtkPrintOperationPreview
94  * @page_nr: the page to render
95  *
96  * Renders a page to the preview, using the print context that
97  * was passed to the #GtkPrintOperation::preview handler together
98  * with @preview.
99  *
100  * Note that this function requires a suitable cairo context to 
101  * be associated with the print context. 
102  *
103  * Since: 2.10 
104  */
105 void    
106 gtk_print_operation_preview_render_page (GtkPrintOperationPreview *preview,
107                                          gint                      page_nr)
108 {
109   g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
110
111   GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->render_page (preview,
112                                                                 page_nr);
113 }
114
115 /**
116  * gtk_print_operation_preview_end_preview:
117  * @preview: a #GtkPrintOperationPreview
118  *
119  * Ends a preview. 
120  *
121  * This function must be called to finish a custom print preview.
122  *
123  * Since: 2.10
124  */
125 void
126 gtk_print_operation_preview_end_preview (GtkPrintOperationPreview *preview)
127 {
128   g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
129
130   GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->end_preview (preview);
131 }
132
133 /**
134  * gtk_print_operation_preview_is_selected:
135  * @preview: a #GtkPrintOperationPreview
136  * @page_nr: a page number
137  *
138  * Returns whether the given page is included in the set of pages that
139  * have been selected for printing.
140  * 
141  * Returns: %TRUE if the page has been selected for printing
142  *
143  * Since: 2.10
144  */
145 gboolean
146 gtk_print_operation_preview_is_selected (GtkPrintOperationPreview *preview,
147                                          gint                      page_nr)
148 {
149   g_return_val_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview), FALSE);
150
151   return GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->is_selected (preview, page_nr);
152 }
153
154
155 #define __GTK_PRINT_OPERATION_PREVIEW_C__
156 #include "gtkaliasdef.c"