]> Pileus Git - ~andy/gtk/blob - gtk/gtkprintoperationpreview.c
c640bd9e9905253fbf183e11c3351e49d8fba709
[~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
27 static void gtk_print_operation_preview_base_init (gpointer g_iface);
28
29 GType
30 gtk_print_operation_preview_get_type (void)
31 {
32   static GType print_operation_preview_type = 0;
33
34   if (!print_operation_preview_type)
35     {
36       static const GTypeInfo print_operation_preview_info =
37       {
38         sizeof (GtkPrintOperationPreviewIface), /* class_size */
39         gtk_print_operation_preview_base_init,   /* base_init */
40         NULL,           /* base_finalize */
41         NULL,
42         NULL,           /* class_finalize */
43         NULL,           /* class_data */
44         0,
45         0,              /* n_preallocs */
46         NULL
47       };
48
49       print_operation_preview_type =
50         g_type_register_static (G_TYPE_INTERFACE, I_("GtkPrintOperationPreview"),
51                                 &print_operation_preview_info, 0);
52
53       g_type_interface_add_prerequisite (print_operation_preview_type, G_TYPE_OBJECT);
54     }
55
56   return print_operation_preview_type;
57 }
58
59 static void
60 gtk_print_operation_preview_base_init (gpointer g_iface)
61 {
62   static gboolean initialized = FALSE;
63
64   if (!initialized)
65     {
66       g_signal_new (I_("ready"),
67                     GTK_TYPE_PRINT_OPERATION_PREVIEW,
68                     G_SIGNAL_RUN_LAST,
69                     G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, ready),
70                     NULL, NULL,
71                     g_cclosure_marshal_VOID__OBJECT,
72                     G_TYPE_NONE, 1,
73                     G_TYPE_OBJECT);
74
75       g_signal_new (I_("got-page-size"),
76                     GTK_TYPE_PRINT_OPERATION_PREVIEW,
77                     G_SIGNAL_RUN_LAST,
78                     G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, ready),
79                     NULL, NULL,
80                     _gtk_marshal_VOID__OBJECT_OBJECT,
81                     G_TYPE_NONE, 2,
82                     GTK_TYPE_PRINT_CONTEXT,
83                     GTK_TYPE_PAGE_SETUP);
84
85       initialized = TRUE;
86     }
87 }
88
89
90 void    
91 gtk_print_operation_preview_render_page (GtkPrintOperationPreview *preview,
92                                          gint                      page_nr)
93 {
94   g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
95
96   GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->render_page (preview,
97                                                                 page_nr);
98 }
99
100 void
101 gtk_print_operation_preview_end_preview (GtkPrintOperationPreview *preview)
102 {
103   g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
104
105   GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->end_preview (preview);
106 }
107
108 gboolean
109 gtk_print_operation_preview_is_selected (GtkPrintOperationPreview *preview,
110                                          gint                      page_nr)
111 {
112   g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
113
114   return GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->is_selected (preview, page_nr);
115 }
116