acf303b4cf15860bfc1a84f8dc74b2bb2a755cb5
[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  * modest_window_mgr_get_main_window:
130  * @self: a #ModestWindowMgr
131  *
132  * get the main window, or create if it's not there. don't destroy
133  * it.
134  *
135  * Returns: the main window or NULL in case of error
136  **/
137 ModestWindow*  modest_window_mgr_get_main_window       (ModestWindowMgr *self);
138
139
140 /**
141  * modest_window_mgr_get_easysetup_dialog:
142  * @self: a #ModestWindowMgr
143  *
144  * get the easysetup dialog; if it's NULL, there's no active dialog
145  *
146  * Returns: the easy setup dialog or NULL
147  **/
148 GtkDialog*    modest_window_mgr_get_easysetup_dialog  (ModestWindowMgr *self);
149
150
151 /**
152  * modest_window_mgr_get_easysetup_dialog:
153  * @self: a #ModestWindowMgr
154  *
155  * set the easysetup dialog; set it to NULL after destroying the dialog
156  *
157  * Returns: the easy setup dialog just set
158  **/
159 GtkDialog*    modest_window_mgr_set_easysetup_dialog  (ModestWindowMgr *self,
160                                                        GtkDialog *dialog);
161
162
163 /**
164  * modest_window_mgr_prevent_hibernation_while_window_is_shown:
165  * @self: a #ModestWindowMgr
166  * @window: The window that should prevent hibernation while it is shown.
167  * 
168  * Call this if hibernation should not be allowed because 
169  * windows are open whose state cannot sensible be saved, such as Account 
170  * Settings dialogs.
171  * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE 
172  * until all such windows have been closed. That means, until the windows have 
173  * been hidden - window destruction or other memory management is not relevant.
174  **/
175 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self, 
176         GtkWindow *window);
177
178
179 /**
180  * modest_window_mgr_find_registered_header
181  * @self: a #ModestWindowMgr
182  * @header: a valid #TnyHeader
183  * 
184  * search for the given uid in both the list of preregistered uids and in the window list;
185  * if it's available in the window list, fill the *win out-param
186  *
187  * returns TRUE if found, FALSE otherwise
188  **/
189 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self,  TnyHeader *header,
190                                                ModestWindow **win);
191
192
193 /**
194  * modest_window_mgr_register_header
195  * @self: a #ModestWindowMgr
196  * @header: a valid #TnyHeader
197  * 
198  * register the uid, even before the window is created. thus, we know when
199  * some window creation might already be underway. the uid will automatically be
200  * removed when the window itself will registered
201  * 
202  **/
203 void  modest_window_mgr_register_header   (ModestWindowMgr *self,  TnyHeader *header);
204         
205
206 /**
207  * modest_window_mgr_unregister_header
208  * @self: a #ModestWindowMgr
209  * @header: a valid #TnyHeader
210  * 
211  * unregister the uid. We could need to do that if there is any error
212  * retrieving a message. In that case the window will not be
213  * registered and thus the header will not be removed, so we must do
214  * it manually
215  **/
216 void  modest_window_mgr_unregister_header (ModestWindowMgr *self,  TnyHeader *header);
217
218 /**
219  * modest_window_mgr_get_hibernation_is_prevented:
220  * @self: a #ModestWindowMgr
221  * @result: Whether any windows are currently preventing hibernation.
222  * 
223  * Use this to discover whether hibernation should not be allowed because 
224  * windows are open whose state cannot sensible be saved, such as Account 
225  * Settings dialogs. This function will return true after someone has called 
226  * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before 
227  * that window has been closed.
228  **/
229 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
230
231 /**
232  * modest_window_mgr_save_state_for_all_windows:
233  * @self: a #ModestWindowMgr
234  * 
235  * Save any state for all windows. For instance, call this before allowing 
236  * application hibernation.
237  **/
238 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
239         
240 G_END_DECLS
241
242 #endif /* __MODEST_WINDOW_MGR_H__ */
243