* Fixes NB#106248, do not allow launching a mailbox and folders windows at the same...
[modest] / src / hildon2 / modest-hildon2-window-mgr.c
index be4c0b2..447d010 100644 (file)
@@ -31,6 +31,7 @@
 #include <hildon/hildon.h>
 #include "modest-hildon2-window-mgr.h"
 #include "modest-msg-edit-window.h"
+#include "modest-mailboxes-window.h"
 #include "modest-header-window.h"
 #include "modest-main-window.h"
 #include "modest-conf.h"
@@ -195,12 +196,6 @@ modest_hildon2_window_mgr_instance_init (ModestHildon2WindowMgr *obj)
        priv->modal_handler_uids = NULL;
        priv->display_state = OSSO_DISPLAY_ON;
 
-       /* Connect to the account store "account-removed" signal" */
-       priv->accounts_handler = g_signal_connect (modest_runtime_get_account_store (),
-                                                  "account-removed",
-                                                  G_CALLBACK (on_account_removed),
-                                                  obj);
-
        /* Listen for changes in the screen, we don't want to show a
           led pattern when the display is on for example */
        osso_hw_set_display_event_cb (modest_maemo_utils_get_osso_context (),
@@ -396,11 +391,30 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
        }
 
        if (MODEST_IS_FOLDER_WINDOW (current_top) && MODEST_IS_FOLDER_WINDOW (window)) {
-               g_debug ("Trying to register a second folder window is not allowed");
+               gtk_window_present (GTK_WINDOW (win));
+               return FALSE;
+       }
+
+       if (MODEST_IS_MAILBOXES_WINDOW (current_top) && MODEST_IS_MAILBOXES_WINDOW (window)) {
+               gtk_window_present (GTK_WINDOW (win));
+               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 (win));
+               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));
@@ -414,7 +428,7 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
        g_object_ref (window);
        priv->window_list = g_list_prepend (priv->window_list, window);
 
-       nested_msg = MODEST_IS_MSG_VIEW_WINDOW (window) && 
+       nested_msg = MODEST_IS_MSG_VIEW_WINDOW (window) &&
                MODEST_IS_MSG_VIEW_WINDOW (parent);
 
        /* Close views if they're being shown. Nevertheless we must
@@ -813,6 +827,20 @@ static ModestWindow *
 modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self)
 {
        ModestWindow *initial_window = NULL;
+       ModestHildon2WindowMgrPrivate *priv;
+
+       priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
+
+       /* Connect to the account store "account-removed" signal". We
+          do this here because in the init the singletons are still
+          not initialized properly */
+       if (!g_signal_handler_is_connected (modest_runtime_get_account_store (),
+                                           priv->accounts_handler)) {
+               priv->accounts_handler = g_signal_connect (modest_runtime_get_account_store (),
+                                                          "account-removed",
+                                                          G_CALLBACK (on_account_removed),
+                                                          self);
+       }
 
        /* Return accounts window */
        initial_window = MODEST_WINDOW (modest_accounts_window_new ());