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