diff options
-rw-r--r-- | mail/ChangeLog | 17 | ||||
-rw-r--r-- | mail/folder-browser.c | 36 | ||||
-rw-r--r-- | mail/mail-display.c | 1 | ||||
-rw-r--r-- | mail/message-list.c | 84 | ||||
-rw-r--r-- | mail/message-list.h | 3 |
5 files changed, 116 insertions, 25 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index d4ebf0808d..ebf858866a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,20 @@ +2000-05-01 NotZed <NotZed@HelixCode.com> + + * folder-browser.c (folder_browser_gui_init): A hackish little + quick-search entry. + (search_activate): Perform a quick-search on the folder subject + only. + + * message-list.c (get_message_info): If there is an active search, + then get the data from that ... use this instead of + _get_message_info(). + (ml_row_count): If we have an active search, get the info from its + result. + (select_msg): Changed to use get_message_info, so searches work. + (ml_value_at): And same here. + + * mail-display.c: Include missing errno.h. + 2000-04-30 Dan Winship <danw@helixcode.com> * session.c (session_providers_init): This is no longer necessary. diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 1e9603040b..cdb4296205 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -193,8 +193,25 @@ folder_browser_properties_init (FolderBrowser *fb) } static void +search_activate(GtkEntry *entry, FolderBrowser *fb) +{ + char *text; + + text = gtk_entry_get_text(entry); + if (text == NULL || text[0] == 0) { + message_list_set_search (fb->message_list, NULL); + } else { + char *search = g_strdup_printf("(match-all (header-contains \"Subject\" \"%s\"))", text); + message_list_set_search (fb->message_list, search); + g_free(search); + } +} + +static void folder_browser_gui_init (FolderBrowser *fb) { + GtkWidget *entry, *hbox, *label; + /* * The panned container */ @@ -203,9 +220,26 @@ folder_browser_gui_init (FolderBrowser *fb) gtk_table_attach ( GTK_TABLE (fb), fb->vpaned, - 0, 1, 0, 2, + 0, 1, 1, 3, + GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, + 0, 0); + + /* quick-search entry */ + hbox = gtk_hbox_new(FALSE, 3); + gtk_widget_show(hbox); + entry = gtk_entry_new(); + gtk_widget_show(entry); + gtk_signal_connect(entry, "activate", search_activate, fb); + label = gtk_label_new("Search (subject contains)"); + gtk_widget_show(label); + gtk_box_pack_end((GtkBox *)hbox, entry, FALSE, FALSE, 3); + gtk_box_pack_end((GtkBox *)hbox, label, FALSE, FALSE, 3); + gtk_table_attach ( + GTK_TABLE (fb), hbox, + 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, + 0, 0, 0); fb->message_list_w = message_list_get_widget (fb->message_list); diff --git a/mail/mail-display.c b/mail/mail-display.c index 9605456935..c6eb792d52 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -11,6 +11,7 @@ #include <config.h> #include <sys/stat.h> #include <fcntl.h> +#include <errno.h> #include <gnome.h> #include "e-util/e-setup.h" #include "e-util/e-util.h" diff --git a/mail/message-list.c b/mail/message-list.c index f4988df486..7536946f44 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -55,6 +55,27 @@ on_row_selection_cmd (ETable *table, gpointer user_data); +CamelMessageInfo *get_message_info(MessageList *message_list, gint row) +{ + CamelMessageInfo *info = NULL; + + if (message_list->matches) { + char *uid; + + uid = g_list_nth_data(message_list->matches, row); + if (uid) + info = camel_folder_summary_get_by_uid(message_list->folder, uid); + } else { + GPtrArray *msg_info_array; + msg_info_array = camel_folder_summary_get_message_info + (message_list->folder, row, 1); + if (msg_info_array && msg_info_array->len > 0) { + info = msg_info_array->pdata[0]; + } + g_ptr_array_free(msg_info_array, TRUE); + } + return info; +} /* select a message and display it */ static void @@ -66,15 +87,10 @@ select_msg (MessageList *message_list, gint row) camel_exception_init (&ex); if (camel_folder_has_uid_capability (message_list->folder)) { - GPtrArray *msg_info_array; CamelMessageInfo *msg_info; - - msg_info_array = camel_folder_summary_get_message_info - (message_list->folder, row, 1); - - if (msg_info_array) { - msg_info = msg_info_array->pdata[0]; - + + msg_info = get_message_info(message_list, row); + if (msg_info) { message = camel_folder_get_message_by_uid (message_list->folder, msg_info->uid, &ex); @@ -85,8 +101,6 @@ select_msg (MessageList *message_list, gint row) } } - g_ptr_array_free (msg_info_array, TRUE); - if (message) mail_display_set_message (message_list->parent_folder_browser->mail_display, CAMEL_MEDIUM (message)); @@ -117,11 +131,15 @@ ml_row_count (ETableModel *etm, void *data) return 0; } - camel_exception_init (&ex); + if (message_list->matches) { + v = g_list_length(message_list->matches); + } else { + camel_exception_init (&ex); - v = camel_folder_get_message_count (message_list->folder, &ex); - if (camel_exception_get_id (&ex)) - v = 0; + v = camel_folder_get_message_count (message_list->folder, &ex); + if (camel_exception_get_id (&ex)) + v = 0; + } /* in the case where no message is available, return 1 * however, cause we want to be able to show a text */ @@ -135,7 +153,6 @@ ml_value_at (ETableModel *etm, int col, int row, void *data) static char buffer [10]; MessageList *message_list = data; CamelFolder *folder; - GPtrArray *msg_info_array = NULL; CamelMessageInfo *msg_info; CamelException ex; void *retval = NULL; @@ -148,17 +165,14 @@ ml_value_at (ETableModel *etm, int col, int row, void *data) /* retrieve the message information array */ - msg_info_array = camel_folder_summary_get_message_info (folder, row, 1); + msg_info = get_message_info(message_list, row); /* * in the case where it is zero message long * display nothing */ - if (msg_info_array->len == 0) + if (msg_info == NULL) goto nothing_to_see; - - msg_info = msg_info_array->pdata[0]; - switch (col){ case COL_ONLINE_STATUS: @@ -216,7 +230,6 @@ ml_value_at (ETableModel *etm, int col, int row, void *data) g_assert_not_reached (); } - g_ptr_array_free (msg_info_array, TRUE); return retval; @@ -225,8 +238,6 @@ ml_value_at (ETableModel *etm, int col, int row, void *data) * in the case there is nothing to look at, * notify the user. */ - if (msg_info_array) - g_ptr_array_free (msg_info_array, TRUE); if (col == COL_SUBJECT) return "No item in this view"; else @@ -656,6 +667,26 @@ message_list_new (FolderBrowser *parent_folder_browser) } void +message_list_set_search (MessageList *message_list, const char *search) +{ + if (message_list->matches) { + /* FIXME: free contents too ... */ + g_list_free(message_list->matches); + message_list->matches = NULL; + } + if (search) { + CamelException ex; + + printf("Searching for: %s\n", search); + camel_exception_init (&ex); + message_list->matches = camel_folder_search_by_expression(message_list->folder, search, &ex); + } + + e_table_model_changed (message_list->table_model); + select_msg (message_list, 0); +} + +void message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder) { CamelException ex; @@ -666,7 +697,12 @@ message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder) g_return_if_fail (IS_MESSAGE_LIST (message_list)); g_return_if_fail (CAMEL_IS_FOLDER (camel_folder)); g_return_if_fail (camel_folder_has_summary_capability (camel_folder)); - + + if (message_list->matches) { + /* FIXME: free contents too ... */ + g_list_free(message_list->matches); + message_list->matches = NULL; + } camel_exception_init (&ex); diff --git a/mail/message-list.h b/mail/message-list.h index d751b784a2..fc20302b25 100644 --- a/mail/message-list.h +++ b/mail/message-list.h @@ -59,6 +59,9 @@ struct _MessageList { CamelFolder *folder; + /* FIXME: This should use a better format ... */ + GList *matches; /* when a search has been performed ... */ + /* used by the idle-call to select a row */ int row_to_select; guint idle_id; |