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);
81 typedef struct _ModestHildon2WindowMgrPrivate ModestHildon2WindowMgrPrivate;
82 struct _ModestHildon2WindowMgrPrivate {
85 GQueue *modal_windows;
87 gboolean fullscreen_mode;
89 GHashTable *destroy_handlers;
90 GHashTable *viewer_handlers;
91 GSList *window_state_uids;
95 GSList *modal_handler_uids;
96 ModestWindow *current_top;
98 #define MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
99 MODEST_TYPE_HILDON2_WINDOW_MGR, \
100 ModestHildon2WindowMgrPrivate))
102 static GObjectClass *parent_class = NULL;
105 modest_hildon2_window_mgr_get_type (void)
107 static GType my_type = 0;
109 static const GTypeInfo my_info = {
110 sizeof(ModestHildon2WindowMgrClass),
111 NULL, /* base init */
112 NULL, /* base finalize */
113 (GClassInitFunc) modest_hildon2_window_mgr_class_init,
114 NULL, /* class finalize */
115 NULL, /* class data */
116 sizeof(ModestHildon2WindowMgr),
118 (GInstanceInitFunc) modest_hildon2_window_mgr_instance_init,
121 my_type = g_type_register_static (MODEST_TYPE_WINDOW_MGR,
122 "ModestHildon2WindowMgr",
129 modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass)
131 GObjectClass *gobject_class;
132 ModestWindowMgrClass *mgr_class;
134 gobject_class = (GObjectClass*) klass;
135 mgr_class = (ModestWindowMgrClass *) klass;
137 parent_class = g_type_class_peek_parent (klass);
138 gobject_class->finalize = modest_hildon2_window_mgr_finalize;
139 mgr_class->register_window = modest_hildon2_window_mgr_register_window;
140 mgr_class->unregister_window = modest_hildon2_window_mgr_unregister_window;
141 mgr_class->set_fullscreen_mode = modest_hildon2_window_mgr_set_fullscreen_mode;
142 mgr_class->get_fullscreen_mode = modest_hildon2_window_mgr_get_fullscreen_mode;
143 mgr_class->show_toolbars = modest_hildon2_window_mgr_show_toolbars;
144 mgr_class->get_main_window = modest_hildon2_window_mgr_get_main_window;
145 mgr_class->get_modal = modest_hildon2_window_mgr_get_modal;
146 mgr_class->set_modal = modest_hildon2_window_mgr_set_modal;
147 mgr_class->find_registered_header = modest_hildon2_window_mgr_find_registered_header;
148 mgr_class->get_window_list = modest_hildon2_window_mgr_get_window_list;
149 mgr_class->close_all_windows = modest_hildon2_window_mgr_close_all_windows;
150 mgr_class->show_initial_window = modest_hildon2_window_mgr_show_initial_window;
152 g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowMgrPrivate));
157 modest_hildon2_window_mgr_instance_init (ModestHildon2WindowMgr *obj)
159 ModestHildon2WindowMgrPrivate *priv;
161 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(obj);
162 priv->window_list = NULL;
163 priv->fullscreen_mode = FALSE;
164 priv->current_top = NULL;
165 priv->window_state_uids = NULL;
167 priv->modal_windows = g_queue_new ();
168 priv->queue_lock = g_mutex_new ();
170 /* Could not initialize it from gconf, singletons are not
172 priv->destroy_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
173 priv->viewer_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
175 priv->closing_time = 0;
177 priv->modal_handler_uids = NULL;
181 modest_hildon2_window_mgr_finalize (GObject *obj)
183 ModestHildon2WindowMgrPrivate *priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE(obj);
185 modest_signal_mgr_disconnect_all_and_destroy (priv->window_state_uids);
186 priv->window_state_uids = NULL;
188 if (priv->window_list) {
189 GList *iter = priv->window_list;
190 /* unregister pending windows */
192 ModestWindow *window = (ModestWindow *) iter->data;
193 iter = g_list_next (iter);
194 modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (obj), window);
196 g_list_free (priv->window_list);
197 priv->window_list = NULL;
200 /* Free the hash table with the handlers */
201 if (priv->destroy_handlers) {
202 g_hash_table_destroy (priv->destroy_handlers);
203 priv->destroy_handlers = NULL;
206 if (priv->viewer_handlers) {
207 g_hash_table_destroy (priv->viewer_handlers);
208 priv->viewer_handlers = NULL;
211 modest_signal_mgr_disconnect_all_and_destroy (priv->modal_handler_uids);
212 priv->modal_handler_uids = NULL;
214 if (priv->modal_windows) {
215 g_mutex_lock (priv->queue_lock);
216 g_queue_free (priv->modal_windows);
217 priv->modal_windows = NULL;
218 g_mutex_unlock (priv->queue_lock);
220 g_mutex_free (priv->queue_lock);
222 /* Do not unref priv->main_window because it does not hold a
225 G_OBJECT_CLASS(parent_class)->finalize (obj);
229 modest_hildon2_window_mgr_new (void)
231 return MODEST_WINDOW_MGR(g_object_new(MODEST_TYPE_HILDON2_WINDOW_MGR, NULL));
235 modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self)
237 ModestHildon2WindowMgrPrivate *priv = NULL;
238 gboolean ret_value = FALSE;
240 HildonWindowStack *stack;
241 gboolean failed = FALSE;
243 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
244 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
246 stack = hildon_window_stack_get_default ();
248 while ((window = hildon_window_stack_peek (stack)) != NULL) {
249 g_signal_emit_by_name (G_OBJECT (window), "delete-event", NULL, &ret_value);
250 if (ret_value == TRUE) {
260 compare_msguids (ModestWindow *win,
263 const gchar *msg_uid;
265 if ((!MODEST_IS_MSG_EDIT_WINDOW (win)) && (!MODEST_IS_MSG_VIEW_WINDOW (win)))
268 /* Get message uid from msg window */
269 if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
270 msg_uid = modest_msg_edit_window_get_message_uid (MODEST_MSG_EDIT_WINDOW (win));
271 if (msg_uid && uid &&!strcmp (msg_uid, uid))
274 msg_uid = modest_msg_view_window_get_message_uid (MODEST_MSG_VIEW_WINDOW (win));
277 if (msg_uid && uid &&!strcmp (msg_uid, uid))
284 modest_hildon2_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header,
287 ModestHildon2WindowMgrPrivate *priv = NULL;
289 gboolean has_header, has_window = FALSE;
292 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
293 g_return_val_if_fail (TNY_IS_HEADER(header), FALSE);
295 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
297 has_header = MODEST_WINDOW_MGR_CLASS (parent_class)->find_registered_header (self, header, win);
299 uid = modest_tny_folder_get_header_unique_id (header);
301 item = g_list_find_custom (priv->window_list, uid, (GCompareFunc) compare_msguids);
305 if ((!MODEST_IS_MSG_VIEW_WINDOW(item->data)) &&
306 (!MODEST_IS_MSG_EDIT_WINDOW (item->data)))
307 g_debug ("not a valid window!");
309 g_debug ("found a window");
310 *win = MODEST_WINDOW (item->data);
316 return has_header || has_window;
320 modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self)
322 ModestHildon2WindowMgrPrivate *priv;
324 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
325 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
327 return g_list_copy (priv->window_list);
331 modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
332 ModestWindow *window,
333 ModestWindow *parent)
336 ModestHildon2WindowMgrPrivate *priv;
338 HildonProgram *program;
339 GtkWidget *current_top;
340 HildonWindowStack *stack;
343 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
344 g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
346 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
348 program = hildon_program_get_instance ();
349 win = g_list_find (priv->window_list, window);
351 /* this is for the case we want to register the window and it was already
352 * registered. We leave silently, telling the operation was succesful.
354 gtk_window_present (GTK_WINDOW (win));
358 stack = hildon_window_stack_get_default ();
360 if (!MODEST_WINDOW_MGR_CLASS (parent_class)->register_window (self, window, parent))
363 /* Add to list. Keep a reference to the window */
364 g_object_ref (window);
365 priv->window_list = g_list_prepend (priv->window_list, window);
367 current_top = hildon_window_stack_peek (stack);
369 nested_msg = MODEST_IS_MSG_VIEW_WINDOW (window) &&
370 MODEST_IS_MSG_VIEW_WINDOW (parent);
371 /* Close views if they're being shown */
373 (MODEST_IS_MSG_EDIT_WINDOW (current_top) ||
374 MODEST_IS_MSG_VIEW_WINDOW (current_top))) {
377 /* If the current view has modal dialogs then
378 we fail to register the new view */
379 if ((current_top != NULL) &&
380 window_has_modals (MODEST_WINDOW (current_top))) {
381 /* Window on top but it has opened dialogs */
385 /* Close the current view */
386 g_signal_emit_by_name (G_OBJECT (current_top), "delete-event", NULL, &retval);
387 if (retval == TRUE) {
388 /* Cancelled closing top window, then we fail to register */
393 /* Listen to object destruction */
394 handler_id = g_malloc0 (sizeof (gint));
395 *handler_id = g_signal_connect (window, "delete-event", G_CALLBACK (on_window_destroy), self);
396 g_hash_table_insert (priv->destroy_handlers, window, handler_id);
398 /* Show toolbar always */
399 modest_window_show_toolbar (window, TRUE);
403 /* Add to list. Keep a reference to the window */
404 priv->window_list = g_list_remove (priv->window_list, window);
405 g_object_unref (window);
406 current_top = hildon_window_stack_peek (stack);
408 gtk_window_present (GTK_WINDOW (current_top));
413 cancel_window_operations (ModestWindow *window)
415 GSList* pending_ops = NULL;
417 /* cancel open and receive operations */
418 pending_ops = modest_mail_operation_queue_get_by_source (modest_runtime_get_mail_operation_queue (),
420 while (pending_ops != NULL) {
421 ModestMailOperationTypeOperation type;
422 GSList* tmp_list = NULL;
424 type = modest_mail_operation_get_type_operation (MODEST_MAIL_OPERATION (pending_ops->data));
425 if (type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || type == MODEST_MAIL_OPERATION_TYPE_OPEN) {
426 modest_mail_operation_cancel (pending_ops->data);
428 g_object_unref (G_OBJECT (pending_ops->data));
429 tmp_list = pending_ops;
430 pending_ops = g_slist_next (pending_ops);
431 g_slist_free_1 (tmp_list);
436 window_has_modals (ModestWindow *window)
440 gboolean retvalue = FALSE;
442 /* First we fetch all toplevels */
443 toplevels = gtk_window_list_toplevels ();
444 for (node = toplevels; node != NULL; node = g_list_next (node)) {
445 if (GTK_IS_WINDOW (node->data) &&
446 gtk_window_get_transient_for (GTK_WINDOW (node->data)) == GTK_WINDOW (window) &&
447 GTK_WIDGET_VISIBLE (node->data)) {
452 g_list_free (toplevels);
457 window_can_close (ModestWindow *window)
459 /* An editor can be always closed no matter the dialogs it has
461 if (MODEST_IS_MSG_EDIT_WINDOW (window))
464 return !window_has_modals (window);
468 on_window_destroy (ModestWindow *window,
470 ModestHildon2WindowMgr *self)
472 gboolean no_propagate = FALSE;
474 if (!window_can_close (window))
477 if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
478 gboolean sent = FALSE;
479 sent = modest_msg_edit_window_get_sent (MODEST_MSG_EDIT_WINDOW (window));
480 /* Save currently edited message to Drafts if it was not sent */
481 if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
483 if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
488 /* Unregister window */
489 modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (self), window);
490 no_propagate = FALSE;
496 modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
497 ModestWindow *window)
500 ModestHildon2WindowMgrPrivate *priv;
501 gulong *tmp, handler_id;
502 gboolean check_close_all = FALSE;
505 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
506 g_return_if_fail (MODEST_IS_WINDOW (window));
508 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
510 win = g_list_find (priv->window_list, window);
512 g_warning ("Trying to unregister a window that has not being registered yet");
516 /* Remember this for the end of the method */
517 if (MODEST_IS_FOLDER_WINDOW (window))
518 check_close_all = TRUE;
520 /* Remove the viewer window handler from the hash table. The
521 HashTable could not exist if the main window was closed
522 when there were other windows remaining */
523 if (MODEST_IS_MSG_VIEW_WINDOW (window) && priv->viewer_handlers) {
524 tmp = (gulong *) g_hash_table_lookup (priv->viewer_handlers, window);
525 /* If the viewer was created without a main window
526 (for example when opening a message through D-Bus
527 the viewer handlers was not registered */
529 g_signal_handler_disconnect (window, *tmp);
530 g_hash_table_remove (priv->viewer_handlers, window);
534 /* Remove from list & hash table */
535 priv->window_list = g_list_remove_link (priv->window_list, win);
536 tmp = g_hash_table_lookup (priv->destroy_handlers, window);
539 g_hash_table_remove (priv->destroy_handlers, window);
541 /* cancel open and receive operations */
542 cancel_window_operations (window);
544 /* Check if it's the topmost window, and remove the window from the stack.
545 * This is needed for the cases there's no other topmost window that will
546 * replace it in topmost handler.
548 if (window == priv->current_top)
549 priv->current_top = NULL;
551 /* Disconnect the "window-state-event" handler, we won't need it anymore */
552 if (priv->window_state_uids) {
553 priv->window_state_uids =
554 modest_signal_mgr_disconnect (priv->window_state_uids,
556 "notify::is-topmost");
559 /* Disconnect the "delete-event" handler, we won't need it anymore */
560 g_signal_handler_disconnect (window, handler_id);
562 /* Destroy the window */
563 g_object_unref (win->data);
566 MODEST_WINDOW_MGR_CLASS (parent_class)->unregister_window (self, window);
568 /* We have to get the number of windows here in order not to
569 emit the signal too many times */
570 num_windows = modest_window_mgr_get_num_windows (self);
572 /* Check if we have to destroy the accounts window as
573 well. This happens if we only have one or none remote
575 if (check_close_all) {
576 ModestTnyAccountStore *acc_store = modest_runtime_get_account_store ();
577 if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2)
578 modest_window_mgr_close_all_windows (self);
581 /* If there are no more windows registered emit the signal */
582 if (num_windows == 0)
583 g_signal_emit_by_name (self, "window-list-empty");
588 modest_hildon2_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
591 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
597 modest_hildon2_window_mgr_get_fullscreen_mode (ModestWindowMgr *self)
603 modest_hildon2_window_mgr_show_toolbars (ModestWindowMgr *self,
605 gboolean show_toolbars,
608 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
614 modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
616 ModestHildon2WindowMgrPrivate *priv;
617 ModestWindow *result;
619 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
620 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
622 /* TODO: make this return NULL always */
624 result = MODEST_WINDOW_MGR_CLASS (parent_class)->get_main_window (self, FALSE);
625 /* create the main window, if it hasn't been created yet */
626 if (!result && show) {
627 /* modest_window_mgr_register_window will set priv->main_window */
628 result = modest_main_window_new ();
629 /* We have to remove all other windows */
630 if (!modest_window_mgr_close_all_windows (self)) {
631 gtk_widget_destroy (GTK_WIDGET (result));
634 if (!modest_window_mgr_register_window (self, result, NULL)) {
635 gtk_widget_destroy (GTK_WIDGET (result));
639 g_debug ("%s: created main window: %p\n", __FUNCTION__, result);
643 gtk_widget_show_all (GTK_WIDGET (result));
644 gtk_window_present (GTK_WINDOW (result));
652 modest_hildon2_window_mgr_get_modal (ModestWindowMgr *self)
654 ModestHildon2WindowMgrPrivate *priv;
655 GList *toplevel_list;
658 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
659 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
662 toplevel_list = gtk_window_list_toplevels ();
663 while (toplevel_list) {
664 if (gtk_window_is_active (toplevel_list->data)) {
665 toplevel = toplevel_list->data;
668 toplevel_list = g_list_next (toplevel_list);
676 modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
680 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
681 g_return_if_fail (GTK_IS_WINDOW (window));
683 gtk_window_set_modal (window, TRUE);
684 gtk_window_set_transient_for (window, parent);
685 gtk_window_set_destroy_with_parent (window, TRUE);
688 static ModestWindow *
689 modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self)
691 ModestWindow *initial_window = NULL;
692 ModestTnyAccountStore *acc_store;
694 /* Always create accounts window. We'll decide later if we
695 want to show it or not, depending the number of accounts */
696 initial_window = MODEST_WINDOW (modest_accounts_window_new ());
697 modest_window_mgr_register_window (self, initial_window, NULL);
699 /* If there are less than 2 remote accounts then directly show
700 the folder window and do not show the accounts window */
701 acc_store = modest_runtime_get_account_store ();
702 if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2) {
703 ModestAccountMgr *mgr;
705 /* Show first the accounts window to add it to the
706 stack. This has to be changed when the new
707 stackable API is available. There will be a method
708 to show all the windows that will only show the
709 last one to the user. The current code shows both
710 windows, one after the other */
711 gtk_widget_show (GTK_WIDGET (initial_window));
713 initial_window = MODEST_WINDOW (modest_folder_window_new (NULL));
714 mgr = modest_runtime_get_account_mgr ();
715 modest_folder_window_set_account (MODEST_FOLDER_WINDOW (initial_window),
716 modest_account_mgr_get_default_account (mgr));
717 modest_window_mgr_register_window (self, initial_window, NULL);
720 return initial_window;