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 "modest-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 gboolean (*find_registered_message_uid) (ModestWindowMgr *self,
82 GList * (*get_window_list) (ModestWindowMgr *self);
83 ModestWindow * (*show_initial_window) (ModestWindowMgr *self);
84 ModestWindow * (*get_current_top) (ModestWindowMgr *self);
85 gboolean (*screen_is_on) (ModestWindowMgr *self);
87 void (*window_list_empty) (ModestWindowMgr *self);
88 void (*progress_list_changed) (ModestWindowMgr *self);
92 /* member functions */
93 GType modest_window_mgr_get_type (void) G_GNUC_CONST;
95 /* typical parameter-less _new function */
96 ModestWindowMgr* modest_window_mgr_new (void);
100 * modest_window_mgr_register_window:
101 * @self: the #ModestWindowMgr
102 * @window: a #ModestWindow
104 * Registers a new window in the window manager. The window manager
105 * will keep a reference.
107 gboolean modest_window_mgr_register_window (ModestWindowMgr *self,
108 ModestWindow *window,
109 ModestWindow *parent);
112 * modest_window_mgr_unregister_window:
113 * @self: the #ModestWindowMgr
114 * @window: a #ModestWindow
116 * Unregisters a given window from the window manager. The window
117 * manager will free its reference to it.
119 void modest_window_mgr_unregister_window (ModestWindowMgr *self,
120 ModestWindow *window);
123 * modest_window_mgr_register_banner:
124 * @self: a #ModestWindowMgr
126 * Increase the count of pending banners in the window manager
128 void modest_window_mgr_register_banner (ModestWindowMgr *self);
131 * modest_window_mgr_unregister_banner:
132 * @self: a #ModestWindowMgr
134 * Decrease the count of pending banners in the window manager
136 void modest_window_mgr_unregister_banner (ModestWindowMgr *self);
139 * modest_window_mgr_set_fullscreen_mode:
140 * @self: a #ModestWindowMgr
143 * sets/unsets the application windows in fullscreen mode
145 void modest_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
149 * modest_window_mgr_get_fullscreen_mode:
150 * @self: a #ModestWindowMgr
152 * gets the application current fullscreen mode
154 * Return value: TRUE is the application is in fullscrenn mode,
157 gboolean modest_window_mgr_get_fullscreen_mode (ModestWindowMgr *self);
161 * modest_window_mgr_show_toolbars:
162 * @self: a #ModestWindowMgr
163 * @window_type: apply the show toolbars command only to the windows of this type
164 * @show_toolbar: whether or not the toolbars should be shown
165 * @fullscreen: TRUE/FALSE for show/hide in fullscreen mode, otherwise
166 * it applies to normal mode
168 * shows or hides the toolbars of the registered windows. Note that if
169 * the #fullscreen attribute is TRUE and the application is in normal
170 * mode, you will not see the changes until the application switches
171 * to fullscreen mode and viceversa
173 void modest_window_mgr_show_toolbars (ModestWindowMgr *self,
175 gboolean show_toolbars,
176 gboolean fullscreen);
178 * modest_window_mgr_get_main_window:
179 * @self: a #ModestWindowMgr
180 * @show: if TRUE, create the main window and show it if it was not existing.
182 * get the main window, and depending on @create, create one if it does not exist yet
184 * Returns: the main window or NULL in case of error, or the main-window
187 ModestWindow* modest_window_mgr_get_main_window (ModestWindowMgr *self,
191 * modest_window_mgr_set_main_window:
192 * @self: a #ModestWindowMgr
193 * @main_win: a #ModestMainWindow
195 void modest_window_mgr_set_main_window (ModestWindowMgr *self, ModestWindow *main_win);
199 * modest_window_mgr_main_window_exists:
200 * @self: a #ModestWindowMgr
202 * do we have a main window?
204 * Returns: TRUE if there's a main window, FALSE otherwise
206 gboolean modest_window_mgr_main_window_exists (ModestWindowMgr *self);
211 * modest_window_mgr_get_modal:
212 * @self: a #ModestWindowMgr
214 * get the modal window; if it's NULL, there's no active modal window
216 * Returns: the modal window or NULL
218 GtkWindow* modest_window_mgr_get_modal (ModestWindowMgr *self);
222 * modest_window_mgr_get_easysetup_dialog:
223 * @self: a #ModestWindowMgr
225 * set the modal dialog; set it to NULL after destroying the dialog
228 void modest_window_mgr_set_modal (ModestWindowMgr *self,
233 * modest_window_mgr_prevent_hibernation_while_window_is_shown:
234 * @self: a #ModestWindowMgr
235 * @window: The window that should prevent hibernation while it is shown.
237 * Call this if hibernation should not be allowed because
238 * windows are open whose state cannot sensible be saved, such as Account
240 * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE
241 * until all such windows have been closed. That means, until the windows have
242 * been hidden - window destruction or other memory management is not relevant.
244 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self,
250 * modest_window_mgr_register_help_id
251 * @self: a #ModestWindowMgr
253 * @help_id: the help_id for this window
255 * register a help id for a window
258 modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id);
262 * modest_window_mgr_get_help_id:
263 * @self: a #ModestWindowMgr
266 * get the help id for a window; if the window is the main-window and some folder is
267 * selected, it will return the proper help_id for that
269 * Returns: a help _id
272 modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win);
277 * modest_window_mgr_find_registered_header
278 * @self: a #ModestWindowMgr
279 * @header: a valid #TnyHeader
281 * search for the given uid in both the list of preregistered uids and in the window list;
282 * if it's available in the window list, fill the *win out-param
284 * returns TRUE if found, FALSE otherwise
286 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header,
291 * modest_window_mgr_find_registered_header
292 * @self: a #ModestWindowMgr
293 * @msg_uid: a message uid
295 * search for the given uid in both the list of preregistered uids and in the window list;
296 * if it's available in the window list, fill the *win out-param
298 * returns TRUE if found, FALSE otherwise
300 gboolean modest_window_mgr_find_registered_message_uid (ModestWindowMgr *self, const gchar *msg_uid,
304 * modest_window_mgr_get_window_list:
305 * @self: a #ModestWindowMgr
307 * get the list of windows registered in window mgr.
309 * Returns: a #GList, that caller should free
311 GList *modest_window_mgr_get_window_list (ModestWindowMgr *self);
314 * modest_window_mgr_close_all_windows
315 * @self: a #ModestWindowMgr
317 * Close all registered windows. If failed (for example because
318 * one confirmation dialog rejected the operation), return %FALSE
320 gboolean modest_window_mgr_close_all_windows (ModestWindowMgr *self);
323 * modest_window_mgr_register_header
324 * @self: a #ModestWindowMgr
325 * @header: a valid #TnyHeader
326 * @alt_uid: alternative uid in case @header does not provide one
328 * register the uid, even before the window is created. thus, we know when
329 * some window creation might already be underway. the uid will automatically be
330 * removed when the window itself will registered
333 void modest_window_mgr_register_header (ModestWindowMgr *self, TnyHeader *header, const gchar *alt_uid);
337 * modest_window_mgr_unregister_header
338 * @self: a #ModestWindowMgr
339 * @header: a valid #TnyHeader
341 * unregister the uid. We could need to do that if there is any error
342 * retrieving a message. In that case the window will not be
343 * registered and thus the header will not be removed, so we must do
346 void modest_window_mgr_unregister_header (ModestWindowMgr *self, TnyHeader *header);
349 * modest_window_mgr_get_hibernation_is_prevented:
350 * @self: a #ModestWindowMgr
351 * @result: Whether any windows are currently preventing hibernation.
353 * Use this to discover whether hibernation should not be allowed because
354 * windows are open whose state cannot sensible be saved, such as Account
355 * Settings dialogs. This function will return true after someone has called
356 * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before
357 * that window has been closed.
359 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
362 * modest_window_mgr_save_state_for_all_windows:
363 * @self: a #ModestWindowMgr
365 * Save any state for all windows. For instance, call this before allowing
366 * application hibernation.
368 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
371 * modest_window_mgr_get_num_windows:
372 * @self: a #ModestWindowMgr
374 * Gets the number of already registered windows, and pending banners
376 * Returns: the number of already registered windows, and pending banners
378 guint modest_window_mgr_get_num_windows (ModestWindowMgr *self);
381 * modest_window_mgr_get_msg_view_window:
382 * @self: a #ModestWindowMgr
384 * obtain a cached #ModestMsgViewWindow if available, or construct a new
387 * Returns: a #ModestMsgViewWindow
389 GtkWidget * modest_window_mgr_get_msg_view_window (ModestWindowMgr *self);
392 * modest_window_mgr_get_msg_edit_window:
393 * @self: a #ModestWindowMgr
395 * obtain a cached #ModestMsgEditWindow if available, or construct a new
398 * Returns: a #ModestMsgEditWindow
400 GtkWidget * modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self);
403 * modest_window_mgr_show_initial_window:
404 * @self: a #ModestWindowMgr
406 * This function determines which is the window that should be
407 * initially launched. After that it shows that window. If there is no
408 * account available this function also launches the account setup
411 * Returns: the initial window. NULL if something goes wrong
413 ModestWindow* modest_window_mgr_show_initial_window (ModestWindowMgr *self);
416 * modest_window_mgr_get_current_top:
417 * @self: a #ModestWindowMgr
419 * this function returns the ModestWindow that is currently on top of all the others
421 * Returns: the topmost #ModestWindow
423 ModestWindow* modest_window_mgr_get_current_top (ModestWindowMgr *self);
426 * modest_window_mgr_screen_is_on:
427 * @self: a #ModestWindowMgr
429 * this function returns if device display is on or not
431 * Returns: %TRUE if screen is on, %FALSE if not
433 gboolean modest_window_mgr_screen_is_on (ModestWindowMgr *self);
436 * modest_window_mgr_get_progress_operations:
437 * @self: a #ModestWindowMgr
439 * get a list of operations in progress
441 * Returns: a newly allocated #TnyList
443 TnyList *modest_window_mgr_get_progress_operations (ModestWindowMgr *self);
446 * modest_window_mgr_has_progress_operation:
447 * @self: a #ModestWindowMgr
449 * is there are send/receive or receive operations in progress for any account.
451 * Returns: %TRUE if receive progress operations are in progress.
453 gboolean modest_window_mgr_has_progress_operation (ModestWindowMgr *self);
456 * modest_window_mgr_has_progress_operation_on_account:
457 * @self: a #ModestWindowMgr
458 * @account_name: a string
460 * is there are send/receive or receive operations in progress for @account_name.
462 * Returns: %TRUE if receive progress operations are in progress.
464 gboolean modest_window_mgr_has_progress_operation_on_account (ModestWindowMgr *self,
465 const gchar *account_name);
469 #endif /* __MODEST_WINDOW_MGR_H__ */