2005-08-10 [colin] 1.9.13cvs29
authorColin Leroy <colin@colino.net>
Wed, 10 Aug 2005 06:20:49 +0000 (06:20 +0000)
committerColin Leroy <colin@colino.net>
Wed, 10 Aug 2005 06:20:49 +0000 (06:20 +0000)
* src/folder.c
* src/folderutils.c
* src/folderview.c
* src/imap_gtk.c
* src/mainwindow.c
* src/mh_gtk.c
* src/procmsg.c
* src/summaryview.c
Optimize folder_has_parent_of_type
Prevent moving special sub-folders from contextual menus
Rework message a bit ("Empty all messages" -> "Delete all
messages")
Fix bug #780 (MSexchange IMAP - using IMAP "Sent Items"
and "Deleted Items" folders)

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/folder.c
src/folderutils.c
src/folderview.c
src/imap_gtk.c
src/mainwindow.c
src/mh_gtk.c
src/procmsg.c
src/summaryview.c

index c422d2d..b616c70 100644 (file)
@@ -1,3 +1,20 @@
+2005-08-10 [colin]     1.9.13cvs29
+
+       * src/folder.c
+       * src/folderutils.c
+       * src/folderview.c
+       * src/imap_gtk.c
+       * src/mainwindow.c
+       * src/mh_gtk.c
+       * src/procmsg.c
+       * src/summaryview.c
+               Optimize folder_has_parent_of_type
+               Prevent moving special sub-folders from contextual menus
+               Rework message a bit ("Empty all messages" -> "Delete all
+               messages")
+               Fix bug #780 (MSexchange IMAP - using IMAP "Sent Items" 
+               and "Deleted Items" folders)
+
 2005-08-08 [colin]     1.9.13cvs28
 
        * src/summaryview.c
index 34165a1..fd6492d 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.213.2.48 -r 1.213.2.49 src/folder.c;  ) > 1.9.13cvs26.patchset
 ( cvs diff -u -r 1.395.2.107 -r 1.395.2.108 src/summaryview.c;  ) > 1.9.13cvs27.patchset
 ( cvs diff -u -r 1.395.2.108 -r 1.395.2.109 src/summaryview.c;  cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/prefs_summaries.c;  ) > 1.9.13cvs28.patchset
+( cvs diff -u -r 1.213.2.49 -r 1.213.2.50 src/folder.c;  cvs diff -u -r 1.3.2.6 -r 1.3.2.7 src/folderutils.c;  cvs diff -u -r 1.207.2.55 -r 1.207.2.56 src/folderview.c;  cvs diff -u -r 1.1.2.17 -r 1.1.2.18 src/imap_gtk.c;  cvs diff -u -r 1.274.2.53 -r 1.274.2.54 src/mainwindow.c;  cvs diff -u -r 1.2.2.10 -r 1.2.2.11 src/mh_gtk.c;  cvs diff -u -r 1.150.2.34 -r 1.150.2.35 src/procmsg.c;  cvs diff -u -r 1.395.2.109 -r 1.395.2.110 src/summaryview.c;  ) > 1.9.13cvs29.patchset
index 1b16606..a44bb07 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=28
+EXTRA_VERSION=29
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index fd2b70d..204b360 100644 (file)
@@ -295,6 +295,7 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
        item->apply_sub = FALSE;
        item->mark_queue = NULL;
        item->data = NULL;
+       item->parent_stype = -1;
 
        item->prefs = folder_item_prefs_new();
 
@@ -3559,6 +3560,14 @@ gboolean folder_has_parent_of_type(FolderItem *item,
                                          SpecialFolderItemType type) 
 {
        FolderItem *cur = item;
+
+       /* if we already know it, make it short */
+       if (item->parent_stype != -1) {
+               return (item->parent_stype == type);
+       }
+       
+       /* if we don't, find the type from the first possible parent,
+        * and set our parent type to be faster next time */
        while (cur) {
                if (cur->stype == type || cur->parent_stype == type) {
                        item->parent_stype = type;
@@ -3566,6 +3575,53 @@ gboolean folder_has_parent_of_type(FolderItem *item,
                }
                cur = folder_item_parent(cur);
        }
+       
+       /* if we didn't match what was asked, we didn't return. If our
+        * parent type is unknown, we may as well find it now to be faster
+        * later. */
+       if (item->parent_stype == -1) {
+               cur = item;
+               while (cur) {
+                       /* here's an exception: Inbox subfolders are normal. */
+                       if (item->parent_stype == -1 && cur->stype == F_INBOX 
+                       && item != cur) {
+                               debug_print("set item %s parent type to %d "
+                                       "even if %s is F_INBOX\n",
+                                       item->path, 0, cur->path);
+                               item->parent_stype = F_NORMAL;
+                               break;
+                       }
+                       /* ah, we know this parent's parent's type, we may as 
+                        * well copy it instead of going up the full way */
+                       if (cur->parent_stype != -1) {
+                               item->parent_stype = cur->parent_stype;
+                               debug_print("set item %s parent type to %d "
+                                       "from %s's parent type\n",
+                                       item->path, cur->parent_stype, 
+                                       cur->path);
+                               break;
+                       }
+                       /* we found a parent that has a special type. That's 
+                        * our parent type. */
+                       if (cur->stype != F_NORMAL) {
+                               debug_print("set item %s parent type to %d "
+                                       "from %s's type\n",
+                                       item->path, cur->stype, cur->path);
+                               cur->parent_stype = cur->stype;
+                               item->parent_stype = cur->stype;
+                               break;
+                       }
+                       /* if we didn't find anything, go up once more */
+                       cur = folder_item_parent(cur);
+               }
+               /* as we still didn't find anything, our parents must all be 
+                * normal. */
+               if (item->parent_stype == -1) {
+                       debug_print("set item %s to 0 from default\n", 
+                               item->path);
+                       item->parent_stype = F_NORMAL;
+               }
+       }
        return FALSE;
 }
 
index ebf63a5..32f7fe0 100644 (file)
@@ -22,6 +22,8 @@
 #include "utils.h"
 #include "prefs_common.h"
 #include "folderutils.h"
+#include "prefs_account.h"
+#include "account.h"
 
 gint folderutils_delete_duplicates(FolderItem *item,
                                   DeleteDuplicatesMode mode)
@@ -65,9 +67,18 @@ gint folderutils_delete_duplicates(FolderItem *item,
        if (duplist) {
                switch (mode) {
                case DELETE_DUPLICATES_REMOVE: {
-                       FolderItem *trash = item->folder->trash;
+                       FolderItem *trash = NULL;
+                       gboolean in_trash = FALSE;
+                       PrefsAccount *ac;
 
-                       if (folder_has_parent_of_type(item, F_TRASH) || trash == NULL)
+                       if (NULL != (ac = account_find_from_item(item))) {
+                               trash = account_get_special_folder(ac, F_TRASH);
+                               in_trash = (trash != NULL && trash == item);
+                       }
+                       if (trash == NULL)
+                               trash = item->folder->trash;
+
+                       if (folder_has_parent_of_type(item, F_TRASH) || trash == NULL || in_trash)
                                folder_item_remove_msgs(item, duplist);
                        else                    
                                folder_item_move_msgs(trash, duplist);
index 21e6138..7d62f10 100644 (file)
@@ -1572,6 +1572,8 @@ static gboolean folderview_button_pressed(GtkWidget *ctree, GdkEventButton *even
        FolderViewPopup *fpopup;
        GtkItemFactory *fpopup_factory;
        GtkWidget *popup;
+       FolderItem *special_trash = NULL;
+       PrefsAccount *ac;
 
        if (!event) return FALSE;
 
@@ -1636,11 +1638,14 @@ static gboolean folderview_button_pressed(GtkWidget *ctree, GdkEventButton *even
        if (fpopup->set_sensitivity != NULL)
                fpopup->set_sensitivity(fpopup_factory, item);
 
-       if (item == folder->trash &&
+       if (NULL != (ac = account_find_from_item(item)))
+               special_trash = account_get_special_folder(ac, F_TRASH);
+
+       if ((item == folder->trash || item == special_trash) &&
            gtk_item_factory_get_item(fpopup_factory, "/Empty trash...") == NULL) {
                gtk_item_factory_create_item(fpopup_factory, &folder_view_trash_popup_entries[0], folderview, 1);
                gtk_item_factory_create_item(fpopup_factory, &folder_view_trash_popup_entries[1], folderview, 1);
-       } else if (item != folder->trash) {
+       } else if (item != folder->trash && (special_trash == NULL || item != special_trash)) {
                gtk_item_factory_delete_entry(fpopup_factory, &folder_view_trash_popup_entries[0]);
                gtk_item_factory_delete_entry(fpopup_factory, &folder_view_trash_popup_entries[1]);
        }
@@ -1653,7 +1658,7 @@ static gboolean folderview_button_pressed(GtkWidget *ctree, GdkEventButton *even
                 folderview->selected == folderview->opened);
        SET_SENS("/Properties...", item->node->parent != NULL);
        SET_SENS("/Processing...", item->node->parent != NULL);
-       if (item == folder->trash) {
+       if (item == folder->trash || item == special_trash) {
                GSList *msglist = folder_item_get_msg_list(item);
                SET_SENS("/Empty trash...", msglist != NULL);
                procmsg_msg_list_free(msglist);
@@ -1922,15 +1927,21 @@ static void folderview_empty_trash_cb(FolderView *folderview, guint action,
        GSList *mlist = NULL;
        GSList *cur = NULL;
        if (!folderview->selected) return;
-       
+       FolderItem *special_trash = NULL;
+       PrefsAccount *ac;
+
        item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
-       if (item != item->folder->trash) return;
+
+       if (NULL != (ac = account_find_from_item(item)))
+               special_trash = account_get_special_folder(ac, F_TRASH);
+
+       if (item != item->folder->trash && item != special_trash) return;
        
        if (prefs_common.ask_on_clean) {
                if (alertpanel(_("Empty trash"),
-                              _("Empty all messages in trash?"),
+                              _("Delete all messages in trash?"),
                               GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
                        return;
        }
index d0a6ec8..27e8c44 100644 (file)
@@ -92,12 +92,19 @@ void imap_gtk_init(void)
 
 static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
 {
+       gboolean folder_is_normal = 
+                       item != NULL &&
+                       item->stype == F_NORMAL &&
+                       !folder_has_parent_of_type(item, F_OUTBOX) &&
+                       !folder_has_parent_of_type(item, F_DRAFT) &&
+                       !folder_has_parent_of_type(item, F_QUEUE) &&
+                       !folder_has_parent_of_type(item, F_TRASH);
 #define SET_SENS(name, sens) \
        menu_set_sensitive(factory, name, sens)
 
        SET_SENS("/Create new folder...",   TRUE);
        SET_SENS("/Rename folder...",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
-       SET_SENS("/Move folder...",         item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("/Move folder...",         folder_is_normal && folder_item_parent(item) != NULL);
        SET_SENS("/Delete folder",          item->stype == F_NORMAL && folder_item_parent(item) != NULL);
 
        SET_SENS("/Check for new messages", folder_item_parent(item) == NULL);
index f2add11..fa0a6aa 100644 (file)
@@ -1663,13 +1663,16 @@ void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
                folder = FOLDER(list->data);
                if (folder && folder->trash && folder->trash->total_msgs > 0)
                        has_trash++;
+               if (folder->account && folder->account->set_trash_folder && 
+                   folder_find_item_from_identifier(folder->account->trash_folder))
+                       has_trash++;
        }
 
        if (!has_trash) return;
        
        if (confirm) {
                if (alertpanel(_("Empty trash"),
-                              _("Empty all messages in trash?"),
+                              _("Delete all messages in trash folders?"),
                               GTK_STOCK_YES, GTK_STOCK_NO, NULL)
                    != G_ALERTDEFAULT)
                        return;
index a66d387..f234489 100644 (file)
@@ -83,12 +83,19 @@ void mh_gtk_init(void)
 
 static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
 {
+       gboolean folder_is_normal = 
+                       item != NULL &&
+                       item->stype == F_NORMAL &&
+                       !folder_has_parent_of_type(item, F_OUTBOX) &&
+                       !folder_has_parent_of_type(item, F_DRAFT) &&
+                       !folder_has_parent_of_type(item, F_QUEUE) &&
+                       !folder_has_parent_of_type(item, F_TRASH);
 #define SET_SENS(name, sens) \
        menu_set_sensitive(factory, name, sens)
 
        SET_SENS("/Create new folder...",   TRUE);
        SET_SENS("/Rename folder...",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
-       SET_SENS("/Move folder...",         item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("/Move folder...",         folder_is_normal && folder_item_parent(item) != NULL);
        SET_SENS("/Delete folder",          item->stype == F_NORMAL && folder_item_parent(item) != NULL);
 
        SET_SENS("/Check for new messages", folder_item_parent(item) == NULL);
index 9559de6..4f22350 100644 (file)
@@ -670,8 +670,13 @@ void procmsg_empty_all_trash(void)
        GList *cur;
 
        for (cur = folder_get_list(); cur != NULL; cur = cur->next) {
-               trash = FOLDER(cur->data)->trash;
+               Folder *folder = FOLDER(cur->data);
+               trash = folder->trash;
                procmsg_empty_trash(trash);
+               if (folder->account && folder->account->set_trash_folder && 
+                   folder_find_item_from_identifier(folder->account->trash_folder))
+                       procmsg_empty_trash(
+                               folder_find_item_from_identifier(folder->account->trash_folder));
        }
 }
 
index 92be606..2257266 100644 (file)
@@ -3131,12 +3131,16 @@ void summary_delete(SummaryView *summaryview)
 
 void summary_delete_trash(SummaryView *summaryview)
 {
-       FolderItem *to_folder;
-
+       FolderItem *to_folder = NULL;
+       PrefsAccount *ac;
        if (!summaryview->folder_item ||
            FOLDER_TYPE(summaryview->folder_item->folder) == F_NEWS) return;
+       
+       if (NULL != (ac = account_find_from_item(summaryview->folder_item)))
+               to_folder = account_get_special_folder(ac, F_TRASH);
 
-       to_folder = summaryview->folder_item->folder->trash;
+       if (to_folder == NULL)
+               to_folder = summaryview->folder_item->folder->trash;
        
        if (to_folder == NULL || to_folder == summaryview->folder_item)
                summary_delete(summaryview);