* Some fixes to the window manager
authorSergio Villar Senin <svillar@igalia.com>
Mon, 15 Dec 2008 16:32:04 +0000 (16:32 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 15 Dec 2008 16:32:04 +0000 (16:32 +0000)
pmo-drop-split-view-r6855

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

index ad97d75..2f68ed4 100644 (file)
@@ -338,6 +338,7 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
        HildonProgram *program;
        GtkWidget *current_top;
        HildonWindowStack *stack;
+       gboolean nested_msg;
 
        g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
        g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
@@ -365,29 +366,31 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
 
        current_top = hildon_window_stack_peek (stack);
 
-       /* policy is: if no parent, then we close all up message views, but no account/folder/header window */
-
-       if (!parent || ((GtkWidget *) parent != current_top)) {
-               gboolean close_canceled = FALSE;
-
-               if ((current_top != NULL) &&
-                   window_has_modals (MODEST_WINDOW (current_top))) {
-                       /* Window on top but it has opened dialogs */
-                       goto fail;
-               }
-               while (current_top && !close_canceled) {
-                       current_top = hildon_window_stack_peek (stack);
-                       if (MODEST_IS_MSG_VIEW_WINDOW (current_top) || MODEST_IS_MSG_EDIT_WINDOW (current_top)) {
-                               g_signal_emit_by_name (G_OBJECT (current_top), "delete-event", NULL, &close_canceled);
-                       } else {
-                               break;
-                       }
-               }
-
-               if (close_canceled)
-                       goto fail;
-
-       }
+        nested_msg = MODEST_IS_MSG_VIEW_WINDOW (window) && 
+                MODEST_IS_MSG_VIEW_WINDOW (parent);
+
+        /* Close views if they're being shown. Nevertheless we must
+           allow nested messages */
+        if (!nested_msg &&
+            (MODEST_IS_MSG_EDIT_WINDOW (current_top) ||
+             MODEST_IS_MSG_VIEW_WINDOW (current_top))) {
+                gboolean retval;
+
+                /* 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;
+                }
+
+                /* 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;
+                }
+        }
 
        /* Listen to object destruction */
        handler_id = g_malloc0 (sizeof (gint));
index ecdd800..a3ae0ce 100644 (file)
@@ -1637,7 +1637,8 @@ reply_forward_cb (ModestMailOperation *mail_op,
        mgr = modest_runtime_get_window_mgr ();
        modest_window_mgr_register_window (mgr, msg_win, (ModestWindow *) rf_helper->parent_window);
 
-       if (rf_helper->parent_window != NULL) {
+       /* Note that register_window could have deleted the account */
+       if (MODEST_IS_WINDOW (rf_helper->parent_window)) {
                gdouble parent_zoom;
 
                parent_zoom = modest_window_get_zoom (MODEST_WINDOW (rf_helper->parent_window));