Now we check the accounts for sorting special folders in folder view
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 27 Nov 2008 11:01:32 +0000 (11:01 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 27 Nov 2008 11:01:32 +0000 (11:01 +0000)
pmo-drop-split-view-r6437

src/widgets/modest-folder-view.c

index 7aa4b08..ab051e1 100644 (file)
@@ -1681,24 +1681,48 @@ get_cmp_rows_type_pos (GObject *folder)
 }
 
 static gint
-get_cmp_pos (TnyFolderType t)
+get_cmp_pos (TnyFolderType t, TnyFolder *folder_store)
 {
+       TnyAccount *account;
+       gboolean is_special;
        /* Inbox, Outbox, Drafts, Sent, User */
        /* 0, 1, 2, 3, 4 */
 
+       if (!TNY_IS_FOLDER (folder_store))
+               return 4;
        switch (t) {
        case TNY_FOLDER_TYPE_INBOX:
-               return 0;
-               break;
+       {
+               account = tny_folder_get_account (folder_store);
+               is_special = (get_cmp_rows_type_pos (G_OBJECT (account)) == 0);
+               g_object_unref (account);
+               return is_special?0:4;
+       }
+       break;
        case TNY_FOLDER_TYPE_OUTBOX:
-               return 1;
-               break;
+       {
+               account = tny_folder_get_account (folder_store);
+               is_special = (get_cmp_rows_type_pos (G_OBJECT (account)) == 1);
+               g_object_unref (account);
+               return is_special?1:4;
+       }
+       break;
        case TNY_FOLDER_TYPE_DRAFTS:
-               return 2;
-               break;
+       {
+               account = tny_folder_get_account (folder_store);
+               is_special = (get_cmp_rows_type_pos (G_OBJECT (account)) == 1);
+               g_object_unref (account);
+               return is_special?2:4;
+       }
+       break;
        case TNY_FOLDER_TYPE_SENT:
-               return 3;
-               break;
+       {
+               account = tny_folder_get_account (folder_store);
+               is_special = (get_cmp_rows_type_pos (G_OBJECT (account)) == 1);
+               g_object_unref (account);
+               return is_special?3:4;
+       }
+       break;
        default:
                return 4;
        }
@@ -1798,23 +1822,10 @@ cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2,
        if (!folder1 || !folder2)
                goto finish;
 
-       /* First sort by type. First the special folders, then the archives */
-       cmp = get_cmp_pos (type) - get_cmp_pos (type2);
-       if (cmp != 0) {
-               /* Special folders from remote accounts (Drafts,
-                  Sentbox...) except Inbox must not be listed at the
-                  beginning but inside their accounts as the other
-                  normal folders */
-               if (cmp < 0) {
-                       if ((type == TNY_FOLDER_TYPE_INBOX) ||
-                           !modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (folder1)))
-                               goto finish;
-               } else {
-                       if ((type2 == TNY_FOLDER_TYPE_INBOX) ||
-                           !modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (folder2)))
-                               goto finish;
-               }
-       }
+       /* Sort by type. First the special folders, then the archives */
+       cmp = get_cmp_pos (type, (TnyFolder *) folder1) - get_cmp_pos (type2, (TnyFolder *) folder2);
+       if (cmp != 0)
+               goto finish;
 
        /* Now we sort using the account of each folder */
        cmp = compare_accounts (TNY_FOLDER_STORE (folder1), TNY_FOLDER_STORE (folder2));