diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-reader.c | 11 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 42 | ||||
-rw-r--r-- | mail/em-folder-tree-model.h | 6 | ||||
-rw-r--r-- | mail/message-list.c | 10 |
4 files changed, 64 insertions, 5 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 0cb67ce3b1..5a0ef4628d 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -575,17 +575,26 @@ action_mail_mark_unread_cb (GtkAction *action, EMailReader *reader) { GtkWidget *message_list; + EMFolderTreeModel *model; + const gchar *folder_uri; guint32 mask = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED; guint32 set = 0; + guint n_marked; message_list = e_mail_reader_get_message_list (reader); - e_mail_reader_mark_selected (reader, mask, set); + n_marked = e_mail_reader_mark_selected (reader, mask, set); if (MESSAGE_LIST (message_list)->seen_id != 0) { g_source_remove (MESSAGE_LIST (message_list)->seen_id); MESSAGE_LIST (message_list)->seen_id = 0; } + + /* Notify the tree model that the user has marked messages as + * unread so it doesn't mistake the event as new mail arriving. */ + model = em_folder_tree_model_get_default (); + folder_uri = e_mail_reader_get_folder_uri (reader); + em_folder_tree_model_user_marked_unread (model, folder_uri, n_marked); } static void diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 81610275a3..82620f76ab 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -1312,14 +1312,50 @@ em_folder_tree_model_lookup_store_info (EMFolderTreeModel *model, GtkTreeRowReference * em_folder_tree_model_lookup_uri (EMFolderTreeModel *model, - const gchar *uri) + const gchar *folder_uri) { GtkTreeRowReference *reference; g_return_val_if_fail (EM_IS_FOLDER_TREE_MODEL (model), NULL); - g_return_val_if_fail (uri != NULL, NULL); + g_return_val_if_fail (folder_uri != NULL, NULL); - reference = g_hash_table_lookup (model->priv->uri_index, uri); + reference = g_hash_table_lookup (model->priv->uri_index, folder_uri); return gtk_tree_row_reference_valid (reference) ? reference : NULL; } + +void +em_folder_tree_model_user_marked_unread (EMFolderTreeModel *model, + const gchar *folder_uri, + guint n_marked) +{ + GtkTreeRowReference *reference; + GtkTreePath *path; + GtkTreeIter iter; + guint unread; + + /* The user marked messages in the given folder as unread. + * Update our unread counts so we don't misinterpret this + * event as new mail arriving. */ + + g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model)); + g_return_if_fail (folder_uri != NULL); + + reference = em_folder_tree_model_lookup_uri (model, folder_uri); + g_return_if_fail (gtk_tree_row_reference_valid (reference)); + + path = gtk_tree_row_reference_get_path (reference); + gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path); + gtk_tree_path_free (path); + + gtk_tree_model_get ( + GTK_TREE_MODEL (model), &iter, + COL_UINT_UNREAD, &unread, -1); + + unread += n_marked; + + gtk_tree_store_set ( + GTK_TREE_STORE (model), &iter, + COL_UINT_UNREAD_LAST_SEL, unread, + COL_UINT_UNREAD, unread, -1); +} diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h index 82775ae6bf..25ed2d8188 100644 --- a/mail/em-folder-tree-model.h +++ b/mail/em-folder-tree-model.h @@ -152,7 +152,11 @@ EMFolderTreeModelStoreInfo * GtkTreeRowReference * em_folder_tree_model_lookup_uri (EMFolderTreeModel *model, - const gchar *uri); + const gchar *folder_uri); +void em_folder_tree_model_user_marked_unread + (EMFolderTreeModel *model, + const gchar *folder_uri, + guint n_marked); G_END_DECLS diff --git a/mail/message-list.c b/mail/message-list.c index d218c9ed3a..848bef204d 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -3951,6 +3951,16 @@ on_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event, Mess uid = camel_message_info_uid (info); camel_folder_set_message_flags (list->folder, uid, flag, ~flags); + /* Notify the folder tree model that the user has marked a message + * as unread so it doesn't mistake the event as new mail arriving. */ + if (flag == CAMEL_MESSAGE_SEEN) { + EMFolderTreeModel *model; + + model = em_folder_tree_model_get_default (); + em_folder_tree_model_user_marked_unread ( + model, list->folder_uri, 1); + } + if (flag == CAMEL_MESSAGE_SEEN && list->seen_id) { g_source_remove (list->seen_id); list->seen_id = 0; |