2005-01-21 [colin] 1.0.0cvs4
authorColin Leroy <colin@colino.net>
Fri, 21 Jan 2005 10:23:32 +0000 (10:23 +0000)
committerColin Leroy <colin@colino.net>
Fri, 21 Jan 2005 10:23:32 +0000 (10:23 +0000)
* src/folder.h
* src/folderview.c
* src/folderview.h
* src/summaryview.c
* src/gtk/quicksearch.c
* src/gtk/quicksearch.h
Make quicksearch recursive - results materialized
by search icons in the folderview.

ChangeLog.claws
PATCHSETS
configure.ac
src/folder.h
src/folderview.c
src/folderview.h
src/gtk/quicksearch.c
src/gtk/quicksearch.h
src/summaryview.c

index 7104627..fbb6678 100644 (file)
@@ -1,3 +1,14 @@
+2005-01-21 [colin]     1.0.0cvs4
+
+       * src/folder.h
+       * src/folderview.c
+       * src/folderview.h
+       * src/summaryview.c
+       * src/gtk/quicksearch.c
+       * src/gtk/quicksearch.h
+               Make quicksearch recursive - results materialized
+               by search icons in the folderview.
+
 2005-01-20 [holger]    1.0.0cvs3
 
        * src/addrindex.c
index 843a581..69fae31 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.24 -r 1.25 po/ja.po; cvs diff -u -r 1.9 -r 1.10 po/ko.po; ) > 1.0.0cvs1.patchset
 ( cvs diff -u -r 1.315 -r 1.316 src/mainwindow.c; cvs diff -u -r 1.30 -r 1.31 src/mbox.c; cvs diff -u -r 1.4 -r 1.5 src/mbox.h; cvs diff -u -r 1.451 -r 1.452 src/summaryview.c; cvs diff -u -r 1.74 -r 1.75 src/summaryview.h; ) > 1.0.0cvs2.patchset
 ( cvs diff -u -r 1.35 -r 1.36 src/addrindex.c; cvs diff -u -r 1.14 -r 1.15 src/addrindex.h; ) > 1.0.0cvs3.patchset
+( cvs diff -u -r 1.107 -r 1.108 src/folder.h; cvs diff -u -r 1.254 -r 1.255 src/folderview.c; cvs diff -u -r 1.27 -r 1.28 src/folderview.h; cvs diff -u -r 1.452 -r 1.453 src/summaryview.c; cvs diff -u -r 1.9 -r 1.10 src/gtk/quicksearch.c; cvs diff -u -r 1.3 -r 1.4 src/gtk/quicksearch.h; ) > 1.0.0cvs4.patchset
index 769db04..1a5561b 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=3
+EXTRA_VERSION=4
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 04a7cff..b61ea30 100644 (file)
@@ -587,6 +587,7 @@ struct _FolderItem
        guint threaded       : 1; /* threaded folder view */
        guint hide_read_msgs : 1; /* hide read messages   */
        guint ret_rcpt       : 1; /* return receipt       */
+       guint search_match   : 1;
 
        gint op_count;
        guint opened         : 1; /* opened by summary view */
index 616396a..306cc2a 100644 (file)
@@ -992,6 +992,9 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
        FolderItem *item;
        GdkPixmap *xpm, *openxpm;
        GdkBitmap *mask, *openmask;
+       static GdkPixmap *searchicon;
+       static GdkBitmap *searchmask;
+
        gchar *name;
        gchar *str;
        gboolean add_unread_mark;
@@ -1074,6 +1077,15 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
        }
        name = folder_item_get_name(item);
 
+       if (item->search_match) {
+               if (!searchicon) {
+                       stock_pixmap_gdk(folderview->ctree, STOCK_PIXMAP_QUICKSEARCH,
+                        &searchicon, &searchmask);
+               }
+               xpm = openxpm = searchicon;
+               mask = openmask = searchmask;
+       }
+
        if (!GTK_CTREE_ROW(node)->expanded &&
            folderview_have_unread_children(folderview, node))
                add_unread_mark = TRUE;
@@ -1203,6 +1215,27 @@ void folderview_update_item(FolderItem *item, gboolean update_summary)
 }
 #endif
 
+void folderview_update_search_icon(FolderItem *item, gboolean matches)
+{
+       GList *list;
+       FolderView *folderview;
+       GtkCTree *ctree;
+       GtkCTreeNode *node;
+
+       g_return_if_fail(item != NULL);
+
+       for (list = folderview_list; list != NULL; list = list->next) {
+               folderview = (FolderView *)list->data;
+               ctree = GTK_CTREE(folderview->ctree);
+
+               node = gtk_ctree_find_by_row_data(ctree, NULL, item);
+               if (node) {
+                       item->search_match = matches;
+                       folderview_update_node(folderview, node);
+               }
+       }
+}
+
 gboolean folderview_update_item_claws(gpointer source, gpointer data)
 {
        FolderItemUpdateData *update_info = (FolderItemUpdateData *)source;
index 79e5fb4..ffe4a05 100644 (file)
@@ -107,5 +107,7 @@ void folderview_reflect_prefs_pixmap_theme  (FolderView *folderview);
 
 void folderview_register_popup         (FolderViewPopup        *fpopup);
 void folderview_unregister_popup       (FolderViewPopup        *fpopup);
+void folderview_update_search_icon     (FolderItem             *item,  
+                                        gboolean                matches);
 
 #endif /* __FOLDERVIEW_H__ */
index 7744969..d77a994 100644 (file)
@@ -34,6 +34,8 @@
 #include "matcher.h"
 #include "matcher_parser.h"
 #include "quicksearch.h"
+#include "folderview.h"
+#include "folder.h"
 
 struct _QuickSearch
 {
@@ -50,9 +52,12 @@ struct _QuickSearch
        QuickSearchExecuteCallback       callback;
        gpointer                         callback_data;
        gboolean                         running;
+       FolderItem                      *root_folder_item
 };
 
 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);
 
 static void prepare_matcher(QuickSearch *quicksearch)
 {
@@ -64,7 +69,7 @@ static void prepare_matcher(QuickSearch *quicksearch)
        }
 
        if (search_string == NULL || search_string[0] == '\0') {
-               quicksearch->active = FALSE;
+               quicksearch_set_active(quicksearch, FALSE);
                return;
        }
 
@@ -77,7 +82,7 @@ static void prepare_matcher(QuickSearch *quicksearch)
                        g_free(newstr);
                } else {
                        quicksearch->matcher_list = NULL;
-                       quicksearch->active = FALSE;
+                       quicksearch_set_active(quicksearch, FALSE);
 
                        return;
                }
@@ -87,7 +92,7 @@ static void prepare_matcher(QuickSearch *quicksearch)
                quicksearch->search_string = g_strdup(search_string);
        }
 
-       quicksearch->active = TRUE;
+       quicksearch_set_active(quicksearch, TRUE);
 }
 
 static gint searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
@@ -361,7 +366,7 @@ void quicksearch_show(QuickSearch *quicksearch)
 
 void quicksearch_hide(QuickSearch *quicksearch)
 {
-       quicksearch->active = FALSE;
+       quicksearch_set_active(quicksearch, FALSE);
        gtk_widget_hide(quicksearch->hbox_search);
 }
 
@@ -387,6 +392,14 @@ gboolean quicksearch_is_active(QuickSearch *quicksearch)
        return quicksearch->active;
 }
 
+static void quicksearch_set_active(QuickSearch *quicksearch, gboolean active)
+{
+       quicksearch->active = active;
+       if (!active) {
+               quicksearch_reset_cur_folder_item(quicksearch);
+       }
+}
+
 void quicksearch_set_execute_callback(QuickSearch *quicksearch,
                                      QuickSearchExecuteCallback callback,
                                      gpointer data)
@@ -419,10 +432,12 @@ gboolean quicksearch_match(QuickSearch *quicksearch, MsgInfo *msginfo)
                break;
        }
 
-       if (prefs_common.summary_quicksearch_type != QUICK_SEARCH_EXTENDED && quicksearch->search_string &&
+       if (prefs_common.summary_quicksearch_type != QUICK_SEARCH_EXTENDED && 
+           quicksearch->search_string &&
             searched_header && strcasestr(searched_header, quicksearch->search_string) != NULL)
                return TRUE;
-       else if ((quicksearch->matcher_list != NULL) && matcherlist_match(quicksearch->matcher_list, msginfo))
+       else if ((quicksearch->matcher_list != NULL) && 
+                matcherlist_match(quicksearch->matcher_list, msginfo))
                return TRUE;
 
        return FALSE;
@@ -616,3 +631,69 @@ gboolean quicksearch_is_running(QuickSearch *quicksearch)
        return quicksearch->running;
 }
 
+
+static gboolean quicksearch_match_subfolder(QuickSearch *quicksearch, 
+                                FolderItem *src)
+{
+       GSList *msglist = folder_item_get_msg_list(src);
+       GSList *cur;
+       gboolean result = FALSE;
+       
+       for (cur = msglist; cur != NULL; cur = cur->next) {
+               MsgInfo *msg = (MsgInfo *)cur->data;
+               if (quicksearch_match(quicksearch, msg)) {
+                       procmsg_msginfo_free(msg);
+                       result = TRUE;
+                       break;
+               }
+               procmsg_msginfo_free(msg);
+       }
+
+       g_slist_free(msglist);
+       return result;
+}
+
+void quicksearch_search_subfolders(QuickSearch *quicksearch, 
+                                  FolderView *folderview,
+                                  FolderItem *folder_item)
+{
+       FolderItem *cur = NULL;
+       GNode *node = folder_item->node->children;
+       
+       for (; node != NULL; node = node->next) {
+               cur = FOLDER_ITEM(node->data);
+               if (quicksearch_match_subfolder(quicksearch, cur)) {
+                       folderview_update_search_icon(cur, TRUE);
+               } else {
+                       folderview_update_search_icon(cur, FALSE);
+               }
+               if (cur->node->children)
+                       quicksearch_search_subfolders(quicksearch,
+                                                     folderview,
+                                                     cur);
+       }
+       quicksearch->root_folder_item = folder_item;
+}
+
+static void quicksearch_reset_folder_items(QuickSearch *quicksearch,
+                                   FolderItem *folder_item)
+{
+       FolderItem *cur = NULL;
+       GNode *node = folder_item->node->children;
+       
+       for (; node != NULL; node = node->next) {
+               cur = FOLDER_ITEM(node->data);
+               folderview_update_search_icon(cur, FALSE);
+               if (cur->node->children)
+                       quicksearch_reset_folder_items(quicksearch,
+                                                      cur);
+       }
+}
+
+void quicksearch_reset_cur_folder_item(QuickSearch *quicksearch)
+{
+       if (quicksearch->root_folder_item)
+               quicksearch_reset_folder_items(quicksearch, quicksearch->root_folder_item);
+       
+       quicksearch->root_folder_item = NULL;
+}
index 0458b51..5ab5019 100644 (file)
@@ -45,5 +45,8 @@ void quicksearch_set_execute_callback(QuickSearch *quicksearch,
 gboolean quicksearch_match(QuickSearch *quicksearch, MsgInfo *msginfo);
 gchar *expand_search_string(const gchar *str);
 gboolean quicksearch_is_running(QuickSearch *quicksearch);
-
+void quicksearch_reset_cur_folder_item(QuickSearch *quicksearch);
+void quicksearch_search_subfolders(QuickSearch *quicksearch, 
+                                  FolderView  *folderview,
+                                  FolderItem  *folder_item);
 #endif /* QUICKSEARCH_H */
index 5fea159..1c9a1c7 100644 (file)
@@ -782,6 +782,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        guint displayed_msgnum = 0;
        GSList *cur;
         GSList *not_killed;
+       gboolean quicksearch_changed = FALSE;
 
        if (summary_is_locked(summaryview)) return FALSE;
 
@@ -793,6 +794,9 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                quicksearch_set(summaryview->quicksearch, prefs_common.summary_quicksearch_type, "");
        }
 
+       if (quicksearch_is_running(summaryview->quicksearch))
+               quicksearch_changed = TRUE;
+
        /* STATUSBAR_POP(summaryview->mainwin); */
 
        is_refresh = (item == summaryview->folder_item) ? TRUE : FALSE;
@@ -906,7 +910,16 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                        else
                                procmsg_msginfo_free(msginfo);
                }
-
+               
+               if (quicksearch_changed) {
+                       /* only scan subfolders when quicksearch changed,
+                        * not when search is the same and folder changed */
+                       quicksearch_reset_cur_folder_item(summaryview->quicksearch);
+                       quicksearch_search_subfolders(summaryview->quicksearch, 
+                                             summaryview->folderview,
+                                             summaryview->folder_item);
+               }
+               
                g_slist_free(mlist);
                mlist = not_killed;
        }