* some further cleanups of the help system, added:
[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 };
52
53 struct _ModestWindowMgrClass {
54         GObjectClass parent_class;
55 };
56
57
58 /* member functions */
59 GType        modest_window_mgr_get_type    (void) G_GNUC_CONST;
60
61 /* typical parameter-less _new function */
62 ModestWindowMgr*    modest_window_mgr_new         (void);
63
64
65 /**
66  * modest_window_mgr_register_window:
67  * @self: the #ModestWindowMgr
68  * @window: a #ModestWindow
69  * 
70  * Registers a new window in the window manager. The window manager
71  * will keep a reference.
72  **/
73 void           modest_window_mgr_register_window       (ModestWindowMgr *self, 
74                                                         ModestWindow *window);
75
76 /**
77  * modest_window_mgr_unregister_window:
78  * @self: the #ModestWindowMgr
79  * @window: a #ModestWindow
80  * 
81  * Unregisters a given window from the window manager. The window
82  * manager will free its reference to it.
83  **/
84 void           modest_window_mgr_unregister_window     (ModestWindowMgr *self, 
85                                                         ModestWindow *window);
86
87
88
89 /**
90  * modest_window_mgr_set_fullscreen_mode:
91  * @self: a #ModestWindowMgr
92  * @on: a #gboolean
93  * 
94  * sets/unsets the application windows in fullscreen mode
95  **/
96 void           modest_window_mgr_set_fullscreen_mode   (ModestWindowMgr *self,
97                                                         gboolean on);
98
99 /**
100  * modest_window_mgr_get_fullscreen_mode:
101  * @self: a #ModestWindowMgr
102  * 
103  * gets the application current fullscreen mode
104  *
105  * Return value: TRUE is the application is in fullscrenn mode,
106  * otherwise FALSE
107  **/
108 gboolean       modest_window_mgr_get_fullscreen_mode   (ModestWindowMgr *self);
109
110
111 /**
112  * modest_window_mgr_show_toolbars:
113  * @self: a #ModestWindowMgr
114  * @window_type: apply the show toolbars command only to the windows of this type
115  * @show_toolbar: whether or not the toolbars should be shown
116  * @fullscreen: TRUE/FALSE for show/hide in fullscreen mode, otherwise
117  * it applies to normal mode
118  * 
119  * shows or hides the toolbars of the registered windows. Note that if
120  * the #fullscreen attribute is TRUE and the application is in normal
121  * mode, you will not see the changes until the application switches
122  * to fullscreen mode and viceversa
123  **/
124 void           modest_window_mgr_show_toolbars         (ModestWindowMgr *self,
125                                                         GType window_type,
126                                                         gboolean show_toolbars,
127                                                         gboolean fullscreen);
128 /**
129  * modest_window_mgr_get_main_window:
130  * @self: a #ModestWindowMgr
131  * @create: if TRUE, create the main window if it was not yet existing
132  *
133  * get the main window, and depending on @create, create one if it does not exist yet
134  *
135  * Returns: the main window or NULL in case of error, or the main-window
136  * did not yet exist
137  **/
138 ModestWindow*  modest_window_mgr_get_main_window       (ModestWindowMgr *self,
139                                                         gboolean create);
140
141
142 /**
143  * modest_window_mgr_main_window_exists:
144  * @self: a #ModestWindowMgr
145  *
146  * do we have a main window?
147  *
148  * Returns: TRUE if there's a main window, FALSE otherwise
149  **/
150 gboolean  modest_window_mgr_main_window_exists       (ModestWindowMgr *self);
151
152
153
154 /**
155  * modest_window_mgr_get_modal:
156  * @self: a #ModestWindowMgr
157  *
158  * get the modal window; if it's NULL, there's no active modal window
159  *
160  * Returns: the modal window or NULL
161  **/
162 GtkWindow*    modest_window_mgr_get_modal  (ModestWindowMgr *self);
163
164
165 /**
166  * modest_window_mgr_get_easysetup_dialog:
167  * @self: a #ModestWindowMgr
168  *
169  * set the modal dialog; set it to NULL after destroying the dialog
170  *
171  * Returns: the modal dialog just set
172  **/
173 void          modest_window_mgr_set_modal  (ModestWindowMgr *self,
174                                             GtkWindow *window);
175
176 /**
177  * modest_window_mgr_prevent_hibernation_while_window_is_shown:
178  * @self: a #ModestWindowMgr
179  * @window: The window that should prevent hibernation while it is shown.
180  * 
181  * Call this if hibernation should not be allowed because 
182  * windows are open whose state cannot sensible be saved, such as Account 
183  * Settings dialogs.
184  * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE 
185  * until all such windows have been closed. That means, until the windows have 
186  * been hidden - window destruction or other memory management is not relevant.
187  **/
188 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self, 
189         GtkWindow *window);
190
191
192
193 /**
194  * modest_window_mgr_register_help_id
195  * @self: a #ModestWindowMgr
196  * @win: some window
197  * @help_id: the help_id for this window
198  * 
199  * register a help id for a window
200  **/
201 void
202 modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id);
203
204
205 /**
206  * modest_window_mgr_get_help_id:
207  * @self: a #ModestWindowMgr
208  * @win: some window
209  * 
210  * get the help id for a window; if the window is the main-window and some folder is
211  * selected, it will return the proper help_id for that
212  *
213  * Returns: a help _id
214  **/
215 const gchar*
216 modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win);
217
218
219
220 /**
221  * modest_window_mgr_find_registered_header
222  * @self: a #ModestWindowMgr
223  * @header: a valid #TnyHeader
224  * 
225  * search for the given uid in both the list of preregistered uids and in the window list;
226  * if it's available in the window list, fill the *win out-param
227  *
228  * returns TRUE if found, FALSE otherwise
229  **/
230 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self,  TnyHeader *header,
231                                                ModestWindow **win);
232
233
234 /**
235  * modest_window_mgr_close_all_windows
236  * @self: a #ModestWindowMgr
237  * 
238  * Close all registered windows. 
239  **/
240 void modest_window_mgr_close_all_windows (ModestWindowMgr *self);
241
242 /**
243  * modest_window_mgr_register_header
244  * @self: a #ModestWindowMgr
245  * @header: a valid #TnyHeader
246  * @alt_uid: alternative uid in case @header does not provide one
247  * 
248  * register the uid, even before the window is created. thus, we know when
249  * some window creation might already be underway. the uid will automatically be
250  * removed when the window itself will registered
251  * 
252  **/
253 void  modest_window_mgr_register_header   (ModestWindowMgr *self,  TnyHeader *header, const gchar *alt_uid);
254         
255
256 /**
257  * modest_window_mgr_unregister_header
258  * @self: a #ModestWindowMgr
259  * @header: a valid #TnyHeader
260  * 
261  * unregister the uid. We could need to do that if there is any error
262  * retrieving a message. In that case the window will not be
263  * registered and thus the header will not be removed, so we must do
264  * it manually
265  **/
266 void  modest_window_mgr_unregister_header (ModestWindowMgr *self,  TnyHeader *header);
267
268 /**
269  * modest_window_mgr_get_hibernation_is_prevented:
270  * @self: a #ModestWindowMgr
271  * @result: Whether any windows are currently preventing hibernation.
272  * 
273  * Use this to discover whether hibernation should not be allowed because 
274  * windows are open whose state cannot sensible be saved, such as Account 
275  * Settings dialogs. This function will return true after someone has called 
276  * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before 
277  * that window has been closed.
278  **/
279 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
280
281 /**
282  * modest_window_mgr_save_state_for_all_windows:
283  * @self: a #ModestWindowMgr
284  * 
285  * Save any state for all windows. For instance, call this before allowing 
286  * application hibernation.
287  **/
288 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
289         
290 G_END_DECLS
291
292 #endif /* __MODEST_WINDOW_MGR_H__ */
293