- main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
- TRUE); /* create if non-existent */
- if (!main_win) {
- g_warning ("%s: BUG: no main window", __FUNCTION__);
- gdk_threads_leave (); /* CHECKED */
- return FALSE; /* don't call me again */
+ acc_name = (gchar *) user_data;
+ mgr = modest_runtime_get_window_mgr ();
+
+ top = modest_window_mgr_get_current_top (mgr);
+ if (!top)
+ top = modest_window_mgr_show_initial_window (mgr);
+
+#ifdef MODEST_TOOLKIT_HILDON2
+ if (MODEST_IS_ACCOUNTS_WINDOW (top)) {
+ GtkWidget *new_window;
+ ModestProtocolType store_protocol;
+ gboolean mailboxes_protocol;
+
+ store_protocol = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
+ acc_name);
+ mailboxes_protocol =
+ modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
+ store_protocol,
+ MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS);
+
+ if (mailboxes_protocol) {
+ new_window = GTK_WIDGET (modest_mailboxes_window_new (acc_name));
+ } else {
+ new_window = GTK_WIDGET (modest_folder_window_new (NULL));
+ modest_folder_window_set_account (MODEST_FOLDER_WINDOW (new_window),
+ acc_name);
+ }
+
+ if (modest_window_mgr_register_window (mgr, MODEST_WINDOW (new_window), NULL)) {
+ gtk_widget_show (new_window);
+ } else {
+ gtk_widget_destroy (new_window);
+ new_window = NULL;
+ }