1 /* Copyright (c) 2006,2007 Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
30 #ifndef __MODEST_WINDOW_MGR_H__
31 #define __MODEST_WINDOW_MGR_H__
33 #include <glib-object.h>
34 #include "widgets/modest-msg-view-window.h"
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,ModestWindowMgrClass))
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))
46 typedef struct _ModestWindowMgr ModestWindowMgr;
47 typedef struct _ModestWindowMgrClass ModestWindowMgrClass;
49 struct _ModestWindowMgr {
53 struct _ModestWindowMgrClass {
54 GObjectClass parent_class;
57 gboolean (*register_window) (ModestWindowMgr *self,
59 ModestWindow *parent);
60 void (*unregister_window) (ModestWindowMgr *self,
61 ModestWindow *window);
62 void (*set_fullscreen_mode) (ModestWindowMgr *self,
64 gboolean (*get_fullscreen_mode) (ModestWindowMgr *self);
65 void (*show_toolbars) (ModestWindowMgr *self,
67 gboolean show_toolbars,
69 ModestWindow * (*get_main_window) (ModestWindowMgr *self,
71 gboolean (*close_all_windows) (ModestWindowMgr *self);
72 GtkWindow * (*get_modal) (ModestWindowMgr *self);
73 void (*set_modal) (ModestWindowMgr *self,
76 gboolean (*find_registered_header) (ModestWindowMgr *self,
79 GList * (*get_window_list) (ModestWindowMgr *self);
80 ModestWindow * (*show_initial_window) (ModestWindowMgr *self);
81 ModestWindow * (*get_current_top) (ModestWindowMgr *self);
82 gboolean (*screen_is_on) (ModestWindowMgr *self);
84 void (*window_list_empty) (ModestWindowMgr *self);
88 /* member functions */
89 GType modest_window_mgr_get_type (void) G_GNUC_CONST;
91 /* typical parameter-less _new function */
92 ModestWindowMgr* modest_window_mgr_new (void);
96 * modest_window_mgr_register_window:
97 * @self: the #ModestWindowMgr
98 * @window: a #ModestWindow
100 * Registers a new window in the window manager. The window manager
101 * will keep a reference.
103 gboolean modest_window_mgr_register_window (ModestWindowMgr *self,
104 ModestWindow *window,
105 ModestWindow *parent);
108 * modest_window_mgr_unregister_window:
109 * @self: the #ModestWindowMgr
110 * @window: a #ModestWindow
112 * Unregisters a given window from the window manager. The window
113 * manager will free its reference to it.
115 void modest_window_mgr_unregister_window (ModestWindowMgr *self,
116 ModestWindow *window);
119 * modest_window_mgr_register_banner:
120 * @self: a #ModestWindowMgr
122 * Increase the count of pending banners in the window manager
124 void modest_window_mgr_register_banner (ModestWindowMgr *self);
127 * modest_window_mgr_unregister_banner:
128 * @self: a #ModestWindowMgr
130 * Decrease the count of pending banners in the window manager
132 void modest_window_mgr_unregister_banner (ModestWindowMgr *self);
135 * modest_window_mgr_set_fullscreen_mode:
136 * @self: a #ModestWindowMgr
139 * sets/unsets the application windows in fullscreen mode
141 void modest_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
145 * modest_window_mgr_get_fullscreen_mode:
146 * @self: a #ModestWindowMgr
148 * gets the application current fullscreen mode
150 * Return value: TRUE is the application is in fullscrenn mode,
153 gboolean modest_window_mgr_get_fullscreen_mode (ModestWindowMgr *self);
157 * modest_window_mgr_show_toolbars:
158 * @self: a #ModestWindowMgr
159 * @window_type: apply the show toolbars command only to the windows of this type
160 * @show_toolbar: whether or not the toolbars should be shown
161 * @fullscreen: TRUE/FALSE for show/hide in fullscreen mode, otherwise
162 * it applies to normal mode
164 * shows or hides the toolbars of the registered windows. Note that if
165 * the #fullscreen attribute is TRUE and the application is in normal
166 * mode, you will not see the changes until the application switches
167 * to fullscreen mode and viceversa
169 void modest_window_mgr_show_toolbars (ModestWindowMgr *self,
171 gboolean show_toolbars,
172 gboolean fullscreen);
174 * modest_window_mgr_get_main_window:
175 * @self: a #ModestWindowMgr
176 * @show: if TRUE, create the main window and show it if it was not existing.
178 * get the main window, and depending on @create, create one if it does not exist yet
180 * Returns: the main window or NULL in case of error, or the main-window
183 ModestWindow* modest_window_mgr_get_main_window (ModestWindowMgr *self,
187 * modest_window_mgr_set_main_window:
188 * @self: a #ModestWindowMgr
189 * @main_win: a #ModestMainWindow
191 void modest_window_mgr_set_main_window (ModestWindowMgr *self, ModestWindow *main_win);
195 * modest_window_mgr_main_window_exists:
196 * @self: a #ModestWindowMgr
198 * do we have a main window?
200 * Returns: TRUE if there's a main window, FALSE otherwise
202 gboolean modest_window_mgr_main_window_exists (ModestWindowMgr *self);
207 * modest_window_mgr_get_modal:
208 * @self: a #ModestWindowMgr
210 * get the modal window; if it's NULL, there's no active modal window
212 * Returns: the modal window or NULL
214 GtkWindow* modest_window_mgr_get_modal (ModestWindowMgr *self);
218 * modest_window_mgr_get_easysetup_dialog:
219 * @self: a #ModestWindowMgr
221 * set the modal dialog; set it to NULL after destroying the dialog
224 void modest_window_mgr_set_modal (ModestWindowMgr *self,
229 * modest_window_mgr_prevent_hibernation_while_window_is_shown:
230 * @self: a #ModestWindowMgr
231 * @window: The window that should prevent hibernation while it is shown.
233 * Call this if hibernation should not be allowed because
234 * windows are open whose state cannot sensible be saved, such as Account
236 * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE
237 * until all such windows have been closed. That means, until the windows have
238 * been hidden - window destruction or other memory management is not relevant.
240 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self,
246 * modest_window_mgr_register_help_id
247 * @self: a #ModestWindowMgr
249 * @help_id: the help_id for this window
251 * register a help id for a window
254 modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id);
258 * modest_window_mgr_get_help_id:
259 * @self: a #ModestWindowMgr
262 * get the help id for a window; if the window is the main-window and some folder is
263 * selected, it will return the proper help_id for that
265 * Returns: a help _id
268 modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win);
273 * modest_window_mgr_find_registered_header
274 * @self: a #ModestWindowMgr
275 * @header: a valid #TnyHeader
277 * search for the given uid in both the list of preregistered uids and in the window list;
278 * if it's available in the window list, fill the *win out-param
280 * returns TRUE if found, FALSE otherwise
282 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header,
286 * modest_window_mgr_get_window_list:
287 * @self: a #ModestWindowMgr
289 * get the list of windows registered in window mgr.
291 * Returns: a #GList, that caller should free
293 GList *modest_window_mgr_get_window_list (ModestWindowMgr *self);
296 * modest_window_mgr_close_all_windows
297 * @self: a #ModestWindowMgr
299 * Close all registered windows. If failed (for example because
300 * one confirmation dialog rejected the operation), return %FALSE
302 gboolean modest_window_mgr_close_all_windows (ModestWindowMgr *self);
305 * modest_window_mgr_register_header
306 * @self: a #ModestWindowMgr
307 * @header: a valid #TnyHeader
308 * @alt_uid: alternative uid in case @header does not provide one
310 * register the uid, even before the window is created. thus, we know when
311 * some window creation might already be underway. the uid will automatically be
312 * removed when the window itself will registered
315 void modest_window_mgr_register_header (ModestWindowMgr *self, TnyHeader *header, const gchar *alt_uid);
319 * modest_window_mgr_unregister_header
320 * @self: a #ModestWindowMgr
321 * @header: a valid #TnyHeader
323 * unregister the uid. We could need to do that if there is any error
324 * retrieving a message. In that case the window will not be
325 * registered and thus the header will not be removed, so we must do
328 void modest_window_mgr_unregister_header (ModestWindowMgr *self, TnyHeader *header);
331 * modest_window_mgr_get_hibernation_is_prevented:
332 * @self: a #ModestWindowMgr
333 * @result: Whether any windows are currently preventing hibernation.
335 * Use this to discover whether hibernation should not be allowed because
336 * windows are open whose state cannot sensible be saved, such as Account
337 * Settings dialogs. This function will return true after someone has called
338 * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before
339 * that window has been closed.
341 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
344 * modest_window_mgr_save_state_for_all_windows:
345 * @self: a #ModestWindowMgr
347 * Save any state for all windows. For instance, call this before allowing
348 * application hibernation.
350 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
353 * modest_window_mgr_get_num_windows:
354 * @self: a #ModestWindowMgr
356 * Gets the number of already registered windows, and pending banners
358 * Returns: the number of already registered windows, and pending banners
360 guint modest_window_mgr_get_num_windows (ModestWindowMgr *self);
363 * modest_window_mgr_get_msg_view_window:
364 * @self: a #ModestWindowMgr
366 * obtain a cached #ModestMsgViewWindow if available, or construct a new
369 * Returns: a #ModestMsgViewWindow
371 GtkWidget * modest_window_mgr_get_msg_view_window (ModestWindowMgr *self);
374 * modest_window_mgr_get_msg_edit_window:
375 * @self: a #ModestWindowMgr
377 * obtain a cached #ModestMsgEditWindow if available, or construct a new
380 * Returns: a #ModestMsgEditWindow
382 GtkWidget * modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self);
385 * modest_window_mgr_show_initial_window:
386 * @self: a #ModestWindowMgr
388 * This function determines which is the window that should be
389 * initially launched. After that it shows that window. If there is no
390 * account available this function also launches the account setup
393 * Returns: the initial window. NULL if something goes wrong
395 ModestWindow* modest_window_mgr_show_initial_window (ModestWindowMgr *self);
398 * modest_window_mgr_get_current_top:
399 * @self: a #ModestWindowMgr
401 * this function returns the ModestWindow that is currently on top of all the others
403 * Returns: the topmost #ModestWindow
405 ModestWindow* modest_window_mgr_get_current_top (ModestWindowMgr *self);
408 * modest_window_mgr_screen_is_on:
409 * @self: a #ModestWindowMgr
411 * this function returns if device display is on or not
413 * Returns: %TRUE if screen is on, %FALSE if not
415 gboolean modest_window_mgr_screen_is_on (ModestWindowMgr *self);
419 #endif /* __MODEST_WINDOW_MGR_H__ */