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