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 gboolean (*close_all_windows) (ModestWindowMgr *self);
71 GtkWindow * (*get_modal) (ModestWindowMgr *self);
72 void (*set_modal) (ModestWindowMgr *self,
75 gboolean (*find_registered_header) (ModestWindowMgr *self,
78 gboolean (*find_registered_message_uid) (ModestWindowMgr *self,
81 GList * (*get_window_list) (ModestWindowMgr *self);
82 ModestWindow * (*show_initial_window) (ModestWindowMgr *self);
83 ModestWindow * (*get_current_top) (ModestWindowMgr *self);
84 gboolean (*close_all_but_initial) (ModestWindowMgr *self);
86 gboolean (*screen_is_on) (ModestWindowMgr *self);
87 void (*create_caches) (ModestWindowMgr *self);
89 ModestWindow * (*get_folder_window) (ModestWindowMgr *self);
92 void (*window_list_empty) (ModestWindowMgr *self);
93 void (*progress_list_changed) (ModestWindowMgr *self);
97 /* member functions */
98 GType modest_window_mgr_get_type (void) G_GNUC_CONST;
100 /* typical parameter-less _new function */
101 ModestWindowMgr* modest_window_mgr_new (void);
105 * modest_window_mgr_register_window:
106 * @self: the #ModestWindowMgr
107 * @window: a #ModestWindow
109 * Registers a new window in the window manager. The window manager
110 * will keep a reference.
112 gboolean modest_window_mgr_register_window (ModestWindowMgr *self,
113 ModestWindow *window,
114 ModestWindow *parent);
117 * modest_window_mgr_unregister_window:
118 * @self: the #ModestWindowMgr
119 * @window: a #ModestWindow
121 * Unregisters a given window from the window manager. The window
122 * manager will free its reference to it.
124 void modest_window_mgr_unregister_window (ModestWindowMgr *self,
125 ModestWindow *window);
128 * modest_window_mgr_register_banner:
129 * @self: a #ModestWindowMgr
131 * Increase the count of pending banners in the window manager
133 void modest_window_mgr_register_banner (ModestWindowMgr *self);
136 * modest_window_mgr_unregister_banner:
137 * @self: a #ModestWindowMgr
139 * Decrease the count of pending banners in the window manager
141 void modest_window_mgr_unregister_banner (ModestWindowMgr *self);
144 * modest_window_mgr_set_fullscreen_mode:
145 * @self: a #ModestWindowMgr
148 * sets/unsets the application windows in fullscreen mode
150 void modest_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
154 * modest_window_mgr_get_fullscreen_mode:
155 * @self: a #ModestWindowMgr
157 * gets the application current fullscreen mode
159 * Return value: TRUE is the application is in fullscrenn mode,
162 gboolean modest_window_mgr_get_fullscreen_mode (ModestWindowMgr *self);
166 * modest_window_mgr_show_toolbars:
167 * @self: a #ModestWindowMgr
168 * @window_type: apply the show toolbars command only to the windows of this type
169 * @show_toolbar: whether or not the toolbars should be shown
170 * @fullscreen: TRUE/FALSE for show/hide in fullscreen mode, otherwise
171 * it applies to normal mode
173 * shows or hides the toolbars of the registered windows. Note that if
174 * the #fullscreen attribute is TRUE and the application is in normal
175 * mode, you will not see the changes until the application switches
176 * to fullscreen mode and viceversa
178 void modest_window_mgr_show_toolbars (ModestWindowMgr *self,
180 gboolean show_toolbars,
181 gboolean fullscreen);
184 * modest_window_mgr_get_modal:
185 * @self: a #ModestWindowMgr
187 * get the modal window; if it's NULL, there's no active modal window
189 * Returns: the modal window or NULL
191 GtkWindow* modest_window_mgr_get_modal (ModestWindowMgr *self);
195 * modest_window_mgr_get_easysetup_dialog:
196 * @self: a #ModestWindowMgr
198 * set the modal dialog; set it to NULL after destroying the dialog
201 void modest_window_mgr_set_modal (ModestWindowMgr *self,
206 * modest_window_mgr_prevent_hibernation_while_window_is_shown:
207 * @self: a #ModestWindowMgr
208 * @window: The window that should prevent hibernation while it is shown.
210 * Call this if hibernation should not be allowed because
211 * windows are open whose state cannot sensible be saved, such as Account
213 * This causes modest_window_mgr_get_hibernation_is_prevented() to return TRUE
214 * until all such windows have been closed. That means, until the windows have
215 * been hidden - window destruction or other memory management is not relevant.
217 void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self,
223 * modest_window_mgr_register_help_id
224 * @self: a #ModestWindowMgr
226 * @help_id: the help_id for this window
228 * register a help id for a window
231 modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const gchar* help_id);
235 * modest_window_mgr_get_help_id:
236 * @self: a #ModestWindowMgr
239 * get the help id for a window; if the window is the main-window and some folder is
240 * selected, it will return the proper help_id for that
242 * Returns: a help _id
245 modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win);
250 * modest_window_mgr_find_registered_header
251 * @self: a #ModestWindowMgr
252 * @header: a valid #TnyHeader
254 * search for the given uid in both the list of preregistered uids and in the window list;
255 * if it's available in the window list, fill the *win out-param
257 * returns TRUE if found, FALSE otherwise
259 gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header,
264 * modest_window_mgr_find_registered_header
265 * @self: a #ModestWindowMgr
266 * @msg_uid: a message uid
268 * search for the given uid in both the list of preregistered uids and in the window list;
269 * if it's available in the window list, fill the *win out-param
271 * returns TRUE if found, FALSE otherwise
273 gboolean modest_window_mgr_find_registered_message_uid (ModestWindowMgr *self, const gchar *msg_uid,
277 * modest_window_mgr_get_window_list:
278 * @self: a #ModestWindowMgr
280 * get the list of windows registered in window mgr.
282 * Returns: a #GList, that caller should free
284 GList *modest_window_mgr_get_window_list (ModestWindowMgr *self);
287 * modest_window_mgr_close_all_windows
288 * @self: a #ModestWindowMgr
290 * Close all registered windows. If failed (for example because
291 * one confirmation dialog rejected the operation), return %FALSE
293 gboolean modest_window_mgr_close_all_windows (ModestWindowMgr *self);
296 * modest_window_mgr_register_header
297 * @self: a #ModestWindowMgr
298 * @header: a valid #TnyHeader
299 * @alt_uid: alternative uid in case @header does not provide one
301 * register the uid, even before the window is created. thus, we know when
302 * some window creation might already be underway. the uid will automatically be
303 * removed when the window itself will registered
306 void modest_window_mgr_register_header (ModestWindowMgr *self, TnyHeader *header, const gchar *alt_uid);
310 * modest_window_mgr_unregister_header
311 * @self: a #ModestWindowMgr
312 * @header: a valid #TnyHeader
314 * unregister the uid. We could need to do that if there is any error
315 * retrieving a message. In that case the window will not be
316 * registered and thus the header will not be removed, so we must do
319 void modest_window_mgr_unregister_header (ModestWindowMgr *self, TnyHeader *header);
322 * modest_window_mgr_get_hibernation_is_prevented:
323 * @self: a #ModestWindowMgr
324 * @result: Whether any windows are currently preventing hibernation.
326 * Use this to discover whether hibernation should not be allowed because
327 * windows are open whose state cannot sensible be saved, such as Account
328 * Settings dialogs. This function will return true after someone has called
329 * modest_window_mgr_prevent_hibernation_while_window_is_shown() and before
330 * that window has been closed.
332 gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
335 * modest_window_mgr_save_state_for_all_windows:
336 * @self: a #ModestWindowMgr
338 * Save any state for all windows. For instance, call this before allowing
339 * application hibernation.
341 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
344 * modest_window_mgr_get_num_windows:
345 * @self: a #ModestWindowMgr
347 * Gets the number of already registered windows, and pending banners
349 * Returns: the number of already registered windows, and pending banners
351 guint modest_window_mgr_get_num_windows (ModestWindowMgr *self);
354 * modest_window_mgr_get_msg_view_window:
355 * @self: a #ModestWindowMgr
357 * obtain a cached #ModestMsgViewWindow if available, or construct a new
360 * Returns: a #ModestMsgViewWindow
362 GtkWidget * modest_window_mgr_get_msg_view_window (ModestWindowMgr *self);
365 * modest_window_mgr_get_msg_edit_window:
366 * @self: a #ModestWindowMgr
368 * obtain a cached #ModestMsgEditWindow if available, or construct a new
371 * Returns: a #ModestMsgEditWindow
373 GtkWidget * modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self);
376 * modest_window_mgr_show_initial_window:
377 * @self: a #ModestWindowMgr
379 * This function determines which is the window that should be
380 * initially launched. After that it shows that window. If there is no
381 * account available this function also launches the account setup
384 * Returns: the initial window. NULL if something goes wrong
386 ModestWindow* modest_window_mgr_show_initial_window (ModestWindowMgr *self);
389 * modest_window_mgr_get_current_top:
390 * @self: a #ModestWindowMgr
392 * this function returns the ModestWindow that is currently on top of all the others
394 * Returns: the topmost #ModestWindow
396 ModestWindow* modest_window_mgr_get_current_top (ModestWindowMgr *self);
399 * modest_window_mgr_screen_is_on:
400 * @self: a #ModestWindowMgr
402 * this function returns if device display is on or not
404 * Returns: %TRUE if screen is on, %FALSE if not
406 gboolean modest_window_mgr_screen_is_on (ModestWindowMgr *self);
409 * modest_window_mgr_get_progress_operations:
410 * @self: a #ModestWindowMgr
412 * get a list of operations in progress
414 * Returns: a newly allocated #TnyList
416 TnyList *modest_window_mgr_get_progress_operations (ModestWindowMgr *self);
419 * modest_window_mgr_has_progress_operation:
420 * @self: a #ModestWindowMgr
422 * is there are send/receive or receive operations in progress for any account.
424 * Returns: %TRUE if receive progress operations are in progress.
426 gboolean modest_window_mgr_has_progress_operation (ModestWindowMgr *self);
429 * modest_window_mgr_has_progress_operation_on_account:
430 * @self: a #ModestWindowMgr
431 * @account_name: a string
433 * is there are send/receive or receive operations in progress for @account_name.
435 * Returns: %TRUE if receive progress operations are in progress.
437 gboolean modest_window_mgr_has_progress_operation_on_account (ModestWindowMgr *self,
438 const gchar *account_name);
441 * modest_window_mgr_create_caches:
442 * @self: a #ModestWindowMgr
444 * creates cached windows. This is called in modest main, just before the show-ui
445 * code. So it should be valid for the two startup ways (with --show-ui and without).
447 void modest_window_mgr_create_caches (ModestWindowMgr *self);
450 * modest_window_mgr_close_all_but_initial:
451 * @self: a #ModestWindowMgr
453 * closes all but the initial window.
455 * Returns: %TRUE if the initial window is returned in @initial_window
456 * and it does not have any other dialog or window on top, otherwhise
459 gboolean modest_window_mgr_close_all_but_initial (ModestWindowMgr *self);
461 ModestWindow *modest_window_mgr_get_folder_window (ModestWindowMgr *self);
466 #endif /* __MODEST_WINDOW_MGR_H__ */