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