0.8.8claws65
authorChristoph Hohmann <reboot@gmx.ch>
Tue, 7 Jan 2003 22:48:35 +0000 (22:48 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Tue, 7 Jan 2003 22:48:35 +0000 (22:48 +0000)
* src/folder.c
        fix update for source folder when moving messages
* src/procmsg.[ch]
* src/summaryview.c
        use function to set to_folder for message infos and
        automatically update the op_count for old and new
        folder

ChangeLog.claws
configure.in
src/folder.c
src/procmsg.c
src/procmsg.h
src/summaryview.c

index 657c754..716898e 100644 (file)
@@ -1,4 +1,14 @@
-2003-01-°7 [melvin]    0.8.8claws64
+2003-01-07 [christoph] 0.8.8claws65
+
+       * src/folder.c
+               fix update for source folder when moving messages
+       * src/procmsg.[ch]
+       * src/summaryview.c
+               use function to set to_folder for message infos and
+               automatically update the op_count for old and new
+               folder
+
+2003-01-07 [melvin]    0.8.8claws64
 
        * src/prefs_actions.c
                Fixed bug where an '%p' Action on a displayed image crashed 
index 48bab4c..5fdf286 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws64
+EXTRA_VERSION=claws65
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index bfac64b..6b65078 100644 (file)
@@ -1853,7 +1853,7 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                        if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
                                msginfo->folder->unreadmarked--;
                        msginfo->folder->total--;                       
-                       folder_item_update(dest, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
+                       folder_item_update(msginfo->folder, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
                }
 
                l2 = g_slist_next(l2);
index f0f84ad..ba12921 100644 (file)
@@ -659,6 +659,8 @@ void procmsg_move_messages(GSList *mlist)
 
        if (!mlist) return;
 
+       folder_item_update_freeze();
+
        for (cur = mlist; cur != NULL; cur = cur->next) {
                msginfo = (MsgInfo *)cur->data;
                if (!dest) {
@@ -673,12 +675,15 @@ void procmsg_move_messages(GSList *mlist)
                        dest = msginfo->to_folder;
                        movelist = g_slist_append(movelist, msginfo);
                }
+               procmsg_msginfo_set_to_folder(msginfo, NULL);
        }
 
        if (movelist) {
                folder_item_move_msgs_with_dest(dest, movelist);
                g_slist_free(movelist);
        }
+
+       folder_item_update_thaw();
 }
 
 void procmsg_copy_messages(GSList *mlist)
@@ -689,14 +694,7 @@ void procmsg_copy_messages(GSList *mlist)
 
        if (!mlist) return;
 
-       /* 
-       
-       Horrible: Scanning 2 times for every copy!
-
-       hash = procmsg_to_folder_hash_table_create(mlist);
-       folder_item_scan_foreach(hash);
-       g_hash_table_destroy(hash);
-       */
+       folder_item_update_freeze();
 
        for (cur = mlist; cur != NULL; cur = cur->next) {
                msginfo = (MsgInfo *)cur->data;
@@ -712,12 +710,15 @@ void procmsg_copy_messages(GSList *mlist)
                        dest = msginfo->to_folder;
                        copylist = g_slist_append(copylist, msginfo);
                }
+               procmsg_msginfo_set_to_folder(msginfo, NULL);
        }
 
        if (copylist) {
                folder_item_copy_msgs_with_dest(dest, copylist);
                g_slist_free(copylist);
        }
+
+       folder_item_update_thaw();
 }
 
 gchar *procmsg_get_message_file_path(MsgInfo *msginfo)
@@ -1114,11 +1115,11 @@ MsgInfo *procmsg_msginfo_get_full_info(MsgInfo *msginfo)
        full_msginfo->size = msginfo->size;
        full_msginfo->mtime = msginfo->mtime;
        full_msginfo->folder = msginfo->folder;
-       full_msginfo->to_folder = msginfo->to_folder;
 #if USE_GPGME
        full_msginfo->plaintext_file = g_strdup(msginfo->plaintext_file);
        full_msginfo->decryption_failed = msginfo->decryption_failed;
 #endif
+       procmsg_msginfo_set_to_folder(full_msginfo, msginfo->to_folder);
 
        return full_msginfo;
 }
@@ -1131,6 +1132,11 @@ void procmsg_msginfo_free(MsgInfo *msginfo)
        if (msginfo->refcnt > 0)
                return;
 
+       if (msginfo->to_folder) {
+               msginfo->to_folder->op_count--;
+               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+       }
+
        g_free(msginfo->fromspace);
        g_free(msginfo->references);
        g_free(msginfo->returnreceiptto);
@@ -1708,3 +1714,22 @@ static void procmsg_update_unread_children(MsgInfo *info, gboolean newly_marked)
                procmsg_msginfo_free(tmp);
        }
 }
+
+/**
+ * Set the destination folder for a copy or move operation
+ *
+ * \param msginfo The message which's destination folder is changed
+ * \param to_folder The destination folder for the operation
+ */
+void procmsg_msginfo_set_to_folder(MsgInfo *msginfo, FolderItem *to_folder)
+{
+       if(msginfo->to_folder != NULL) {
+               msginfo->to_folder->op_count--;
+               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+       }
+       msginfo->to_folder = to_folder;
+       if(to_folder != NULL) {
+               to_folder->op_count++;
+               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+       }
+}
index 71688b1..536c0e5 100644 (file)
@@ -294,4 +294,6 @@ gboolean procmsg_msg_has_flagged_parent     (MsgInfo        *info,
                                         MsgPermFlags    perm_flags);
 gboolean procmsg_msg_has_marked_parent (MsgInfo        *info);
 GSList *procmsg_find_children          (MsgInfo        *info);
+void procmsg_msginfo_set_to_folder     (MsgInfo        *msginfo,
+                                        FolderItem     *to_folder);
 #endif /* __PROCMSG_H__ */
index 3d2f36e..e2d3763 100644 (file)
@@ -2784,20 +2784,14 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
        if (MSG_IS_MOVE(msginfo->flags)) {
                summaryview->moved--;
                changed = TRUE;
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
        }
        if (MSG_IS_COPY(msginfo->flags)) {
                summaryview->copied--;
                changed = TRUE;
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
        }
        changed |= summary_update_unread_children (summaryview, msginfo, TRUE);
 
-       msginfo->to_folder = NULL;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
        procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
        procmsg_msginfo_set_flags(msginfo, MSG_MARKED, 0);
        summary_set_row_marks(summaryview, row);
@@ -2822,12 +2816,7 @@ static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
                summaryview->copied--;
                changed = TRUE;
        }
-       if (changed && !prefs_common.immediate_exec) {
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-       }
-       msginfo->to_folder = NULL;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
        procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
        procmsg_msginfo_set_flags(msginfo, MSG_LOCKED, 0);
        summary_set_row_marks(summaryview, row);
@@ -2911,7 +2900,7 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        if (MSG_IS_DELETED(msginfo->flags)) {
-               msginfo->to_folder = NULL;
+               procmsg_msginfo_set_to_folder(msginfo, NULL);
                procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, 0);
                summaryview->deleted--;
        }
@@ -3010,20 +2999,14 @@ static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
        if (MSG_IS_MOVE(msginfo->flags)) {
                summaryview->moved--;
                changed = TRUE;
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
        }
        if (MSG_IS_COPY(msginfo->flags)) {
                summaryview->copied--;
                changed = TRUE;
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
        }
        changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
 
-       msginfo->to_folder = NULL;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, MSG_MOVE | MSG_COPY);
        procmsg_msginfo_set_flags(msginfo, MSG_DELETED, 0);
        summaryview->deleted++;
@@ -3176,26 +3159,16 @@ static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
        if (MSG_IS_MOVE(msginfo->flags)) {
-               if (!prefs_common.immediate_exec) {
-                       msginfo->to_folder->op_count--;
-                       if (msginfo->to_folder->op_count == 0)
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-               }
                summaryview->moved--;
                changed = TRUE;
        }
        if (MSG_IS_COPY(msginfo->flags)) {
-               if (!prefs_common.immediate_exec) {
-                       msginfo->to_folder->op_count--;
-                       if (msginfo->to_folder->op_count == 0)
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-               }
                summaryview->copied--;
                changed = TRUE;
        }
        changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
 
-       msginfo->to_folder = NULL;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE | MSG_COPY);
        summary_set_row_marks(summaryview, row);
 
@@ -3217,43 +3190,25 @@ void summary_unmark(SummaryView *summaryview)
 static void summary_move_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                                FolderItem *to_folder)
 {
-       gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
 
        g_return_if_fail(to_folder != NULL);
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
-       if (MSG_IS_MOVE(msginfo->flags)) {
-               if (!prefs_common.immediate_exec) {
-                       msginfo->to_folder->op_count--;
-                       if (msginfo->to_folder->op_count == 0) {
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-                               changed = TRUE;
-                       }
-               }
-       }
-       msginfo->to_folder = to_folder;
+       procmsg_msginfo_set_to_folder(msginfo, to_folder);
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
        if (MSG_IS_COPY(msginfo->flags)) {
                summaryview->copied--;
-               if (!prefs_common.immediate_exec)
-                       msginfo->to_folder->op_count--;
        }
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_COPY);
        if (!MSG_IS_MOVE(msginfo->flags)) {
                procmsg_msginfo_set_flags(msginfo, 0, MSG_MOVE);
                summaryview->moved++;
-               changed = TRUE;
        }
        if (!prefs_common.immediate_exec) {
                summary_set_row_marks(summaryview, row);
-               if (changed) {
-                       msginfo->to_folder->op_count++;
-                       if (msginfo->to_folder->op_count == 1)
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-               }
        }
 
        debug_print("Message %d is set to move to %s\n",
@@ -3312,42 +3267,25 @@ void summary_move_to(SummaryView *summaryview)
 static void summary_copy_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                                FolderItem *to_folder)
 {
-       gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
 
        g_return_if_fail(to_folder != NULL);
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
-       if (MSG_IS_COPY(msginfo->flags)) {
-               if (!prefs_common.immediate_exec) {
-                       msginfo->to_folder->op_count--;
-                       if (msginfo->to_folder->op_count == 0) {
-                               changed = TRUE;
-                       }
-               }
-       }
-       msginfo->to_folder = to_folder;
+       procmsg_msginfo_set_to_folder(msginfo, to_folder);
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
        if (MSG_IS_MOVE(msginfo->flags)) {
                summaryview->moved--;
-               if (!prefs_common.immediate_exec)
-                       msginfo->to_folder->op_count--;
        }
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE);
        if (!MSG_IS_COPY(msginfo->flags)) {
                procmsg_msginfo_set_flags(msginfo, 0, MSG_COPY);
                summaryview->copied++;
-               changed = TRUE;
        }
        if (!prefs_common.immediate_exec) {
                summary_set_row_marks(summaryview, row);
-               if (changed) {
-                       msginfo->to_folder->op_count++;
-                       if (msginfo->to_folder->op_count == 1)
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-               }
        }
 
        debug_print("Message %d is set to copy to %s\n",
@@ -3630,10 +3568,6 @@ static void summary_execute_move_func(GtkCTree *ctree, GtkCTreeNode *node,
        msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
 
        if (msginfo && MSG_IS_MOVE(msginfo->flags) && msginfo->to_folder) {
-               if (!prefs_common.immediate_exec &&
-                   msginfo->to_folder->op_count > 0)
-                       msginfo->to_folder->op_count--;
-
                summaryview->mlist =
                        g_slist_append(summaryview->mlist, msginfo);
                gtk_ctree_node_set_row_data(ctree, node, NULL);
@@ -3671,10 +3605,6 @@ static void summary_execute_copy_func(GtkCTree *ctree, GtkCTreeNode *node,
        msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
 
        if (msginfo && MSG_IS_COPY(msginfo->flags) && msginfo->to_folder) {
-               if (!prefs_common.immediate_exec &&
-                   msginfo->to_folder->op_count > 0)
-                       msginfo->to_folder->op_count--;
-
                summaryview->mlist =
                        g_slist_append(summaryview->mlist, msginfo);