From 645cd15163d63f0fcf9ee1f5436c33376844e437 Mon Sep 17 00:00:00 2001 From: Tristan Chabredier Date: Mon, 20 Feb 2006 12:57:32 +0000 Subject: [PATCH] 2006-02-20 [wwp] 2.0.0cvs63 * src/summary_search.c enhancements to the summary search: - add the ability to stop the running search (upon ESC-key press, new Stop button or when Clear button is pressed) - don't search if no criteria (From/To/Subject/Body) is set - ensure that a busy mouse pointer is always shown when searching, show it even a bit earlier --- ChangeLog | 10 ++++++ PATCHSETS | 1 + configure.ac | 2 +- src/summary_search.c | 73 ++++++++++++++++++++++++++++++++++++++------ 4 files changed, 76 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5aeae441..39b140fb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-02-20 [wwp] 2.0.0cvs63 + + * src/summary_search.c + enhancements to the summary search: + - add the ability to stop the running search + (upon ESC-key press, new Stop button or when Clear button is pressed) + - don't search if no criteria (From/To/Subject/Body) is set + - ensure that a busy mouse pointer is always shown when searching, + show it even a bit earlier + 2006-02-19 [colin] 2.0.0cvs62 * src/compose.c diff --git a/PATCHSETS b/PATCHSETS index 83cf2ff95..c6b856f2f 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1246,3 +1246,4 @@ ( cvs diff -u -r 1.94.2.76 -r 1.94.2.77 src/messageview.c; cvs diff -u -r 1.204.2.76 -r 1.204.2.77 src/prefs_common.c; cvs diff -u -r 1.103.2.41 -r 1.103.2.42 src/prefs_common.h; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/prefs_message.c; ) > 2.0.0cvs60.patchset ( cvs diff -u -r 1.179.2.92 -r 1.179.2.93 src/imap.c; cvs diff -u -r 1.1.4.28 -r 1.1.4.29 src/etpan/imap-thread.c; cvs diff -u -r 1.1.4.7 -r 1.1.4.8 src/etpan/imap-thread.h; ) > 2.0.0cvs61.patchset ( cvs diff -u -r 1.382.2.242 -r 1.382.2.243 src/compose.c; cvs diff -u -r 1.179.2.93 -r 1.179.2.94 src/imap.c; cvs diff -u -r 1.395.2.170 -r 1.395.2.171 src/summaryview.c; cvs diff -u -r 1.1.4.29 -r 1.1.4.30 src/etpan/imap-thread.c; cvs diff -u -r 1.1.4.8 -r 1.1.4.9 src/etpan/imap-thread.h; cvs diff -u -r 1.1.2.33 -r 1.1.2.34 src/gtk/quicksearch.c; ) > 2.0.0cvs62.patchset +( cvs diff -u -r 1.15.2.23 -r 1.15.2.24 src/summary_search.c; ) > 2.0.0cvs63.patchset diff --git a/configure.ac b/configure.ac index 741a4dda9..49f991daa 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=0 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=62 +EXTRA_VERSION=63 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/summary_search.c b/src/summary_search.c index 19f365a79..f58f31974 100644 --- a/src/summary_search.c +++ b/src/summary_search.c @@ -78,10 +78,13 @@ static struct SummarySearchWindow { GtkWidget *prev_btn; GtkWidget *next_btn; GtkWidget *close_btn; + GtkWidget *stop_btn; SummaryView *summaryview; MatcherList *matcher_list; + + gboolean is_searching; } search_window; static void summary_search_create (void); @@ -97,6 +100,8 @@ static void summary_search_next_clicked (GtkButton *button, gpointer data); static void summary_search_all_clicked (GtkButton *button, gpointer data); +static void summary_search_stop_clicked (GtkButton *button, + gpointer data); static void adv_condition_btn_clicked (GtkButton *button, gpointer data); @@ -157,6 +162,9 @@ static void summary_search_create(void) GtkWidget *prev_btn; GtkWidget *next_btn; GtkWidget *close_btn; + GtkWidget *stop_btn; + + gboolean is_searching = FALSE; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW (window), _("Search messages")); @@ -314,6 +322,11 @@ static void summary_search_create(void) gtk_box_pack_start(GTK_BOX(confirm_area), close_btn, TRUE, TRUE, 0); gtk_widget_show(close_btn); + /* stop button hidden */ + stop_btn = gtk_button_new_from_stock(GTK_STOCK_STOP); + GTK_WIDGET_SET_FLAGS(stop_btn, GTK_CAN_DEFAULT); + gtk_box_pack_start(GTK_BOX(confirm_area), stop_btn, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox1), confirm_area, FALSE, FALSE, 0); gtk_widget_grab_default(next_btn); @@ -339,6 +352,8 @@ static void summary_search_create(void) (G_OBJECT(close_btn), "clicked", g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide), window, NULL), FALSE); + g_signal_connect(G_OBJECT(stop_btn), "clicked", + G_CALLBACK(summary_search_stop_clicked), NULL); search_window.window = window; search_window.bool_optmenu = bool_optmenu; @@ -355,7 +370,9 @@ static void summary_search_create(void) search_window.prev_btn = prev_btn; search_window.next_btn = next_btn; search_window.close_btn = close_btn; + search_window.stop_btn = stop_btn; search_window.matcher_list = NULL; + search_window.is_searching = is_searching; } static void summary_search_execute(gboolean backward, gboolean search_all) @@ -388,7 +405,10 @@ static void summary_search_execute(gboolean backward, gboolean search_all) adv_condition = gtk_entry_get_text(GTK_ENTRY(search_window.adv_condition_entry)); if (adv_condition[0] != '\0') { search_window.matcher_list = matcher_parser_get_cond((gchar*)adv_condition); + /* TODO: check for condition parsing error and show an error dialog */ } else { + /* TODO: warn if no search condition? (or make buttons enabled only when + at least one search condition has been set */ summary_unlock(summaryview); return; } @@ -408,8 +428,23 @@ static void summary_search_execute(gboolean backward, gboolean search_all) to_str = gtk_entry_get_text(GTK_ENTRY(search_window.to_entry)); subject_str = gtk_entry_get_text(GTK_ENTRY(search_window.subject_entry)); body_str = gtk_entry_get_text(GTK_ENTRY(search_window.body_entry)); + + if ( (from_str[0] == '\0') && + (to_str[0] == '\0') && + (subject_str[0] == '\0') && + (body_str[0] == '\0')) { + /* TODO: warn if no search criteria? (or make buttons enabled only when + at least one search criteria has been set */ + summary_unlock(summaryview); + return; + } } + search_window.is_searching = TRUE; + main_window_cursor_wait(summaryview->mainwin); + gtk_widget_hide(search_window.close_btn); + gtk_widget_show(search_window.stop_btn); + if (search_all) { gtk_clist_freeze(GTK_CLIST(ctree)); gtk_clist_unselect_all(GTK_CLIST(ctree)); @@ -422,6 +457,8 @@ static void summary_search_execute(gboolean backward, gboolean search_all) node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); if (!node) { + search_window.is_searching = FALSE; + main_window_cursor_normal(summaryview->mainwin); summary_unlock(summaryview); return; } @@ -434,10 +471,7 @@ static void summary_search_execute(gboolean backward, gboolean search_all) (ctree, summaryview->selected); } - if (body_str && *body_str) - main_window_cursor_wait(summaryview->mainwin); - - for (;;) { + for (; search_window.is_searching;) { if (!node) { gchar *str; AlertValue val; @@ -559,11 +593,14 @@ static void summary_search_execute(gboolean backward, gboolean search_all) node = backward ? gtkut_ctree_node_prev(ctree, node) : gtkut_ctree_node_next(ctree, node); - } - if (body_str && *body_str) - main_window_cursor_normal(summaryview->mainwin); + GTK_EVENTS_FLUSH(); + } + search_window.is_searching = FALSE; + gtk_widget_hide(search_window.stop_btn); + gtk_widget_show(search_window.close_btn); + main_window_cursor_normal(summaryview->mainwin); summary_unlock(summaryview); } @@ -583,6 +620,10 @@ static void summary_search_clear(GtkButton *button, gpointer data) gtk_editable_delete_text(GTK_EDITABLE(search_window.body_entry), 0, -1); } + /* stop searching */ + if (search_window.is_searching) { + search_window.is_searching = FALSE; + } } static void summary_search_prev_clicked(GtkButton *button, gpointer data) @@ -619,6 +660,11 @@ static void adv_condition_btn_done(MatcherList * matchers) } } +static void summary_search_stop_clicked(GtkButton *button, gpointer data) +{ + search_window.is_searching = FALSE; +} + static void adv_condition_btn_clicked(GtkButton *button, gpointer data) { const gchar * cond_str; @@ -668,7 +714,16 @@ static void adv_condition_activated(void) static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data) { - if (event && event->keyval == GDK_Escape) - gtk_widget_hide(search_window.window); + if (event && event->keyval == GDK_Escape) { + /* ESC key will: + - stop a running search + - close the search window if no search is running + */ + if (!search_window.is_searching) { + gtk_widget_hide(search_window.window); + } else { + search_window.is_searching = FALSE; + } + } return FALSE; } -- 2.25.1