* Changes in the autotools stuff affecting a lot of platform dependent
[modest] / src / widgets / modest-mime-part-view.c
1 /* Copyright (c) 2007, 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 <modest-mime-part-view.h>
33 #include <modest-marshal.h>
34
35 enum {
36         ACTIVATE_LINK,
37         LINK_HOVER,
38         FETCH_URL,
39         LAST_SIGNAL
40 };
41
42 static guint mime_part_view_signals[LAST_SIGNAL] = { 0 };
43
44 /**
45  * modest_mime_part_view_is_empty:
46  * @self: a #ModestMimePartView
47  *
48  * checks if the mail shown can be considered as empty or not.
49  *
50  * Returns: %TRUE if mail shown is empty, %FALSE otherwise.
51  */
52 gboolean
53 modest_mime_part_view_is_empty (ModestMimePartView *self)
54 {
55         return MODEST_MIME_PART_VIEW_GET_IFACE (self)->is_empty_func (self);
56 }
57
58 /**
59  * modest_mime_part_view_get_view_images:
60  * @self: a #ModestMimePartView
61  *
62  * checks if we have enabled capability to view contained images.
63  *
64  * Returns: %TRUE if we show images, %FALSE otherwise.
65  */
66 gboolean
67 modest_mime_part_view_get_view_images (ModestMimePartView *self)
68 {
69         return MODEST_MIME_PART_VIEW_GET_IFACE (self)->get_view_images_func (self);
70 }
71
72 /**
73  * modest_mime_part_view_set_view_images:
74  * @self: a #ModestMimePartView
75  * @view_images: a #gboolean
76  *
77  * set if we want to show images or not.
78  */
79 void
80 modest_mime_part_view_set_view_images (ModestMimePartView *self, gboolean view_images)
81 {
82         MODEST_MIME_PART_VIEW_GET_IFACE (self)->set_view_images_func (self, view_images);
83 }
84
85 /**
86  * modest_mime_part_view_has_external_images: 
87  * @self: a #ModestMimePartView
88  *
89  * checks if there are external images in the mime part.
90  *
91  * Returns: %TRUE if there are external images, %FALSE otherwise.
92  */
93 gboolean
94 modest_mime_part_view_has_external_images (ModestMimePartView *self)
95 {
96         return MODEST_MIME_PART_VIEW_GET_IFACE (self)->has_external_images_func (self);
97 }
98
99 static void
100 modest_mime_part_view_base_init (gpointer g_class)
101 {
102         static gboolean initialized = FALSE;
103
104         if (!initialized) {
105
106                 /**
107                  * ModestMimePartView::activate-link:
108                  * @self: a #ModestMimePartView instance the signal is emitted
109                  * @string: a string containing the URI
110                  *
111                  * This signal is emitted when a URI is activated
112                  *
113                  * Returns:
114                  */
115                 mime_part_view_signals[ACTIVATE_LINK] =
116                         g_signal_new ("activate_link",
117                                       MODEST_TYPE_MIME_PART_VIEW,
118                                       G_SIGNAL_RUN_LAST,
119                                       G_STRUCT_OFFSET (ModestMimePartViewIface, activate_link),
120                                       NULL, NULL,
121                                       modest_marshal_BOOLEAN__STRING,
122                                       G_TYPE_BOOLEAN, 1,
123                                       G_TYPE_STRING);
124                 /**
125                  * ModestMimePartView::link-hover:
126                  * @self: a #ModestMimePartView instance the signal is emitted
127                  * @string: a string containing the URI
128                  *
129                  * This signal is emitted when user passes the mouse over a link
130                  *
131                  * Returns:
132                  */
133                 mime_part_view_signals[LINK_HOVER] =
134                         g_signal_new ("link_hover",
135                                       MODEST_TYPE_MIME_PART_VIEW,
136                                       G_SIGNAL_RUN_LAST,
137                                       G_STRUCT_OFFSET (ModestMimePartViewIface, link_hover),
138                                       NULL, NULL,
139                                       modest_marshal_BOOLEAN__STRING,
140                                       G_TYPE_BOOLEAN, 1,
141                                       G_TYPE_STRING);
142
143                 /**
144                  * ModestMimePartView::fetch-url:
145                  * @self: a #ModestMimePartView instance the signal is emitted
146                  * @string: a string containing the URI
147                  * @stream: a #TnyStream
148                  *
149                  * This signal is emitted when the page is rendered, and some
150                  * url has to be resolved externally. You have to put the
151                  * required information in the stream (images, etc).
152                  *
153                  * Returns:
154                  */
155                 mime_part_view_signals[FETCH_URL] =
156                         g_signal_new ("fetch_url",
157                                       MODEST_TYPE_MIME_PART_VIEW,
158                                       G_SIGNAL_RUN_LAST,
159                                       G_STRUCT_OFFSET (ModestMimePartViewIface, fetch_url),
160                                       NULL, NULL,
161                                       modest_marshal_BOOLEAN__STRING_OBJECT,
162                                       G_TYPE_BOOLEAN, 2,
163                                       G_TYPE_STRING,
164                                       G_TYPE_OBJECT);
165                 initialized = TRUE;
166         }
167 }
168
169 GType
170 modest_mime_part_view_get_type (void)
171 {
172         static GType type = 0;
173
174         if (G_UNLIKELY(type == 0)) 
175         {
176                 static const GTypeInfo info = 
177                 {
178                   sizeof (ModestMimePartViewIface),
179                   modest_mime_part_view_base_init,   /* base_init */
180                   NULL,   /* base_finalize */
181                   NULL,   /* class_init */
182                   NULL,   /* class_finalize */
183                   NULL,   /* class_data */
184                   0,
185                   0,      /* n_preallocs */
186                   NULL,   /* instance_init */
187                   NULL
188                 };
189
190                 type = g_type_register_static (G_TYPE_INTERFACE,
191                         "ModestMimePartView", &info, 0);
192
193         }
194
195         return type;
196 }