a276c6a90a6f33ceb711d8900a99ffd413862b3a
[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 static void
59 modest_mime_part_view_base_init (gpointer g_class)
60 {
61         static gboolean initialized = FALSE;
62
63         if (!initialized) {
64
65                 /**
66                  * ModestMimePartView::activate-link:
67                  * @self: a #ModestMimePartView instance the signal is emitted
68                  * @string: a string containing the URI
69                  *
70                  * This signal is emitted when a URI is activated
71                  *
72                  * Returns:
73                  */
74                 mime_part_view_signals[ACTIVATE_LINK] =
75                         g_signal_new ("activate_link",
76                                       MODEST_TYPE_MIME_PART_VIEW,
77                                       G_SIGNAL_RUN_LAST,
78                                       G_STRUCT_OFFSET (ModestMimePartViewIface, activate_link),
79                                       NULL, NULL,
80                                       modest_marshal_BOOLEAN__STRING,
81                                       G_TYPE_BOOLEAN, 1,
82                                       G_TYPE_STRING);
83                 /**
84                  * ModestMimePartView::link-hover:
85                  * @self: a #ModestMimePartView instance the signal is emitted
86                  * @string: a string containing the URI
87                  *
88                  * This signal is emitted when user passes the mouse over a link
89                  *
90                  * Returns:
91                  */
92                 mime_part_view_signals[LINK_HOVER] =
93                         g_signal_new ("link_hover",
94                                       MODEST_TYPE_MIME_PART_VIEW,
95                                       G_SIGNAL_RUN_LAST,
96                                       G_STRUCT_OFFSET (ModestMimePartViewIface, link_hover),
97                                       NULL, NULL,
98                                       modest_marshal_BOOLEAN__STRING,
99                                       G_TYPE_BOOLEAN, 1,
100                                       G_TYPE_STRING);
101
102                 /**
103                  * ModestMimePartView::fetch-url:
104                  * @self: a #ModestMimePartView instance the signal is emitted
105                  * @string: a string containing the URI
106                  * @stream: a #TnyStream
107                  *
108                  * This signal is emitted when the page is rendered, and some
109                  * url has to be resolved externally. You have to put the
110                  * required information in the stream (images, etc).
111                  *
112                  * Returns:
113                  */
114                 mime_part_view_signals[FETCH_URL] =
115                         g_signal_new ("fetch_url",
116                                       MODEST_TYPE_MIME_PART_VIEW,
117                                       G_SIGNAL_RUN_LAST,
118                                       G_STRUCT_OFFSET (ModestMimePartViewIface, fetch_url),
119                                       NULL, NULL,
120                                       modest_marshal_BOOLEAN__STRING_OBJECT,
121                                       G_TYPE_BOOLEAN, 2,
122                                       G_TYPE_STRING,
123                                       G_TYPE_OBJECT);
124                 initialized = TRUE;
125         }
126 }
127
128 GType
129 modest_mime_part_view_get_type (void)
130 {
131         static GType type = 0;
132
133         if (G_UNLIKELY(type == 0)) 
134         {
135                 static const GTypeInfo info = 
136                 {
137                   sizeof (ModestMimePartViewIface),
138                   modest_mime_part_view_base_init,   /* base_init */
139                   NULL,   /* base_finalize */
140                   NULL,   /* class_init */
141                   NULL,   /* class_finalize */
142                   NULL,   /* class_data */
143                   0,
144                   0,      /* n_preallocs */
145                   NULL,   /* instance_init */
146                   NULL
147                 };
148
149                 type = g_type_register_static (G_TYPE_INTERFACE,
150                         "ModestMimePartView", &info, 0);
151
152         }
153
154         return type;
155 }