- /* TODO: rethink this method it will be different depending on
- the type of the window that we're registering */
- if (!parent || ((GtkWidget *) parent != current_top)) {
- guint num_windows = hildon_window_stack_size (stack);
-
- /* We have to close all windows with the exception of the root window */
- if (num_windows > 1)
- hildon_window_stack_pop (stack, num_windows - 1, NULL);
-
- /* We remove 1 because we added it before */
- if (modest_window_mgr_num_windows (MODEST_WINDOW_MGR (self)) - 1> 1) {
- /* Then we couldn't close one of the preceding windows, so we have to stop the
- * window register process and fail.
- */
+ /* Close views if they're being shown */
+ if (MODEST_IS_MSG_EDIT_WINDOW (current_top) ||
+ MODEST_IS_MSG_VIEW_WINDOW (current_top)) {
+ gboolean retval;
+
+ /* TODO: allow nested messages, maybe we should add
+ something to the msg view when it's showing an
+ email sent as attachment */
+
+ /* If the current view has modal dialogs then
+ we fail to register the new view */
+ if ((current_top != NULL) &&
+ window_has_modals (MODEST_WINDOW (current_top))) {
+ /* Window on top but it has opened dialogs */