Visual feedback when there are unread answers to marked mails
authorColin Leroy <colin@colino.net>
Mon, 25 Nov 2002 15:38:06 +0000 (15:38 +0000)
committerColin Leroy <colin@colino.net>
Mon, 25 Nov 2002 15:38:06 +0000 (15:38 +0000)
12 files changed:
ChangeLog.claws
configure.in
src/folder.c
src/folder.h
src/folderview.c
src/main.c
src/procmsg.c
src/procmsg.h
src/summaryview.c
src/summaryview.h
src/utils.c
src/utils.h

index 4b28f19..1658624 100644 (file)
@@ -1,3 +1,18 @@
+2002-11-25 [colin]     0.8.6claws4
+
+       * src/utils.[ch]
+               Add slist_concat_unique(), function to merge
+               two GSList filtering dups
+       * src/folder.[ch]
+       * src/summaryview.[ch]
+       * src/folderview.c
+       * src/main.c
+               Add detection/update/display of unread answers
+               to marked mails
+       * src/procmsg.[ch]
+               Add procmsg_find_children()
+               Add procmsg_msg_has_marked_parent()
+
 2002-11-25 [colin]     0.8.6claws3
 
        * src/ssl_certificate.[ch]
index 0173091..2d92660 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws3
+EXTRA_VERSION=claws4
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 20035e2..58aaeb2 100644 (file)
@@ -207,6 +207,7 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
        item->mtime = 0;
        item->new = 0;
        item->unread = 0;
+       item->unreadmarked = 0;
        item->total = 0;
        item->last_num = -1;
        item->cache = NULL;
@@ -464,6 +465,7 @@ struct TotalMsgCount
 {
        guint new;
        guint unread;
+       guint unreadmarked;
        guint total;
 };
 
@@ -513,14 +515,15 @@ static void folder_count_total_msgs_func(FolderItem *item, gpointer data)
 
        count->new += item->new;
        count->unread += item->unread;
+       count->unreadmarked += item->unreadmarked;
        count->total += item->total;
 }
 
-void folder_count_total_msgs(guint *new, guint *unread, guint *total)
+void folder_count_total_msgs(guint *new, guint *unread, guint *unreadmarked, guint *total)
 {
        struct TotalMsgCount count;
 
-       count.new = count.unread = count.total = 0;
+       count.new = count.unread = count.unreadmarked = count.total = 0;
 
        debug_print("Counting total number of messages...\n");
 
@@ -528,6 +531,7 @@ void folder_count_total_msgs(guint *new, guint *unread, guint *total)
 
        *new = count.new;
        *unread = count.unread;
+       *unreadmarked = count.unreadmarked;
        *total = count.total;
 }
 
@@ -992,7 +996,7 @@ gint folder_item_scan(FolderItem *item)
 {
        Folder *folder;
        GSList *folder_list = NULL, *cache_list = NULL, *folder_list_cur, *cache_list_cur, *new_list = NULL;
-       guint newcnt = 0, unreadcnt = 0, totalcnt = 0;
+       guint newcnt = 0, unreadcnt = 0, totalcnt = 0, unreadmarkedcnt = 0;
        guint cache_max_num, folder_max_num, cache_cur_num, folder_cur_num;
        gboolean contentchange = FALSE;
     
@@ -1139,6 +1143,8 @@ gint folder_item_scan(FolderItem *item)
                                                newcnt++;
                                        if (MSG_IS_UNREAD(newmsginfo->flags) && !MSG_IS_IGNORE_THREAD(newmsginfo->flags))
                                                unreadcnt++;
+                                       if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
+                                               unreadmarkedcnt++;
                                        procmsg_msginfo_free(newmsginfo);
                                }                                       
 
@@ -1148,6 +1154,8 @@ gint folder_item_scan(FolderItem *item)
                                        newcnt++;
                                if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                                        unreadcnt++;
+                               if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+                                       unreadmarkedcnt++;
                        }
                        totalcnt++;
                        procmsg_msginfo_free(msginfo);
@@ -1193,6 +1201,8 @@ gint folder_item_scan(FolderItem *item)
                                        newcnt++;
                                if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                                        unreadcnt++;
+                               if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+                                       unreadmarkedcnt++;
                                totalcnt++;
                                procmsg_msginfo_free(msginfo);
                        }
@@ -1213,6 +1223,8 @@ gint folder_item_scan(FolderItem *item)
                                    newcnt++;
                                if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                                    unreadcnt++;
+                               if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+                                       unreadmarkedcnt++;
                                totalcnt++;
                                procmsg_msginfo_free(msginfo);
                                debug_print("Added newly found message %d to cache.\n", num);
@@ -1223,7 +1235,7 @@ gint folder_item_scan(FolderItem *item)
        item->new = newcnt;
        item->unread = unreadcnt;
        item->total = totalcnt;
-       
+       item->unreadmarked = unreadmarkedcnt;
        g_slist_free(new_list);
 
        folder_update_item(item, contentchange);
@@ -1463,6 +1475,8 @@ gint folder_item_add_msg(FolderItem *dest, const gchar *file,
                                dest->new++;
                        if (MSG_IS_UNREAD(msginfo->flags))
                                dest->unread++;
+                       if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+                               dest->unreadmarked++;
                        dest->total++;
                        dest->need_update = TRUE;
 
@@ -1665,6 +1679,8 @@ gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
                                dest->new++;
                        if (MSG_IS_UNREAD(newmsginfo->flags))
                                dest->unread++;
+                       if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
+                               dest->unreadmarked++;
                        dest->total++;
                        dest->need_update = TRUE;
 
@@ -1681,6 +1697,8 @@ gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
                                msginfo->folder->new--;
                        if (MSG_IS_UNREAD(msginfo->flags))
                                msginfo->folder->unread--;
+                       if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+                               msginfo->folder->unreadmarked--;
                        msginfo->folder->total--;
                        msginfo->folder->need_update = TRUE;
                }
@@ -1774,6 +1792,8 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                                        dest->new++;
                                if (MSG_IS_UNREAD(newmsginfo->flags))
                                        dest->unread++;
+                               if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
+                                       dest->unreadmarked++;
                                dest->total++;
                                dest->need_update = TRUE;
 
@@ -1806,6 +1826,8 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                                msginfo->folder->new--;
                        if (MSG_IS_UNREAD(msginfo->flags))
                                msginfo->folder->unread--;
+                       if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+                               msginfo->folder->unreadmarked--;
                        msginfo->folder->total--;                       
                        msginfo->folder->need_update = TRUE;
                }
@@ -1872,6 +1894,8 @@ gint folder_item_copy_msg(FolderItem *dest, MsgInfo *msginfo)
                                dest->new++;
                        if (MSG_IS_UNREAD(newmsginfo->flags))
                                dest->unread++;
+                       if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
+                               dest->unreadmarked++;
                        dest->total++;
                        dest->need_update = TRUE;
 
@@ -1961,6 +1985,8 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
                                        dest->new++;
                                if (MSG_IS_UNREAD(newmsginfo->flags))
                                        dest->unread++;
+                               if (MSG_IS_UNREAD(newmsginfo->flags) && procmsg_msg_has_marked_parent(newmsginfo))
+                                       dest->unreadmarked++;
                                dest->total++;
                                dest->need_update = TRUE;
 
@@ -1996,6 +2022,8 @@ gint folder_item_remove_msg(FolderItem *item, gint num)
                        item->new--;
                if (MSG_IS_UNREAD(msginfo->flags))
                        item->unread--;
+               if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+                       item->unreadmarked--;
                procmsg_msginfo_free(msginfo);
                msgcache_remove_msg(item->cache, num);
        }
@@ -2057,6 +2085,7 @@ gint folder_item_remove_all_msg(FolderItem *item)
 
                item->new = 0;
                item->unread = 0;
+               item->unreadmarked = 0;
                item->total = 0;
                item->need_update = TRUE;
        }
@@ -2128,7 +2157,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        gboolean ret_rcpt = FALSE, hidereadmsgs = FALSE; /* CLAWS */
        FolderSortKey sort_key = SORT_BY_NONE;
        FolderSortType sort_type = SORT_ASCENDING;
-       gint new = 0, unread = 0, total = 0;
+       gint new = 0, unread = 0, total = 0, unreadmarked = 0;
        time_t mtime = 0;
 
        g_return_val_if_fail(node->data != NULL, FALSE);
@@ -2168,6 +2197,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
                        new = atoi(attr->value);
                else if (!strcmp(attr->name, "unread"))
                        unread = atoi(attr->value);
+               else if (!strcmp(attr->name, "unreadmarked"))
+                       unreadmarked = atoi(attr->value);
                else if (!strcmp(attr->name, "total"))
                        total = atoi(attr->value);
                else if (!strcmp(attr->name, "no_sub"))
@@ -2225,6 +2256,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        item->mtime = mtime;
        item->new = new;
        item->unread = unread;
+       item->unreadmarked = unreadmarked;
        item->total = total;
        item->no_sub = no_sub;
        item->no_select = no_select;
@@ -2422,8 +2454,8 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                }
 
                fprintf(fp,
-                       " mtime=\"%lu\" new=\"%d\" unread=\"%d\" total=\"%d\"",
-                       item->mtime, item->new, item->unread, item->total);
+                       " mtime=\"%lu\" new=\"%d\" unread=\"%d\" unreadmarked=\"%d\" total=\"%d\"",
+                       item->mtime, item->new, item->unread, item->unreadmarked, item->total);
 
                if (item->account)
                        fprintf(fp, " account_id=\"%d\"",
index 4790d4a..4866ba4 100644 (file)
@@ -243,6 +243,7 @@ struct _FolderItem
        gint new;
        gint unread;
        gint total;
+       gint unreadmarked;
 
        gint last_num;
 
@@ -328,6 +329,7 @@ void   folder_func_to_all_folders   (FolderItemFunc function,
                                         gpointer data);
 void   folder_count_total_msgs (guint          *new,
                                 guint          *unread,
+                                guint          *unreadmarked,
                                 guint          *total);
 
 Folder     *folder_find_from_path              (const gchar    *path);
index cb04255..d78aab2 100644 (file)
@@ -1170,18 +1170,24 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                 prefs_common.display_folder_unread) {
 
                if (item->unread > 0)
-                       str = g_strdup_printf("%s (%d%s)", name, item->unread,
-                                             add_unread_mark ? "+" : "");
+                       str = g_strdup_printf("%s (%d%s%s)", name, item->unread,
+                                             add_unread_mark ? "+" : "", 
+                                             item->unreadmarked > 0 ? "!":"");
                else
                        str = g_strdup_printf("%s (+)", name);
                gtk_ctree_set_node_info(ctree, node, str, FOLDER_SPACING,
                                        xpm, mask, openxpm, openmask,
                                        FALSE, GTK_CTREE_ROW(node)->expanded);
                g_free(str);
-       } else
-               gtk_ctree_set_node_info(ctree, node, name, FOLDER_SPACING,
+       } else {
+               str = g_strdup_printf("%s%s", name, 
+                                     item->unreadmarked > 0 ? " (!)":"");
+       
+               gtk_ctree_set_node_info(ctree, node, str, FOLDER_SPACING,
                                        xpm, mask, openxpm, openmask,
                                        FALSE, GTK_CTREE_ROW(node)->expanded);
+               g_free(str);
+       }
        g_free(name);
 
        if (!item->parent) {
@@ -1207,7 +1213,7 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                use_color =
                        (item->new > 0) ||
                        (add_unread_mark &&
-                        folderview_have_new_children(folderview, node));
+                        folderview_have_new_children(folderview, node));       
        }
 
        gtk_ctree_node_set_foreground(ctree, node, NULL);
index 76ce038..c2d2c09 100644 (file)
@@ -763,10 +763,10 @@ static void lock_socket_input_cb(gpointer data,
        } else if (!strncmp(buf, "offline", 7)) {
                main_window_toggle_work_offline(mainwin, TRUE);
        } else if (!strncmp(buf, "status", 6)) {
-               guint new, unread, total;
+               guint new, unread, unreadmarked, total;
 
-               folder_count_total_msgs(&new, &unread, &total);
-               g_snprintf(buf, sizeof(buf), "%d %d %d\n", new, unread, total);
+               folder_count_total_msgs(&new, &unread, &unreadmarked, &total);
+               g_snprintf(buf, sizeof(buf), "%d %d %d %d\n", new, unread, unreadmarked, total);
                fd_write(sock, buf, strlen(buf));
        }
 
index aca7ca0..8508388 100644 (file)
@@ -51,7 +51,7 @@ struct _FlagInfo
 
 static GHashTable *procmsg_read_mark_file      (const gchar    *folder);
 void   procmsg_msginfo_write_flags             (MsgInfo        *msginfo);
-
+static void procmsg_update_unread_children (MsgInfo *info, gboolean newly_marked);
 
 GHashTable *procmsg_msg_hash_table_create(GSList *mlist)
 {
@@ -903,6 +903,7 @@ gint procmsg_send_queue(FolderItem *queue, gboolean save_msgs)
 
        return ret;
 }
+
 gint procmsg_remove_special_headers(const gchar *in, const gchar *out)
 {
        FILE *fp, *outfp;
@@ -1461,6 +1462,17 @@ void procmsg_msginfo_set_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmp
                item->need_update = TRUE;
        }
 
+       if (!MSG_IS_UNREAD(msginfo->flags) &&(perm_flags & MSG_UNREAD)
+       && procmsg_msg_has_marked_parent(msginfo)) {
+               item->unreadmarked++;
+               item->need_update = TRUE;
+       }
+       
+       if (!MSG_IS_MARKED(msginfo->flags) && (perm_flags & MSG_MARKED)) {
+               procmsg_update_unread_children(msginfo, TRUE);
+       }
+
+
        /* if ignore thread flag is set */
        if ((perm_flags & MSG_IGNORE_THREAD) && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
                if (MSG_IS_NEW(msginfo->flags) || (perm_flags & MSG_NEW)) {
@@ -1471,6 +1483,16 @@ void procmsg_msginfo_set_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmp
                        item->unread--;
                        item->need_update = TRUE;
                }
+               if ((perm_flags & MSG_UNREAD) || (MSG_IS_UNREAD(msginfo->flags)
+               && procmsg_msg_has_marked_parent(msginfo))) {
+                       item->unreadmarked--;
+                       item->need_update = TRUE;
+               }
+               if ((perm_flags & MSG_MARKED) || MSG_IS_MARKED(msginfo->flags)
+               && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+                       procmsg_update_unread_children(msginfo, FALSE);
+               }
+
        }
 
        if (MSG_IS_IMAP(msginfo->flags))
@@ -1506,6 +1528,18 @@ void procmsg_msginfo_unset_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgT
                item->unread--;
                item->need_update = TRUE;
        }
+       
+       if (MSG_IS_UNREAD(msginfo->flags) && (perm_flags & MSG_UNREAD)
+       && !MSG_IS_IGNORE_THREAD(msginfo->flags)
+       && procmsg_msg_has_marked_parent(msginfo)) {
+               item->unreadmarked--;
+               item->need_update = TRUE;
+       }
+
+       if (MSG_IS_MARKED(msginfo->flags) && (perm_flags & MSG_MARKED)
+       && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+               procmsg_update_unread_children(msginfo, FALSE);
+       }
 
        /* if ignore thread flag is unset */
        if ((perm_flags & MSG_IGNORE_THREAD) && MSG_IS_IGNORE_THREAD(msginfo->flags)) {
@@ -1517,6 +1551,15 @@ void procmsg_msginfo_unset_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgT
                        item->unread++;
                        item->need_update = TRUE;
                }
+               if (MSG_IS_UNREAD(msginfo->flags) && !(perm_flags & MSG_UNREAD)
+               && procmsg_msg_has_marked_parent(msginfo)) {
+                       item->unreadmarked++;
+                       item->need_update = TRUE;
+               }
+               if (MSG_IS_MARKED(msginfo->flags) && !(perm_flags & MSG_MARKED)) {
+                       procmsg_update_unread_children(msginfo, TRUE);
+               }
+
        }
 
        if (MSG_IS_IMAP(msginfo->flags))
@@ -1548,6 +1591,68 @@ void procmsg_msginfo_write_flags(MsgInfo *msginfo)
        g_free(destdir);
 }
 
+gboolean procmsg_msg_has_marked_parent (MsgInfo *info)
+{
+       MsgInfo *tmp;
+       g_return_val_if_fail(info != NULL, FALSE);
+       if (info != NULL && info->folder != NULL && info->inreplyto != NULL) {
+               tmp = folder_item_get_msginfo_by_msgid(info->folder, info->inreplyto);
+               if (tmp && MSG_IS_MARKED(tmp->flags)) {
+                       procmsg_msginfo_free(tmp);
+                       return TRUE;
+               } else if (tmp != NULL) {
+                       gboolean result = procmsg_msg_has_marked_parent(tmp);
+                       procmsg_msginfo_free(tmp);
+                       return result;
+               } else {
+                       return FALSE;
+               }
+       } else
+               return FALSE;
+}      
+
+GSList *procmsg_find_children (MsgInfo *info)
+{
+       GSList *children = NULL;
+       GSList *all, *cur;
+       
+       g_return_val_if_fail(info!=NULL, NULL);
+       if (info->msgid == NULL)
+               return NULL;
+       all = folder_item_get_msg_list(info->folder);
+       for (cur = all; cur != NULL; cur = g_slist_next(cur)) {
+               MsgInfo *tmp = (MsgInfo *)cur->data;
+               if (tmp->inreplyto && !strcmp(tmp->inreplyto, info->msgid)) {
+                       GSList *grand_children;
+                       children = g_slist_prepend(children, tmp);
+                       grand_children = procmsg_find_children(tmp);
+                       children = slist_concat_unique(children, grand_children);
+                       g_slist_free(grand_children);
+               }
+               if (tmp && tmp != info)
+                       procmsg_msginfo_free(tmp);
+       }
+       
+       return children;
+}
+
+static void procmsg_update_unread_children (MsgInfo *info, gboolean newly_marked)
+{
+       GSList *children = procmsg_find_children(info);
+       GSList *cur;
+       for (cur = children; cur != NULL; cur = g_slist_next(cur)) {
+               MsgInfo *tmp = (MsgInfo *)cur->data;
+               if(MSG_IS_UNREAD(tmp->flags) && !MSG_IS_IGNORE_THREAD(tmp->flags)) {
+                       if(newly_marked) 
+                               info->folder->unreadmarked++;
+                       else
+                               info->folder->unreadmarked--;
+                       info->folder->need_update = TRUE;
+               }
+               procmsg_msginfo_free(tmp);
+       }
+}
+
 /*
  * callback handling
  */
index f493b98..a2d844b 100644 (file)
@@ -290,4 +290,6 @@ void msginfo_update_item            (MsgInfo        *info);
 gint procmsg_remove_special_headers    (const gchar    *in, 
                                         const gchar    *out);
 
+gboolean procmsg_msg_has_marked_parent (MsgInfo        *info);
+GSList *procmsg_find_children          (MsgInfo        *info);
 #endif /* __PROCMSG_H__ */
index af792a9..3a335f1 100644 (file)
@@ -1751,6 +1751,10 @@ static void summary_set_marks_func(GtkCTree *ctree, GtkCTreeNode *node,
                summaryview->newmsgs++;
        if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread++;
+       if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
+       && procmsg_msg_has_marked_parent(msginfo))
+               summaryview->unreadmarked++;
+
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted++;
 
@@ -1778,6 +1782,9 @@ static void summary_update_status(SummaryView *summaryview)
                        summaryview->newmsgs++;
                if (MSG_IS_UNREAD(msginfo->flags)&& !MSG_IS_IGNORE_THREAD(msginfo->flags))
                        summaryview->unread++;
+               if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
+               && procmsg_msg_has_marked_parent(msginfo))
+                       summaryview->unreadmarked++;
                if (MSG_IS_DELETED(msginfo->flags))
                        summaryview->deleted++;
                if (MSG_IS_MOVE(msginfo->flags))
@@ -2338,6 +2345,9 @@ static void summary_display_msg_full(SummaryView *summaryview,
                        summaryview->newmsgs--;
                if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                        summaryview->unread--;
+               if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags) 
+               && procmsg_msg_has_marked_parent(msginfo))
+                       summaryview->unreadmarked--;
                if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
                        procmsg_msginfo_unset_flags
                                (msginfo, MSG_NEW | MSG_UNREAD, 0);
@@ -2647,6 +2657,25 @@ void summary_set_marks_selected(SummaryView *summaryview)
                summary_set_row_marks(summaryview, GTK_CTREE_NODE(cur->data));
 }
 
+static gboolean summary_update_unread_children (SummaryView *summaryview, MsgInfo *info, gboolean newly_marked)
+{
+       GSList *children = procmsg_find_children(info);
+       GSList *cur;
+       gboolean changed = FALSE;
+       for (cur = children; cur != NULL; cur = g_slist_next(cur)) {
+               MsgInfo *tmp = (MsgInfo *)cur->data;
+               if(MSG_IS_UNREAD(tmp->flags) && !MSG_IS_IGNORE_THREAD(tmp->flags)) {
+                       if(newly_marked) 
+                               summaryview->unreadmarked++;
+                       else
+                               summaryview->unreadmarked--;
+                       changed = TRUE;
+               }
+               procmsg_msginfo_free(tmp);
+       }
+       return changed;
+}
+
 static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
 {
        gboolean changed = FALSE;
@@ -2664,6 +2693,8 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
                summaryview->copied--;
                changed = TRUE;
        }
+       changed |= summary_update_unread_children (summaryview, msginfo, TRUE);
+
        if (changed && !prefs_common.immediate_exec) {
                msginfo->to_folder->op_count--;
                if (msginfo->to_folder->op_count == 0)
@@ -2733,6 +2764,9 @@ static void summary_mark_row_as_read(SummaryView *summaryview,
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread--;
+       if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
+       && procmsg_msg_has_marked_parent(msginfo))
+               summaryview->unreadmarked--;
 
        procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
        summary_set_row_marks(summaryview, row);
@@ -2790,6 +2824,10 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
        if (!MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread++;
 
+       if (!MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
+       && procmsg_msg_has_marked_parent(msginfo))
+               summaryview->unreadmarked++;
+
        procmsg_msginfo_unset_flags(msginfo, MSG_REPLIED | MSG_FORWARDED, 0);
        procmsg_msginfo_set_flags(msginfo, MSG_UNREAD, 0);
        debug_print("Message %d is marked as unread\n",
@@ -2883,6 +2921,8 @@ static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
                summaryview->copied--;
                changed = TRUE;
        }
+       changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
+
        if (changed && !prefs_common.immediate_exec) {
                msginfo->to_folder->op_count--;
                if (msginfo->to_folder->op_count == 0)
@@ -3045,6 +3085,8 @@ static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
                summaryview->copied--;
                changed = TRUE;
        }
+       changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
+
        if (changed && !prefs_common.immediate_exec) {
                msginfo->to_folder->op_count--;
                if (msginfo->to_folder->op_count == 0)
@@ -4675,8 +4717,7 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
        switch (column < 0 ? column : summaryview->col_state[column].type) {
        case S_COL_MARK:
                if (MSG_IS_MARKED(msginfo->flags)) {
-                       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, 0);
-                       summary_set_row_marks(summaryview, row);
+                       summary_unmark_row(summaryview, row);
                } else
                        summary_mark_row(summaryview, row);
                break;
@@ -5097,6 +5138,8 @@ static void summary_ignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpoin
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags))
                summaryview->unread--;
+       if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+               summaryview->unreadmarked--;
 
        procmsg_msginfo_set_flags(msginfo, MSG_IGNORE_THREAD, 0);
 
@@ -5129,6 +5172,8 @@ static void summary_unignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpo
                summaryview->newmsgs++;
        if (MSG_IS_UNREAD(msginfo->flags))
                summaryview->unread++;
+       if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
+               summaryview->unreadmarked++;
 
        procmsg_msginfo_unset_flags(msginfo, MSG_IGNORE_THREAD, 0);
 
index 5bcaad5..0c3f293 100644 (file)
@@ -146,6 +146,7 @@ struct _SummaryView
        /* current message status */
        gint   newmsgs;
        gint   unread;
+       gint   unreadmarked;
        gint   messages;
        off_t  total_size;
        gint   deleted;
index 86cf395..6cb751a 100644 (file)
@@ -72,6 +72,24 @@ void slist_free_strings(GSList *list)
        }
 }
 
+GSList *slist_concat_unique (GSList *first, GSList *second)
+{
+       GSList *tmp, *ret;
+       if (first == NULL) {
+               if (second == NULL)
+                       return NULL;
+               else 
+                       return second;
+       } else if (second == NULL)
+               return first;
+       ret = first;
+       for (tmp = second; tmp != NULL; tmp = g_slist_next(tmp)) {
+               if (g_slist_find(ret, tmp->data) == NULL)
+                       ret = g_slist_prepend(ret, tmp->data);
+       }
+       return ret;
+}
 static void hash_free_strings_func(gpointer key, gpointer value, gpointer data)
 {
        g_free(key);
index 387e26a..883223a 100644 (file)
@@ -247,6 +247,8 @@ gchar *strrchr_with_skip_quote              (const gchar    *str,
                                         gint            c);
 void extract_address                   (gchar          *str);
 
+GSList *slist_concat_unique            (GSList         *first,
+                                        GSList         *second);
 GSList *address_list_append            (GSList         *addr_list,
                                         const gchar    *str);
 GSList *references_list_append         (GSList         *msgid_list,