From 26639aa0178c8093ba7845327b117dcf6855fe47 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Fri, 29 Sep 2006 16:59:06 +0000 Subject: [PATCH] 2006-09-29 [colin] 2.5.2cvs22 * src/matcher_parser.h * src/matcher_parser_parse.y * src/prefs_filtering.c * src/statusbar.c * src/summary_search.c * src/summaryview.c * src/gtk/quicksearch.c * src/gtk/quicksearch.h Optimise searches by setting different refresh intervals (depending if the search is fast or not) --- ChangeLog | 14 ++++++++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/gtk/quicksearch.c | 21 ++++++++++++++++----- src/gtk/quicksearch.h | 1 + src/matcher_parser.h | 2 +- src/matcher_parser_parse.y | 28 ++++++++++++++++------------ src/prefs_filtering.c | 4 ++-- src/statusbar.c | 2 +- src/summary_search.c | 15 ++++++++++----- src/summaryview.c | 10 +++++++--- 11 files changed, 70 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 251800b25..f17db233e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-09-29 [colin] 2.5.2cvs22 + + * src/matcher_parser.h + * src/matcher_parser_parse.y + * src/prefs_filtering.c + * src/statusbar.c + * src/summary_search.c + * src/summaryview.c + * src/gtk/quicksearch.c + * src/gtk/quicksearch.h + Optimise searches by setting different + refresh intervals (depending if the + search is fast or not) + 2006-09-29 [colin] 2.5.2cvs21 * src/codeconv.c diff --git a/PATCHSETS b/PATCHSETS index afe0026a6..fa4a09bb7 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1935,3 +1935,4 @@ ( cvs diff -u -r 1.12.2.37 -r 1.12.2.38 src/action.c; cvs diff -u -r 1.382.2.312 -r 1.382.2.313 src/compose.c; cvs diff -u -r 1.207.2.124 -r 1.207.2.125 src/folderview.c; cvs diff -u -r 1.274.2.151 -r 1.274.2.152 src/mainwindow.c; cvs diff -u -r 1.94.2.107 -r 1.94.2.108 src/messageview.c; cvs diff -u -r 1.15.2.33 -r 1.15.2.34 src/summary_search.c; cvs diff -u -r 1.43.2.53 -r 1.43.2.54 src/toolbar.c; ) > 2.5.2cvs19.patchset ( cvs diff -u -r 1.1.4.33 -r 1.1.4.34 src/gtk/gtksctree.c; cvs diff -u -r 1.1.4.9 -r 1.1.4.10 src/gtk/gtksctree.h; ) > 2.5.2cvs20.patchset ( cvs diff -u -r 1.65.2.49 -r 1.65.2.50 src/codeconv.c; cvs diff -u -r 1.96.2.151 -r 1.96.2.152 src/textview.c; ) > 2.5.2cvs21.patchset +( cvs diff -u -r 1.4.2.4 -r 1.4.2.5 src/matcher_parser.h; cvs diff -u -r 1.25.2.17 -r 1.25.2.18 src/matcher_parser_parse.y; cvs diff -u -r 1.59.2.49 -r 1.59.2.50 src/prefs_filtering.c; cvs diff -u -r 1.5.2.10 -r 1.5.2.11 src/statusbar.c; cvs diff -u -r 1.15.2.34 -r 1.15.2.35 src/summary_search.c; cvs diff -u -r 1.395.2.257 -r 1.395.2.258 src/summaryview.c; cvs diff -u -r 1.1.2.45 -r 1.1.2.46 src/gtk/quicksearch.c; cvs diff -u -r 1.1.2.7 -r 1.1.2.8 src/gtk/quicksearch.h; ) > 2.5.2cvs22.patchset diff --git a/configure.ac b/configure.ac index 64c4bea4d..13cec78c2 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=5 MICRO_VERSION=2 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=21 +EXTRA_VERSION=22 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/gtk/quicksearch.c b/src/gtk/quicksearch.c index 53ac07388..ac33069be 100644 --- a/src/gtk/quicksearch.c +++ b/src/gtk/quicksearch.c @@ -62,12 +62,18 @@ struct _QuickSearch gboolean matching; gboolean deferred_free; FolderItem *root_folder_item; + gboolean is_fast; }; static void quicksearch_set_running(QuickSearch *quicksearch, gboolean run); static void quicksearch_set_active(QuickSearch *quicksearch, gboolean active); static void quicksearch_reset_folder_items(QuickSearch *quicksearch, FolderItem *folder_item); +gboolean quicksearch_is_fast(QuickSearch *quicksearch) +{ + return quicksearch->is_fast; +} + static void prepare_matcher(QuickSearch *quicksearch) { const gchar *search_string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(quicksearch->search_string_entry)->entry)); @@ -95,7 +101,7 @@ static void prepare_matcher(QuickSearch *quicksearch) newstr = expand_search_string(search_string); if (newstr && newstr[0] != '\0') { - quicksearch->matcher_list = matcher_parser_get_cond(newstr); + quicksearch->matcher_list = matcher_parser_get_cond(newstr, &quicksearch->is_fast); g_free(newstr); } else { quicksearch->matcher_list = NULL; @@ -349,7 +355,7 @@ static gboolean search_condition_expr(GtkMenuItem *widget, gpointer data) { const gchar * cond_str; MatcherList * matchers = NULL; - + g_return_val_if_fail( mainwindow_get_mainwindow()->summaryview->quicksearch != NULL, FALSE); @@ -360,7 +366,7 @@ static gboolean search_condition_expr(GtkMenuItem *widget, gpointer data) GTK_ENTRY(GTK_COMBO(mainwindow_get_mainwindow()->summaryview->quicksearch-> search_string_entry)->entry)); if (*cond_str != '\0') { - matchers = matcher_parser_get_cond((gchar*)cond_str); + matchers = matcher_parser_get_cond((gchar*)cond_str, NULL); } prefs_matcher_open(matchers, search_condition_expr_done); @@ -914,21 +920,26 @@ static gboolean quicksearch_match_subfolder(QuickSearch *quicksearch, GSList *cur; gboolean result = FALSE; gint num = 0, total = src->total_msgs; + gint interval = quicksearch_is_fast(quicksearch) ? 1000:100; + statusbar_print_all(_("Searching in %s... \n"), src->path ? src->path : "(null)"); + folder_item_update_freeze(); for (cur = msglist; cur != NULL; cur = cur->next) { MsgInfo *msg = (MsgInfo *)cur->data; - statusbar_progress_all(num++,total, 50); + statusbar_progress_all(num++,total, interval); if (quicksearch_match(quicksearch, msg)) { procmsg_msginfo_free(msg); result = TRUE; break; } procmsg_msginfo_free(msg); - GTK_EVENTS_FLUSH(); + if (num % interval == 0) + GTK_EVENTS_FLUSH(); if (!quicksearch_is_active(quicksearch)) break; } + folder_item_update_thaw(); statusbar_progress_all(0,0,0); statusbar_pop_all(); diff --git a/src/gtk/quicksearch.h b/src/gtk/quicksearch.h index 7250f25e8..973e25e8e 100644 --- a/src/gtk/quicksearch.h +++ b/src/gtk/quicksearch.h @@ -51,5 +51,6 @@ void quicksearch_reset_cur_folder_item(QuickSearch *quicksearch); void quicksearch_search_subfolders(QuickSearch *quicksearch, FolderView *folderview, FolderItem *folder_item); +gboolean quicksearch_is_fast(QuickSearch *quicksearch); #endif /* QUICKSEARCH_H */ diff --git a/src/matcher_parser.h b/src/matcher_parser.h index c3f965b73..eb41091ef 100644 --- a/src/matcher_parser.h +++ b/src/matcher_parser.h @@ -30,7 +30,7 @@ extern int matcher_parserlineno; void matcher_parser_start_parsing (FILE *f); int matcher_parserparse (void); -MatcherList *matcher_parser_get_cond (gchar *str); +MatcherList *matcher_parser_get_cond (gchar *str, gboolean *is_fast); MatcherProp *matcher_parser_get_prop (gchar *str); FilteringProp *matcher_parser_get_filtering (gchar *str); GSList *matcher_parser_get_action_list(gchar *str); diff --git a/src/matcher_parser_parse.y b/src/matcher_parser_parse.y index 74b589cc4..4721ed40f 100644 --- a/src/matcher_parser_parse.y +++ b/src/matcher_parser_parse.y @@ -49,6 +49,7 @@ static gint account_id = 0; static MatcherList *cond; static GSList *action_list = NULL; static FilteringAction *action = NULL; +static gboolean matcher_is_fast = TRUE; static FilteringProp *filtering; @@ -198,7 +199,7 @@ MatcherList *matcher_parser_get_account(gchar *str) return cond; } -MatcherList *matcher_parser_get_cond(gchar *str) +MatcherList *matcher_parser_get_cond(gchar *str, gboolean *is_fast) { void *bufstate; @@ -207,6 +208,7 @@ MatcherList *matcher_parser_get_cond(gchar *str) return cond; } + matcher_is_fast = TRUE; /* bad coding to enable the sub-grammar matching in yacc */ matcher_parserlineno = 1; @@ -217,6 +219,8 @@ MatcherList *matcher_parser_get_cond(gchar *str) matcher_parserparse(); matcher_parse_op = MATCHER_PARSE_FILE; matcher_parser_delete_buffer(bufstate); + if (is_fast) + *is_fast = matcher_is_fast; return cond; } @@ -248,7 +252,7 @@ MatcherProp *matcher_parser_get_prop(gchar *str) MatcherProp *prop; matcher_parserlineno = 1; - list = matcher_parser_get_cond(str); + list = matcher_parser_get_cond(str, NULL); if (list == NULL) return NULL; @@ -953,7 +957,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_HEADER; expr = $2; prop = matcherprop_new(criteria, header, match_type, expr, 0); @@ -966,7 +970,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_NOT_HEADER; expr = $2; prop = matcherprop_new(criteria, header, match_type, expr, 0); @@ -976,7 +980,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_HEADERS_PART; expr = $3; prop = matcherprop_new(criteria, NULL, match_type, expr, 0); @@ -985,7 +989,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_NOT_HEADERS_PART; expr = $3; prop = matcherprop_new(criteria, NULL, match_type, expr, 0); @@ -1020,7 +1024,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_MESSAGE; expr = $3; prop = matcherprop_new(criteria, NULL, match_type, expr, 0); @@ -1029,7 +1033,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_NOT_MESSAGE; expr = $3; prop = matcherprop_new(criteria, NULL, match_type, expr, 0); @@ -1038,7 +1042,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_BODY_PART; expr = $3; prop = matcherprop_new(criteria, NULL, match_type, expr, 0); @@ -1047,7 +1051,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_NOT_BODY_PART; expr = $3; prop = matcherprop_new(criteria, NULL, match_type, expr, 0); @@ -1056,7 +1060,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_TEST; expr = $2; prop = matcherprop_new(criteria, NULL, 0, expr, 0); @@ -1065,7 +1069,7 @@ MATCHER_ALL { gint criteria = 0; gchar *expr = NULL; - + matcher_is_fast = FALSE; criteria = MATCHCRITERIA_NOT_TEST; expr = $2; prop = matcherprop_new(criteria, NULL, 0, expr, 0); diff --git a/src/prefs_filtering.c b/src/prefs_filtering.c index 5c42dc8c9..c29c7f1f6 100644 --- a/src/prefs_filtering.c +++ b/src/prefs_filtering.c @@ -923,7 +923,7 @@ static void prefs_filtering_condition_define(void) cond_str = gtk_editable_get_chars(GTK_EDITABLE(filtering.cond_entry), 0, -1); if (*cond_str != '\0') { - matchers = matcher_parser_get_cond(cond_str); + matchers = matcher_parser_get_cond(cond_str, NULL); if (matchers == NULL) alertpanel_error(_("Condition string is not valid.")); } @@ -1008,7 +1008,7 @@ static FilteringProp * prefs_filtering_dialog_to_filtering(gboolean alert) goto fail; } - cond = matcher_parser_get_cond(cond_str); + cond = matcher_parser_get_cond(cond_str, NULL); if (cond == NULL) { if(alert == TRUE) alertpanel_error(_("Condition string is not valid.")); diff --git a/src/statusbar.c b/src/statusbar.c index d59fb67ee..04b076ec3 100644 --- a/src/statusbar.c +++ b/src/statusbar.c @@ -161,8 +161,8 @@ void statusbar_verbosity_set(gboolean verbose) void statusbar_progress_all (gint done, gint total, gint step) { gchar buf[32]; - g_snprintf(buf, sizeof(buf), "%d / %d", done, total); if (total && done % step == 0) { + g_snprintf(buf, sizeof(buf), "%d / %d", done, total); gtk_progress_bar_set_text (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), buf); gtk_progress_bar_set_fraction diff --git a/src/summary_search.c b/src/summary_search.c index 902832ecf..5458dd826 100644 --- a/src/summary_search.c +++ b/src/summary_search.c @@ -431,6 +431,9 @@ static void summary_search_execute(gboolean backward, gboolean search_all) const gchar *from_str = NULL, *to_str = NULL, *subject_str = NULL; const gchar *body_str = NULL, *adv_condition = NULL; StrFindFunc str_find_func = NULL; + gboolean is_fast = TRUE; + gint interval = 1000; + gint i = 0; if (summary_is_locked(summaryview)) { return; @@ -447,7 +450,9 @@ 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); + search_window.matcher_list = matcher_parser_get_cond((gchar*)adv_condition, &is_fast); + if (!is_fast) + interval = 100; /* TODO: check for condition parsing error and show an error dialog */ } else { /* TODO: warn if no search condition? (or make buttons enabled only when @@ -517,7 +522,7 @@ static void summary_search_execute(gboolean backward, gboolean search_all) } } - for (; search_window.is_searching;) { + for (; search_window.is_searching; i++) { if (!node) { gchar *str; AlertValue val; @@ -648,8 +653,8 @@ static void summary_search_execute(gboolean backward, gboolean search_all) node = backward ? gtkut_ctree_node_prev(ctree, node) : gtkut_ctree_node_next(ctree, node); - - GTK_EVENTS_FLUSH(); + if (i % interval == 0) + GTK_EVENTS_FLUSH(); } search_window.is_searching = FALSE; @@ -735,7 +740,7 @@ static void adv_condition_btn_clicked(GtkButton *button, gpointer data) cond_str = gtk_entry_get_text( GTK_ENTRY(search_window.adv_condition_entry)); if (*cond_str != '\0') { - matchers = matcher_parser_get_cond((gchar*)cond_str); + matchers = matcher_parser_get_cond((gchar*)cond_str, NULL); } prefs_matcher_open(matchers, adv_condition_btn_done); diff --git a/src/summaryview.c b/src/summaryview.c index a91b1eb94..aadc67174 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -1067,26 +1067,30 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item) if (quicksearch_is_active(summaryview->quicksearch)) { GSList *not_killed; + gint interval = quicksearch_is_fast(summaryview->quicksearch) ? 1000:100; START_TIMING("quicksearch"); gint num = 0, total = summaryview->folder_item->total_msgs; statusbar_print_all(_("Searching in %s... \n"), summaryview->folder_item->path ? summaryview->folder_item->path : "(null)"); not_killed = NULL; + folder_item_update_freeze(); for (cur = mlist ; cur != NULL && cur->data != NULL ; cur = g_slist_next(cur)) { MsgInfo * msginfo = (MsgInfo *) cur->data; - statusbar_progress_all(num++,total, 50); + statusbar_progress_all(num++,total, interval); if (!msginfo->hidden && quicksearch_match(summaryview->quicksearch, msginfo)) not_killed = g_slist_prepend(not_killed, msginfo); else procmsg_msginfo_free(msginfo); - GTK_EVENTS_FLUSH(); + if (num % interval == 0) + GTK_EVENTS_FLUSH(); if (!quicksearch_is_active(summaryview->quicksearch)) { break; } } + folder_item_update_thaw(); statusbar_progress_all(0,0,0); statusbar_pop_all(); @@ -4623,7 +4627,7 @@ gboolean summary_filter_get_mode(void) _("Apply these rules regardless of the account they belong to")); account_rules_user_current = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON(account_rules_skip), - _("Use current account for these rules")); + _("Apply these rules if they apply to the current account")); gtk_box_pack_start (GTK_BOX (vbox), account_rules_skip, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), account_rules_force, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), account_rules_user_current, FALSE, FALSE, 0); -- 2.25.1