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