1 /* Copyright (c) 2008, 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.
31 #include "modest-hildon2-window-mgr.h"
32 #include "modest-msg-edit-window.h"
33 #include "modest-main-window.h"
34 #include "modest-conf.h"
35 #include "modest-defs.h"
36 #include "modest-signal-mgr.h"
37 #include "modest-runtime.h"
38 #include "modest-platform.h"
39 #include "modest-ui-actions.h"
40 #include "modest-debug.h"
41 #include "modest-tny-folder.h"
42 #include <hildon/hildon.h>
44 /* 'private'/'protected' functions */
45 static void modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass);
46 static void modest_hildon2_window_mgr_instance_init (ModestHildon2WindowMgr *obj);
47 static void modest_hildon2_window_mgr_finalize (GObject *obj);
49 static gboolean on_window_destroy (ModestWindow *window,
51 ModestHildon2WindowMgr *self);
53 static gboolean modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
55 ModestWindow *parent);
56 static void modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
57 ModestWindow *window);
58 static void modest_hildon2_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
60 static gboolean modest_hildon2_window_mgr_get_fullscreen_mode (ModestWindowMgr *self);
61 static void modest_hildon2_window_mgr_show_toolbars (ModestWindowMgr *self,
63 gboolean show_toolbars,
65 static ModestWindow* modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show);
66 static GtkWindow *modest_hildon2_window_mgr_get_modal (ModestWindowMgr *self);
67 static void modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
70 static gboolean modest_hildon2_window_mgr_find_registered_header (ModestWindowMgr *self,
73 static GList *modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self);
74 static gboolean modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self);
75 static gboolean window_can_close (ModestWindow *window);
76 static gboolean window_has_modals (ModestWindow *window);
78 typedef struct _ModestHildon2WindowMgrPrivate ModestHildon2WindowMgrPrivate;
79 struct _ModestHildon2WindowMgrPrivate {
82 GQueue *modal_windows;
84 gboolean fullscreen_mode;
86 GHashTable *destroy_handlers;
87 GHashTable *viewer_handlers;
88 GSList *window_state_uids;
92 GSList *modal_handler_uids;
93 ModestWindow *current_top;
95 #define MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
96 MODEST_TYPE_HILDON2_WINDOW_MGR, \
97 ModestHildon2WindowMgrPrivate))
99 static GObjectClass *parent_class = NULL;
102 modest_hildon2_window_mgr_get_type (void)
104 static GType my_type = 0;
106 static const GTypeInfo my_info = {
107 sizeof(ModestHildon2WindowMgrClass),
108 NULL, /* base init */
109 NULL, /* base finalize */
110 (GClassInitFunc) modest_hildon2_window_mgr_class_init,
111 NULL, /* class finalize */
112 NULL, /* class data */
113 sizeof(ModestHildon2WindowMgr),
115 (GInstanceInitFunc) modest_hildon2_window_mgr_instance_init,
118 my_type = g_type_register_static (MODEST_TYPE_WINDOW_MGR,
119 "ModestHildon2WindowMgr",
126 modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass)
128 GObjectClass *gobject_class;
129 ModestWindowMgrClass *mgr_class;
131 gobject_class = (GObjectClass*) klass;
132 mgr_class = (ModestWindowMgrClass *) klass;
134 parent_class = g_type_class_peek_parent (klass);
135 gobject_class->finalize = modest_hildon2_window_mgr_finalize;
136 mgr_class->register_window = modest_hildon2_window_mgr_register_window;
137 mgr_class->unregister_window = modest_hildon2_window_mgr_unregister_window;
138 mgr_class->set_fullscreen_mode = modest_hildon2_window_mgr_set_fullscreen_mode;
139 mgr_class->get_fullscreen_mode = modest_hildon2_window_mgr_get_fullscreen_mode;
140 mgr_class->show_toolbars = modest_hildon2_window_mgr_show_toolbars;
141 mgr_class->get_main_window = modest_hildon2_window_mgr_get_main_window;
142 mgr_class->get_modal = modest_hildon2_window_mgr_get_modal;
143 mgr_class->set_modal = modest_hildon2_window_mgr_set_modal;
144 mgr_class->find_registered_header = modest_hildon2_window_mgr_find_registered_header;
145 mgr_class->get_window_list = modest_hildon2_window_mgr_get_window_list;
146 mgr_class->close_all_windows = modest_hildon2_window_mgr_close_all_windows;
148 g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowMgrPrivate));
153 modest_hildon2_window_mgr_instance_init (ModestHildon2WindowMgr *obj)
155 ModestHildon2WindowMgrPrivate *priv;
157 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(obj);
158 priv->window_list = NULL;
159 priv->fullscreen_mode = FALSE;
160 priv->current_top = NULL;
161 priv->window_state_uids = NULL;
163 priv->modal_windows = g_queue_new ();
164 priv->queue_lock = g_mutex_new ();
166 /* Could not initialize it from gconf, singletons are not
168 priv->destroy_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
169 priv->viewer_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
171 priv->closing_time = 0;
173 priv->modal_handler_uids = NULL;
177 modest_hildon2_window_mgr_finalize (GObject *obj)
179 ModestHildon2WindowMgrPrivate *priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(obj);
181 modest_signal_mgr_disconnect_all_and_destroy (priv->window_state_uids);
182 priv->window_state_uids = NULL;
184 if (priv->window_list) {
185 GList *iter = priv->window_list;
186 /* unregister pending windows */
188 ModestWindow *window = (ModestWindow *) iter->data;
189 iter = g_list_next (iter);
190 modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (obj), window);
192 g_list_free (priv->window_list);
193 priv->window_list = NULL;
196 /* Free the hash table with the handlers */
197 if (priv->destroy_handlers) {
198 g_hash_table_destroy (priv->destroy_handlers);
199 priv->destroy_handlers = NULL;
202 if (priv->viewer_handlers) {
203 g_hash_table_destroy (priv->viewer_handlers);
204 priv->viewer_handlers = NULL;
207 modest_signal_mgr_disconnect_all_and_destroy (priv->modal_handler_uids);
208 priv->modal_handler_uids = NULL;
210 if (priv->modal_windows) {
211 g_mutex_lock (priv->queue_lock);
212 g_queue_free (priv->modal_windows);
213 priv->modal_windows = NULL;
214 g_mutex_unlock (priv->queue_lock);
216 g_mutex_free (priv->queue_lock);
218 /* Do not unref priv->main_window because it does not hold a
222 G_OBJECT_CLASS(parent_class)->finalize (obj);
226 modest_hildon2_window_mgr_new (void)
228 return MODEST_WINDOW_MGR(g_object_new(MODEST_TYPE_HILDON2_WINDOW_MGR, NULL));
232 modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self)
234 gboolean ret_value = FALSE;
236 gboolean failed = FALSE;
237 HildonWindowStack *stack;
239 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
241 stack = hildon_window_stack_get_default ();
243 while ((window = hildon_window_stack_peek (stack)) != NULL) {
244 g_signal_emit_by_name (window, "delete-event", NULL, &ret_value);
245 if (ret_value == TRUE) {
255 compare_msguids (ModestWindow *win,
258 const gchar *msg_uid;
260 if ((!MODEST_IS_MSG_EDIT_WINDOW (win)) && (!MODEST_IS_MSG_VIEW_WINDOW (win)))
263 /* Get message uid from msg window */
264 if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
265 msg_uid = modest_msg_edit_window_get_message_uid (MODEST_MSG_EDIT_WINDOW (win));
266 if (msg_uid && uid &&!strcmp (msg_uid, uid))
269 msg_uid = modest_msg_view_window_get_message_uid (MODEST_MSG_VIEW_WINDOW (win));
272 if (msg_uid && uid &&!strcmp (msg_uid, uid))
279 modest_hildon2_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header,
282 ModestHildon2WindowMgrPrivate *priv = NULL;
284 gboolean has_header, has_window = FALSE;
287 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
288 g_return_val_if_fail (TNY_IS_HEADER(header), FALSE);
290 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
292 has_header = MODEST_WINDOW_MGR_CLASS (parent_class)->find_registered_header (self, header, win);
294 uid = modest_tny_folder_get_header_unique_id (header);
296 item = g_list_find_custom (priv->window_list, uid, (GCompareFunc) compare_msguids);
300 if ((!MODEST_IS_MSG_VIEW_WINDOW(item->data)) &&
301 (!MODEST_IS_MSG_EDIT_WINDOW (item->data)))
302 g_debug ("not a valid window!");
304 g_debug ("found a window");
305 *win = MODEST_WINDOW (item->data);
311 return has_header || has_window;
315 modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self)
317 ModestHildon2WindowMgrPrivate *priv;
319 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
320 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
322 return g_list_copy (priv->window_list);
326 modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
327 ModestWindow *window,
328 ModestWindow *parent)
331 ModestHildon2WindowMgrPrivate *priv;
333 ModestWindow *main_window;
334 HildonProgram *program;
335 GtkWidget *current_top;
336 HildonWindowStack *stack;
338 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
339 g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
341 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
343 program = hildon_program_get_instance ();
344 win = g_list_find (priv->window_list, window);
346 /* this is for the case we want to register the window and it was already
347 * registered. We leave silently, telling the operation was succesful.
349 gtk_window_present (GTK_WINDOW (win));
353 stack = hildon_window_stack_get_default ();
355 if (!MODEST_WINDOW_MGR_CLASS (parent_class)->register_window (self, window, parent))
358 /* Add to list. Keep a reference to the window */
359 g_object_ref (window);
360 priv->window_list = g_list_prepend (priv->window_list, window);
362 current_top = hildon_window_stack_peek (stack);
364 /* TODO: rethink this method it will be different depending on
365 the type of the window that we're registering */
366 if (!parent || ((GtkWidget *) parent != current_top)) {
367 guint num_windows = hildon_window_stack_size (stack);
369 /* We have to close all windows with the exception of the root window */
371 hildon_window_stack_pop (stack, num_windows - 1, NULL);
373 /* We remove 1 because we added it before */
374 if (modest_window_mgr_num_windows (MODEST_WINDOW_MGR (self)) - 1> 1) {
375 /* Then we couldn't close one of the preceding windows, so we have to stop the
376 * window register process and fail.
381 if ((current_top != NULL) && !MODEST_IS_MAIN_WINDOW (current_top)) {
383 g_signal_emit_by_name (G_OBJECT (current_top), "delete-event", NULL, &retval);
384 if (retval == TRUE) {
385 /* Cancelled closing top window, then we fail to register */
388 current_top = hildon_window_stack_peek (stack);
390 if ((current_top != NULL) && !MODEST_IS_MAIN_WINDOW (current_top)) {
391 /* Closing the stacked windows failed, then we shouldn't show the
395 if ((current_top != NULL) &&
396 window_has_modals (MODEST_WINDOW (current_top))) {
397 /* Window on top but it has opened dialogs */
402 /* Listen to object destruction */
403 handler_id = g_malloc0 (sizeof (gint));
404 *handler_id = g_signal_connect (window, "delete-event", G_CALLBACK (on_window_destroy), self);
405 g_hash_table_insert (priv->destroy_handlers, window, handler_id);
407 main_window = modest_window_mgr_get_main_window (self, FALSE);
408 /* If there is a msg view window, let the main window listen the msg-changed signal */
409 if (MODEST_IS_MSG_VIEW_WINDOW(window) && main_window) {
411 handler = g_malloc0 (sizeof (gulong));
412 *handler = g_signal_connect (window, "msg-changed",
413 G_CALLBACK (modest_main_window_on_msg_view_window_msg_changed),
415 g_hash_table_insert (priv->viewer_handlers, window, handler);
418 /* Show toolbar always */
419 modest_window_show_toolbar (window, TRUE);
423 /* Add to list. Keep a reference to the window */
424 priv->window_list = g_list_remove (priv->window_list, window);
425 g_object_unref (window);
427 current_top = hildon_window_stack_peek (stack);
429 gtk_window_present (GTK_WINDOW (current_top));
434 cancel_window_operations (ModestWindow *window)
436 GSList* pending_ops = NULL;
438 /* cancel open and receive operations */
439 pending_ops = modest_mail_operation_queue_get_by_source (modest_runtime_get_mail_operation_queue (),
441 while (pending_ops != NULL) {
442 ModestMailOperationTypeOperation type;
443 GSList* tmp_list = NULL;
445 type = modest_mail_operation_get_type_operation (MODEST_MAIL_OPERATION (pending_ops->data));
446 if (type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || type == MODEST_MAIL_OPERATION_TYPE_OPEN) {
447 modest_mail_operation_cancel (pending_ops->data);
449 g_object_unref (G_OBJECT (pending_ops->data));
450 tmp_list = pending_ops;
451 pending_ops = g_slist_next (pending_ops);
452 g_slist_free_1 (tmp_list);
457 window_has_modals (ModestWindow *window)
461 gboolean retvalue = FALSE;
463 /* First we fetch all toplevels */
464 toplevels = gtk_window_list_toplevels ();
465 for (node = toplevels; node != NULL; node = g_list_next (node)) {
466 if (GTK_IS_WINDOW (node->data) &&
467 gtk_window_get_transient_for (GTK_WINDOW (node->data)) == GTK_WINDOW (window)) {
472 g_list_free (toplevels);
477 window_can_close (ModestWindow *window)
479 /* An editor can be always closed no matter the dialogs it has
481 if (MODEST_IS_MSG_EDIT_WINDOW (window))
484 return !window_has_modals (window);
488 on_window_destroy (ModestWindow *window,
490 ModestHildon2WindowMgr *self)
492 gboolean no_propagate = FALSE;
494 if (!window_can_close (window)) {
497 /* Specific stuff first */
498 if (MODEST_IS_MAIN_WINDOW (window)) {
499 ModestHildon2WindowMgrPrivate *priv;
500 ModestMainWindowContentsStyle style;
501 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
503 /* If we're on header view, then just go to folder view and don't close */
504 style = modest_main_window_get_contents_style (MODEST_MAIN_WINDOW (window));
505 if (style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) {
506 modest_main_window_set_contents_style (MODEST_MAIN_WINDOW (window),
507 MODEST_MAIN_WINDOW_CONTENTS_STYLE_FOLDERS);
511 /* Do not unregister it, just hide */
512 gtk_widget_hide_all (GTK_WIDGET (window));
514 /* Cancel pending operations */
515 cancel_window_operations (window);
517 /* Fake the window system, make it think that there is no window */
518 if (modest_window_mgr_num_windows (MODEST_WINDOW_MGR (self)) == 0)
519 g_signal_emit_by_name (self, "window-list-empty");
524 if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
525 gboolean sent = FALSE;
526 sent = modest_msg_edit_window_get_sent (MODEST_MSG_EDIT_WINDOW (window));
527 /* Save currently edited message to Drafts if it was not sent */
528 if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
530 if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
534 /* Unregister window */
535 modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (self), window);
536 no_propagate = FALSE;
543 disconnect_msg_changed (gpointer key,
548 handler_id = GPOINTER_TO_UINT(value);
550 if (key && G_IS_OBJECT(key))
551 g_signal_handler_disconnect (G_OBJECT (key), handler_id);
555 modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
556 ModestWindow *window)
559 ModestHildon2WindowMgrPrivate *priv;
560 gulong *tmp, handler_id;
562 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
563 g_return_if_fail (MODEST_IS_WINDOW (window));
565 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
567 win = g_list_find (priv->window_list, window);
569 g_warning ("Trying to unregister a window that has not being registered yet");
573 /* If it's the main window unset it */
574 if (MODEST_IS_MAIN_WINDOW (window)) {
575 modest_window_mgr_set_main_window (self, NULL);
577 /* Disconnect all emissions of msg-changed */
578 if (priv->viewer_handlers) {
579 g_hash_table_foreach (priv->viewer_handlers,
580 disconnect_msg_changed,
582 g_hash_table_destroy (priv->viewer_handlers);
583 priv->viewer_handlers = NULL;
587 /* Remove the viewer window handler from the hash table. The
588 HashTable could not exist if the main window was closed
589 when there were other windows remaining */
590 if (MODEST_IS_MSG_VIEW_WINDOW (window) && priv->viewer_handlers) {
591 tmp = (gulong *) g_hash_table_lookup (priv->viewer_handlers, window);
592 /* If the viewer was created without a main window
593 (for example when opening a message through D-Bus
594 the viewer handlers was not registered */
596 g_signal_handler_disconnect (window, *tmp);
597 g_hash_table_remove (priv->viewer_handlers, window);
601 /* Remove from list & hash table */
602 priv->window_list = g_list_remove_link (priv->window_list, win);
603 tmp = g_hash_table_lookup (priv->destroy_handlers, window);
606 g_hash_table_remove (priv->destroy_handlers, window);
608 /* cancel open and receive operations */
609 cancel_window_operations (window);
611 /* Check if it's the topmost window, and remove the window from the stack.
612 * This is needed for the cases there's no other topmost window that will
613 * replace it in topmost handler.
615 if (window == priv->current_top)
616 priv->current_top = NULL;
618 /* Disconnect the "window-state-event" handler, we won't need it anymore */
619 if (priv->window_state_uids) {
620 #ifndef MODEST_TOOLKIT_GTK
621 priv->window_state_uids =
622 modest_signal_mgr_disconnect (priv->window_state_uids,
624 "notify::is-topmost");
626 priv->window_state_uids =
627 modest_signal_mgr_disconnect (priv->window_state_uids,
629 "window-state-event");
633 /* Disconnect the "delete-event" handler, we won't need it anymore */
634 g_signal_handler_disconnect (window, handler_id);
636 /* Destroy the window */
637 g_object_unref (win->data);
640 MODEST_WINDOW_MGR_CLASS (parent_class)->unregister_window (self, window);
642 /* If there are no more windows registered emit the signal */
643 if (modest_window_mgr_num_windows (self) == 0)
644 g_signal_emit_by_name (self, "window-list-empty");
650 modest_hildon2_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
653 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
659 modest_hildon2_window_mgr_get_fullscreen_mode (ModestWindowMgr *self)
665 modest_hildon2_window_mgr_show_toolbars (ModestWindowMgr *self,
667 gboolean show_toolbars,
670 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
676 modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
678 ModestHildon2WindowMgrPrivate *priv;
679 ModestWindow *result;
681 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
682 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
684 result = MODEST_WINDOW_MGR_CLASS (parent_class)->get_main_window (self, FALSE);
685 /* create the main window, if it hasn't been created yet */
686 if (!result && show) {
687 /* modest_window_mgr_register_window will set priv->main_window */
688 result = modest_main_window_new ();
689 /* We have to remove all other windows */
690 if (!modest_window_mgr_close_all_windows (self)) {
691 gtk_widget_destroy (GTK_WIDGET (result));
694 if (!modest_window_mgr_register_window (self, result, NULL)) {
695 gtk_widget_destroy (GTK_WIDGET (result));
699 g_debug ("%s: created main window: %p\n", __FUNCTION__, result);
703 gtk_widget_show_all (GTK_WIDGET (result));
704 gtk_window_present (GTK_WINDOW (result));
712 modest_hildon2_window_mgr_get_modal (ModestWindowMgr *self)
714 ModestHildon2WindowMgrPrivate *priv;
715 GList *toplevel_list;
718 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
719 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
722 toplevel_list = gtk_window_list_toplevels ();
723 while (toplevel_list) {
724 if (gtk_window_is_active (toplevel_list->data)) {
725 toplevel = toplevel_list->data;
728 toplevel_list = g_list_next (toplevel_list);
736 modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
740 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
741 g_return_if_fail (GTK_IS_WINDOW (window));
743 gtk_window_set_modal (window, TRUE);
744 gtk_window_set_transient_for (window, parent);
745 gtk_window_set_destroy_with_parent (window, TRUE);