Make windows inherit from ModestShellWindow in gtk
[modest] / src / widgets / modest-msg-view-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_VIEW_WINDOW_H__
31 #define __MODEST_MSG_VIEW_WINDOW_H__
32
33 #include <tny-msg.h>
34 #include <tny-folder.h>
35 #ifdef MODEST_TOOLKIT_HILDON2
36 #include <modest-hildon2-window.h>
37 #else
38 #include <modest-shell-window.h>
39 #endif
40 #include <widgets/modest-window.h>
41 #include <widgets/modest-header-view.h>
42 #include <gtk/gtk.h>
43
44 G_BEGIN_DECLS
45
46 /* convenience macros */
47 #define MODEST_TYPE_MSG_VIEW_WINDOW             (modest_msg_view_window_get_type())
48 #define MODEST_MSG_VIEW_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MSG_VIEW_WINDOW,ModestMsgViewWindow))
49 #define MODEST_MSG_VIEW_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MSG_VIEW_WINDOW,ModestWindow))
50 #define MODEST_IS_MSG_VIEW_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MSG_VIEW_WINDOW))
51 #define MODEST_IS_MSG_VIEW_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MSG_VIEW_WINDOW))
52 #define MODEST_MSG_VIEW_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MSG_VIEW_WINDOW,ModestMsgVIewWindowClass))
53
54
55 typedef struct {
56 #ifdef MODEST_TOOLKIT_HILDON2
57         ModestHildon2Window parent;
58 #else
59         ModestShellWindow parent;
60 #endif
61 } ModestMsgViewWindow;
62         
63 typedef struct {
64 #ifdef MODEST_TOOLKIT_HILDON2
65         ModestHildon2WindowClass parent_class;
66 #else
67         ModestShellWindowClass parent_class;
68 #endif
69
70         void (*msg_changed) (ModestMsgViewWindow *self,
71                              GtkTreeModel *model,
72                              GtkTreeRowReference *row_reference, 
73                              gpointer user_data);
74
75         gboolean (*scroll_child) (ModestMsgViewWindow *self,
76                                    GtkScrollType scroll_type,
77                                    gboolean horizontal,
78                                    gpointer userdata);
79 } ModestMsgViewWindowClass;
80
81 /**
82  * modest_msg_view_window_get_type:
83  * 
84  * get the GType for the #ModestMsgViewWindow class
85  *
86  * Returns: a GType for #ModestMsgViewWindow
87  */
88 GType        modest_msg_view_window_get_type    (void) G_GNUC_CONST;
89         
90
91 /**
92  * modest_msg_view_window_new_for_attachment:
93  * @msg: an #TnyMsg instance
94  * @modest_account_name: the account name 
95  * @mailbox: the mailbox (if any)
96  * 
97  * instantiates a new #ModestMsgViewWindow widget to view a message that is an
98  * attachment in another message.
99  * The account name is used to
100  * set the proper account when choosing reply/forward from the msg view window
101  *
102  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
103  */
104 ModestWindow*   modest_msg_view_window_new_for_attachment         (TnyMsg *msg, 
105                                                                    const gchar *modest_account_name,
106                                                                    const gchar *mailbox,
107                                                                    const gchar *msg_uid);
108
109 /**
110  * modest_msg_view_window_new_with_other_body:
111  * @msg: an #TnyMsg instance
112  * @modest_account_name: the account name 
113  * @mailbox: the mailbox (if any)
114  * 
115  * instantiates a new #ModestMsgViewWindow widget to view a message that is a different body
116  * in another message.
117  * The account name is used to
118  * set the proper account when choosing reply/forward from the msg view window
119  *
120  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
121  */
122 ModestWindow*   modest_msg_view_window_new_with_other_body         (TnyMsg *msg,
123                                                                    TnyMimePart *other_body,
124                                                                    const gchar *modest_account_name,
125                                                                    const gchar *mailbox,
126                                                                    const gchar *msg_uid);
127
128 /**
129  * modest_msg_view_window_is_other_body:
130  * @self: a #ModestMsgViewWindow
131  *
132  * tells if the view window is showing other body
133  *
134  * Returns: %TRUE if showing "not first body"
135  */
136 gboolean modest_msg_view_window_is_other_body (ModestMsgViewWindow *self);
137
138 /**
139  * modest_msg_view_window_new_with_header_model:
140  * @msg: an #TnyMsg instance
141  * @modest_account_name: the account name 
142  * @mailbox: the mailbox (if any)
143  * @model: a #GtkTreeModel, with the format used by #ModestHeaderView
144  * @row_reference: a #GtkTreeRowReference, pointing to the position of @msg in @model.
145  * 
146  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
147  * set the proper account when choosing reply/forward from the msg view window.
148  * This constructor also passes a reference to the @model of the header view
149  * to allow selecting previous/next messages in the message list when appropriate.
150  *
151  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
152  */
153 ModestWindow*   modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
154                                                               const gchar *modest_account_name, 
155                                                               const gchar *mailbox,
156                                                               const gchar *msg_uid,
157                                                               GtkTreeModel *model, 
158                                                               GtkTreeRowReference *row_reference);
159
160 /**
161  * modest_msg_view_window_new_from_header_view:
162  * @header_view: an #ModestHeaderView instance
163  * @modest_account_name: the account name 
164  * @mailbox: the mailbox (if any)
165  * @msg_uid: the initial uid reserved by this window
166  * @row_reference: a #GtkTreeRowReference, pointing to the selected position @model.
167  * 
168  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
169  * set the proper account when choosing reply/forward from the msg view window.
170  * It's different from new_with_header_model, as it creates the window and then
171  * loads the message in that window.
172  *
173  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
174  */
175 ModestWindow*   modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view, 
176                                                              const gchar *modest_account_name, 
177                                                              const gchar *mailbox,
178                                                              const gchar *msg_uid,
179                                                              GtkTreeRowReference *row_reference);
180
181
182 /**
183  * modest_msg_view_window_new_from_uid:
184  */
185 ModestWindow *
186 modest_msg_view_window_new_from_uid (const gchar *modest_account_name,
187                                      const gchar *mailbox,
188                                      const gchar *msg_uid);
189                                               
190 /**
191  * modest_msg_view_window_new_for_search_result:
192  * @msg: an #TnyMsg instance
193  * @modest_account_name: the account name 
194  * 
195  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
196  * set the proper account when choosing reply/forward from the msg view window.
197  * This constructor marks the window as being for a search result, which should 
198  * cause some UI to be disabled, such as the previous/next buttons.
199  *
200  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
201  */
202 ModestWindow *
203 modest_msg_view_window_new_for_search_result (TnyMsg *msg, 
204                                               const gchar *modest_account_name,
205                                               const gchar *mailbox,
206                                               const gchar *msg_uid);
207                                               
208 /**
209  * modest_msg_view_window_get_header:
210  * @window: an #ModestMsgViewWindow instance
211  * 
212  * get the message header in this msg view. Header instance is get
213  * from tree_model of headers list. 
214  * 
215  * Returns: a new #TnyHeader instance, or NULL in case of error
216  */
217 TnyHeader*
218 modest_msg_view_window_get_header (ModestMsgViewWindow *self);
219
220 /**
221  * modest_msg_view_window_get_message:
222  * @window: an #ModestMsgViewWindow instance
223  * 
224  * get a new reference to the message in this msg view. The caller
225  * must free this new reference
226  * 
227  * Returns: a new #TnyMsg instance, or NULL in case of error
228  */
229 TnyMsg*         modest_msg_view_window_get_message     (ModestMsgViewWindow *window);
230
231 /**
232  * modest_msg_view_window_get_message_uid:
233  * @msg: an #ModestMsgViewWindow instance
234  * 
235  * gets the unique identifier for the message in this msg view. The
236  * returned value *must* not be freed
237  * 
238  * Returns: the id of the #TnyMsg being shown, or NULL in case of error
239  */
240 const gchar*    modest_msg_view_window_get_message_uid (ModestMsgViewWindow *window);
241
242 /**
243  * modest_msg_view_window_select_next_message:
244  * @window: a #ModestMsgViewWindow instance
245  *
246  * select the next message obtained from the header view this view 
247  * was called from
248  *
249  * Returns: %TRUE if a new message is shown.
250  */
251 gboolean        modest_msg_view_window_select_next_message (ModestMsgViewWindow *window);
252
253 /**
254  * modest_msg_view_window_select_previous_message:
255  * @window: a #ModestMsgViewWindow instance
256  *
257  * select the previous message obtained from the header view this view 
258  * was called from
259  *
260  * Returns: %TRUE if a new message is shown.
261  */
262 gboolean        modest_msg_view_window_select_previous_message (ModestMsgViewWindow *window);
263
264 /**
265  * modest_msg_view_window_view_attachment:
266  * @window: a #ModestMsgViewWindow
267  * @mime_part: a #TnyMimePart
268  *
269  * Opens @mime_part, or the currently selected attachment if @mime_part is %NULL. 
270  * If it's a message, it opens it  for viewing. Otherwise it opens a temporary file 
271  * with the contents of the attachment.
272  */
273 void            modest_msg_view_window_view_attachment (ModestMsgViewWindow *window,
274                                                         TnyMimePart *mime_part);
275
276 /**
277  * modest_msg_view_window_get_attachments:
278  * @window: a #ModestMsgViewWindow
279  *
280  * Get selected attachments from #ModetMsgView private object.  
281  */
282 TnyList *         modest_msg_view_window_get_attachments (ModestMsgViewWindow *win);
283
284 /**
285  * modest_msg_view_window_save_attachments:
286  * @window: a #ModestMsgViewWindow
287  * @mime_parts: a #TnyList of #TnyMimePart
288  *
289  * Save the #TnyMimePart attachments in @mime_parts, or currently selected attachments
290  * if @mime_parts is %NULL, offering a dialog to the user to choose the location.
291  */
292 void            modest_msg_view_window_save_attachments (ModestMsgViewWindow *window,
293                                                          TnyList *mime_parts);
294
295 /**
296  * modest_msg_view_window_remove_attachments:
297  * @window: a #ModestMsgViewWindow
298  * @get_all: a #gboolean. If %TRUE, purges all attachmnents, if %FALSE,
299  * purges only selected ones.
300  *
301  * Removes selected attachments.
302  */
303 void            modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window,
304                                                            gboolean get_all);
305
306
307 /**
308  * modest_msg_view_window_toolbar_on_transfer_mode:
309  * @window: a #ModestMsgViewWindow
310  *
311  * Check if toolbar is in transfer mode, which determines whether a
312  * transfer operation is being processed.
313  */
314 gboolean  modest_msg_view_window_toolbar_on_transfer_mode     (ModestMsgViewWindow *self);
315
316
317 /**
318  * modest_msg_view_window_last_message_selected:
319  * @window: a #ModestMsgViewWindow
320  *
321  * Check message currently viewed is the last message into folder . 
322 */
323 gboolean modest_msg_view_window_last_message_selected (ModestMsgViewWindow *window); 
324
325
326 /**
327  * modest_msg_view_window_first_message_selected:
328  * @window: a #ModestMsgViewWindow
329  *
330  * Check message currently viewed is the last message into folder . 
331 */
332 gboolean modest_msg_view_window_first_message_selected (ModestMsgViewWindow *window);
333
334 /**
335  * modest_msg_view_window_has_headers_model:
336  * @window: a #ModestMsgViewWindow
337  *
338  * Check if window has been created with a full headers model. 
339 */
340 gboolean modest_msg_view_window_has_headers_model (ModestMsgViewWindow *window);
341
342 /**
343  * modest_msg_view_window_is_search_result:
344  * @window: a #ModestMsgViewWindow
345  *
346  * Check if window has been created to show a search result. 
347  */
348 gboolean modest_msg_view_window_is_search_result (ModestMsgViewWindow *window);
349
350
351 /**
352  * modest_msg_view_window_get_folder_type:
353  * @window: a #ModestMsgViewWindow
354  *
355  * Gets folder type of message currently viewed . 
356 */
357 TnyFolderType
358 modest_msg_view_window_get_folder_type (ModestMsgViewWindow *window);
359
360 /**
361  * modest_msg_view_window_transfer_mode_enabled:
362  * @window: a #ModestMsgViewWindow
363  *
364  * Determines if some transfer operation is in progress.
365  *
366  * Returns: TRUE if transfer mode is enabled, FASE otherwise.
367 */
368 gboolean 
369 modest_msg_view_window_transfer_mode_enabled (ModestMsgViewWindow *self);
370
371 /**
372  * modest_msg_view_window_add_to_contacts:
373  * @self: a #ModestMsgViewWindow
374  *
375  * activates the add to contacts use case. In Diablo and gnome it gets the
376  * clipboard selection current value and tries to add it to the addressbook.
377  * In fremantle, it shows the add to contacts dialog to select the recipient
378  * to add.
379  */
380 void
381 modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self);
382
383 /**
384  * modest_msg_view_window_get_msg_view:
385  * @self: a #ModestMsgViewWindow
386  *
387  * Tells that external images should be fetched in this window.
388  */
389 void
390 modest_msg_view_window_fetch_images (ModestMsgViewWindow *self);
391
392 /**
393  * modest_msg_view_window_has_blocked_external_images:
394  * @self: a #ModestMsgViewWindow
395  * 
396  * checks if the msg currently shown has blocked external images.
397  *
398  * Returns: %TRUE if external images are blocked, %FALSE otherwise
399  */
400 gboolean modest_msg_view_window_has_blocked_external_images (ModestMsgViewWindow *self);
401
402 /**
403  * modest_msg_view_window_reload:
404  * @self: a #ModestMsgViewWindow
405  *
406  * Reloads currently loaded message. This is intended to show the message in case it
407  * has some update on the previously visible result.
408  */
409 void modest_msg_view_window_reload (ModestMsgViewWindow *self);
410
411 G_END_DECLS
412
413 #endif /* __MODEST_MSG_VIEW_WINDOW_H__ */
414