Create new method in ModestMsgView and ModestMsgViewWindow for setting a msg
[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         LAST_SIGNAL
43 };
44 static guint signals[LAST_SIGNAL] = {0};
45
46 void
47 modest_msg_view_set_msg_with_other_body (ModestMsgView *self, TnyMsg *msg, TnyMimePart *part)
48 {
49         return MODEST_MSG_VIEW_GET_IFACE (self)->set_msg_with_other_body_func (self, msg, part);
50 }
51
52 GtkAdjustment*
53 modest_msg_view_get_vadjustment (ModestMsgView *self)
54 {
55         return MODEST_MSG_VIEW_GET_IFACE (self)->get_vadjustment_func (self);
56 }
57
58 GtkAdjustment*
59 modest_msg_view_get_hadjustment (ModestMsgView *self)
60 {
61         return MODEST_MSG_VIEW_GET_IFACE (self)->get_hadjustment_func (self);
62 }
63
64 void
65 modest_msg_view_set_vadjustment (ModestMsgView *self, GtkAdjustment *vadj)
66 {
67         MODEST_MSG_VIEW_GET_IFACE (self)->set_vadjustment_func (self, vadj);
68 }
69
70 void
71 modest_msg_view_set_hadjustment (ModestMsgView *self, GtkAdjustment *hadj)
72 {
73         MODEST_MSG_VIEW_GET_IFACE (self)->set_hadjustment_func (self, hadj);
74 }
75
76 void
77 modest_msg_view_set_shadow_type (ModestMsgView *self, GtkShadowType type)
78 {
79         MODEST_MSG_VIEW_GET_IFACE (self)->set_shadow_type_func (self, type);
80 }
81
82 GtkShadowType
83 modest_msg_view_get_shadow_type (ModestMsgView *self)
84 {
85         return MODEST_MSG_VIEW_GET_IFACE (self)->get_shadow_type_func (self);
86 }
87
88 TnyHeaderFlags
89 modest_msg_view_get_priority (ModestMsgView *self)
90 {
91         return MODEST_MSG_VIEW_GET_IFACE (self)->get_priority_func (self);
92 }
93
94 void
95 modest_msg_view_set_priority (ModestMsgView *self, TnyHeaderFlags flags)
96 {
97         MODEST_MSG_VIEW_GET_IFACE (self)->set_priority_func (self, flags);
98 }
99
100 void
101 modest_msg_view_set_view_images (ModestMsgView *self, gboolean view_images)
102 {
103         MODEST_MSG_VIEW_GET_IFACE (self)->set_view_images_func (self, view_images);
104 }
105
106 TnyList*
107 modest_msg_view_get_selected_attachments (ModestMsgView *self)
108 {
109         return MODEST_MSG_VIEW_GET_IFACE (self)->get_selected_attachments_func (self);
110 }
111
112 TnyList*
113 modest_msg_view_get_attachments (ModestMsgView *self)
114 {
115         return MODEST_MSG_VIEW_GET_IFACE (self)->get_attachments_func (self);
116 }
117
118 void
119 modest_msg_view_grab_focus (ModestMsgView *self)
120 {
121         MODEST_MSG_VIEW_GET_IFACE (self)->grab_focus_func (self);
122 }
123
124 void
125 modest_msg_view_remove_attachment (ModestMsgView *self, TnyMimePart *attachment)
126 {
127         MODEST_MSG_VIEW_GET_IFACE (self)->remove_attachment_func (self, attachment);
128 }
129
130 void
131 modest_msg_view_request_fetch_images (ModestMsgView *self)
132 {
133         MODEST_MSG_VIEW_GET_IFACE (self)->request_fetch_images_func (self);
134 }
135
136 gboolean
137 modest_msg_view_has_blocked_external_images (ModestMsgView *self)
138 {
139         return MODEST_MSG_VIEW_GET_IFACE (self)->has_blocked_external_images_func (self);
140 }
141
142 static void
143 modest_msg_view_base_init (gpointer g_class)
144 {
145         static gboolean initialized = FALSE;
146
147         if (!initialized) {
148                 
149                 signals[ATTACHMENT_CLICKED_SIGNAL] =
150                         g_signal_new ("attachment_clicked",
151                                       MODEST_TYPE_MSG_VIEW,
152                                       G_SIGNAL_RUN_FIRST,
153                                       G_STRUCT_OFFSET(ModestMsgViewIface, attachment_clicked),
154                                       NULL, NULL,
155                                       g_cclosure_marshal_VOID__OBJECT,
156                                       G_TYPE_NONE, 1, G_TYPE_OBJECT);
157                 
158                 signals[RECPT_ACTIVATED_SIGNAL] =
159                         g_signal_new ("recpt_activated",
160                                       MODEST_TYPE_MSG_VIEW,
161                                       G_SIGNAL_RUN_FIRST,
162                                       G_STRUCT_OFFSET(ModestMsgViewIface, recpt_activated),
163                                       NULL, NULL,
164                                       g_cclosure_marshal_VOID__STRING,
165                                       G_TYPE_NONE, 1, G_TYPE_STRING);
166                 
167                 signals[LINK_CONTEXTUAL_SIGNAL] =
168                         g_signal_new ("link_contextual",
169                                       MODEST_TYPE_MSG_VIEW,
170                                       G_SIGNAL_RUN_FIRST,
171                                       G_STRUCT_OFFSET(ModestMsgViewIface, link_contextual),
172                                       NULL, NULL,
173                                       g_cclosure_marshal_VOID__STRING,
174                                       G_TYPE_NONE, 1, G_TYPE_STRING);
175                 
176                 signals[FETCH_IMAGE_SIGNAL] =
177                         g_signal_new ("fetch_image",
178                                       MODEST_TYPE_MSG_VIEW,
179                                       G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST,
180                                       G_STRUCT_OFFSET(ModestMsgViewIface, fetch_image),
181                                       NULL, NULL,
182                                       modest_marshal_BOOLEAN__STRING_OBJECT,
183                                       G_TYPE_BOOLEAN, 2, G_TYPE_STRING, G_TYPE_OBJECT);
184                 
185                 signals[SHOW_DETAILS_SIGNAL] =
186                         g_signal_new ("show_details",
187                                       MODEST_TYPE_MSG_VIEW,
188                                       G_SIGNAL_RUN_FIRST,
189                                       G_STRUCT_OFFSET(ModestMsgViewIface, show_details),
190                                       NULL, NULL,
191                                       g_cclosure_marshal_VOID__VOID,
192                                       G_TYPE_NONE, 0);
193                 
194                 initialized = TRUE;
195         }
196 }
197
198 GType
199 modest_msg_view_get_type (void)
200 {
201         static GType my_type = 0;
202         if (!my_type) {
203                 static const GTypeInfo my_info = {
204                         sizeof(ModestMsgViewIface),
205                         modest_msg_view_base_init,   /* base init */
206                         NULL,           /* base finalize */
207                         NULL,           /* class_init */
208                         NULL,           /* class finalize */
209                         NULL,           /* class data */
210                         0,
211                         0,              /* n_preallocs */
212                         NULL,           /* instance_init */
213                         NULL
214                 };
215
216                 my_type = g_type_register_static (G_TYPE_INTERFACE,
217                                                   "ModestMsgView",
218                                                   &my_info, 0);
219
220                 g_type_interface_add_prerequisite (my_type,
221                                                    MODEST_TYPE_ZOOMABLE);
222                 g_type_interface_add_prerequisite (my_type,
223                                                    MODEST_TYPE_ISEARCH_VIEW);
224                 g_type_interface_add_prerequisite (my_type,
225                                                    TNY_TYPE_MIME_PART_VIEW);
226                 g_type_interface_add_prerequisite (my_type,
227                                                    TNY_TYPE_HEADER_VIEW);
228                 g_type_interface_add_prerequisite (my_type,
229                                                    MODEST_TYPE_MIME_PART_VIEW);
230
231         }
232         return my_type;
233 }