2007-10-10 [paul] 3.0.2cvs54
[claws.git] / src / prefs_filtering_action.c
index 1b95988d683ce5cf2356f2a4dd18edfaf89c728e..79574def3b9c2df1cf58d1222b30089bb667af49 100644 (file)
@@ -4,7 +4,7 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -47,7 +47,7 @@
 #include "folder.h"
 #include "description_window.h"
 #include "addr_compl.h"
-
+#include "tags.h"
 #include "matcher_parser.h"
 #include "colorlabel.h"
 
@@ -74,6 +74,7 @@ static void prefs_filtering_action_type_selection_changed(GtkList *list,
 static void prefs_filtering_action_type_select(GtkList *list,
     GtkWidget *widget, gpointer user_data);
 static void prefs_filtering_action_select_dest(void);
+static void prefs_filtering_action_select_addressbook(void);
 static void prefs_filtering_action_up(void);
 static void prefs_filtering_action_down(void);
 static void prefs_filtering_action_set_dialog(GSList *action_list);
@@ -115,6 +116,14 @@ static struct FilteringAction_ {
        GtkWidget *color_label;
        GtkWidget *color_optmenu;
        GtkWidget *score_label;
+       GtkWidget *header_label;
+       GtkWidget *header_combo;
+       GtkWidget *header_entry;
+       GtkWidget *addressbook_label;
+       GtkWidget *addressbook_btn;
+       GtkWidget *tags_label;
+       GtkWidget *tags_list;
+       GtkWidget *tags_combo;
 
        gint current_action;
 } filtering_action;
@@ -130,6 +139,8 @@ typedef enum Action_ {
        ACTION_UNLOCK,
        ACTION_MARK_AS_READ,
        ACTION_MARK_AS_UNREAD,
+       ACTION_MARK_AS_SPAM,
+       ACTION_MARK_AS_HAM,
        ACTION_FORWARD,
        ACTION_FORWARD_AS_ATTACHMENT,
        ACTION_REDIRECT,
@@ -137,8 +148,13 @@ typedef enum Action_ {
        ACTION_COLOR,
        ACTION_CHANGE_SCORE,
        ACTION_SET_SCORE,
+       ACTION_SET_TAG,
+       ACTION_UNSET_TAG,
+       ACTION_CLEAR_TAGS,
        ACTION_HIDE,
        ACTION_IGNORE,
+       ACTION_WATCH,
+       ACTION_ADD_TO_ADDRESSBOOK,
        ACTION_STOP,
        /* add other action constants */
 } Action;
@@ -156,6 +172,8 @@ static struct {
        { N_("Unlock"),                 ACTION_UNLOCK   },
        { N_("Mark as read"),           ACTION_MARK_AS_READ },
        { N_("Mark as unread"),         ACTION_MARK_AS_UNREAD },
+       { N_("Mark as spam"),           ACTION_MARK_AS_SPAM },
+       { N_("Mark as ham"),            ACTION_MARK_AS_HAM },
        { N_("Forward"),                ACTION_FORWARD  },
        { N_("Forward as attachment"),  ACTION_FORWARD_AS_ATTACHMENT },
        { N_("Redirect"),               ACTION_REDIRECT },
@@ -163,8 +181,13 @@ static struct {
        { N_("Color"),                  ACTION_COLOR    },
        { N_("Change score"),           ACTION_CHANGE_SCORE},
        { N_("Set score"),              ACTION_SET_SCORE},
+       { N_("Apply tag"),              ACTION_SET_TAG},
+       { N_("Unset tag"),              ACTION_UNSET_TAG},
+       { N_("Clear tags"),             ACTION_CLEAR_TAGS},
        { N_("Hide"),                   ACTION_HIDE     },
        { N_("Ignore thread"),          ACTION_IGNORE   },
+       { N_("Watch thread"),           ACTION_WATCH    },
+       { N_("Add to address book"),    ACTION_ADD_TO_ADDRESSBOOK       },
        { N_("Stop filter"),            ACTION_STOP     },
 };
 
@@ -214,6 +237,10 @@ void prefs_filtering_action_open(GSList *action_list,
 
        if (!filtering_action.window) {
                prefs_filtering_action_create();
+       } else {
+               /* update color label menu */
+               gtk_option_menu_set_menu(GTK_OPTION_MENU(filtering_action.color_optmenu),
+                               colorlabel_create_color_menu());
        }
 
        manage_window_set_transient(GTK_WINDOW(filtering_action.window));
@@ -264,8 +291,16 @@ static void prefs_filtering_action_create(void)
        GtkWidget *color_label;
        GtkWidget *account_label;
        GtkWidget *account_combo;
+       GtkWidget *header_label;
+       GtkWidget *header_combo;
+       GtkWidget *header_entry;
+       GtkWidget *addressbook_label;
+       GtkWidget *addressbook_btn;
        GtkWidget *dest_entry;
        GtkWidget *dest_btn;
+       GtkWidget *tags_label;
+       GtkWidget *tags_list;
+       GtkWidget *tags_combo;
         GList * cur;
 
        GtkWidget *reg_hbox;
@@ -292,6 +327,7 @@ static void prefs_filtering_action_create(void)
        static GdkGeometry geometry;
 
         GList * accounts;
+       GSList *tmp, *tags;
 
        debug_print("Creating matcher configuration window...\n");
 
@@ -409,6 +445,24 @@ static void prefs_filtering_action_create(void)
        gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(account_combo)->entry),
                               FALSE);
 
+       /* header */
+
+       header_label = gtk_label_new(_("Header name"));
+       gtk_widget_show(header_label);
+       gtk_misc_set_alignment(GTK_MISC(header_label), 0, 0.5);
+       gtk_box_pack_start (GTK_BOX (hbox1), header_label, FALSE, FALSE, 0);
+
+       header_combo = gtk_combo_new();
+       gtk_widget_show(header_combo);
+       gtk_widget_set_size_request(header_combo, 120, -1);
+       gtkut_combo_set_items(GTK_COMBO (header_combo),
+                             "From", "To", "Cc", "Reply-To", "Sender",
+                             NULL);
+       gtk_box_pack_start (GTK_BOX (hbox1), header_combo,
+                           TRUE, TRUE, 0);
+       header_entry = GTK_COMBO(header_combo)->entry;
+       gtk_entry_set_editable(GTK_ENTRY(header_entry), TRUE);
+
        /* destination */
 
        hbox1 = gtk_hbox_new (FALSE, VSPACING);
@@ -441,6 +495,16 @@ static void prefs_filtering_action_create(void)
        gtk_misc_set_alignment (GTK_MISC (score_label), 0, 0.5);
        gtk_box_pack_start (GTK_BOX (hbox1), score_label, FALSE, FALSE, 0);
 
+       addressbook_label = gtk_label_new (_("Book/folder"));
+       gtk_widget_show(addressbook_label);
+       gtk_misc_set_alignment(GTK_MISC(addressbook_label), 0, 0.5);
+       gtk_box_pack_start(GTK_BOX(hbox1), addressbook_label, FALSE, FALSE, 0);
+
+       tags_label = gtk_label_new (_("Tag"));
+       gtk_widget_show (tags_label);
+       gtk_misc_set_alignment (GTK_MISC (tags_label), 0, 0.5);
+       gtk_box_pack_start (GTK_BOX (hbox1), tags_label, FALSE, FALSE, 0);
+
        dest_entry = gtk_entry_new ();
        gtk_widget_set_size_request (dest_entry, 150, -1);
        gtk_widget_show (dest_entry);
@@ -451,6 +515,31 @@ static void prefs_filtering_action_create(void)
                                 colorlabel_create_color_menu());
        gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, TRUE, TRUE, 0);
 
+       tags_combo = gtk_combo_new ();
+       gtk_widget_set_size_request (tags_combo, 150, -1);
+       gtk_widget_show (tags_combo);
+
+       combo_items = NULL;
+       for (tmp = tags = tags_get_list() ; tmp != NULL;
+            tmp = tmp->next) {
+               gchar *name = g_strdup(tags_get_tag(GPOINTER_TO_INT(tmp->data)));
+
+               combo_items = g_list_append(combo_items, (gpointer) name);
+       }
+
+       gtk_combo_set_popdown_strings(GTK_COMBO(tags_combo), combo_items);
+
+       for(cur = g_list_first(combo_items) ; cur != NULL ;
+           cur = g_list_next(cur))
+               g_free(cur->data);
+       g_list_free(combo_items);
+       g_slist_free(tags);
+
+       gtk_box_pack_start (GTK_BOX (hbox1), tags_combo,
+                           TRUE, TRUE, 0);
+       tags_list = GTK_COMBO(tags_combo)->list;
+       gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(tags_combo)->entry),
+                              FALSE);
        dest_btn = gtk_button_new_with_label (_("Select ..."));
        gtk_widget_show (dest_btn);
        gtk_box_pack_start (GTK_BOX (hbox1), dest_btn, FALSE, FALSE, 0);
@@ -458,6 +547,13 @@ static void prefs_filtering_action_create(void)
                          G_CALLBACK(prefs_filtering_action_select_dest),
                          NULL);
 
+       addressbook_btn = gtk_button_new_with_label (_("Select ..."));
+       gtk_widget_show (addressbook_btn);
+       gtk_box_pack_start (GTK_BOX (hbox1), addressbook_btn, FALSE, FALSE, 0);
+       g_signal_connect (G_OBJECT (addressbook_btn), "clicked",
+                         G_CALLBACK(prefs_filtering_action_select_addressbook),
+                         NULL);
+
 #if GTK_CHECK_VERSION(2, 8, 0)
        exec_btn = gtk_button_new_from_stock(GTK_STOCK_INFO);
 #else
@@ -554,6 +650,9 @@ static void prefs_filtering_action_create(void)
        filtering_action.account_label = account_label;
        filtering_action.account_list = account_list;
        filtering_action.account_combo = account_combo;
+       filtering_action.tags_label = tags_label;
+       filtering_action.tags_list = tags_list;
+       filtering_action.tags_combo = tags_combo;
        filtering_action.dest_entry = dest_entry;
        filtering_action.dest_btn = dest_btn;
        filtering_action.dest_label = dest_label;
@@ -563,6 +662,11 @@ static void prefs_filtering_action_create(void)
        filtering_action.color_label   = color_label;
        filtering_action.color_optmenu = color_optmenu;
        filtering_action.score_label = score_label;
+       filtering_action.header_label = header_label;
+       filtering_action.header_combo = header_combo;
+       filtering_action.header_entry = header_entry;
+       filtering_action.addressbook_label = addressbook_label;
+       filtering_action.addressbook_btn = addressbook_btn;
        filtering_action.ok_btn = ok_btn;
        filtering_action.action_list_view = action_list_view;
 }
@@ -717,6 +821,12 @@ static gint prefs_filtering_action_get_matching_from_action(Action action_id)
        switch (action_id) {
        case ACTION_MOVE:
                return MATCHACTION_MOVE;
+       case ACTION_SET_TAG:
+               return MATCHACTION_SET_TAG;
+       case ACTION_UNSET_TAG:
+               return MATCHACTION_UNSET_TAG;
+       case ACTION_CLEAR_TAGS:
+               return MATCHACTION_CLEAR_TAGS;
        case ACTION_COPY:
                return MATCHACTION_COPY;
        case ACTION_DELETE:
@@ -733,6 +843,10 @@ static gint prefs_filtering_action_get_matching_from_action(Action action_id)
                return MATCHACTION_MARK_AS_READ;
        case ACTION_MARK_AS_UNREAD:
                return MATCHACTION_MARK_AS_UNREAD;
+       case ACTION_MARK_AS_SPAM:
+               return MATCHACTION_MARK_AS_SPAM;
+       case ACTION_MARK_AS_HAM:
+               return MATCHACTION_MARK_AS_HAM;
        case ACTION_FORWARD:
                return MATCHACTION_FORWARD;
        case ACTION_FORWARD_AS_ATTACHMENT:
@@ -747,12 +861,16 @@ static gint prefs_filtering_action_get_matching_from_action(Action action_id)
                return MATCHACTION_HIDE;
        case ACTION_IGNORE:
                return MATCHACTION_IGNORE;
+       case ACTION_WATCH:
+               return MATCHACTION_WATCH;
        case ACTION_STOP:
                return MATCHACTION_STOP;
        case ACTION_CHANGE_SCORE:
                return MATCHACTION_CHANGE_SCORE;
        case ACTION_SET_SCORE:
                return MATCHACTION_SET_SCORE;
+       case ACTION_ADD_TO_ADDRESSBOOK:
+               return MATCHACTION_ADD_TO_ADDRESSBOOK;
        default:
                return -1;
        }
@@ -777,6 +895,7 @@ static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
         FilteringAction * action;
         gchar * score_str = NULL;
         gint score;
+       gchar * header = NULL;
         
        action_id = get_sel_from_list(GTK_LIST(filtering_action.action_type_list));
        action_type = prefs_filtering_action_get_matching_from_action(action_id);
@@ -826,9 +945,36 @@ static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
                }
                 score = strtol(score_str, NULL, 10);
                 break;
+       case ACTION_ADD_TO_ADDRESSBOOK:
+               header = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.header_entry), 0, -1);
+               if (*header == '\0') {
+                       if (alert)
+                                alertpanel_error(_("Header is not set."));
+                       g_free(header);
+                       return NULL;
+               }
+               destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
+               if (*destination == '\0') {
+                       if (alert)
+                                alertpanel_error(_("Target addressbook/folder is not set."));
+                       g_free(destination);
+                       return NULL;
+               }
+               break;
+       case ACTION_SET_TAG:
+       case ACTION_UNSET_TAG:
+               destination = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(filtering_action.tags_combo)->entry), 0, -1);
+               if (*destination == '\0') {
+                       if (alert)
+                                alertpanel_error(_("Tag name is empty."));
+                       g_free(destination);
+                       return NULL;
+               }
+               break;
        case ACTION_STOP:
        case ACTION_HIDE:
        case ACTION_IGNORE:
+       case ACTION_WATCH:
         case ACTION_DELETE:
         case ACTION_MARK:
         case ACTION_UNMARK:
@@ -836,12 +982,14 @@ static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
         case ACTION_UNLOCK:
         case ACTION_MARK_AS_READ:
         case ACTION_MARK_AS_UNREAD:
+        case ACTION_MARK_AS_SPAM:
+        case ACTION_MARK_AS_HAM:
+        case ACTION_CLEAR_TAGS:
        default:
                break;
        }
-       
        action = filteringaction_new(action_type, account_id,
-            destination, labelcolor, score);
+            destination, labelcolor, score, header);
        
        g_free(destination);
        g_free(score_str);
@@ -869,6 +1017,7 @@ static void prefs_filtering_action_register_cb(void)
         * list items to be unselectable)
         * prefs_filtering_action_reset_dialog(); */
        gtk_list_select_item(GTK_LIST(filtering_action.account_list), 0);
+       gtk_list_select_item(GTK_LIST(filtering_action.tags_list), 0);
        gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
 }
 
@@ -1024,7 +1173,8 @@ static gboolean prefs_filtering_action_key_pressed(GtkWidget *widget,
  */
 static void prefs_filtering_action_cancel(void)
 {
-       gtk_widget_hide(filtering_action.window);
+       gtk_widget_destroy(filtering_action.window);
+       filtering_action.window = NULL;
        inc_unlock();
 }
 
@@ -1050,7 +1200,8 @@ static void prefs_filtering_action_ok(void)
         }
         g_slist_free(action_list);
 
-       gtk_widget_hide(filtering_action.window);
+       gtk_widget_destroy(filtering_action.window);
+       filtering_action.window = NULL;
         inc_unlock();
 }
 
@@ -1098,7 +1249,7 @@ static DescriptionWindow exec_desc_win = {
         2,
         N_("Filtering Action: 'Execute'"),
        N_("'Execute' allows you to send a message or message element "
-          "to an external program or script.\n\n"
+          "to an external program or script.\n"
           "The following symbols can be used:"),
        exec_desc_strings
 };
@@ -1125,6 +1276,20 @@ static void prefs_filtering_action_select_dest(void)
        g_free(path);
 }
 
+static void prefs_filtering_action_select_addressbook(void)
+{
+       gchar *folderpath = NULL;
+       gchar *prev = NULL;
+       gboolean ret = FALSE;
+
+       prev = g_strdup(gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1));
+       folderpath = prev;
+       ret = addressbook_folder_selection(&folderpath);
+       if ( ret != FALSE && folderpath != NULL)
+               gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), folderpath);
+       g_free(prev);
+}
+
 static void prefs_filtering_action_type_selection_changed(GtkList *list,
     gpointer user_data)
 {
@@ -1163,7 +1328,12 @@ static void prefs_filtering_action_type_select(GtkList *list,
        case ACTION_MOVE:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, TRUE);
                gtk_widget_show(filtering_action.dest_btn);
@@ -1176,11 +1346,23 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_COPY:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, TRUE);
                gtk_widget_show(filtering_action.dest_btn);
@@ -1193,11 +1375,23 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_DELETE:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, FALSE);
                gtk_widget_show(filtering_action.dest_btn);
@@ -1210,6 +1404,13 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_MARK:
        case ACTION_UNMARK:
@@ -1217,12 +1418,21 @@ static void prefs_filtering_action_type_select(GtkList *list,
        case ACTION_UNLOCK:
        case ACTION_MARK_AS_READ:
        case ACTION_MARK_AS_UNREAD:
+       case ACTION_MARK_AS_SPAM:
+       case ACTION_MARK_AS_HAM:
         case ACTION_STOP:
         case ACTION_HIDE:
        case ACTION_IGNORE:
+       case ACTION_WATCH:
+       case ACTION_CLEAR_TAGS:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, FALSE);
                gtk_widget_show(filtering_action.dest_btn);
@@ -1235,11 +1445,23 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_FORWARD:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, TRUE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, TRUE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, TRUE);
                gtk_widget_show(filtering_action.dest_btn);
@@ -1252,11 +1474,23 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_FORWARD_AS_ATTACHMENT:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, TRUE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, TRUE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, TRUE);
                gtk_widget_show(filtering_action.dest_btn);
@@ -1269,11 +1503,23 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_REDIRECT:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, TRUE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, TRUE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, TRUE);
                gtk_widget_show(filtering_action.dest_btn);
@@ -1286,11 +1532,23 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_EXECUTE:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, TRUE);
                gtk_widget_hide(filtering_action.dest_btn);
@@ -1302,11 +1560,23 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_COLOR:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_hide(filtering_action.dest_entry);
                gtk_widget_hide(filtering_action.dest_btn);
                gtk_widget_hide(filtering_action.dest_label);
@@ -1317,12 +1587,24 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_show(filtering_action.color_optmenu);
                gtk_widget_show(filtering_action.color_label);
                gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        case ACTION_CHANGE_SCORE:
        case ACTION_SET_SCORE:
                gtk_widget_show(filtering_action.account_label);
                gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_show(filtering_action.account_combo);
                gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
                gtk_widget_show(filtering_action.dest_entry);
                gtk_widget_set_sensitive(filtering_action.dest_entry, TRUE);
                gtk_widget_hide(filtering_action.dest_btn);
@@ -1334,6 +1616,72 @@ static void prefs_filtering_action_type_select(GtkList *list,
                gtk_widget_hide(filtering_action.color_optmenu);
                gtk_widget_hide(filtering_action.color_label);
                gtk_widget_show(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
+               break;
+       case ACTION_ADD_TO_ADDRESSBOOK:
+               gtk_widget_hide(filtering_action.account_label);
+               gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_hide(filtering_action.account_combo);
+               gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_hide(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, FALSE);
+               gtk_widget_hide(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, FALSE);
+               gtk_widget_show(filtering_action.dest_entry);
+               gtk_widget_set_sensitive(filtering_action.dest_entry, TRUE);
+               gtk_widget_hide(filtering_action.dest_btn);
+               gtk_widget_set_sensitive(filtering_action.dest_btn, FALSE);
+               gtk_widget_hide(filtering_action.dest_label);
+               gtk_widget_set_sensitive(filtering_action.dest_label, FALSE);
+               gtk_widget_hide(filtering_action.recip_label);
+               gtk_widget_hide(filtering_action.exec_label);
+               gtk_widget_hide(filtering_action.exec_btn);
+               gtk_widget_hide(filtering_action.color_optmenu);
+               gtk_widget_hide(filtering_action.color_label);
+               gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_show(filtering_action.header_label);
+               gtk_widget_show(filtering_action.header_combo);
+               gtk_widget_show(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, TRUE);
+               gtk_widget_show(filtering_action.addressbook_label);
+               gtk_widget_show(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, TRUE);
+               break;
+       case ACTION_SET_TAG:
+       case ACTION_UNSET_TAG:
+               gtk_widget_show(filtering_action.account_label);
+               gtk_widget_set_sensitive(filtering_action.account_label, FALSE);
+               gtk_widget_show(filtering_action.account_combo);
+               gtk_widget_set_sensitive(filtering_action.account_combo, FALSE);
+               gtk_widget_show(filtering_action.tags_label);
+               gtk_widget_set_sensitive(filtering_action.tags_label, TRUE);
+               gtk_widget_show(filtering_action.tags_combo);
+               gtk_widget_set_sensitive(filtering_action.tags_combo, TRUE);
+               gtk_widget_hide(filtering_action.dest_entry);
+               gtk_widget_set_sensitive(filtering_action.dest_entry, FALSE);
+               gtk_widget_hide(filtering_action.dest_btn);
+               gtk_widget_set_sensitive(filtering_action.dest_btn, FALSE);
+               gtk_widget_hide(filtering_action.dest_label);
+               gtk_widget_hide(filtering_action.recip_label);
+               gtk_widget_set_sensitive(filtering_action.recip_label, TRUE);
+               gtk_widget_hide(filtering_action.exec_label);
+               gtk_widget_hide(filtering_action.exec_btn);
+               gtk_widget_hide(filtering_action.color_optmenu);
+               gtk_widget_hide(filtering_action.color_label);
+               gtk_widget_hide(filtering_action.score_label);
+               gtk_widget_hide(filtering_action.header_label);
+               gtk_widget_hide(filtering_action.header_combo);
+               gtk_widget_hide(filtering_action.header_entry);
+               gtk_widget_set_sensitive(filtering_action.header_entry, FALSE);
+               gtk_widget_hide(filtering_action.addressbook_label);
+               gtk_widget_hide(filtering_action.addressbook_btn);
+               gtk_widget_set_sensitive(filtering_action.addressbook_btn, FALSE);
                break;
        }
 }
@@ -1496,6 +1844,14 @@ static gboolean prefs_filtering_actions_selected
                gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
                                     ACTION_MARK_AS_UNREAD);
                break;
+       case MATCHACTION_MARK_AS_SPAM:
+               gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
+                                    ACTION_MARK_AS_SPAM);
+               break;
+       case MATCHACTION_MARK_AS_HAM:
+               gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
+                                    ACTION_MARK_AS_HAM);
+               break;
        case MATCHACTION_FORWARD:
                list_id = get_list_id_from_account_id(action->account_id);
                gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
@@ -1546,9 +1902,19 @@ static gboolean prefs_filtering_actions_selected
                gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
                                     ACTION_IGNORE);
                break;
+       case MATCHACTION_WATCH:
+               gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
+                                    ACTION_WATCH);
+               break;
+       case MATCHACTION_ADD_TO_ADDRESSBOOK:
+               if (action->header)
+                       gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), action->header);
+               else
+                       gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), "");
+               gtk_list_select_item(GTK_LIST(filtering_action.action_type_list),
+                                    ACTION_ADD_TO_ADDRESSBOOK);
        }
 
        filteringaction_free(action); /* XXX: memleak */
        return TRUE;
 }
-