* Added a method to unregister a header in the window manager in case of error
[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 "widgets/modest-msg-view-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,GObject))
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         /* insert public members, if any */
52 };
53
54 struct _ModestWindowMgrClass {
55         GObjectClass parent_class;
56         /* insert signal callback declarations, eg. */
57         /* void (* my_event) (ModestWindowMgr* obj); */
58 };
59
60 /* member functions */
61 GType        modest_window_mgr_get_type    (void) G_GNUC_CONST;
62
63 /* typical parameter-less _new function */
64 ModestWindowMgr*    modest_window_mgr_new         (void);
65
66
67 /**
68  * modest_window_mgr_register_window:
69  * @self: the #ModestWindowMgr
70  * @window: a #ModestWindow
71  * 
72  * Registers a new window in the window manager. The window manager
73  * will keep a reference.
74  **/
75 void           modest_window_mgr_register_window       (ModestWindowMgr *self, 
76                                                         ModestWindow *window);
77
78 /**
79  * modest_window_mgr_unregister_window:
80  * @self: the #ModestWindowMgr
81  * @window: a #ModestWindow
82  * 
83  * Unregisters a given window from the window manager. The window
84  * manager will free its reference to it.
85  **/
86 void           modest_window_mgr_unregister_window     (ModestWindowMgr *self, 
87                                                         ModestWindow *window);
88
89
90
91 /**
92  * modest_window_mgr_set_fullscreen_mode:
93  * @self: a #ModestWindowMgr
94  * @on: a #gboolean
95  * 
96  * sets/unsets the application windows in fullscreen mode
97  **/
98 void           modest_window_mgr_set_fullscreen_mode   (ModestWindowMgr *self,
99                                                         gboolean on);
100
101 /**
102  * modest_window_mgr_get_fullscreen_mode:
103  * @self: a #ModestWindowMgr
104  * 
105  * gets the application current fullscreen mode
106  *
107  * Return value: TRUE is the application is in fullscrenn mode,
108  * otherwise FALSE
109  **/
110 gboolean       modest_window_mgr_get_fullscreen_mode   (ModestWindowMgr *self);
111
112
113 /**
114  * modest_window_mgr_show_toolbars:
115  * @self: a #ModestWindowMgr
116  * @show_toolbar: whether or not the toolbars should be shown
117  * @fullscreen: TRUE/FALSE for show/hide in fullscreen mode, otherwise
118  * it applies to normal mode
119  * 
120  * shows or hides the toolbars of the registered windows. Note that if
121  * the #fullscreen attribute is TRUE and the application is in normal
122  * mode, you will not see the changes until the application switches
123  * to fullscreen mode and viceversa
124  **/
125 void           modest_window_mgr_show_toolbars         (ModestWindowMgr *self,
126                                                         gboolean show_toolbars,
127                                                         gboolean fullscreen);
128
129 ModestWindow*  modest_window_mgr_get_main_window       (ModestWindowMgr *self);
130
131 /**
132  * modest_window_mgr_prevent_hibernation_while_window_is_shown:
133  * @self: a #ModestWindowMgr
134  * @window: The window that should prevent hibernation while it is shown.
135  * 
136  * Call this if hibernation should not be allowed because 
137  * windows are open whose state cannot sensible be saved, such as Account 
138  * Settings dialogs.
139  * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE 
140  * until all such windows have been closed. That means, until the windows have 
141  * been hidden - window destruction or other memory management is not relevant.
142  **/
143 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self, 
144         GtkWindow *window);
145
146
147 /**
148  * modest_window_mgr_find_registered_header
149  * @self: a #ModestWindowMgr
150  * @header: a valid #TnyHeader
151  * 
152  * search for the given uid in both the list of preregistered uids and in the window list;
153  * if it's available in the window list, fill the *win out-param
154  *
155  * returns TRUE if found, FALSE otherwise
156  **/
157 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self,  TnyHeader *header,
158                                                ModestWindow **win);
159
160
161 /**
162  * modest_window_mgr_register_header
163  * @self: a #ModestWindowMgr
164  * @header: a valid #TnyHeader
165  * 
166  * register the uid, even before the window is created. thus, we know when
167  * some window creation might already be underway. the uid will automatically be
168  * removed when the window itself will registered
169  * 
170  **/
171 void  modest_window_mgr_register_header   (ModestWindowMgr *self,  TnyHeader *header);
172         
173
174 /**
175  * modest_window_mgr_unregister_header
176  * @self: a #ModestWindowMgr
177  * @header: a valid #TnyHeader
178  * 
179  * unregister the uid. We could need to do that if there is any error
180  * retrieving a message. In that case the window will not be
181  * registered and thus the header will not be removed, so we must do
182  * it manually
183  **/
184 void  modest_window_mgr_unregister_header (ModestWindowMgr *self,  TnyHeader *header);
185
186 /**
187  * modest_window_mgr_get_hibernation_is_prevented:
188  * @self: a #ModestWindowMgr
189  * @result: Whether any windows are currently preventing hibernation.
190  * 
191  * Use this to discover whether hibernation should not be allowed because 
192  * windows are open whose state cannot sensible be saved, such as Account 
193  * Settings dialogs. This function will return true after someone has called 
194  * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before 
195  * that window has been closed.
196  **/
197 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
198
199 /**
200  * modest_window_mgr_save_state_for_all_windows:
201  * @self: a #ModestWindowMgr
202  * 
203  * Save any state for all windows. For instance, call this before allowing 
204  * application hibernation.
205  **/
206 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
207         
208 G_END_DECLS
209
210 #endif /* __MODEST_WINDOW_MGR_H__ */
211