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-program.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
226 G_OBJECT_CLASS(parent_class)->finalize (obj);
230 modest_hildon2_window_mgr_new (void)
232 return MODEST_WINDOW_MGR(g_object_new(MODEST_TYPE_HILDON2_WINDOW_MGR, NULL));
236 modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self)
238 ModestHildon2WindowMgrPrivate *priv = NULL;
239 gboolean ret_value = FALSE;
240 HildonStackableWindow *window;
241 HildonProgram *program;
242 gboolean failed = FALSE;
244 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
245 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
247 program = hildon_program_get_instance ();
249 while ((window = hildon_program_peek_window_stack (program)) != NULL) {
250 g_signal_emit_by_name (G_OBJECT (window), "delete-event", NULL, &ret_value);
251 if (ret_value == TRUE) {
261 compare_msguids (ModestWindow *win,
264 const gchar *msg_uid;
266 if ((!MODEST_IS_MSG_EDIT_WINDOW (win)) && (!MODEST_IS_MSG_VIEW_WINDOW (win)))
269 /* Get message uid from msg window */
270 if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
271 msg_uid = modest_msg_edit_window_get_message_uid (MODEST_MSG_EDIT_WINDOW (win));
272 if (msg_uid && uid &&!strcmp (msg_uid, uid))
275 msg_uid = modest_msg_view_window_get_message_uid (MODEST_MSG_VIEW_WINDOW (win));
278 if (msg_uid && uid &&!strcmp (msg_uid, uid))
285 modest_hildon2_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header,
288 ModestHildon2WindowMgrPrivate *priv = NULL;
290 gboolean has_header, has_window = FALSE;
293 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
294 g_return_val_if_fail (TNY_IS_HEADER(header), FALSE);
296 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
298 has_header = MODEST_WINDOW_MGR_CLASS (parent_class)->find_registered_header (self, header, win);
300 uid = modest_tny_folder_get_header_unique_id (header);
302 item = g_list_find_custom (priv->window_list, uid, (GCompareFunc) compare_msguids);
306 if ((!MODEST_IS_MSG_VIEW_WINDOW(item->data)) &&
307 (!MODEST_IS_MSG_EDIT_WINDOW (item->data)))
308 g_debug ("not a valid window!");
310 g_debug ("found a window");
311 *win = MODEST_WINDOW (item->data);
317 return has_header || has_window;
321 modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self)
323 ModestHildon2WindowMgrPrivate *priv;
325 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
326 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
328 return g_list_copy (priv->window_list);
332 modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
333 ModestWindow *window,
334 ModestWindow *parent)
337 ModestHildon2WindowMgrPrivate *priv;
339 HildonProgram *program;
340 GtkWidget *current_top;
342 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
343 g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
345 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
347 program = hildon_program_get_instance ();
348 win = g_list_find (priv->window_list, window);
350 /* this is for the case we want to register the window and it was already
351 * registered. We leave silently, telling the operation was succesful.
353 gtk_window_present (GTK_WINDOW (win));
357 if (!MODEST_WINDOW_MGR_CLASS (parent_class)->register_window (self, window, parent))
360 /* Add to list. Keep a reference to the window */
361 g_object_ref (window);
362 priv->window_list = g_list_prepend (priv->window_list, window);
364 current_top = GTK_WIDGET (hildon_program_peek_window_stack (program));
366 /* policy is: if no parent, then we close all up message views, but no account/folder/header window */
368 if (!parent || ((GtkWidget *) parent != current_top)) {
369 gboolean close_canceled = FALSE;
371 if ((current_top != NULL) &&
372 window_has_modals (MODEST_WINDOW (current_top))) {
373 /* Window on top but it has opened dialogs */
376 while (current_top && !close_canceled) {
377 current_top = GTK_WIDGET (hildon_program_peek_window_stack (program));
378 if (MODEST_IS_MSG_VIEW_WINDOW (current_top) || MODEST_IS_MSG_EDIT_WINDOW (current_top)) {
379 g_signal_emit_by_name (G_OBJECT (current_top), "delete-event", NULL, &close_canceled);
390 /* Listen to object destruction */
391 handler_id = g_malloc0 (sizeof (gint));
392 *handler_id = g_signal_connect (window, "delete-event", G_CALLBACK (on_window_destroy), self);
393 g_hash_table_insert (priv->destroy_handlers, window, handler_id);
395 /* Show toolbar always */
396 modest_window_show_toolbar (window, TRUE);
400 /* Add to list. Keep a reference to the window */
401 priv->window_list = g_list_remove (priv->window_list, window);
402 g_object_unref (window);
403 current_top = GTK_WIDGET (hildon_program_peek_window_stack (program));
405 gtk_window_present (GTK_WINDOW (current_top));
410 cancel_window_operations (ModestWindow *window)
412 GSList* pending_ops = NULL;
414 /* cancel open and receive operations */
415 pending_ops = modest_mail_operation_queue_get_by_source (modest_runtime_get_mail_operation_queue (),
417 while (pending_ops != NULL) {
418 ModestMailOperationTypeOperation type;
419 GSList* tmp_list = NULL;
421 type = modest_mail_operation_get_type_operation (MODEST_MAIL_OPERATION (pending_ops->data));
422 if (type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || type == MODEST_MAIL_OPERATION_TYPE_OPEN) {
423 modest_mail_operation_cancel (pending_ops->data);
425 g_object_unref (G_OBJECT (pending_ops->data));
426 tmp_list = pending_ops;
427 pending_ops = g_slist_next (pending_ops);
428 g_slist_free_1 (tmp_list);
433 window_has_modals (ModestWindow *window)
437 gboolean retvalue = FALSE;
439 /* First we fetch all toplevels */
440 toplevels = gtk_window_list_toplevels ();
441 for (node = toplevels; node != NULL; node = g_list_next (node)) {
442 if (GTK_IS_WINDOW (node->data) &&
443 gtk_window_get_transient_for (GTK_WINDOW (node->data)) == GTK_WINDOW (window)) {
448 g_list_free (toplevels);
453 window_can_close (ModestWindow *window)
455 /* An editor can be always closed no matter the dialogs it has
457 if (MODEST_IS_MSG_EDIT_WINDOW (window))
460 return !window_has_modals (window);
464 on_window_destroy (ModestWindow *window,
466 ModestHildon2WindowMgr *self)
468 gboolean no_propagate = FALSE;
470 if (!window_can_close (window)) {
473 /* Specific stuff first */
474 if (MODEST_IS_MAIN_WINDOW (window)) {
475 ModestHildon2WindowMgrPrivate *priv;
476 ModestMainWindowContentsStyle style;
477 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
479 /* If we're on header view, then just go to folder view and don't close */
480 style = modest_main_window_get_contents_style (MODEST_MAIN_WINDOW (window));
481 if (style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) {
482 modest_main_window_set_contents_style (MODEST_MAIN_WINDOW (window),
483 MODEST_MAIN_WINDOW_CONTENTS_STYLE_FOLDERS);
487 /* Do not unregister it, just hide */
488 gtk_widget_hide_all (GTK_WIDGET (window));
490 /* Cancel pending operations */
491 cancel_window_operations (window);
493 /* Fake the window system, make it think that there is no window */
494 if (modest_window_mgr_num_windows (MODEST_WINDOW_MGR (self)) == 0)
495 g_signal_emit_by_name (self, "window-list-empty");
500 if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
501 gboolean sent = FALSE;
502 sent = modest_msg_edit_window_get_sent (MODEST_MSG_EDIT_WINDOW (window));
503 /* Save currently edited message to Drafts if it was not sent */
504 if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
506 if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
510 /* Unregister window */
511 modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (self), window);
512 no_propagate = FALSE;
519 disconnect_msg_changed (gpointer key,
524 handler_id = GPOINTER_TO_UINT(value);
526 if (key && G_IS_OBJECT(key))
527 g_signal_handler_disconnect (G_OBJECT (key), handler_id);
531 modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
532 ModestWindow *window)
535 ModestHildon2WindowMgrPrivate *priv;
536 gulong *tmp, handler_id;
538 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
539 g_return_if_fail (MODEST_IS_WINDOW (window));
541 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
543 win = g_list_find (priv->window_list, window);
545 g_warning ("Trying to unregister a window that has not being registered yet");
549 /* If it's the main window unset it */
550 if (MODEST_IS_MAIN_WINDOW (window)) {
551 modest_window_mgr_set_main_window (self, NULL);
553 /* Disconnect all emissions of msg-changed */
554 if (priv->viewer_handlers) {
555 g_hash_table_foreach (priv->viewer_handlers,
556 disconnect_msg_changed,
558 g_hash_table_destroy (priv->viewer_handlers);
559 priv->viewer_handlers = NULL;
563 /* Remove the viewer window handler from the hash table. The
564 HashTable could not exist if the main window was closed
565 when there were other windows remaining */
566 if (MODEST_IS_MSG_VIEW_WINDOW (window) && priv->viewer_handlers) {
567 tmp = (gulong *) g_hash_table_lookup (priv->viewer_handlers, window);
568 /* If the viewer was created without a main window
569 (for example when opening a message through D-Bus
570 the viewer handlers was not registered */
572 g_signal_handler_disconnect (window, *tmp);
573 g_hash_table_remove (priv->viewer_handlers, window);
577 /* Remove from list & hash table */
578 priv->window_list = g_list_remove_link (priv->window_list, win);
579 tmp = g_hash_table_lookup (priv->destroy_handlers, window);
582 g_hash_table_remove (priv->destroy_handlers, window);
584 /* cancel open and receive operations */
585 cancel_window_operations (window);
587 /* Check if it's the topmost window, and remove the window from the stack.
588 * This is needed for the cases there's no other topmost window that will
589 * replace it in topmost handler.
591 if (window == priv->current_top)
592 priv->current_top = NULL;
594 /* Disconnect the "window-state-event" handler, we won't need it anymore */
595 if (priv->window_state_uids) {
596 #ifndef MODEST_TOOLKIT_GTK
597 priv->window_state_uids =
598 modest_signal_mgr_disconnect (priv->window_state_uids,
600 "notify::is-topmost");
602 priv->window_state_uids =
603 modest_signal_mgr_disconnect (priv->window_state_uids,
605 "window-state-event");
609 /* Disconnect the "delete-event" handler, we won't need it anymore */
610 g_signal_handler_disconnect (window, handler_id);
612 /* Destroy the window */
613 g_object_unref (win->data);
616 MODEST_WINDOW_MGR_CLASS (parent_class)->unregister_window (self, window);
618 /* If there are no more windows registered emit the signal */
619 if (modest_window_mgr_num_windows (self) == 0)
620 g_signal_emit_by_name (self, "window-list-empty");
626 modest_hildon2_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
629 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
635 modest_hildon2_window_mgr_get_fullscreen_mode (ModestWindowMgr *self)
641 modest_hildon2_window_mgr_show_toolbars (ModestWindowMgr *self,
643 gboolean show_toolbars,
646 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
652 modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
654 ModestHildon2WindowMgrPrivate *priv;
655 ModestWindow *result;
657 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
658 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
660 /* TODO: make this return NULL always */
662 result = MODEST_WINDOW_MGR_CLASS (parent_class)->get_main_window (self, FALSE);
663 /* create the main window, if it hasn't been created yet */
664 if (!result && show) {
665 /* modest_window_mgr_register_window will set priv->main_window */
666 result = modest_main_window_new ();
667 /* We have to remove all other windows */
668 if (!modest_window_mgr_close_all_windows (self)) {
669 gtk_widget_destroy (GTK_WIDGET (result));
672 if (!modest_window_mgr_register_window (self, result, NULL)) {
673 gtk_widget_destroy (GTK_WIDGET (result));
677 g_debug ("%s: created main window: %p\n", __FUNCTION__, result);
681 gtk_widget_show_all (GTK_WIDGET (result));
682 gtk_window_present (GTK_WINDOW (result));
690 modest_hildon2_window_mgr_get_modal (ModestWindowMgr *self)
692 ModestHildon2WindowMgrPrivate *priv;
693 GList *toplevel_list;
696 g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
697 priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
700 toplevel_list = gtk_window_list_toplevels ();
701 while (toplevel_list) {
702 if (gtk_window_is_active (toplevel_list->data)) {
703 toplevel = toplevel_list->data;
706 toplevel_list = g_list_next (toplevel_list);
714 modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
718 g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
719 g_return_if_fail (GTK_IS_WINDOW (window));
721 gtk_window_set_modal (window, TRUE);
722 gtk_window_set_transient_for (window, parent);
723 gtk_window_set_destroy_with_parent (window, TRUE);
726 static ModestWindow *
727 modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self)
729 ModestWindow *window = NULL;
730 ModestAccountMgr *mgr;
731 GSList *account_names;
734 mgr = modest_runtime_get_account_mgr ();
735 account_names = modest_account_mgr_account_names (mgr, TRUE);
736 count = g_slist_length (account_names);
739 window = MODEST_WINDOW (modest_accounts_window_new ());
741 window = MODEST_WINDOW (modest_folder_window_new (NULL));
743 modest_folder_window_set_account (MODEST_FOLDER_WINDOW (window),
744 account_names->data);
746 modest_account_mgr_free_account_names (account_names);
747 modest_window_mgr_register_window (self, window, NULL);