* Fixes NB#95749, properly manage new windows
authorSergio Villar Senin <svillar@igalia.com>
Mon, 15 Dec 2008 13:20:34 +0000 (13:20 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 15 Dec 2008 13:20:34 +0000 (13:20 +0000)
pmo-trunk-r6841

src/hildon2/modest-hildon2-window-mgr.c
src/modest-ui-actions.c

index 41d2b3e..04d68dd 100644 (file)
@@ -361,40 +361,27 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
 
        current_top = hildon_window_stack_peek (stack);
 
-       /* 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 */
                        goto fail;
                }
 
-               if ((current_top != NULL) && !MODEST_IS_MAIN_WINDOW (current_top)) {
-                       gboolean retval;
-                       g_signal_emit_by_name (G_OBJECT (current_top), "delete-event", NULL, &retval);
-                       if (retval == TRUE) {
-                               /* Cancelled closing top window, then we fail to register */
-                               goto fail;
-                       }
-                       current_top = hildon_window_stack_peek (stack);
-               }
-               if ((current_top != NULL) && !MODEST_IS_MAIN_WINDOW (current_top)) {
-                       /* Closing the stacked windows failed, then we shouldn't show the
-                          new window */
-                       goto fail;
-               }
-               if ((current_top != NULL) && 
-                   window_has_modals (MODEST_WINDOW (current_top))) {
-                       /* Window on top but it has opened dialogs */
+               /* Close the current view */
+               g_signal_emit_by_name (G_OBJECT (current_top), "delete-event", NULL, &retval);
+               if (retval == TRUE) {
+                       /* Cancelled closing top window, then we fail to register */
                        goto fail;
                }
        }
index fcf54b1..a31dc47 100644 (file)
@@ -772,7 +772,7 @@ modest_ui_actions_compose_msg(ModestWindow *win,
        allowed_size = MODEST_MAX_ATTACHMENT_SIZE;
        msg_win = modest_msg_edit_window_new (msg, account_name, FALSE);
 
-       if (!modest_window_mgr_register_window (modest_runtime_get_window_mgr(), msg_win, NULL)) {
+       if (!modest_window_mgr_register_window (modest_runtime_get_window_mgr(), msg_win, win)) {
                gtk_widget_destroy (GTK_WIDGET (msg_win));
                goto cleanup;
        }