1 /* Copyright (c) 2006,2007 Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
30 #ifndef __MODEST_MSG_EDIT_WINDOW_H__
31 #define __MODEST_MSG_EDIT_WINDOW_H__
34 #include <tny-vfs-stream.h>
35 #ifdef MODEST_TOOLKIT_HILDON2
36 #include <modest-hildon2-window.h>
38 #include <modest-shell-window.h>
40 #include <widgets/modest-window.h>
44 /* convenience macros */
45 #define MODEST_TYPE_MSG_EDIT_WINDOW (modest_msg_edit_window_get_type())
46 #define MODEST_MSG_EDIT_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MSG_EDIT_WINDOW,ModestMsgEditWindow))
47 #define MODEST_MSG_EDIT_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MSG_EDIT_WINDOW,ModestWindow))
48 #define MODEST_IS_MSG_EDIT_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MSG_EDIT_WINDOW))
49 #define MODEST_IS_MSG_EDIT_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MSG_EDIT_WINDOW))
50 #define MODEST_MSG_EDIT_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MSG_EDIT_WINDOW,ModestMsgEditWindowClass))
52 typedef struct _ModestMsgEditWindow ModestMsgEditWindow;
53 typedef struct _ModestMsgEditWindowClass ModestMsgEditWindowClass;
55 struct _ModestMsgEditWindow {
56 #ifdef MODEST_TOOLKIT_HILDON2
57 ModestHildon2Window parent;
59 ModestShellWindow parent;
61 /* insert public members, if any */
64 struct _ModestMsgEditWindowClass {
65 #ifdef MODEST_TOOLKIT_HILDON2
66 ModestHildon2WindowClass parent_class;
68 ModestShellWindowClass parent_class;
70 /* insert signal callback declarations, eg. */
71 /* void (* my_event) (ModestMsgEditWindow* obj); */
76 MODEST_EDIT_TYPE_REPLY,
77 MODEST_EDIT_TYPE_FORWARD,
83 MODEST_MSG_EDIT_FORMAT_TEXT,
84 MODEST_MSG_EDIT_FORMAT_HTML
85 } ModestMsgEditFormat;
88 MODEST_MSG_EDIT_WINDOW_WIDGET_TYPE_BODY,
89 MODEST_MSG_EDIT_WINDOW_WIDGET_TYPE_TO,
90 MODEST_MSG_EDIT_WINDOW_WIDGET_TYPE_CC,
91 MODEST_MSG_EDIT_WINDOW_WIDGET_TYPE_BCC,
92 MODEST_MSG_EDIT_WINDOW_WIDGET_TYPE_SUBJECT,
93 MODEST_MSG_EDIT_WINDOW_WIDGET_TYPE_ATTACHMENTS,
94 MODEST_MSG_EDIT_WINDOW_WIDGET_TYPE_NUM,
95 } ModestMsgEditWindowWidgetType;
97 /** Get these with modest_msg_edit_window_get_msg_data()
98 * and free them with modest_msg_edit_window_free_msg_data().
101 gchar *from, *to, *cc, *bcc, *subject, *plain_body, *html_body;
102 gchar *references, *in_reply_to;
105 TnyHeaderFlags priority_flags;
115 const gchar *font_family;
117 GtkJustification justification;
118 } ModestMsgEditFormatState;
122 * modest_msg_edit_window_get_type:
124 * get the GType for the #ModestMsgEditWindow class
126 * Returns: a GType for #ModestMsgEditWindow
128 GType modest_msg_edit_window_get_type (void) G_GNUC_CONST;
132 * modest_msg_edit_window_new:
133 * @msg: a #TnyMsg instance
134 * @account_name: the account this message applies to
135 * @mailbox: the mailbox (if any)
136 * @preserve_is_rich: if @msg is not rich, open the message as plain text
138 * instantiates a new #ModestMsgEditWindow widget
140 * Returns: a new #ModestMsgEditWindow, or NULL in case of error
142 ModestWindow* modest_msg_edit_window_new (TnyMsg *msg,
143 const gchar *account_name,
144 const gchar *mailbox,
145 gboolean preserve_is_rich);
149 * modest_msg_edit_window_get_msg_data:
150 * @self: a #ModestMsgEditWindow
152 * gets the message data already present in the edit message
153 * window. The message data must be freed with
154 * modest_msg_edit_window_free_msg_data
156 * Returns: the message data
158 MsgData * modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *self);
161 * modest_msg_edit_window_free_msg_data:
162 * @self: a #ModestMsgEditWindow
165 * frees the message data passed as argument
167 void modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *self,
171 * modest_msg_edit_window_get_format:
172 * @self: a #ModestMsgEditWindow
174 * obtains the format type of the message body.
176 * Returns: a #ModestMsgEditFormat
178 ModestMsgEditFormat modest_msg_edit_window_get_format (ModestMsgEditWindow *self);
181 * modest_msg_edit_window_set_format:
182 * @self: a #ModestMsgEditWindow
183 * @format: a #ModestMsgEditFormat
185 * set the @format of the edit window message body.
187 void modest_msg_edit_window_set_format (ModestMsgEditWindow *self,
188 ModestMsgEditFormat format);
191 * modest_msg_edit_window_get_format_state:
192 * @self: a #ModestMsgEditWindow
194 * get the current format state (the format attributes the text user inserts
197 * Returns: a #ModestMsgEditFormatState structure that should be freed with g_free().
199 ModestMsgEditFormatState *modest_msg_edit_window_get_format_state (ModestMsgEditWindow *self);
202 * modest_msg_edit_window_set_format_state:
203 * @self: a #ModestMsgEditWindow
204 * @format_state: a #ModestMsgEditWindowFormatState
206 * sets a new format state (the format attributes the text user inserts
209 void modest_msg_edit_window_set_format_state (ModestMsgEditWindow *self,
210 const ModestMsgEditFormatState *format_state);
213 * modest_msg_edit_window_select_color:
214 * @self: a #ModestMsgEditWindow
216 * show color selection dialog and update text color
218 void modest_msg_edit_window_select_color (ModestMsgEditWindow *window);
221 * modest_msg_edit_window_select_background_color:
222 * @self: a #ModestMsgEditWindow
224 * show color selection dialog and update background color
226 void modest_msg_edit_window_select_background_color (ModestMsgEditWindow *window);
229 * modest_msg_edit_window_insert_image:
230 * @self: a #ModestMsgEditWindow
232 * show a file selection dialog to insert an image
234 void modest_msg_edit_window_insert_image (ModestMsgEditWindow *window);
237 * modest_msg_edit_window_offer_attach_file:
238 * @self: a #ModestMsgEditWindow
240 * show a file selection dialog to attach a file
242 void modest_msg_edit_window_offer_attach_file (ModestMsgEditWindow *window);
245 * modest_msg_edit_window_attach_file_one:
246 * @self: a #ModestMsgEditWindow
247 * @file_uri: The URI of a file to attach to the email message.
248 * @allowed_size: max size allowed for this attachment, 0 for unlimited
250 * attach a file to a MsgEditWindow non interactively,
251 * without file dialog. This is needed by dbus callbacks.
253 * Returns: the filesize (if available)
255 GnomeVFSFileSize modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window, const gchar *file_uri, GnomeVFSFileSize allowed_size);
258 * modest_msg_edit_window_remove_attachments:
259 * @self: a #ModestMsgEditWindow
260 * @att_list: a #GList of #TnyMimePart
262 * remove attachments in @att_list, with a confirmation dialog
264 void modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window,
268 * modest_msg_edit_window_get_parts_size:
269 * @window: a #ModestMsgEditWindow
270 * @parts_count: number of attachments and images attached to the message
271 * @parts_size: sum of sizes of attachments and images
273 void modest_msg_edit_window_get_parts_size (ModestMsgEditWindow *window,
275 guint64 *parts_size);
277 * modest_msg_edit_window_add_part:
278 * @self: a #ModestMsgEditWindow
279 * @part: a #TnyMimePart
281 * Adds @part as an attachment
283 void modest_msg_edit_window_add_part (ModestMsgEditWindow *window,
287 * modest_msg_edit_window_show_cc:
288 * @window: a #ModestMsgEditWindow
291 * Set the CC field as visible (or not visible) depending on @show
293 void modest_msg_edit_window_show_cc (ModestMsgEditWindow *window, gboolean show);
296 * modest_msg_edit_window_show_bcc:
297 * @window: a #ModestMsgEditWindow
300 * Set the BCC field as visible (or not visible) depending on @show
302 void modest_msg_edit_window_show_bcc (ModestMsgEditWindow *window, gboolean show);
305 * modest_msg_edit_window_set_priority_flags:
306 * @window: a #ModestMsgEditWindow
307 * @priority_flags: a #TnyHeaderFlags with priority information
309 * Updates the icon and priority flag to send.
311 void modest_msg_edit_window_set_priority_flags (ModestMsgEditWindow *window,
312 TnyHeaderFlags priority_flags);
315 * modest_msg_edit_window_set_file_format:
316 * @window: a #ModestMsgEditWindow
317 * @file_format: %MODEST_FILE_FORMAT_PLAIN_TEXT or %MODEST_FILE_FORMAT_FORMATTED_TEXT
319 * Changes the current file format.
321 void modest_msg_edit_window_set_file_format (ModestMsgEditWindow *window,
325 * modest_msg_edit_window_select_font:
326 * @window: a #ModestMsgEditWindow
328 * Show the dialog to select the editor font and update the
329 * used font in the editor.
331 void modest_msg_edit_window_select_font (ModestMsgEditWindow *window);
334 * modest_msg_edit_window_undo:
335 * @window: a #ModestMsgEditWindow
337 * Undoes the last operation.
339 void modest_msg_edit_window_undo (ModestMsgEditWindow *window);
342 * modest_msg_edit_window_can_undo:
343 * @window: a #ModestMsgEditWindow
345 * Checks if an undo operation is available
347 * Returns: %TRUE if undo can be done, %FALSE otherwise.
349 gboolean modest_msg_edit_window_can_undo (ModestMsgEditWindow *window);
352 * modest_msg_edit_window_redo:
353 * @window: a #ModestMsgEditWindow
357 void modest_msg_edit_window_redo (ModestMsgEditWindow *window);
360 * modest_msg_edit_window_can_redo:
361 * @window: a #ModestMsgEditWindow
363 * Checks if a redp operation is available
365 * Returns: %TRUE if redo can be done, %FALSE otherwise.
367 gboolean modest_msg_edit_window_can_redo (ModestMsgEditWindow *window);
370 * modest_msg_edit_window_select_contacts:
371 * @window: a #ModestMsgEditWindow
373 * Shows the dialog to add contacts to the currently focused recipient list,
374 * or to To: recipient if no recipient list is focused.
376 void modest_msg_edit_window_select_contacts (ModestMsgEditWindow *window);
379 * modest_msg_edit_window_add_to_contacts:
380 * @self: a #ModestMsgEditWindow
382 * activates the add to contacts use. It shows the add to contacts
383 * dialog to select the recipient to add.
385 void modest_msg_edit_window_add_to_contacts (ModestMsgEditWindow *self);
388 * modest_msg_edit_window_check_names:
389 * @window: a #ModestMsgEditWindow
390 * @add_to_addressbook: if TRUE, add valid addresses to the addressbook
392 * Validates all the recipients, and shows (if required) dialogs for adding contacts
393 * or fixing problems in specific fields.
395 * Returns: %TRUE if all fields were validated, %FALSE otherwise
397 gboolean modest_msg_edit_window_check_names (ModestMsgEditWindow *window,
398 gboolean add_to_addressbook);
401 * modest_msg_edit_window_has_pending_addresses:
402 * @window: a #ModestMsgEditWindow
403 * @add_to_addressbook: if TRUE, add valid addresses to the addressbook
405 * Validates all the recipients, and checks if there are addresses in
406 * any field that could be added to the addressbook
408 * Returns: %TRUE if there are valid pending addresses, %FALSE otherwise
410 gboolean modest_msg_edit_window_has_pending_addresses (ModestMsgEditWindow *window);
413 * modest_msg_edit_window_toggle_isearch_toolbar:
414 * @window: a #ModestMsgEditWindow
417 * Shows/Hides the isearch toolbar
419 void modest_msg_edit_window_toggle_isearch_toolbar (ModestMsgEditWindow *window,
424 * modest_msg_edit_window_is_modified:
425 * @window: a #ModestMsgEditWindow
427 * Examines whether or not the message has been modified
429 * Returns: %TRUE if any field has been modified, %FALSE otherwise
431 gboolean modest_msg_edit_window_is_modified (ModestMsgEditWindow *window);
434 * modest_msg_edit_window_reset_modified:
435 * @window: a #ModestMsgEditWindow
436 * @modified: wheter or not we want to make the buffer as modified or not
438 * Sets the message as modified or not
440 void modest_msg_edit_window_set_modified (ModestMsgEditWindow *window,
444 gboolean modest_msg_edit_window_get_sent (ModestMsgEditWindow *window);
445 void modest_msg_edit_window_set_sent (ModestMsgEditWindow *window,
449 * modest_msg_edit_window_set_draft:
450 * @window: a #ModestMsgEditWindow
451 * @draft: a #TnyMsg, or %NULL
453 * Set @draft as the original draft message of the editor. This
454 * message will be removed on saving or sending the message.
456 void modest_msg_edit_window_set_draft (ModestMsgEditWindow *window,
459 * modest_msg_edit_window_get_message_uid:
460 * @msg: an #ModestMsgEditWindow instance
462 * gets the unique identifier for the message in this msg editor.
463 * This is the identifier of the draft or outbox message the editor was
464 * opened from. If it's a new message, then it returns %NULL
466 * Returns: the id of the #TnyMsg being shown, or NULL in case of error
468 const gchar* modest_msg_edit_window_get_message_uid (ModestMsgEditWindow *window);
471 * modest_msg_edit_window_get_child_widget:
472 * @win: a #ModestMsgEditWindow
473 * @widget_type: the type of the child to obtain
475 * Obtain the child widget of @win of type @widget_type
477 * Returns: a #GtkWidget, or %NULL
480 modest_msg_edit_window_get_child_widget (ModestMsgEditWindow *win,
481 ModestMsgEditWindowWidgetType widget_type);
484 * modest_msg_edit_window_get_clipboard_text:
485 * @win: a #ModestMsgEditWindow
487 * Obtains the currently selected text in selection clipboard
492 modest_msg_edit_window_get_clipboard_text (ModestMsgEditWindow *win);
496 #endif /* __MODEST_MSG_EDIT_WINDOW_H__ */