2007-05-16 Murray Cumming <murrayc@murrayc.com>
[modest] / src / widgets / modest-msg-edit-window.h
1 /* Copyright (c) 2006,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 #ifndef __MODEST_MSG_EDIT_WINDOW_H__
31 #define __MODEST_MSG_EDIT_WINDOW_H__
32
33 #include <tny-msg.h>
34 #include <widgets/modest-window.h>
35
36 G_BEGIN_DECLS
37
38 /* convenience macros */
39 #define MODEST_TYPE_MSG_EDIT_WINDOW             (modest_msg_edit_window_get_type())
40 #define MODEST_MSG_EDIT_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MSG_EDIT_WINDOW,ModestMsgEditWindow))
41 #define MODEST_MSG_EDIT_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MSG_EDIT_WINDOW,ModestWindow))
42 #define MODEST_IS_MSG_EDIT_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MSG_EDIT_WINDOW))
43 #define MODEST_IS_MSG_EDIT_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MSG_EDIT_WINDOW))
44 #define MODEST_MSG_EDIT_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MSG_EDIT_WINDOW,ModestMsgEditWindowClass))
45
46 typedef struct _ModestMsgEditWindow      ModestMsgEditWindow;
47 typedef struct _ModestMsgEditWindowClass ModestMsgEditWindowClass;
48
49 struct _ModestMsgEditWindow {
50          ModestWindow parent;
51         /* insert public members, if any */
52 };
53
54 struct _ModestMsgEditWindowClass {
55         ModestWindowClass parent_class;
56         /* insert signal callback declarations, eg. */
57         /* void (* my_event) (ModestMsgEditWindow* obj); */
58 };
59
60 typedef enum  {
61         MODEST_EDIT_TYPE_NEW,
62         MODEST_EDIT_TYPE_REPLY,
63         MODEST_EDIT_TYPE_FORWARD,
64         
65         MODEST_EDIT_TYPE_NUM
66 } ModestEditType;
67
68 typedef enum {
69         MODEST_MSG_EDIT_FORMAT_TEXT,
70         MODEST_MSG_EDIT_FORMAT_HTML
71 } ModestMsgEditFormat;
72
73 /** Get these with modest_msg_edit_window_get_msg_data() 
74  * and free them with modest_msg_edit_window_free_msg_data().
75  */
76 typedef struct  {
77         gchar *from, *to, *cc, *bcc, *subject, *plain_body, *html_body;
78         GList *attachments;
79         TnyHeaderFlags priority_flags;
80 } MsgData;
81
82 typedef struct {
83         gboolean bold;
84         gboolean italics;
85         gboolean bullet;
86         GdkColor color;
87         const gchar *font_family;
88         gint font_size;
89         GtkJustification justification;
90 } ModestMsgEditFormatState;
91
92
93 /**
94  * modest_msg_edit_window_get_type:
95  * 
96  * get the GType for the #ModestMsgEditWindow class
97  *
98  * Returns: a GType for #ModestMsgEditWindow
99  */
100 GType        modest_msg_edit_window_get_type    (void) G_GNUC_CONST;
101
102
103 /**
104  * modest_msg_edit_window_new:
105  * #msg: a #TnyMsg instance
106  * #account_name: the account this message applies to
107  * 
108  * instantiates a new #ModestMsgEditWindow widget
109  *
110  * Returns: a new #ModestMsgEditWindow, or NULL in case of error
111  */
112 ModestWindow*   modest_msg_edit_window_new         (TnyMsg *msg, const gchar *account_name);
113
114
115 /**
116  * modest_msg_edit_window_get_msg_data:
117  * @self: a #ModestMsgEditWindow
118  * 
119  * gets the message data already present in the edit message
120  * window. The message data must be freed with
121  * modest_msg_edit_window_free_msg_data
122  * 
123  * Returns: the message data
124  **/
125 MsgData *               modest_msg_edit_window_get_msg_data          (ModestMsgEditWindow *self);
126
127 /**
128  * modest_msg_edit_window_free_msg_data:
129  * @self: a #ModestMsgEditWindow
130  * @data: 
131  * 
132  * frees the message data passed as argument
133  **/
134 void                    modest_msg_edit_window_free_msg_data         (ModestMsgEditWindow *self,
135                                                                       MsgData *data);
136
137 /**
138  * modest_msg_edit_window_get_format:
139  * @self: a #ModestMsgEditWindow
140  *
141  * obtains the format type of the message body.
142  *
143  * Returns: a #ModestMsgEditFormat
144  **/
145 ModestMsgEditFormat     modest_msg_edit_window_get_format            (ModestMsgEditWindow *self);
146
147 /**
148  * modest_msg_edit_window_set_format:
149  * @self: a #ModestMsgEditWindow
150  * @format: a #ModestMsgEditFormat
151  *
152  * set the @format of the edit window message body.
153  **/
154 void                    modest_msg_edit_window_set_format            (ModestMsgEditWindow *self,
155                                                                       ModestMsgEditFormat format);
156
157 /**
158  * modest_msg_edit_window_get_format_state:
159  * @self: a #ModestMsgEditWindow
160  *
161  * get the current format state (the format attributes the text user inserts
162  * will get).
163  *
164  * Returns: a #ModestMsgEditFormatState structure that should be freed with g_free().
165  **/
166 ModestMsgEditFormatState *modest_msg_edit_window_get_format_state    (ModestMsgEditWindow *self);
167
168 /**
169  * modest_msg_edit_window_set_format_state:
170  * @self: a #ModestMsgEditWindow
171  * @format_state: a #ModestMsgEditWindowFormatState
172  *
173  * sets a new format state (the format attributes the text user inserts 
174  * will get).
175  **/
176 void                    modest_msg_edit_window_set_format_state      (ModestMsgEditWindow *self,
177                                                                       const ModestMsgEditFormatState *format_state);
178
179 /**
180  * modest_msg_edit_window_select_color:
181  * @self: a #ModestMsgEditWindow
182  *
183  * show color selection dialog and update text color
184  */
185 void                    modest_msg_edit_window_select_color          (ModestMsgEditWindow *window);
186
187 /**
188  * modest_msg_edit_window_select_background_color:
189  * @self: a #ModestMsgEditWindow
190  *
191  * show color selection dialog and update background color
192  */
193 void                    modest_msg_edit_window_select_background_color          (ModestMsgEditWindow *window);
194
195 /**
196  * modest_msg_edit_window_insert_image:
197  * @self: a #ModestMsgEditWindow
198  *
199  * show a file selection dialog to insert an image
200  */
201 void                    modest_msg_edit_window_insert_image          (ModestMsgEditWindow *window);
202
203 /**
204  * modest_msg_edit_window_attach_file:
205  * @self: a #ModestMsgEditWindow
206  *
207  * show a file selection dialog to attach a file
208  */
209 void                    modest_msg_edit_window_attach_file           (ModestMsgEditWindow *window);
210
211 /**
212  * modest_msg_edit_window_remove_attachments:
213  * @self: a #ModestMsgEditWindow
214  * @att_list: a #GList of #TnyMimePart
215  *
216  * remove attachments in @att_list, with a confirmation dialog
217  */
218 void                    modest_msg_edit_window_remove_attachments    (ModestMsgEditWindow *window, 
219                                                                       GList *att_list);
220
221 /**
222  * modest_msg_edit_window_show_cc:
223  * @window: a #ModestMsgEditWindow
224  * @show: a #gboolean
225  *
226  * Set the CC field as visible (or not visible) depending on @show
227  */
228 void                    modest_msg_edit_window_show_cc               (ModestMsgEditWindow *window, gboolean show);
229
230 /**
231  * modest_msg_edit_window_show_bcc:
232  * @window: a #ModestMsgEditWindow
233  * @show: a #gboolean
234  *
235  * Set the BCC field as visible (or not visible) depending on @show
236  */
237 void                    modest_msg_edit_window_show_bcc               (ModestMsgEditWindow *window, gboolean show);
238
239 /**
240  * modest_msg_edit_window_toggle_fullscreen:
241  * @window: a #ModestMsgEditWindow
242  *
243  * toggles the current fullscreen status
244  */
245 void            modest_msg_edit_window_toggle_fullscreen (ModestMsgEditWindow *window);
246
247 /**
248  * modest_msg_edit_window_set_priority_flags:
249  * @window: a #ModestMsgEditWindow
250  * @priority_flags: a #TnyHeaderFlags with priority information
251  *
252  * Updates the icon and priority flag to send.
253  */
254 void            modest_msg_edit_window_set_priority_flags (ModestMsgEditWindow *window,
255                                                            TnyHeaderFlags priority_flags);
256
257 /**
258  * modest_msg_edit_window_set_file_format:
259  * @window: a #ModestMsgEditWindow
260  * @file_format: %MODEST_FILE_FORMAT_PLAIN_TEXT or %MODEST_FILE_FORMAT_FORMATTED_TEXT
261  *
262  * Changes the current file format.
263  */
264 void            modest_msg_edit_window_set_file_format (ModestMsgEditWindow *window,
265                                                         gint file_format);
266
267 /**
268  * modest_msg_edit_window_select_font:
269  * @window: a #ModestMsgEditWindow
270  *
271  * Show the dialog to select the editor font and update the
272  * used font in the editor.
273  */
274 void            modest_msg_edit_window_select_font        (ModestMsgEditWindow *window);
275
276 /**
277  * modest_msg_edit_window_undo:
278  * @window: a #ModestMsgEditWindow
279  *
280  * Undoes the last operation.
281  */
282 void            modest_msg_edit_window_undo               (ModestMsgEditWindow *window);
283
284 /**
285  * modest_msg_edit_window_select_contacts:
286  * @window: a #ModestMsgEditWindow
287  *
288  * Shows the dialog to add contacts to the currently focused recipient list,
289  * or to To: recipient if no recipient list is focused.
290  */
291 void            modest_msg_edit_window_select_contacts    (ModestMsgEditWindow *window);
292
293 /**
294  * modest_msg_edit_window_check_names:
295  * @window: a #ModestMsgEditWindow
296  *
297  * Validates all the recipients, and shows (if required) dialogs for adding contacts
298  * or fixing problems in specific fields.
299  *
300  * Returns: %TRUE if all fields were validated, %FALSE otherwise
301  */
302 gboolean        modest_msg_edit_window_check_names    (ModestMsgEditWindow *window);
303
304 G_END_DECLS
305
306 #endif /* __MODEST_MSG_EDIT_WINDOW_H__ */
307