add 'fast filter' for claws' filtering
authorPaul Mangan <paul@claws-mail.org>
Fri, 29 Mar 2002 09:12:54 +0000 (09:12 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 29 Mar 2002 09:12:54 +0000 (09:12 +0000)
ChangeLog.claws
configure.in
src/mainwindow.c
src/prefs_filtering.c
src/prefs_filtering.h
src/prefs_matcher.c
src/summaryview.c

index 43d4dda..662f6fc 100644 (file)
@@ -1,3 +1,13 @@
+2002-03-29 [paul]      0.7.4claws54
+
+       * src/mainwindow.c
+         src/prefs_filtering.[ch]
+         src/prefs_matcher.c
+         src/summaryview.c
+               add 'fast filter' for claws' filtering,
+               /Tools/Create filter rule/... patch submitted
+               by Neill Miller <neillm@thecodefactory.org>
+
 2002-03-29 [paul]      0.7.4claws53
 
        * sync with 0.7.4cvs24
index a1133cb..1cd2023 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws53
+EXTRA_VERSION=claws54
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index ba3c8eb..fb23b9a 100644 (file)
@@ -2935,7 +2935,7 @@ static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
                                    GtkWidget *widget)
 {
-       prefs_filtering_open(NULL);
+       prefs_filtering_open(NULL, NULL, NULL);
 }
 
 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
index 1d47db0..cce549a 100644 (file)
@@ -79,7 +79,8 @@ static struct Filtering {
 /* widget creating functions */
 static void prefs_filtering_create             (void);
 
-static void prefs_filtering_set_dialog (void);
+static void prefs_filtering_set_dialog (const gchar *header,
+                                        const gchar *key);
 static void prefs_filtering_set_list   (void);
 
 /* callback functions */
@@ -233,7 +234,9 @@ static gchar * action_text [] = {
        N_("Delete on Server")
 };
 
-void prefs_filtering_open(FolderItem * item)
+void prefs_filtering_open(FolderItem * item,
+                         const gchar *header,
+                         const gchar *key)
 {
        if (prefs_rc_is_readonly(FILTERING_RC))
                return;
@@ -249,7 +252,7 @@ void prefs_filtering_open(FolderItem * item)
 
        cur_item = item;
 
-       prefs_filtering_set_dialog();
+       prefs_filtering_set_dialog(header, key);
 
        gtk_widget_show(filtering.window);
 
@@ -692,16 +695,20 @@ void prefs_filtering_delete_path(const gchar *path)
        prefs_matcher_write_config();
 }
 
-static void prefs_filtering_set_dialog(void)
+static void prefs_filtering_set_dialog(const gchar *header, const gchar *key)
 {
        GtkCList *clist = GTK_CLIST(filtering.cond_clist);
        GSList *cur;
        GSList * prefs_filtering;
+       gchar *cond_str[1];
+       gint row;
        
        gtk_clist_freeze(clist);
        gtk_clist_clear(clist);
 
-       prefs_filtering_clist_set_row(-1, NULL);
+       cond_str[0] = _("(New)");
+       row = gtk_clist_append(clist, cond_str);
+       gtk_clist_set_row_data(clist, row, NULL);
 
        if (cur_item == NULL)
                prefs_filtering = global_processing;
@@ -711,13 +718,26 @@ static void prefs_filtering_set_dialog(void)
        for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur)) {
                FilteringProp * prop = (FilteringProp *) cur->data;
 
-               prefs_filtering_clist_set_row(-1, prop);
+               cond_str[0] = filteringprop_to_string(prop);
+               subst_char(cond_str[0], '\t', ':');
+               row = gtk_clist_append(clist, cond_str);
+               gtk_clist_set_row_data(clist, row, prop);
+
+               g_free(cond_str[0]);
        }
 
        prefs_filtering_update_hscrollbar();
        gtk_clist_thaw(clist);
 
        prefs_filtering_reset_dialog();
+
+       if (header && key) {
+               gchar *match_str = g_strconcat(header, " ",
+                       get_matchparser_tab_str(MATCHTYPE_MATCHCASE),
+                       " \"", key, "\"", NULL);
+               gtk_entry_set_text(GTK_ENTRY(filtering.cond_entry), match_str);
+               g_free(match_str);
+       }
 }
 
 static void prefs_filtering_reset_dialog(void)
index a665b32..224d25e 100644 (file)
@@ -24,7 +24,9 @@
 void prefs_scoring_read_config (void);
 void prefs_scoring_write_config        (void);
 */
-void prefs_filtering_open              (FolderItem * item);
+void prefs_filtering_open              (FolderItem * item,
+                                        const gchar    *header,
+                                        const gchar    *key);
 void prefs_filtering_rename_path       (const gchar    *old_path,
                                         const gchar    *new_path);
 void prefs_filtering_delete_path       (const gchar    *path);
index 70b8504..d2a1b5a 100644 (file)
@@ -381,7 +381,7 @@ static void prefs_matcher_create(void)
        gtkut_combo_set_items (GTK_COMBO (header_combo),
                               "Subject", "From", "To", "Cc", "Reply-To",
                               "Sender", "X-ML-Name", "X-List", "X-Sequence",
-                              "X-Mailer",
+                              "X-Mailer","X-BeenThere",
                               NULL);
        gtk_table_attach (GTK_TABLE (table1), header_combo, 1, 2, 1, 2,
                          0, 0, 0, 0);
index 4bbfeb7..a7a75f8 100644 (file)
@@ -3935,23 +3935,42 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
 
 void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
 {
-       static HeaderEntry hentry[] = {{"List-Id:",        NULL, FALSE},
+       static HeaderEntry hentry[] = {{"X-BeenThere:",    NULL, FALSE},
                                       {"X-ML-Name:",      NULL, FALSE},
                                       {"X-List:",         NULL, FALSE},
                                       {"X-Mailing-list:", NULL, FALSE},
+                                      {"List-Id:",        NULL, FALSE},
                                       {NULL,              NULL, FALSE}};
+
+       static gchar *header_strs[] = {"From", "from", "To", "to", "Subject", "subject"};
+
+       static gchar *hentry_strs[]   = {"X-BeenThere", "X-ML-Name", "X-List",
+                                        "X-Mailing-List", "List-Id",
+                                        "header \"X-BeenThere\"", "header \"X-ML-Name\"",
+                                        "header \"X-List\"", "header \"X-Mailing-List\"",
+                                        "header \"List-Id\""};
        enum
        {
-               H_LIST_ID        = 0,
+               H_X_BEENTHERE    = 0,
                H_X_ML_NAME      = 1,
                H_X_LIST         = 2,
-               H_X_MAILING_LIST = 3
+               H_X_MAILING_LIST = 3,
+               H_LIST_ID        = 4
+       };
+
+       enum
+       {
+               H_FROM    = 0,
+               H_TO      = 2,
+               H_SUBJECT = 4
        };
 
        MsgInfo *msginfo;
        gchar *header = NULL;
        gchar *key = NULL;
        FILE *fp;
+       int header_offset;
+       int hentry_offset;
 
        if (!summaryview->selected) return;
 
@@ -3959,6 +3978,15 @@ void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
                                              summaryview->selected);
        if (!msginfo) return;
 
+       if (global_processing) {
+               header_offset = 1;
+               hentry_offset = 5;
+       }
+       else {
+               header_offset = 0;
+               hentry_offset = 0;
+       }
+
        switch (type) {
        case FILTER_BY_NONE:
                break;
@@ -3967,50 +3995,58 @@ void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
                procheader_get_header_fields(fp, hentry);
                fclose(fp);
 
-               if (hentry[H_LIST_ID].body != NULL) {
-                       header = "List-Id";
-                       Xstrdup_a(key, hentry[H_LIST_ID].body, );
+               if (hentry[H_X_BEENTHERE].body != NULL) {
+                       header = hentry_strs[H_X_BEENTHERE + hentry_offset];
+                       Xstrdup_a(key, hentry[H_X_BEENTHERE].body, );
                } else if (hentry[H_X_ML_NAME].body != NULL) {
-                       header = "X-ML-Name";
+                       header = hentry_strs[H_X_ML_NAME + hentry_offset];
                        Xstrdup_a(key, hentry[H_X_ML_NAME].body, );
                } else if (hentry[H_X_LIST].body != NULL) {
-                       header = "X-List";
+                       header = hentry_strs[H_X_LIST + hentry_offset];
                        Xstrdup_a(key, hentry[H_X_LIST].body, );
                } else if (hentry[H_X_MAILING_LIST].body != NULL) {
-                       header = "X-Mailing-list";
+                       header = hentry_strs[H_X_MAILING_LIST + hentry_offset];
                        Xstrdup_a(key, hentry[H_X_MAILING_LIST].body, );
+               } else if (hentry[H_LIST_ID].body != NULL) {
+                       header = hentry_strs[H_LIST_ID + hentry_offset];
+                       Xstrdup_a(key, hentry[H_LIST_ID].body, );
                } else if (msginfo->subject) {
-                       header = "Subject";
+                       header = header_strs[H_SUBJECT + header_offset];
                        key = msginfo->subject;
                }
 
-               g_free(hentry[H_LIST_ID].body);
-               hentry[H_LIST_ID].body = NULL;
+               g_free(hentry[H_X_BEENTHERE].body);
+               hentry[H_X_BEENTHERE].body = NULL;
                g_free(hentry[H_X_ML_NAME].body);
                hentry[H_X_ML_NAME].body = NULL;
                g_free(hentry[H_X_LIST].body);
                hentry[H_X_LIST].body = NULL;
                g_free(hentry[H_X_MAILING_LIST].body);
                hentry[H_X_MAILING_LIST].body = NULL;
+               g_free(hentry[H_LIST_ID].body);
+               hentry[H_LIST_ID].body = NULL;
 
                break;
        case FILTER_BY_FROM:
-               header = "From";
+               header = header_strs[H_FROM + header_offset];
                key = msginfo->from;
                break;
        case FILTER_BY_TO:
-               header = "To";
+               header = header_strs[H_TO + header_offset];
                key = msginfo->to;
                break;
        case FILTER_BY_SUBJECT:
-               header = "Subject";
+               header = header_strs[H_SUBJECT + header_offset];
                key = msginfo->subject;
                break;
        default:
                break;
        }
 
-       prefs_filter_open(header, key);
+       if (global_processing)
+               prefs_filtering_open(NULL, header, key);
+       else
+               prefs_filter_open(header, key);
 }
 
 void summary_reply(SummaryView *summaryview, ComposeMode mode)