Modified webpage: now tinymail repository is in gitorious.
[modest] / src / widgets / modest-msg-view.c
1 /* Copyright (c) 2006, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include <config.h>
31
32 #include <widgets/modest-msg-view.h>
33 #include <widgets/modest-isearch-view.h>
34 #include <modest-marshal.h>
35
36 enum {
37         ATTACHMENT_CLICKED_SIGNAL,
38         RECPT_ACTIVATED_SIGNAL,
39         LINK_CONTEXTUAL_SIGNAL,
40         FETCH_IMAGE_SIGNAL,
41         SHOW_DETAILS_SIGNAL,
42         LIMIT_ERROR_SIGNAL,
43         HANDLE_CALENDAR_SIGNAL,
44         LAST_SIGNAL
45 };
46 static guint signals[LAST_SIGNAL] = {0};
47
48 void
49 modest_msg_view_set_msg_with_other_body (ModestMsgView *self, TnyMsg *msg, TnyMimePart *part)
50 {
51         return MODEST_MSG_VIEW_GET_IFACE (self)->set_msg_with_other_body_func (self, msg, part);
52 }
53
54 GtkAdjustment*
55 modest_msg_view_get_vadjustment (ModestMsgView *self)
56 {
57         return MODEST_MSG_VIEW_GET_IFACE (self)->get_vadjustment_func (self);
58 }
59
60 GtkAdjustment*
61 modest_msg_view_get_hadjustment (ModestMsgView *self)
62 {
63         return MODEST_MSG_VIEW_GET_IFACE (self)->get_hadjustment_func (self);
64 }
65
66 void
67 modest_msg_view_set_vadjustment (ModestMsgView *self, GtkAdjustment *vadj)
68 {
69         MODEST_MSG_VIEW_GET_IFACE (self)->set_vadjustment_func (self, vadj);
70 }
71
72 void
73 modest_msg_view_set_hadjustment (ModestMsgView *self, GtkAdjustment *hadj)
74 {
75         MODEST_MSG_VIEW_GET_IFACE (self)->set_hadjustment_func (self, hadj);
76 }
77
78 void
79 modest_msg_view_set_shadow_type (ModestMsgView *self, GtkShadowType type)
80 {
81         MODEST_MSG_VIEW_GET_IFACE (self)->set_shadow_type_func (self, type);
82 }
83
84 GtkShadowType
85 modest_msg_view_get_shadow_type (ModestMsgView *self)
86 {
87         return MODEST_MSG_VIEW_GET_IFACE (self)->get_shadow_type_func (self);
88 }
89
90 TnyHeaderFlags
91 modest_msg_view_get_priority (ModestMsgView *self)
92 {
93         return MODEST_MSG_VIEW_GET_IFACE (self)->get_priority_func (self);
94 }
95
96 void
97 modest_msg_view_set_priority (ModestMsgView *self, TnyHeaderFlags flags)
98 {
99         MODEST_MSG_VIEW_GET_IFACE (self)->set_priority_func (self, flags);
100 }
101
102 void
103 modest_msg_view_set_view_images (ModestMsgView *self, gboolean view_images)
104 {
105         MODEST_MSG_VIEW_GET_IFACE (self)->set_view_images_func (self, view_images);
106 }
107
108 TnyList*
109 modest_msg_view_get_selected_attachments (ModestMsgView *self)
110 {
111         return MODEST_MSG_VIEW_GET_IFACE (self)->get_selected_attachments_func (self);
112 }
113
114 TnyList*
115 modest_msg_view_get_attachments (ModestMsgView *self)
116 {
117         return MODEST_MSG_VIEW_GET_IFACE (self)->get_attachments_func (self);
118 }
119
120 void
121 modest_msg_view_grab_focus (ModestMsgView *self)
122 {
123         MODEST_MSG_VIEW_GET_IFACE (self)->grab_focus_func (self);
124 }
125
126 void
127 modest_msg_view_remove_attachment (ModestMsgView *self, TnyMimePart *attachment)
128 {
129         MODEST_MSG_VIEW_GET_IFACE (self)->remove_attachment_func (self, attachment);
130 }
131
132 void
133 modest_msg_view_set_branding (ModestMsgView *self, const gchar *brand_name, const GdkPixbuf *brand_icon)
134 {
135         MODEST_MSG_VIEW_GET_IFACE (self)->set_branding_func (self, brand_name, brand_icon);
136 }
137
138 void
139 modest_msg_view_request_fetch_images (ModestMsgView *self)
140 {
141         MODEST_MSG_VIEW_GET_IFACE (self)->request_fetch_images_func (self);
142 }
143
144 gboolean
145 modest_msg_view_has_blocked_external_images (ModestMsgView *self)
146 {
147         return MODEST_MSG_VIEW_GET_IFACE (self)->has_blocked_external_images_func (self);
148 }
149
150 static void
151 modest_msg_view_base_init (gpointer g_class)
152 {
153         static gboolean initialized = FALSE;
154
155         if (!initialized) {
156                 
157                 signals[ATTACHMENT_CLICKED_SIGNAL] =
158                         g_signal_new ("attachment_clicked",
159                                       MODEST_TYPE_MSG_VIEW,
160                                       G_SIGNAL_RUN_FIRST,
161                                       G_STRUCT_OFFSET(ModestMsgViewIface, attachment_clicked),
162                                       NULL, NULL,
163                                       g_cclosure_marshal_VOID__OBJECT,
164                                       G_TYPE_NONE, 1, G_TYPE_OBJECT);
165                 
166                 signals[RECPT_ACTIVATED_SIGNAL] =
167                         g_signal_new ("recpt_activated",
168                                       MODEST_TYPE_MSG_VIEW,
169                                       G_SIGNAL_RUN_FIRST,
170                                       G_STRUCT_OFFSET(ModestMsgViewIface, recpt_activated),
171                                       NULL, NULL,
172                                       g_cclosure_marshal_VOID__STRING,
173                                       G_TYPE_NONE, 1, G_TYPE_STRING);
174                 
175                 signals[LINK_CONTEXTUAL_SIGNAL] =
176                         g_signal_new ("link_contextual",
177                                       MODEST_TYPE_MSG_VIEW,
178                                       G_SIGNAL_RUN_FIRST,
179                                       G_STRUCT_OFFSET(ModestMsgViewIface, link_contextual),
180                                       NULL, NULL,
181                                       g_cclosure_marshal_VOID__STRING,
182                                       G_TYPE_NONE, 1, G_TYPE_STRING);
183                 
184                 signals[FETCH_IMAGE_SIGNAL] =
185                         g_signal_new ("fetch_image",
186                                       MODEST_TYPE_MSG_VIEW,
187                                       G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST,
188                                       G_STRUCT_OFFSET(ModestMsgViewIface, fetch_image),
189                                       NULL, NULL,
190                                       modest_marshal_BOOLEAN__STRING_OBJECT,
191                                       G_TYPE_BOOLEAN, 2, G_TYPE_STRING, G_TYPE_OBJECT);
192                 
193                 signals[SHOW_DETAILS_SIGNAL] =
194                         g_signal_new ("show_details",
195                                       MODEST_TYPE_MSG_VIEW,
196                                       G_SIGNAL_RUN_FIRST,
197                                       G_STRUCT_OFFSET(ModestMsgViewIface, show_details),
198                                       NULL, NULL,
199                                       g_cclosure_marshal_VOID__VOID,
200                                       G_TYPE_NONE, 0);
201                 
202                 signals[LIMIT_ERROR_SIGNAL] =
203                         g_signal_new ("limit_error",
204                                       MODEST_TYPE_MSG_VIEW,
205                                       G_SIGNAL_RUN_FIRST,
206                                       G_STRUCT_OFFSET(ModestMsgViewIface, limit_error),
207                                       NULL, NULL,
208                                       g_cclosure_marshal_VOID__VOID,
209                                       G_TYPE_NONE, 0);
210                 
211                 signals[HANDLE_CALENDAR_SIGNAL] =
212                         g_signal_new ("handle_calendar",
213                                       MODEST_TYPE_MSG_VIEW,
214                                       G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST,
215                                       G_STRUCT_OFFSET(ModestMsgViewIface, handle_calendar),
216                                       NULL, NULL,
217                                       modest_marshal_BOOLEAN__OBJECT_OBJECT,
218                                       G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT, G_TYPE_OBJECT);
219                 initialized = TRUE;
220         }
221 }
222
223 GType
224 modest_msg_view_get_type (void)
225 {
226         static GType my_type = 0;
227         if (!my_type) {
228                 static const GTypeInfo my_info = {
229                         sizeof(ModestMsgViewIface),
230                         modest_msg_view_base_init,   /* base init */
231                         NULL,           /* base finalize */
232                         NULL,           /* class_init */
233                         NULL,           /* class finalize */
234                         NULL,           /* class data */
235                         0,
236                         0,              /* n_preallocs */
237                         NULL,           /* instance_init */
238                         NULL
239                 };
240
241                 my_type = g_type_register_static (G_TYPE_INTERFACE,
242                                                   "ModestMsgView",
243                                                   &my_info, 0);
244
245                 g_type_interface_add_prerequisite (my_type,
246                                                    MODEST_TYPE_ZOOMABLE);
247                 g_type_interface_add_prerequisite (my_type,
248                                                    MODEST_TYPE_ISEARCH_VIEW);
249                 g_type_interface_add_prerequisite (my_type,
250                                                    TNY_TYPE_MIME_PART_VIEW);
251                 g_type_interface_add_prerequisite (my_type,
252                                                    TNY_TYPE_HEADER_VIEW);
253                 g_type_interface_add_prerequisite (my_type,
254                                                    MODEST_TYPE_MIME_PART_VIEW);
255
256         }
257         return my_type;
258 }