}
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;
}
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));