From 3408495144e731c76aa54d13c3d3affb515f4a41 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 16 Jun 2006 07:56:58 +0000 Subject: added 'Mark all read' to the folder context menu. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1082 ee746299-78ed-0310-b773-934348b2243d --- libsylph/procmsg.c | 34 ++++++++++++++++++++++++++++++++++ libsylph/procmsg.h | 1 + 2 files changed, 35 insertions(+) (limited to 'libsylph') diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c index 3a47da3d..4cb56811 100644 --- a/libsylph/procmsg.c +++ b/libsylph/procmsg.c @@ -380,6 +380,40 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item) g_hash_table_destroy(mark_table); } +static void mark_all_read_func(gpointer key, gpointer value, gpointer data) +{ + MSG_UNSET_PERM_FLAGS(*((MsgFlags *)value), MSG_NEW|MSG_UNREAD); +} + +void procmsg_mark_all_read(FolderItem *item) +{ + GHashTable *mark_table; + + debug_print("Marking all messages as read\n"); + + mark_table = procmsg_read_mark_file(item); + if (mark_table) { + g_hash_table_foreach(mark_table, mark_all_read_func, NULL); + procmsg_write_mark_file(item, mark_table); + hash_free_value_mem(mark_table); + g_hash_table_destroy(mark_table); + } + + if (item->mark_queue) { + GSList *cur; + MsgInfo *msginfo; + + for (cur = item->mark_queue; cur != NULL; cur = cur->next) { + msginfo = (MsgInfo *)cur->data; + MSG_UNSET_PERM_FLAGS + (msginfo->flags, MSG_NEW|MSG_UNREAD); + } + item->mark_dirty = TRUE; + } + + item->new = item->unread = 0; +} + static FolderSortType cmp_func_sort_type; GSList *procmsg_sort_msg_list(GSList *mlist, FolderSortKey sort_key, diff --git a/libsylph/procmsg.h b/libsylph/procmsg.h index f61b6f9b..3fc7e119 100644 --- a/libsylph/procmsg.h +++ b/libsylph/procmsg.h @@ -221,6 +221,7 @@ GSList *procmsg_read_cache (FolderItem *item, gboolean scan_file); void procmsg_set_flags (GSList *mlist, FolderItem *item); +void procmsg_mark_all_read (FolderItem *item); GSList *procmsg_sort_msg_list (GSList *mlist, FolderSortKey sort_key, FolderSortType sort_type); -- cgit v1.2.3