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 <hildon/hildon.h>
32 #include "modest-hildon2-window-mgr.h"
33 #include "modest-msg-edit-window.h"
34 #include "modest-main-window.h"
35 #include "modest-conf.h"
36 #include "modest-defs.h"
37 #include "modest-signal-mgr.h"
38 #include "modest-runtime.h"
39 #include "modest-platform.h"
40 #include "modest-ui-actions.h"
41 #include "modest-debug.h"
42 #include "modest-tny-folder.h"
43 #include "modest-folder-window.h"
44 #include "modest-accounts-window.h"
46 /* 'private'/'protected' functions */
47 static void modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass);
48 static void modest_hildon2_window_mgr_instance_init (ModestHildon2WindowMgr *obj);
49 static void modest_hildon2_window_mgr_finalize (GObject *obj);
51 static gboolean on_window_destroy (ModestWindow *window,
53 ModestHildon2WindowMgr *self);
55 static gboolean modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
57 ModestWindow *parent);
58 static void modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
59 ModestWindow *window);
60 static void modest_hildon2_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
62 static gboolean modest_hildon2_window_mgr_get_fullscreen_mode (ModestWindowMgr *self);
63 static void modest_hildon2_window_mgr_show_toolbars (ModestWindowMgr *self,
65 gboolean show_toolbars,
67 static ModestWindow* modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show);
68 static GtkWindow *modest_hildon2_window_mgr_get_modal (ModestWindowMgr *self);
69 static void modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
72 static gboolean modest_hildon2_window_mgr_find_registered_header (ModestWindowMgr *self,
75 static GList *modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self);
76 static gboolean modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self);
77 static gboolean window_can_close (ModestWindow *window);
78 static gboolean window_has_modals (ModestWindow *window);
79 static ModestWindow *modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self);
80 static ModestWindow *modest_hildon2_window_mgr_get_current_top (ModestWindowMgr *self);
82 typedef struct _ModestHildon2WindowMgrPrivate ModestHildon2WindowMgrPrivate;
83 struct _ModestHildon2WindowMgrPrivate {
86 GQueue *modal_windows;
88 gboolean fullscreen_mode;
90 GHashTable *destroy_handlers;
91 GHashTable *viewer_handlers;
92 GSList *window_state_uids;
96 GSList *modal_handler_uids;
97 ModestWindow *current_top;
99 #define MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
100 MODEST_TYPE_HILDON2_WINDOW_MGR, \
101 ModestHildon2WindowMgrPrivate))
103 static GObjectClass *parent_class = NULL;
106 modest_hildon2_window_mgr_get_type (void)
108 static GType my_type = 0;
110 static const GTypeInfo my_info = {
111 sizeof(ModestHildon2WindowMgrClass),
112 NULL, /* base init */
113 NULL, /* base finalize */
114 (GClassInitFunc) modest_hildon2_window_mgr_class_init,
115 NULL, /* class finalize */
116 NULL, /* class data */
117 sizeof(ModestHildon2WindowMgr),
119 (GInstanceInitFunc) modest_hildon2_window_mgr_instance_init,
122 my_type = g_type_register_static (MODEST_TYPE_WINDOW_MGR,
123 "ModestHildon2WindowMgr",
130 modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass)
132 GObjectClass *gobject_class;
133 ModestWindowMgrClass *mgr_class;
135 gobject_class = (GObjectClass*) klass;
136 mgr_class = (ModestWindowMgrClass *) klass;
138 parent_class = g_type_class_peek_parent (klass);
139 gobject_class->finalize = modest_hildon2_window_mgr_finalize;
140 mgr_class->register_window = modest_hildon2_window_mgr_register_window;
141 mgr_class->unregister_window = modest_hildon2_window_mgr_unregister_window;
142 mgr_class->set_fullscreen_mode = modest_hildon2_window_mgr_set_fullscreen_mode;
143 mgr_class->get_fullscreen_mode = modest_hildon2_window_mgr_get_fullscreen_mode;
144 mgr_class->show_toolbars = modest_hildon2_window_mgr_show_toolbars;
145 mgr_class->get_main_window = modest_hildon2_window_mgr_get_main_window;
146 mgr_class->get_modal = modest_hildon2_window_mgr_get_modal;
147 mgr_class->set_modal = modest_hildon2_window_mgr_set_modal;
148 mgr_class->find_registered_header = modest_hildon2_window_mgr_find_registered_header;
149 mgr_class->get_window_list = modest_hildon2_window_mgr_get_window_list;
150 mgr_class->close_all_windows = modest_hildon2_window_mgr_close_all_windows;
151 mgr_class->show_initial_window = modest_hildon2_window_mgr_show_initial_window;
152 mgr_class->get_current_top = modest_hildon2_window_mgr_get_current_top;
154 g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowMgrPrivate));
159 modest_hildon2_window_mgr_instance_init (ModestHildon2WindowMgr *obj)
161 ModestHildon2WindowMgrPrivate *priv;
163 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(obj);
164 priv->window_list = NULL;
165 priv->fullscreen_mode = FALSE;
166 priv->current_top = NULL;
167 priv->window_state_uids = NULL;
169 priv->modal_windows = g_queue_new ();
170 priv->queue_lock = g_mutex_new ();
172 /* Could not initialize it from gconf, singletons are not
174 priv->destroy_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
175 priv->viewer_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
177 priv->closing_time = 0;
179 priv->modal_handler_uids = NULL;
183 modest_hildon2_window_mgr_finalize (GObject *obj)
185 ModestHildon2WindowMgrPrivate *priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(obj);
187 modest_signal_mgr_disconnect_all_and_destroy (priv->window_state_uids);
188 priv->window_state_uids = NULL;
190 if (priv->window_list) {
191 GList *iter = priv->window_list;
192 /* unregister pending windows */
194 ModestWindow *window = (ModestWindow *) iter->data;
195 iter = g_list_next (iter);
196 modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (obj), window);
198 g_list_free (priv->window_list);
199 priv->window_list = NULL;
202 /* Free the hash table with the handlers */
203 if (priv->destroy_handlers) {
204 g_hash_table_destroy (priv->destroy_handlers);
205 priv->destroy_handlers = NULL;
208 if (priv->viewer_handlers) {
209 g_hash_table_destroy (priv->viewer_handlers);
210 priv->viewer_handlers = NULL;
213 modest_signal_mgr_disconnect_all_and_destroy (priv->modal_handler_uids);
214 priv->modal_handler_uids = NULL;
216 if (priv->modal_windows) {
217 g_mutex_lock (priv->queue_lock);
218 g_queue_free (priv->modal_windows);
219 priv->modal_windows = NULL;
220 g_mutex_unlock (priv->queue_lock);
222 g_mutex_free (priv->queue_lock);
224 /* Do not unref priv->main_window because it does not hold a
227 G_OBJECT_CLASS(parent_class)->finalize (obj);
231 modest_hildon2_window_mgr_new (void)
233 return MODEST_WINDOW_MGR(g_object_new(MODEST_TYPE_HILDON2_WINDOW_MGR, NULL));
237 modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self)
239 ModestHildon2WindowMgrPrivate *priv = NULL;
240 gboolean ret_value = FALSE;
242 HildonWindowStack *stack;
243 gboolean failed = FALSE;
245 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
246 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
248 stack = hildon_window_stack_get_default ();
250 while ((window = hildon_window_stack_peek (stack)) != NULL) {
251 g_signal_emit_by_name (G_OBJECT (window), "delete-event", NULL, &ret_value);
252 if (ret_value == TRUE) {
262 compare_msguids (ModestWindow *win,
265 const gchar *msg_uid;
267 if ((!MODEST_IS_MSG_EDIT_WINDOW (win)) && (!MODEST_IS_MSG_VIEW_WINDOW (win)))
270 /* Get message uid from msg window */
271 if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
272 msg_uid = modest_msg_edit_window_get_message_uid (MODEST_MSG_EDIT_WINDOW (win));
273 if (msg_uid && uid &&!strcmp (msg_uid, uid))
276 msg_uid = modest_msg_view_window_get_message_uid (MODEST_MSG_VIEW_WINDOW (win));
279 if (msg_uid && uid &&!strcmp (msg_uid, uid))
286 modest_hildon2_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header,
289 ModestHildon2WindowMgrPrivate *priv = NULL;
291 gboolean has_header, has_window = FALSE;
294 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
295 g_return_val_if_fail (TNY_IS_HEADER(header), FALSE);
297 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
299 has_header = MODEST_WINDOW_MGR_CLASS (parent_class)->find_registered_header (self, header, win);
301 uid = modest_tny_folder_get_header_unique_id (header);
303 item = g_list_find_custom (priv->window_list, uid, (GCompareFunc) compare_msguids);
307 if ((!MODEST_IS_MSG_VIEW_WINDOW(item->data)) &&
308 (!MODEST_IS_MSG_EDIT_WINDOW (item->data)))
309 g_debug ("not a valid window!");
311 g_debug ("found a window");
312 *win = MODEST_WINDOW (item->data);
318 return has_header || has_window;
322 modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self)
324 ModestHildon2WindowMgrPrivate *priv;
326 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
327 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
329 return g_list_copy (priv->window_list);
333 modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
334 ModestWindow *window,
335 ModestWindow *parent)
338 ModestHildon2WindowMgrPrivate *priv;
340 HildonProgram *program;
341 HildonWindowStack *stack;
342 gboolean nested_msg = FALSE;
344 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
345 g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
347 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
349 program = hildon_program_get_instance ();
350 win = g_list_find (priv->window_list, window);
352 /* this is for the case we want to register the window and it was already
353 * registered. We leave silently, telling the operation was succesful.
355 gtk_window_present (GTK_WINDOW (win));
359 stack = hildon_window_stack_get_default ();
361 if (!MODEST_WINDOW_MGR_CLASS (parent_class)->register_window (self, window, parent))
364 /* Add to list. Keep a reference to the window */
365 g_object_ref (window);
366 priv->window_list = g_list_prepend (priv->window_list, window);
368 if (priv->current_top == NULL)
369 priv->current_top = (ModestWindow *) hildon_window_stack_peek (stack);
370 nested_msg = MODEST_IS_MSG_VIEW_WINDOW (window) &&
371 MODEST_IS_MSG_VIEW_WINDOW (parent);
373 /* Close views if they're being shown. Nevertheless we must
374 allow nested messages */
376 (MODEST_IS_MSG_EDIT_WINDOW (priv->current_top) ||
377 MODEST_IS_MSG_VIEW_WINDOW (priv->current_top))) {
380 /* If the current view has modal dialogs then
381 we fail to register the new view */
382 if ((priv->current_top != NULL) &&
383 window_has_modals (MODEST_WINDOW (priv->current_top))) {
384 /* Window on top but it has opened dialogs */
388 /* Close the current view */
389 g_signal_emit_by_name (G_OBJECT (priv->current_top), "delete-event", NULL, &retval);
390 if (retval == TRUE) {
391 /* Cancelled closing top window, then we fail to register */
396 /* Listen to object destruction */
397 handler_id = g_malloc0 (sizeof (gint));
398 *handler_id = g_signal_connect (window, "delete-event", G_CALLBACK (on_window_destroy), self);
399 g_hash_table_insert (priv->destroy_handlers, window, handler_id);
401 /* Show toolbar always */
402 modest_window_show_toolbar (window, TRUE);
406 /* Add to list. Keep a reference to the window */
407 priv->window_list = g_list_remove (priv->window_list, window);
408 g_object_unref (window);
409 priv->current_top = (ModestWindow *) hildon_window_stack_peek (stack);
410 if (priv->current_top)
411 gtk_window_present (GTK_WINDOW (priv->current_top));
416 cancel_window_operations (ModestWindow *window)
418 GSList* pending_ops = NULL;
420 /* cancel open and receive operations */
421 pending_ops = modest_mail_operation_queue_get_by_source (modest_runtime_get_mail_operation_queue (),
423 while (pending_ops != NULL) {
424 ModestMailOperationTypeOperation type;
425 GSList* tmp_list = NULL;
427 type = modest_mail_operation_get_type_operation (MODEST_MAIL_OPERATION (pending_ops->data));
428 if (type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || type == MODEST_MAIL_OPERATION_TYPE_OPEN) {
429 modest_mail_operation_cancel (pending_ops->data);
431 g_object_unref (G_OBJECT (pending_ops->data));
432 tmp_list = pending_ops;
433 pending_ops = g_slist_next (pending_ops);
434 g_slist_free_1 (tmp_list);
439 window_has_modals (ModestWindow *window)
443 gboolean retvalue = FALSE;
445 /* First we fetch all toplevels */
446 toplevels = gtk_window_list_toplevels ();
447 for (node = toplevels; node != NULL; node = g_list_next (node)) {
448 if (GTK_IS_WINDOW (node->data) &&
449 gtk_window_get_transient_for (GTK_WINDOW (node->data)) == GTK_WINDOW (window) &&
450 GTK_WIDGET_VISIBLE (node->data)) {
455 g_list_free (toplevels);
460 window_can_close (ModestWindow *window)
462 /* An editor can be always closed no matter the dialogs it has
464 if (MODEST_IS_MSG_EDIT_WINDOW (window))
467 return !window_has_modals (window);
471 on_window_destroy (ModestWindow *window,
473 ModestHildon2WindowMgr *self)
475 gboolean no_propagate = FALSE;
477 if (!window_can_close (window))
480 if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
481 gboolean sent = FALSE;
482 sent = modest_msg_edit_window_get_sent (MODEST_MSG_EDIT_WINDOW (window));
483 /* Save currently edited message to Drafts if it was not sent */
484 if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
486 if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
491 /* Unregister window */
492 modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (self), window);
493 no_propagate = FALSE;
499 modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
500 ModestWindow *window)
503 ModestHildon2WindowMgrPrivate *priv;
504 gulong *tmp, handler_id;
505 gboolean check_close_all = FALSE;
508 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
509 g_return_if_fail (MODEST_IS_WINDOW (window));
511 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
513 win = g_list_find (priv->window_list, window);
515 g_warning ("Trying to unregister a window that has not being registered yet");
519 /* Remember this for the end of the method */
520 if (MODEST_IS_FOLDER_WINDOW (window))
521 check_close_all = TRUE;
523 /* Remove the viewer window handler from the hash table. The
524 HashTable could not exist if the main window was closed
525 when there were other windows remaining */
526 if (MODEST_IS_MSG_VIEW_WINDOW (window) && priv->viewer_handlers) {
527 tmp = (gulong *) g_hash_table_lookup (priv->viewer_handlers, window);
528 /* If the viewer was created without a main window
529 (for example when opening a message through D-Bus
530 the viewer handlers was not registered */
532 g_signal_handler_disconnect (window, *tmp);
533 g_hash_table_remove (priv->viewer_handlers, window);
537 /* Remove from list & hash table */
538 priv->window_list = g_list_remove_link (priv->window_list, win);
539 tmp = g_hash_table_lookup (priv->destroy_handlers, window);
542 g_hash_table_remove (priv->destroy_handlers, window);
544 /* cancel open and receive operations */
545 cancel_window_operations (window);
547 /* Check if it's the topmost window, and remove the window from the stack.
548 * This is needed for the cases there's no other topmost window that will
549 * replace it in topmost handler.
551 if (window == priv->current_top)
552 priv->current_top = NULL;
554 /* Disconnect the "window-state-event" handler, we won't need it anymore */
555 if (priv->window_state_uids) {
556 priv->window_state_uids =
557 modest_signal_mgr_disconnect (priv->window_state_uids,
559 "notify::is-topmost");
562 /* Disconnect the "delete-event" handler, we won't need it anymore */
563 g_signal_handler_disconnect (window, handler_id);
565 /* Destroy the window */
566 g_object_unref (win->data);
569 MODEST_WINDOW_MGR_CLASS (parent_class)->unregister_window (self, window);
571 /* We have to get the number of windows here in order not to
572 emit the signal too many times */
573 num_windows = modest_window_mgr_get_num_windows (self);
575 /* Check if we have to destroy the accounts window as
576 well. This happens if we only have one or none remote
578 if (check_close_all) {
579 ModestTnyAccountStore *acc_store = modest_runtime_get_account_store ();
580 if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2)
581 modest_window_mgr_close_all_windows (self);
584 /* If there are no more windows registered emit the signal */
585 if (num_windows == 0)
586 g_signal_emit_by_name (self, "window-list-empty");
591 modest_hildon2_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
594 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
600 modest_hildon2_window_mgr_get_fullscreen_mode (ModestWindowMgr *self)
606 modest_hildon2_window_mgr_show_toolbars (ModestWindowMgr *self,
608 gboolean show_toolbars,
611 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
617 modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
619 ModestHildon2WindowMgrPrivate *priv;
620 ModestWindow *result;
622 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
623 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
625 /* TODO: make this return NULL always */
627 result = MODEST_WINDOW_MGR_CLASS (parent_class)->get_main_window (self, FALSE);
628 /* create the main window, if it hasn't been created yet */
629 if (!result && show) {
630 /* modest_window_mgr_register_window will set priv->main_window */
631 result = modest_main_window_new ();
632 /* We have to remove all other windows */
633 if (!modest_window_mgr_close_all_windows (self)) {
634 gtk_widget_destroy (GTK_WIDGET (result));
637 if (!modest_window_mgr_register_window (self, result, NULL)) {
638 gtk_widget_destroy (GTK_WIDGET (result));
642 g_debug ("%s: created main window: %p\n", __FUNCTION__, result);
646 gtk_widget_show_all (GTK_WIDGET (result));
647 gtk_window_present (GTK_WINDOW (result));
655 modest_hildon2_window_mgr_get_modal (ModestWindowMgr *self)
657 ModestHildon2WindowMgrPrivate *priv;
658 GList *toplevel_list;
661 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
662 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
665 toplevel_list = gtk_window_list_toplevels ();
666 while (toplevel_list) {
667 if (gtk_window_is_active (toplevel_list->data)) {
668 toplevel = toplevel_list->data;
671 toplevel_list = g_list_next (toplevel_list);
679 modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
683 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
684 g_return_if_fail (GTK_IS_WINDOW (window));
686 gtk_window_set_modal (window, TRUE);
687 gtk_window_set_transient_for (window, parent);
688 gtk_window_set_destroy_with_parent (window, TRUE);
691 static ModestWindow *
692 modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self)
694 ModestWindow *initial_window = NULL;
695 ModestTnyAccountStore *acc_store;
697 /* Always create accounts window. We'll decide later if we
698 want to show it or not, depending the number of accounts */
699 initial_window = MODEST_WINDOW (modest_accounts_window_new ());
700 modest_window_mgr_register_window (self, initial_window, NULL);
702 /* If there are less than 2 remote accounts then directly show
703 the folder window and do not show the accounts window */
704 acc_store = modest_runtime_get_account_store ();
705 if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2) {
706 ModestAccountMgr *mgr;
708 /* Show first the accounts window to add it to the
709 stack. This has to be changed when the new
710 stackable API is available. There will be a method
711 to show all the windows that will only show the
712 last one to the user. The current code shows both
713 windows, one after the other */
714 gtk_widget_show (GTK_WIDGET (initial_window));
716 initial_window = MODEST_WINDOW (modest_folder_window_new (NULL));
717 mgr = modest_runtime_get_account_mgr ();
718 modest_folder_window_set_account (MODEST_FOLDER_WINDOW (initial_window),
719 modest_account_mgr_get_default_account (mgr));
720 modest_window_mgr_register_window (self, initial_window, NULL);
723 return initial_window;
727 static ModestWindow *
728 modest_hildon2_window_mgr_get_current_top (ModestWindowMgr *self)
730 ModestHildon2WindowMgrPrivate *priv;
732 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
733 return priv->current_top;
737 find_folder_window (gconstpointer a,
740 return (MODEST_IS_FOLDER_WINDOW (a)) ? 0 : 1;
744 modest_hildon2_window_mgr_get_folder_window (ModestHildon2WindowMgr *self)
746 ModestHildon2WindowMgrPrivate *priv;
749 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
751 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
753 window = g_list_find_custom (priv->window_list,
757 return (window != NULL) ? MODEST_WINDOW (window->data) : NULL;