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