+ /* Do not allow standalone editors or standalone viewers */
+ if (!current_top &&
+ (MODEST_IS_MSG_VIEW_WINDOW (window) ||
+ MODEST_IS_MSG_EDIT_WINDOW (window)))
+ modest_window_mgr_show_initial_window (self);
+
+ if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+ gchar *uid;
+ TnyHeader *header;
+
+ uid = g_strdup (modest_msg_view_window_get_message_uid (MODEST_MSG_VIEW_WINDOW (window)));
+
+ header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (window));
+
+ if (uid == NULL)
+ uid = modest_tny_folder_get_header_unique_id (header);
+ /* Embedded messages do not have uid */
+ if (uid) {
+ if (g_list_find_custom (priv->window_list, uid, (GCompareFunc) compare_msguids)) {
+ g_debug ("%s found another view window showing the same header", __FUNCTION__);
+ g_free (uid);
+ g_object_unref (header);
+ return FALSE;
+ }
+ g_free (uid);
+ } else if (header) {
+ if (g_list_find_custom (priv->window_list, header, (GCompareFunc) compare_headers)) {
+ g_debug ("%s found another view window showing the same header", __FUNCTION__);
+ g_object_unref (header);
+ return FALSE;
+ }
+ }
+ if (header)
+ g_object_unref (header);
+ }
+
+ /* Do not go backwards */
+ if ((MODEST_IS_MSG_VIEW_WINDOW (current_top) ||
+ MODEST_IS_MSG_EDIT_WINDOW (current_top) ||
+ MODEST_IS_HEADER_WINDOW (current_top)) &&
+ (MODEST_IS_FOLDER_WINDOW (window) ||
+ MODEST_IS_ACCOUNTS_WINDOW (window) ||
+ MODEST_IS_MAILBOXES_WINDOW (window))) {
+ gtk_window_present (GTK_WINDOW (current_top));
+ return FALSE;
+ }
+
+ if (MODEST_IS_FOLDER_WINDOW (current_top) && MODEST_IS_FOLDER_WINDOW (window)) {
+ gboolean retval;
+
+ g_signal_emit_by_name (G_OBJECT (current_top), "delete-event", NULL, &retval);
+
+ if (retval) {
+ gtk_window_present (GTK_WINDOW (current_top));
+ return FALSE;
+ }
+ current_top = (ModestWindow *) hildon_window_stack_peek (stack);
+ }
+
+ if (MODEST_IS_MAILBOXES_WINDOW (current_top) && MODEST_IS_MAILBOXES_WINDOW (window)) {
+ gtk_window_present (GTK_WINDOW (current_top));
+ return FALSE;
+ }
+
+ /* Mailboxes window can not replace folder windows */
+ if (MODEST_IS_FOLDER_WINDOW (current_top) && MODEST_IS_MAILBOXES_WINDOW (window)) {
+ gtk_window_present (GTK_WINDOW (current_top));
+ return FALSE;
+ }
+
+ /* Trying to open a folders window and a mailboxes window at
+ the same time from the accounts window is not allowed */
+ if (MODEST_IS_MAILBOXES_WINDOW (current_top) &&
+ MODEST_IS_FOLDER_WINDOW (window) &&
+ MODEST_IS_ACCOUNTS_WINDOW (parent)) {
+ gtk_window_present (GTK_WINDOW (window));
+ return FALSE;
+ }
+
+ if (MODEST_IS_HEADER_WINDOW (current_top) && MODEST_IS_HEADER_WINDOW (window)) {
+ g_debug ("Trying to register a second header window is not allowed");
+ gtk_window_present (GTK_WINDOW (current_top));
+ return FALSE;
+ }