Added the function that quotes emails
[modest] / src / widgets / modest-window-mgr.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_WINDOW_MGR_H__
31 #define __MODEST_WINDOW_MGR_H__
32
33 #include <glib-object.h>
34 #include "modest-window.h"
35
36 G_BEGIN_DECLS
37
38 /* convenience macros */
39 #define MODEST_TYPE_WINDOW_MGR             (modest_window_mgr_get_type())
40 #define MODEST_WINDOW_MGR(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgr))
41 #define MODEST_WINDOW_MGR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_WINDOW_MGR,ModestWindowMgrClass))
42 #define MODEST_IS_WINDOW_MGR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_WINDOW_MGR))
43 #define MODEST_IS_WINDOW_MGR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_WINDOW_MGR))
44 #define MODEST_WINDOW_MGR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgrClass))
45
46 typedef struct _ModestWindowMgr      ModestWindowMgr;
47 typedef struct _ModestWindowMgrClass ModestWindowMgrClass;
48
49 struct _ModestWindowMgr {
50          GObject parent;
51 };
52
53 struct _ModestWindowMgrClass {
54         GObjectClass parent_class;
55
56         /* Virtuals */
57         gboolean              (*register_window)                (ModestWindowMgr *self,
58                                                                  ModestWindow *window,
59                                                                  ModestWindow *parent);
60         void                  (*unregister_window)              (ModestWindowMgr *self,
61                                                                  ModestWindow *window);
62         void                  (*set_fullscreen_mode)            (ModestWindowMgr *self,
63                                                                  gboolean on);
64         gboolean              (*get_fullscreen_mode)            (ModestWindowMgr *self);
65         void                  (*show_toolbars)                  (ModestWindowMgr *self,
66                                                                  GType window_type,
67                                                                  gboolean show_toolbars,
68                                                                  gboolean fullscreen);
69         ModestWindow *        (*get_main_window)                (ModestWindowMgr *self,
70                                                                  gboolean show);
71         gboolean              (*close_all_windows)              (ModestWindowMgr *self);
72         GtkWindow *           (*get_modal)                      (ModestWindowMgr *self);
73         void                  (*set_modal)                      (ModestWindowMgr *self,
74                                                                  GtkWindow *window,
75                                                                  GtkWindow *parent);
76         gboolean              (*find_registered_header)         (ModestWindowMgr *self,
77                                                                  TnyHeader *header,
78                                                                  ModestWindow **win);
79         gboolean              (*find_registered_message_uid)    (ModestWindowMgr *self,
80                                                                  const gchar *msg_uid,
81                                                                  ModestWindow **win);
82         GList *               (*get_window_list)                (ModestWindowMgr *self);
83         ModestWindow *        (*show_initial_window)            (ModestWindowMgr *self);
84         ModestWindow *        (*get_current_top)                (ModestWindowMgr *self);
85         gboolean              (*screen_is_on)                   (ModestWindowMgr *self);
86         void                  (*create_caches)                  (ModestWindowMgr *self);
87         /* Signals */
88         void (*window_list_empty) (ModestWindowMgr *self);
89         void (*progress_list_changed) (ModestWindowMgr *self);
90 };
91
92
93 /* member functions */
94 GType        modest_window_mgr_get_type    (void) G_GNUC_CONST;
95
96 /* typical parameter-less _new function */
97 ModestWindowMgr*    modest_window_mgr_new         (void);
98
99
100 /**
101  * modest_window_mgr_register_window:
102  * @self: the #ModestWindowMgr
103  * @window: a #ModestWindow
104  * 
105  * Registers a new window in the window manager. The window manager
106  * will keep a reference.
107  **/
108 gboolean           modest_window_mgr_register_window       (ModestWindowMgr *self, 
109                                                             ModestWindow *window,
110                                                             ModestWindow *parent);
111
112 /**
113  * modest_window_mgr_unregister_window:
114  * @self: the #ModestWindowMgr
115  * @window: a #ModestWindow
116  * 
117  * Unregisters a given window from the window manager. The window
118  * manager will free its reference to it.
119  **/
120 void           modest_window_mgr_unregister_window     (ModestWindowMgr *self, 
121                                                         ModestWindow *window);
122
123 /**
124  * modest_window_mgr_register_banner:
125  * @self: a #ModestWindowMgr
126  *
127  * Increase the count of pending banners in the window manager
128  */
129 void           modest_window_mgr_register_banner (ModestWindowMgr *self);
130
131 /**
132  * modest_window_mgr_unregister_banner:
133  * @self: a #ModestWindowMgr
134  *
135  * Decrease the count of pending banners in the window manager
136  */
137 void           modest_window_mgr_unregister_banner (ModestWindowMgr *self);
138
139 /**
140  * modest_window_mgr_set_fullscreen_mode:
141  * @self: a #ModestWindowMgr
142  * @on: a #gboolean
143  * 
144  * sets/unsets the application windows in fullscreen mode
145  **/
146 void           modest_window_mgr_set_fullscreen_mode   (ModestWindowMgr *self,
147                                                         gboolean on);
148
149 /**
150  * modest_window_mgr_get_fullscreen_mode:
151  * @self: a #ModestWindowMgr
152  * 
153  * gets the application current fullscreen mode
154  *
155  * Return value: TRUE is the application is in fullscrenn mode,
156  * otherwise FALSE
157  **/
158 gboolean       modest_window_mgr_get_fullscreen_mode   (ModestWindowMgr *self);
159
160
161 /**
162  * modest_window_mgr_show_toolbars:
163  * @self: a #ModestWindowMgr
164  * @window_type: apply the show toolbars command only to the windows of this type
165  * @show_toolbar: whether or not the toolbars should be shown
166  * @fullscreen: TRUE/FALSE for show/hide in fullscreen mode, otherwise
167  * it applies to normal mode
168  * 
169  * shows or hides the toolbars of the registered windows. Note that if
170  * the #fullscreen attribute is TRUE and the application is in normal
171  * mode, you will not see the changes until the application switches
172  * to fullscreen mode and viceversa
173  **/
174 void           modest_window_mgr_show_toolbars         (ModestWindowMgr *self,
175                                                         GType window_type,
176                                                         gboolean show_toolbars,
177                                                         gboolean fullscreen);
178 /**
179  * modest_window_mgr_get_main_window:
180  * @self: a #ModestWindowMgr
181  * @show: if TRUE, create the main window and show it if it was not existing.
182  *
183  * get the main window, and depending on @create, create one if it does not exist yet
184  *
185  * Returns: the main window or NULL in case of error, or the main-window
186  * did not yet exist
187  **/
188 ModestWindow*  modest_window_mgr_get_main_window       (ModestWindowMgr *self,
189                                                         gboolean show);
190
191 /**
192  * modest_window_mgr_set_main_window:
193  * @self: a #ModestWindowMgr
194  * @main_win: a #ModestMainWindow
195  */
196 void modest_window_mgr_set_main_window (ModestWindowMgr *self, ModestWindow *main_win);
197
198
199 /**
200  * modest_window_mgr_main_window_exists:
201  * @self: a #ModestWindowMgr
202  *
203  * do we have a main window?
204  *
205  * Returns: TRUE if there's a main window, FALSE otherwise
206  **/
207 gboolean  modest_window_mgr_main_window_exists       (ModestWindowMgr *self);
208
209
210
211 /**
212  * modest_window_mgr_get_modal:
213  * @self: a #ModestWindowMgr
214  *
215  * get the modal window; if it's NULL, there's no active modal window
216  *
217  * Returns: the modal window or NULL
218  **/
219 GtkWindow*    modest_window_mgr_get_modal  (ModestWindowMgr *self);
220
221
222 /**
223  * modest_window_mgr_get_easysetup_dialog:
224  * @self: a #ModestWindowMgr
225  *
226  * set the modal dialog; set it to NULL after destroying the dialog
227  *
228  **/
229 void          modest_window_mgr_set_modal  (ModestWindowMgr *self,
230                                             GtkWindow *window,
231                                             GtkWindow *parent);
232
233 /**
234  * modest_window_mgr_prevent_hibernation_while_window_is_shown:
235  * @self: a #ModestWindowMgr
236  * @window: The window that should prevent hibernation while it is shown.
237  * 
238  * Call this if hibernation should not be allowed because 
239  * windows are open whose state cannot sensible be saved, such as Account 
240  * Settings dialogs.
241  * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE 
242  * until all such windows have been closed. That means, until the windows have 
243  * been hidden - window destruction or other memory management is not relevant.
244  **/
245 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self, 
246         GtkWindow *window);
247
248
249
250 /**
251  * modest_window_mgr_register_help_id
252  * @self: a #ModestWindowMgr
253  * @win: some window
254  * @help_id: the help_id for this window
255  * 
256  * register a help id for a window
257  **/
258 void
259 modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id);
260
261
262 /**
263  * modest_window_mgr_get_help_id:
264  * @self: a #ModestWindowMgr
265  * @win: some window
266  * 
267  * get the help id for a window; if the window is the main-window and some folder is
268  * selected, it will return the proper help_id for that
269  *
270  * Returns: a help _id
271  **/
272 const gchar*
273 modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win);
274
275
276
277 /**
278  * modest_window_mgr_find_registered_header
279  * @self: a #ModestWindowMgr
280  * @header: a valid #TnyHeader
281  * 
282  * search for the given uid in both the list of preregistered uids and in the window list;
283  * if it's available in the window list, fill the *win out-param
284  *
285  * returns TRUE if found, FALSE otherwise
286  **/
287 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self,  TnyHeader *header,
288                                                ModestWindow **win);
289
290
291 /**
292  * modest_window_mgr_find_registered_header
293  * @self: a #ModestWindowMgr
294  * @msg_uid: a message uid
295  * 
296  * search for the given uid in both the list of preregistered uids and in the window list;
297  * if it's available in the window list, fill the *win out-param
298  *
299  * returns TRUE if found, FALSE otherwise
300  **/
301 gboolean modest_window_mgr_find_registered_message_uid (ModestWindowMgr *self,  const gchar *msg_uid,
302                                                         ModestWindow **win);
303
304 /**
305  * modest_window_mgr_get_window_list:
306  * @self: a #ModestWindowMgr
307  *
308  * get the list of windows registered in window mgr.
309  *
310  * Returns: a #GList, that caller should free
311  */
312 GList *modest_window_mgr_get_window_list (ModestWindowMgr *self);
313
314 /**
315  * modest_window_mgr_close_all_windows
316  * @self: a #ModestWindowMgr
317  * 
318  * Close all registered windows. If failed (for example because
319  * one confirmation dialog rejected the operation), return %FALSE
320  **/
321 gboolean modest_window_mgr_close_all_windows (ModestWindowMgr *self);
322
323 /**
324  * modest_window_mgr_register_header
325  * @self: a #ModestWindowMgr
326  * @header: a valid #TnyHeader
327  * @alt_uid: alternative uid in case @header does not provide one
328  * 
329  * register the uid, even before the window is created. thus, we know when
330  * some window creation might already be underway. the uid will automatically be
331  * removed when the window itself will registered
332  * 
333  **/
334 void  modest_window_mgr_register_header   (ModestWindowMgr *self,  TnyHeader *header, const gchar *alt_uid);
335         
336
337 /**
338  * modest_window_mgr_unregister_header
339  * @self: a #ModestWindowMgr
340  * @header: a valid #TnyHeader
341  * 
342  * unregister the uid. We could need to do that if there is any error
343  * retrieving a message. In that case the window will not be
344  * registered and thus the header will not be removed, so we must do
345  * it manually
346  **/
347 void  modest_window_mgr_unregister_header (ModestWindowMgr *self,  TnyHeader *header);
348
349 /**
350  * modest_window_mgr_get_hibernation_is_prevented:
351  * @self: a #ModestWindowMgr
352  * @result: Whether any windows are currently preventing hibernation.
353  * 
354  * Use this to discover whether hibernation should not be allowed because 
355  * windows are open whose state cannot sensible be saved, such as Account 
356  * Settings dialogs. This function will return true after someone has called 
357  * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before 
358  * that window has been closed.
359  **/
360 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
361
362 /**
363  * modest_window_mgr_save_state_for_all_windows:
364  * @self: a #ModestWindowMgr
365  * 
366  * Save any state for all windows. For instance, call this before allowing 
367  * application hibernation.
368  **/
369 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
370
371 /**
372  * modest_window_mgr_get_num_windows:
373  * @self: a #ModestWindowMgr
374  * 
375  * Gets the number of already registered windows, and pending banners
376  *
377  * Returns: the number of already registered windows, and pending banners
378  **/
379 guint modest_window_mgr_get_num_windows (ModestWindowMgr *self);
380
381 /**
382  * modest_window_mgr_get_msg_view_window:
383  * @self: a #ModestWindowMgr
384  *
385  * obtain a cached #ModestMsgViewWindow if available, or construct a new
386  * one.
387  *
388  * Returns: a #ModestMsgViewWindow
389  */
390 GtkWidget *   modest_window_mgr_get_msg_view_window (ModestWindowMgr *self);
391
392 /**
393  * modest_window_mgr_get_msg_edit_window:
394  * @self: a #ModestWindowMgr
395  *
396  * obtain a cached #ModestMsgEditWindow if available, or construct a new
397  * one.
398  *
399  * Returns: a #ModestMsgEditWindow
400  */
401 GtkWidget *   modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self);
402
403 /**
404  * modest_window_mgr_show_initial_window:
405  * @self: a #ModestWindowMgr
406  *
407  * This function determines which is the window that should be
408  * initially launched. After that it shows that window. If there is no
409  * account available this function also launches the account setup
410  * wizard.
411  *
412  * Returns: the initial window. NULL if something goes wrong
413  **/
414 ModestWindow* modest_window_mgr_show_initial_window (ModestWindowMgr *self);
415
416 /**
417  * modest_window_mgr_get_current_top:
418  * @self: a #ModestWindowMgr
419  * 
420  * this function returns the ModestWindow that is currently on top of all the others
421  * 
422  * Returns: the topmost #ModestWindow
423  **/
424 ModestWindow* modest_window_mgr_get_current_top (ModestWindowMgr *self);
425
426 /**
427  * modest_window_mgr_screen_is_on:
428  * @self: a #ModestWindowMgr
429  *
430  * this function returns if device display is on or not
431  *
432  * Returns: %TRUE if screen is on, %FALSE if not
433  */
434 gboolean modest_window_mgr_screen_is_on (ModestWindowMgr *self);
435
436 /**
437  * modest_window_mgr_get_progress_operations:
438  * @self: a #ModestWindowMgr
439  *
440  * get a list of operations in progress
441  *
442  * Returns: a newly allocated #TnyList
443  */
444 TnyList *modest_window_mgr_get_progress_operations (ModestWindowMgr *self);
445
446 /**
447  * modest_window_mgr_has_progress_operation:
448  * @self: a #ModestWindowMgr
449  *
450  * is there are send/receive or receive operations in progress for any account.
451  *
452  * Returns: %TRUE if receive progress operations are in progress.
453  */
454 gboolean modest_window_mgr_has_progress_operation (ModestWindowMgr *self);
455
456 /**
457  * modest_window_mgr_has_progress_operation_on_account:
458  * @self: a #ModestWindowMgr
459  * @account_name: a string
460  *
461  * is there are send/receive or receive operations in progress for @account_name.
462  *
463  * Returns: %TRUE if receive progress operations are in progress.
464  */
465 gboolean modest_window_mgr_has_progress_operation_on_account (ModestWindowMgr *self,
466                                                               const gchar *account_name);
467
468 /**
469  * modest_window_mgr_create_caches:
470  * @self: a #ModestWindowMgr
471  *
472  * creates cached windows. This is called in modest main, just before the show-ui
473  * code. So it should be valid for the two startup ways (with --show-ui and without).
474  */
475 void modest_window_mgr_create_caches (ModestWindowMgr *self);
476
477 G_END_DECLS
478
479 #endif /* __MODEST_WINDOW_MGR_H__ */