From 1ff6054e5ef86550df4e2dba80b47b8e81ab8fd2 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 29 Mar 2001 05:34:26 +0000 Subject: Create a vtrash folder, not a vee folder. 2001-03-29 Not Zed * mail-local.c (init_trash): Create a vtrash folder, not a vee folder. * folder-browser-factory.c (control_activate): Hook in the hide deleted thingy. Removed MessageHideDeleted menu stuff. * message-list.c (message_list_set_hidedeleted): New function, to set if we should hide deleted messages automatically/always. (regen_list_regen): If we have hide deleted messages turned on, then hide them. (main_message_changed): Promote to a folder_changed event with a change list, folder_changed has the optimisations to handle this appropriately. (main_folder_changed): IF we get changes events for deleted/undeleted stuff, change to added/removed events, rebuild if necessary. (message_list_set_folder): Setup the default hidedeleted state to be to hide everything unless it is in a vtrash folder. svn path=/trunk/; revision=9009 --- mail/ChangeLog | 21 +++++++++++++ mail/folder-browser-factory.c | 4 +-- mail/mail-local.c | 3 +- mail/message-list.c | 73 +++++++++++++++++++++++++++++++++++-------- mail/message-list.h | 3 ++ 5 files changed, 88 insertions(+), 16 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 4b09f6d39f..36c36b8272 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,24 @@ +2001-03-29 Not Zed + + * mail-local.c (init_trash): Create a vtrash folder, not a vee folder. + + * folder-browser-factory.c (control_activate): Hook in the hide + deleted thingy. + Removed MessageHideDeleted menu stuff. + + * message-list.c (message_list_set_hidedeleted): New function, to + set if we should hide deleted messages automatically/always. + (regen_list_regen): If we have hide deleted messages turned on, + then hide them. + (main_message_changed): Promote to a folder_changed event with a + change list, folder_changed has the optimisations to handle this + appropriately. + (main_folder_changed): IF we get changes events for + deleted/undeleted stuff, change to added/removed events, rebuild + if necessary. + (message_list_set_folder): Setup the default hidedeleted state to + be to hide everything unless it is in a vtrash folder. + 2001-03-28 Jeffrey Stedfast * mail-account-gui.c (setup_service): Move the diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index 30766c8aa9..fd236e5994 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -92,7 +92,7 @@ BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("MessageHideClear", hide_none), BONOBO_UI_UNSAFE_VERB ("MessageHideRead", hide_read), - BONOBO_UI_UNSAFE_VERB ("MessageHideDeleted", hide_deleted), + /*BONOBO_UI_UNSAFE_VERB ("MessageHideDeleted", hide_deleted),*/ BONOBO_UI_UNSAFE_VERB ("MessageHideSelected", hide_selected), /* Folder Menu */ @@ -121,7 +121,7 @@ static struct { { "/menu/Tools/Component/SetMailConfig", "16_configure_mail.xpm", NULL }, { "/menu/Edit/MessageDelete", "delete_message.xpm", NULL }, { "/menu/Edit/MessageUndelete", "undelete_message.xpm", NULL }, - { "/menu/View/MessageHideDeleted", "hide_deleted_messages.xpm", NULL }, + /*{ "/menu/View/MessageHideDeleted", "hide_deleted_messages.xpm", NULL },*/ { "/menu/View/MessageHideRead", "hide_read_messages.xpm", NULL }, { "/menu/View/MessageHideSelected", "hide_selected_messages.xpm", NULL }, { "/menu/View/MessageHideClear", "show_all_messages.xpm", NULL }, diff --git a/mail/mail-local.c b/mail/mail-local.c index 08f056d31c..2511922fa6 100644 --- a/mail/mail-local.c +++ b/mail/mail-local.c @@ -51,6 +51,7 @@ #include "camel/camel.h" #include "camel/camel-vee-store.h" #include "camel/camel-vee-folder.h" +#include "camel/camel-vtrash-folder.h" #include "filter/vfolder-context.h" #include "filter/vfolder-rule.h" @@ -364,7 +365,7 @@ init_trash (CamelStore *store) name = g_strdup_printf ("%s?(match-all (system-flag \"Deleted\"))", "vTrash"); - store->vtrash = camel_vee_folder_new (store, name, CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_VEE_FOLDER_AUTO); + store->vtrash = camel_vtrash_folder_new (store, name); g_free (name); diff --git a/mail/message-list.c b/mail/message-list.c index 2518f35125..6cdf3f7b9f 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -1815,15 +1816,44 @@ static void main_folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) { MessageList *ml = MESSAGE_LIST (user_data); - CamelFolderChangeInfo *changes = (CamelFolderChangeInfo *)event_data; + CamelFolderChangeInfo *changes = (CamelFolderChangeInfo *)event_data, *newchanges; + CamelMessageInfo *info; + CamelFolder *folder = (CamelFolder *)o; + int i; printf("folder changed event, changes = %p\n", changes); if (changes) { printf("changed = %d added = %d removed = %d\n", changes->uid_changed->len, changes->uid_added->len, changes->uid_removed->len); - if (changes->uid_added->len == 0 && changes->uid_removed->len == 0) { - int i; + /* check if the hidden state has changed, if so modify accordingly, then regenerate */ + if (ml->hidedeleted) { + newchanges = camel_folder_change_info_new(); + + for (i=0;iuid_changed->len;i++) { + ETreePath node = g_hash_table_lookup (ml->uid_nodemap, changes->uid_changed->pdata[i]); + + info = camel_folder_get_message_info(folder, changes->uid_changed->pdata[i]); + if (node != NULL && info != NULL && (info->flags & CAMEL_MESSAGE_DELETED) != 0) { + camel_folder_change_info_remove_uid(newchanges, changes->uid_changed->pdata[i]); + } else if (node == NULL && info != NULL && (info->flags & CAMEL_MESSAGE_DELETED) == 0) { + camel_folder_change_info_add_uid(newchanges, changes->uid_changed->pdata[i]); + } else { + camel_folder_change_info_change_uid(newchanges, changes->uid_changed->pdata[i]); + } + camel_folder_free_message_info(folder, info); + } + + if (newchanges->uid_added->len != changes->uid_added->len + || newchanges->uid_removed->len != changes->uid_removed->len) { + camel_folder_change_info_free(changes); + changes = newchanges; + } else { + camel_folder_change_info_free(newchanges); + } + } + + if (changes->uid_added->len == 0 && changes->uid_removed->len == 0 && changes->uid_changed->len < 100) { for (i=0;iuid_changed->len;i++) { ETreePath node = g_hash_table_lookup (ml->uid_nodemap, changes->uid_changed->pdata[i]); if (node) @@ -1835,7 +1865,6 @@ main_folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) } } - mail_regen_list(ml, ml->search, NULL, changes); } @@ -1858,14 +1887,13 @@ folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) static void main_message_changed (CamelObject *o, gpointer uid, gpointer user_data) { - MessageList *message_list = MESSAGE_LIST (user_data); - ETreePath *node; - - node = g_hash_table_lookup (message_list->uid_nodemap, uid); - if (node) - e_tree_model_node_data_changed (message_list->model, node); + MessageList *ml = MESSAGE_LIST (user_data); + CamelFolderChangeInfo *changes; - g_free (uid); + changes = camel_folder_change_info_new(); + camel_folder_change_info_change_uid(changes, uid); + main_folder_changed(o, changes, ml); + g_free(uid); } static void @@ -1921,6 +1949,8 @@ message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder) camel_object_ref (CAMEL_OBJECT (camel_folder)); + message_list->hidedeleted = !(CAMEL_IS_VTRASH_FOLDER(camel_folder)); + hide_load_state(message_list); mail_regen_list(message_list, message_list->search, NULL, NULL); } @@ -2031,6 +2061,16 @@ message_list_set_threaded(MessageList *ml, gboolean threaded) } } +void +message_list_set_hidedeleted(MessageList *ml, gboolean hidedeleted) +{ + if (ml->hidedeleted ^ hidedeleted) { + ml->hidedeleted = hidedeleted; + + mail_regen_list(ml, ml->search, NULL, NULL); + } +} + void message_list_set_search(MessageList *ml, const char *search) { @@ -2207,6 +2247,7 @@ struct _regen_list_msg { char *hideexpr; CamelFolderChangeInfo *changes; gboolean dotree; /* we are building a tree */ + gboolean hidedel; /* we want to/dont want to show deleted messages */ CamelFolderThread *tree; CamelFolder *folder; @@ -2317,8 +2358,13 @@ static void regen_list_regen(struct _mail_msg *mm) m->summary = g_ptr_array_new(); for (i=0;ilen;i++) { info = camel_folder_get_message_info(m->folder, showuids->pdata[i]); - if (info) - g_ptr_array_add(m->summary, info); + if (info) { + /* FIXME: should this be taken account of in above processing? */ + if (m->hidedel && (info->flags & CAMEL_MESSAGE_DELETED) != 0) + camel_folder_free_message_info(m->folder, info); + else + g_ptr_array_add(m->summary, info); + } } if (uidnew) @@ -2409,6 +2455,7 @@ mail_regen_list(MessageList *ml, const char *search, const char *hideexpr, Camel m->hideexpr = g_strdup(hideexpr); m->changes = changes; m->dotree = ml->threaded; + m->hidedel = ml->hidedeleted; gtk_object_ref((GtkObject *)ml); m->folder = ml->folder; camel_object_ref((CamelObject *)m->folder); diff --git a/mail/message-list.h b/mail/message-list.h index 46739ee519..7d7e6b283b 100644 --- a/mail/message-list.h +++ b/mail/message-list.h @@ -68,6 +68,8 @@ struct _MessageList { /* Are we displaying threaded view? */ gboolean threaded; + /* do we automatically hide deleted messages? */ + gboolean hidedeleted; /* Where the ETree cursor is. */ int cursor_row; @@ -119,6 +121,7 @@ void message_list_hide_uids(MessageList *ml, GPtrArray *uids); void message_list_hide_clear(MessageList *ml); void message_list_set_threaded(MessageList *ml, gboolean threaded); +void message_list_set_hidedeleted(MessageList *ml, gboolean hidedeleted); void message_list_set_search(MessageList *ml, const char *search); char *message_list_get_layout (MessageList *message_list); -- cgit v1.2.3