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"
35 #include <tny-header.h>
39 /* convenience macros */
40 #define MODEST_TYPE_WINDOW_MGR (modest_window_mgr_get_type())
41 #define MODEST_WINDOW_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgr))
42 #define MODEST_WINDOW_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_WINDOW_MGR,ModestWindowMgrClass))
43 #define MODEST_IS_WINDOW_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_WINDOW_MGR))
44 #define MODEST_IS_WINDOW_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_WINDOW_MGR))
45 #define MODEST_WINDOW_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_WINDOW_MGR,ModestWindowMgrClass))
47 typedef struct _ModestWindowMgr ModestWindowMgr;
48 typedef struct _ModestWindowMgrClass ModestWindowMgrClass;
50 struct _ModestWindowMgr {
54 struct _ModestWindowMgrClass {
55 GObjectClass parent_class;
58 gboolean (*register_window) (ModestWindowMgr *self,
60 ModestWindow *parent);
61 void (*unregister_window) (ModestWindowMgr *self,
62 ModestWindow *window);
63 void (*set_fullscreen_mode) (ModestWindowMgr *self,
65 gboolean (*get_fullscreen_mode) (ModestWindowMgr *self);
66 void (*show_toolbars) (ModestWindowMgr *self,
68 gboolean show_toolbars,
70 #ifndef MODEST_TOOLKIT_HILDON2
71 ModestWindow * (*get_main_window) (ModestWindowMgr *self,
74 gboolean (*close_all_windows) (ModestWindowMgr *self);
75 GtkWindow * (*get_modal) (ModestWindowMgr *self);
76 void (*set_modal) (ModestWindowMgr *self,
79 gboolean (*find_registered_header) (ModestWindowMgr *self,
82 gboolean (*find_registered_message_uid) (ModestWindowMgr *self,
85 GList * (*get_window_list) (ModestWindowMgr *self);
86 ModestWindow * (*show_initial_window) (ModestWindowMgr *self);
87 ModestWindow * (*get_current_top) (ModestWindowMgr *self);
88 gboolean (*close_all_but_initial) (ModestWindowMgr *self);
90 gboolean (*screen_is_on) (ModestWindowMgr *self);
91 void (*create_caches) (ModestWindowMgr *self);
93 ModestWindow * (*get_folder_window) (ModestWindowMgr *self);
96 void (*window_list_empty) (ModestWindowMgr *self);
97 void (*progress_list_changed) (ModestWindowMgr *self);
101 /* member functions */
102 GType modest_window_mgr_get_type (void) G_GNUC_CONST;
104 /* typical parameter-less _new function */
105 ModestWindowMgr* modest_window_mgr_new (void);
109 * modest_window_mgr_register_window:
110 * @self: the #ModestWindowMgr
111 * @window: a #ModestWindow
113 * Registers a new window in the window manager. The window manager
114 * will keep a reference.
116 gboolean modest_window_mgr_register_window (ModestWindowMgr *self,
117 ModestWindow *window,
118 ModestWindow *parent);
121 * modest_window_mgr_unregister_window:
122 * @self: the #ModestWindowMgr
123 * @window: a #ModestWindow
125 * Unregisters a given window from the window manager. The window
126 * manager will free its reference to it.
128 void modest_window_mgr_unregister_window (ModestWindowMgr *self,
129 ModestWindow *window);
132 * modest_window_mgr_register_banner:
133 * @self: a #ModestWindowMgr
135 * Increase the count of pending banners in the window manager
137 void modest_window_mgr_register_banner (ModestWindowMgr *self);
140 * modest_window_mgr_unregister_banner:
141 * @self: a #ModestWindowMgr
143 * Decrease the count of pending banners in the window manager
145 void modest_window_mgr_unregister_banner (ModestWindowMgr *self);
148 * modest_window_mgr_set_fullscreen_mode:
149 * @self: a #ModestWindowMgr
152 * sets/unsets the application windows in fullscreen mode
154 void modest_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
158 * modest_window_mgr_get_fullscreen_mode:
159 * @self: a #ModestWindowMgr
161 * gets the application current fullscreen mode
163 * Return value: TRUE is the application is in fullscrenn mode,
166 gboolean modest_window_mgr_get_fullscreen_mode (ModestWindowMgr *self);
170 * modest_window_mgr_show_toolbars:
171 * @self: a #ModestWindowMgr
172 * @window_type: apply the show toolbars command only to the windows of this type
173 * @show_toolbar: whether or not the toolbars should be shown
174 * @fullscreen: TRUE/FALSE for show/hide in fullscreen mode, otherwise
175 * it applies to normal mode
177 * shows or hides the toolbars of the registered windows. Note that if
178 * the #fullscreen attribute is TRUE and the application is in normal
179 * mode, you will not see the changes until the application switches
180 * to fullscreen mode and viceversa
182 void modest_window_mgr_show_toolbars (ModestWindowMgr *self,
184 gboolean show_toolbars,
185 gboolean fullscreen);
186 #ifndef MODEST_TOOLKIT_HILDON2
188 * modest_window_mgr_get_main_window:
189 * @self: a #ModestWindowMgr
190 * @show: if TRUE, create the main window and show it if it was not existing.
192 * get the main window, and depending on @create, create one if it does not exist yet
194 * Returns: the main window or NULL in case of error, or the main-window
197 ModestWindow* modest_window_mgr_get_main_window (ModestWindowMgr *self,
201 * modest_window_mgr_set_main_window:
202 * @self: a #ModestWindowMgr
203 * @main_win: a #ModestMainWindow
205 void modest_window_mgr_set_main_window (ModestWindowMgr *self, ModestWindow *main_win);
209 * modest_window_mgr_main_window_exists:
210 * @self: a #ModestWindowMgr
212 * do we have a main window?
214 * Returns: TRUE if there's a main window, FALSE otherwise
216 gboolean modest_window_mgr_main_window_exists (ModestWindowMgr *self);
220 * modest_window_mgr_get_modal:
221 * @self: a #ModestWindowMgr
223 * get the modal window; if it's NULL, there's no active modal window
225 * Returns: the modal window or NULL
227 GtkWindow* modest_window_mgr_get_modal (ModestWindowMgr *self);
231 * modest_window_mgr_get_easysetup_dialog:
232 * @self: a #ModestWindowMgr
234 * set the modal dialog; set it to NULL after destroying the dialog
237 void modest_window_mgr_set_modal (ModestWindowMgr *self,
242 * modest_window_mgr_prevent_hibernation_while_window_is_shown:
243 * @self: a #ModestWindowMgr
244 * @window: The window that should prevent hibernation while it is shown.
246 * Call this if hibernation should not be allowed because
247 * windows are open whose state cannot sensible be saved, such as Account
249 * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE
250 * until all such windows have been closed. That means, until the windows have
251 * been hidden - window destruction or other memory management is not relevant.
253 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self,
259 * modest_window_mgr_register_help_id
260 * @self: a #ModestWindowMgr
262 * @help_id: the help_id for this window
264 * register a help id for a window
267 modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id);
271 * modest_window_mgr_get_help_id:
272 * @self: a #ModestWindowMgr
275 * get the help id for a window; if the window is the main-window and some folder is
276 * selected, it will return the proper help_id for that
278 * Returns: a help _id
281 modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win);
286 * modest_window_mgr_find_registered_header
287 * @self: a #ModestWindowMgr
288 * @header: a valid #TnyHeader
290 * search for the given uid in both the list of preregistered uids and in the window list;
291 * if it's available in the window list, fill the *win out-param
293 * returns TRUE if found, FALSE otherwise
295 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header,
300 * modest_window_mgr_find_registered_header
301 * @self: a #ModestWindowMgr
302 * @msg_uid: a message uid
304 * search for the given uid in both the list of preregistered uids and in the window list;
305 * if it's available in the window list, fill the *win out-param
307 * returns TRUE if found, FALSE otherwise
309 gboolean modest_window_mgr_find_registered_message_uid (ModestWindowMgr *self, const gchar *msg_uid,
313 * modest_window_mgr_get_window_list:
314 * @self: a #ModestWindowMgr
316 * get the list of windows registered in window mgr.
318 * Returns: a #GList, that caller should free
320 GList *modest_window_mgr_get_window_list (ModestWindowMgr *self);
323 * modest_window_mgr_close_all_windows
324 * @self: a #ModestWindowMgr
326 * Close all registered windows. If failed (for example because
327 * one confirmation dialog rejected the operation), return %FALSE
329 gboolean modest_window_mgr_close_all_windows (ModestWindowMgr *self);
332 * modest_window_mgr_register_header
333 * @self: a #ModestWindowMgr
334 * @header: a valid #TnyHeader
335 * @alt_uid: alternative uid in case @header does not provide one
337 * register the uid, even before the window is created. thus, we know when
338 * some window creation might already be underway. the uid will automatically be
339 * removed when the window itself will registered
342 void modest_window_mgr_register_header (ModestWindowMgr *self, TnyHeader *header, const gchar *alt_uid);
346 * modest_window_mgr_unregister_header
347 * @self: a #ModestWindowMgr
348 * @header: a valid #TnyHeader
350 * unregister the uid. We could need to do that if there is any error
351 * retrieving a message. In that case the window will not be
352 * registered and thus the header will not be removed, so we must do
355 void modest_window_mgr_unregister_header (ModestWindowMgr *self, TnyHeader *header);
358 * modest_window_mgr_get_hibernation_is_prevented:
359 * @self: a #ModestWindowMgr
360 * @result: Whether any windows are currently preventing hibernation.
362 * Use this to discover whether hibernation should not be allowed because
363 * windows are open whose state cannot sensible be saved, such as Account
364 * Settings dialogs. This function will return true after someone has called
365 * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before
366 * that window has been closed.
368 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
371 * modest_window_mgr_save_state_for_all_windows:
372 * @self: a #ModestWindowMgr
374 * Save any state for all windows. For instance, call this before allowing
375 * application hibernation.
377 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
380 * modest_window_mgr_get_num_windows:
381 * @self: a #ModestWindowMgr
383 * Gets the number of already registered windows, and pending banners
385 * Returns: the number of already registered windows, and pending banners
387 guint modest_window_mgr_get_num_windows (ModestWindowMgr *self);
390 * modest_window_mgr_get_msg_view_window:
391 * @self: a #ModestWindowMgr
393 * obtain a cached #ModestMsgViewWindow if available, or construct a new
396 * Returns: a #ModestMsgViewWindow
398 GtkWidget * modest_window_mgr_get_msg_view_window (ModestWindowMgr *self);
401 * modest_window_mgr_get_msg_edit_window:
402 * @self: a #ModestWindowMgr
404 * obtain a cached #ModestMsgEditWindow if available, or construct a new
407 * Returns: a #ModestMsgEditWindow
409 GtkWidget * modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self);
412 * modest_window_mgr_show_initial_window:
413 * @self: a #ModestWindowMgr
415 * This function determines which is the window that should be
416 * initially launched. After that it shows that window. If there is no
417 * account available this function also launches the account setup
420 * Returns: the initial window. NULL if something goes wrong
422 ModestWindow* modest_window_mgr_show_initial_window (ModestWindowMgr *self);
425 * modest_window_mgr_get_current_top:
426 * @self: a #ModestWindowMgr
428 * this function returns the ModestWindow that is currently on top of all the others
430 * Returns: the topmost #ModestWindow
432 ModestWindow* modest_window_mgr_get_current_top (ModestWindowMgr *self);
435 * modest_window_mgr_screen_is_on:
436 * @self: a #ModestWindowMgr
438 * this function returns if device display is on or not
440 * Returns: %TRUE if screen is on, %FALSE if not
442 gboolean modest_window_mgr_screen_is_on (ModestWindowMgr *self);
445 * modest_window_mgr_get_progress_operations:
446 * @self: a #ModestWindowMgr
448 * get a list of operations in progress
450 * Returns: a newly allocated #TnyList
452 TnyList *modest_window_mgr_get_progress_operations (ModestWindowMgr *self);
455 * modest_window_mgr_has_progress_operation:
456 * @self: a #ModestWindowMgr
458 * is there are send/receive or receive operations in progress for any account.
460 * Returns: %TRUE if receive progress operations are in progress.
462 gboolean modest_window_mgr_has_progress_operation (ModestWindowMgr *self);
465 * modest_window_mgr_has_progress_operation_on_account:
466 * @self: a #ModestWindowMgr
467 * @account_name: a string
469 * is there are send/receive or receive operations in progress for @account_name.
471 * Returns: %TRUE if receive progress operations are in progress.
473 gboolean modest_window_mgr_has_progress_operation_on_account (ModestWindowMgr *self,
474 const gchar *account_name);
477 * modest_window_mgr_create_caches:
478 * @self: a #ModestWindowMgr
480 * creates cached windows. This is called in modest main, just before the show-ui
481 * code. So it should be valid for the two startup ways (with --show-ui and without).
483 void modest_window_mgr_create_caches (ModestWindowMgr *self);
486 * modest_window_mgr_close_all_but_initial:
487 * @self: a #ModestWindowMgr
489 * closes all but the initial window.
491 * Returns: %TRUE if the initial window is returned in @initial_window
492 * and it does not have any other dialog or window on top, otherwhise
495 gboolean modest_window_mgr_close_all_but_initial (ModestWindowMgr *self);
500 #endif /* __MODEST_WINDOW_MGR_H__ */