Launch mailboxes window on multimailboxes accounts
authorJose Dapena Paz <jdapena@igalia.com>
Mon, 2 Mar 2009 15:42:07 +0000 (15:42 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 2 Mar 2009 15:42:07 +0000 (15:42 +0000)
pmo-trunk-r7753

src/hildon2/modest-accounts-window.c
src/hildon2/modest-mailboxes-window.c

index 765bf84..9a96dda 100644 (file)
@@ -47,6 +47,8 @@
 #include <modest-ui-dimming-manager.h>
 #include <modest-window-priv.h>
 #include <modest-ui-constants.h>
 #include <modest-ui-dimming-manager.h>
 #include <modest-window-priv.h>
 #include <modest-ui-constants.h>
+#include <modest-account-mgr-helpers.h>
+#include <modest-mailboxes-window.h>
 
 
 /* 'private'/'protected' functions */
 
 
 /* 'private'/'protected' functions */
@@ -377,8 +379,10 @@ on_account_activated (GtkTreeView *account_view,
 {
        ModestAccountsWindowPrivate *priv;
        gchar* account_name; 
 {
        ModestAccountsWindowPrivate *priv;
        gchar* account_name; 
-       GtkWidget *folder_window;
+       GtkWidget *new_window;
        gboolean registered;
        gboolean registered;
+       ModestProtocolType store_protocol;
+       gboolean mailboxes_protocol;
 
        priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
 
 
        priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
 
@@ -386,17 +390,32 @@ on_account_activated (GtkTreeView *account_view,
        if (!account_name)
                return;
 
        if (!account_name)
                return;
 
-       folder_window = GTK_WIDGET (modest_folder_window_new (NULL));
+       /* If it's a multimailbox container, we have to show the mailboxes window */
+       store_protocol = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (), 
+                                                               account_name);
+       mailboxes_protocol = 
+               modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
+                                                               store_protocol,
+                                                               MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS);
+       if (mailboxes_protocol) {
+               new_window = GTK_WIDGET (modest_mailboxes_window_new (account_name));
+       } else {
+
+               new_window = GTK_WIDGET (modest_folder_window_new (NULL));
+       }
+
        registered = modest_window_mgr_register_window (modest_runtime_get_window_mgr (), 
        registered = modest_window_mgr_register_window (modest_runtime_get_window_mgr (), 
-                                                       MODEST_WINDOW (folder_window),
+                                                       MODEST_WINDOW (new_window),
                                                        MODEST_WINDOW (self));
 
        if (!registered) {
                                                        MODEST_WINDOW (self));
 
        if (!registered) {
-               gtk_widget_destroy (folder_window);
-               folder_window = NULL;
+               gtk_widget_destroy (new_window);
+               new_window = NULL;
        } else {
        } else {
-               modest_folder_window_set_account (MODEST_FOLDER_WINDOW (folder_window), account_name);
-               gtk_widget_show (folder_window);
+               if (!mailboxes_protocol) {
+                       modest_folder_window_set_account (MODEST_FOLDER_WINDOW (new_window), account_name);
+               }
+               gtk_widget_show (new_window);
        }
        g_free (account_name);
 }
        }
        g_free (account_name);
 }
index d0df4a9..dbf8fa4 100644 (file)
@@ -307,6 +307,8 @@ modest_mailboxes_window_new (const gchar *account)
                                    accel_key, accel_mods, 0);
        gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
 
                                    accel_key, accel_mods, 0);
        gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
 
+       modest_mailboxes_window_set_account (MODEST_MAILBOXES_WINDOW (self), account);
+
        return MODEST_WINDOW(self);
 }
 
        return MODEST_WINDOW(self);
 }