2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
36 #include "prefs_gtk.h"
37 #include "prefs_filtering_action.h"
38 #include "prefs_common.h"
39 #include "mainwindow.h"
40 #include "foldersel.h"
41 #include "manage_window.h"
46 #include "alertpanel.h"
48 #include "description_window.h"
49 #include "addr_compl.h"
51 #include "matcher_parser.h"
52 #include "colorlabel.h"
62 static void prefs_filtering_action_create(void);
63 static void prefs_filtering_action_delete_cb(void);
64 static void prefs_filtering_action_substitute_cb(void);
65 static void prefs_filtering_action_register_cb(void);
66 static void prefs_filtering_action_reset_dialog(void);
67 static gboolean prefs_filtering_action_key_pressed(GtkWidget *widget,
68 GdkEventKey *event, gpointer data);
69 static void prefs_filtering_action_cancel(void);
70 static void prefs_filtering_action_ok(void);
71 static gint prefs_filtering_action_deleted(GtkWidget *widget,
72 GdkEventAny *event, gpointer data);
73 static void prefs_filtering_action_type_selection_changed(GtkWidget *widget,
75 static void prefs_filtering_action_select_dest(void);
76 static void prefs_filtering_action_select_addressbook(void);
77 static void prefs_filtering_action_up(void);
78 static void prefs_filtering_action_down(void);
79 static void prefs_filtering_action_set_dialog(GSList *action_list);
80 static GSList *prefs_filtering_action_get_list(void);
82 static GtkListStore* prefs_filtering_action_create_data_store (void);
83 static void prefs_filtering_action_list_view_insert_action (GtkWidget *list_view,
87 static GtkWidget *prefs_filtering_action_list_view_create (void);
88 static void prefs_filtering_action_create_list_view_columns (GtkTreeView *list_view);
89 static gboolean prefs_filtering_actions_selected (GtkTreeSelection *selector,
92 gboolean currently_selected,
95 static void prefs_filtering_action_exec_info(void);
98 *\brief UI data for matcher dialog
100 static struct FilteringAction_ {
105 GtkWidget *action_list_view;
109 GtkWidget *action_combo;
110 GtkWidget *account_combo;
111 GtkWidget *dest_entry;
114 GtkWidget *color_optmenu;
115 GtkWidget *header_combo;
116 GtkWidget *header_entry;
117 GtkWidget *addressbook_btn;
118 GtkWidget *score_entry;
119 GtkWidget *tags_combo;
125 typedef enum Action_ {
134 ACTION_MARK_AS_UNREAD,
138 ACTION_FORWARD_AS_ATTACHMENT,
150 ACTION_ADD_TO_ADDRESSBOOK,
152 /* add other action constants */
160 { NULL, N_("Move"), ACTION_MOVE },
161 { NULL, N_("Copy"), ACTION_COPY },
162 { NULL, N_("Delete"), ACTION_DELETE },
163 { NULL, N_("Hide"), ACTION_HIDE },
164 { N_("Message flags"), N_("Mark"), ACTION_MARK },
165 { N_("Message flags"), N_("Unmark"), ACTION_UNMARK },
166 { N_("Message flags"), N_("Lock"), ACTION_LOCK },
167 { N_("Message flags"), N_("Unlock"), ACTION_UNLOCK },
168 { N_("Message flags"), N_("Mark as read"), ACTION_MARK_AS_READ },
169 { N_("Message flags"), N_("Mark as unread"), ACTION_MARK_AS_UNREAD },
170 { N_("Message flags"), N_("Mark as spam"), ACTION_MARK_AS_SPAM },
171 { N_("Message flags"), N_("Mark as ham"), ACTION_MARK_AS_HAM },
172 { NULL, N_("Execute"), ACTION_EXECUTE },
173 { NULL, N_("Color"), ACTION_COLOR },
174 { N_("Resend"), N_("Forward"), ACTION_FORWARD },
175 { N_("Resend"), N_("Forward as attachment"), ACTION_FORWARD_AS_ATTACHMENT },
176 { N_("Resend"), N_("Redirect"), ACTION_REDIRECT },
177 { N_("Score"), N_("Change score"), ACTION_CHANGE_SCORE },
178 { N_("Score"), N_("Set score"), ACTION_SET_SCORE },
179 { N_("Tags"), N_("Apply tag"), ACTION_SET_TAG },
180 { N_("Tags"), N_("Unset tag"), ACTION_UNSET_TAG },
181 { N_("Tags"), N_("Clear tags"), ACTION_CLEAR_TAGS },
182 { N_("Threads"), N_("Ignore thread"), ACTION_IGNORE },
183 { N_("Threads"), N_("Watch thread"), ACTION_WATCH },
184 { NULL, N_("Add to address book"), ACTION_ADD_TO_ADDRESSBOOK },
185 { NULL, N_("Stop filter"), ACTION_STOP },
198 static PrefsFilteringActionSignal *filtering_action_callback;
200 static GtkTreeModel *prefs_filtering_action_create_model(void)
202 GtkTreeIter iter, iter2;
204 gchar *curr_menu = NULL;
207 store = gtk_tree_store_new(N_ACTION_COMBO, G_TYPE_STRING, G_TYPE_INT);
209 for(i = 0; action_menu[i].menu || action_menu[i].text; i++)
211 if(action_menu[i].menu) {
212 if(!curr_menu || strcmp(action_menu[i].menu, curr_menu)) {
213 gtk_tree_store_append(store, &iter, NULL);
214 gtk_tree_store_set(store, &iter,
215 ACTION_COMBO_TEXT, action_menu[i].menu,
217 curr_menu = action_menu[i].menu;
220 gtk_tree_store_append(store, &iter2, &iter);
221 gtk_tree_store_set(store, &iter2,
222 ACTION_COMBO_TEXT, action_menu[i].text,
223 ACTION_COMBO_DATA, action_menu[i].action,
228 gtk_tree_store_append(store, &iter, NULL);
229 gtk_tree_store_set(store, &iter,
230 ACTION_COMBO_TEXT, action_menu[i].text,
231 ACTION_COMBO_DATA, action_menu[i].action,
236 return GTK_TREE_MODEL(store);
239 static void cell_is_sensitive(GtkCellLayout *cell_layout,
240 GtkCellRenderer *cell,
241 GtkTreeModel *tree_model,
245 gboolean sensitive = !gtk_tree_model_iter_has_child (tree_model, iter);
246 g_object_set (cell, "sensitive", sensitive, NULL);
250 *\brief Opens the filtering action dialog with a list of actions
252 *\param matchers List of conditions
256 void prefs_filtering_action_open(GSList *action_list,
257 PrefsFilteringActionSignal *cb)
261 if (!filtering_action.window) {
262 prefs_filtering_action_create();
264 /* update color label menu */
265 gtk_option_menu_set_menu(GTK_OPTION_MENU(filtering_action.color_optmenu),
266 colorlabel_create_color_menu());
269 manage_window_set_transient(GTK_WINDOW(filtering_action.window));
270 gtk_widget_grab_focus(filtering_action.ok_btn);
272 filtering_action_callback = cb;
274 prefs_filtering_action_set_dialog(action_list);
276 gtk_widget_show(filtering_action.window);
280 *\brief Save Gtk object size to prefs dataset
282 static void prefs_filtering_action_size_allocate_cb(GtkWidget *widget,
283 GtkAllocation *allocation)
285 g_return_if_fail(allocation != NULL);
287 prefs_common.filteringactionwin_width = allocation->width;
288 prefs_common.filteringactionwin_height = allocation->height;
291 #define LABELS_WIDTH 80
292 #define SECOND_ROW_WIDTH 250
294 static void prefs_filtering_action_check_widget_width(GtkWidget *widget)
298 gtk_widget_size_request(widget, &req);
299 if(req.width > SECOND_ROW_WIDTH)
300 gtk_widget_set_size_request(widget, SECOND_ROW_WIDTH, -1);
304 *\brief Create the matcher dialog
306 static void prefs_filtering_action_create(void)
311 GtkWidget *cancel_btn;
312 GtkWidget *confirm_area;
322 GtkWidget *action_combo;
323 GtkWidget *account_combo;
324 GtkWidget *header_combo;
325 GtkWidget *header_entry;
326 GtkWidget *addressbook_btn;
327 GtkWidget *dest_entry;
329 GtkWidget *score_entry;
330 GtkWidget *tags_combo;
336 GtkWidget *subst_btn;
339 GtkWidget *action_hbox;
340 GtkWidget *action_scrolledwin;
341 GtkWidget *action_list_view;
349 GtkWidget *color_optmenu;
351 static GdkGeometry geometry;
356 GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
357 GtkSizeGroup *size_action = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
359 GtkCellRenderer *renderer;
361 debug_print("Creating matcher configuration window...\n");
363 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_filtering_action");
364 gtk_container_set_border_width(GTK_CONTAINER(window), VBOX_BORDER);
365 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
366 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
367 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
369 vbox = gtk_vbox_new(FALSE, 6);
370 gtk_container_add(GTK_CONTAINER(window), vbox);
372 gtkut_stock_button_set_create(&confirm_area,
373 &cancel_btn, GTK_STOCK_CANCEL,
374 &ok_btn, GTK_STOCK_OK,
376 gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
377 gtk_widget_grab_default(ok_btn);
379 gtk_window_set_title(GTK_WINDOW(window),
380 _("Filtering action configuration"));
381 g_signal_connect(G_OBJECT(window), "delete_event",
382 G_CALLBACK(prefs_filtering_action_deleted), NULL);
383 g_signal_connect(G_OBJECT(window), "size_allocate",
384 G_CALLBACK(prefs_filtering_action_size_allocate_cb), NULL);
385 g_signal_connect(G_OBJECT(window), "key_press_event",
386 G_CALLBACK(prefs_filtering_action_key_pressed), NULL);
387 MANAGE_WINDOW_SIGNALS_CONNECT(window);
388 g_signal_connect(G_OBJECT(ok_btn), "clicked",
389 G_CALLBACK(prefs_filtering_action_ok), NULL);
390 g_signal_connect(G_OBJECT(cancel_btn), "clicked",
391 G_CALLBACK(prefs_filtering_action_cancel), NULL);
393 vbox1 = gtk_vbox_new(FALSE, VSPACING);
394 gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
395 gtk_container_set_border_width(GTK_CONTAINER (vbox1), 2);
397 frame = gtk_frame_new(_("Rule"));
398 gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5);
399 gtk_box_pack_start (GTK_BOX (vbox1), frame, FALSE, FALSE, 0);
400 gtk_widget_set_size_request(frame, -1, 110);
402 table = gtk_table_new(3, 3, FALSE);
403 gtk_container_set_border_width(GTK_CONTAINER(table), 2);
404 gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
405 gtk_table_set_col_spacings (GTK_TABLE (table), HSPACING_NARROW);
406 gtk_container_add(GTK_CONTAINER(frame), table);
408 /* first row labels */
410 label1 = gtk_label_new (_("Action"));
411 gtk_widget_set_size_request(label1, LABELS_WIDTH, -1);
412 gtk_size_group_add_widget(size_group, label1);
413 gtk_misc_set_alignment (GTK_MISC (label1), 1, 0.5);
414 gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
415 GTK_FILL, GTK_SHRINK, 0, 0);
417 label2 = gtk_label_new ("");
418 gtk_size_group_add_widget(size_group, label2);
419 gtk_misc_set_alignment (GTK_MISC (label2), 1, 0.5);
420 gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
421 GTK_FILL, GTK_SHRINK, 0, 0);
423 label3 = gtk_label_new ("");
424 gtk_size_group_add_widget(size_group, label3);
425 gtk_misc_set_alignment (GTK_MISC (label3), 1, 0.5);
426 gtk_table_attach(GTK_TABLE(table), label3, 0, 1, 2, 3,
427 GTK_FILL, GTK_SHRINK, 0, 0);
431 hbox1 = gtk_hbox_new(FALSE, 0);
432 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 0, 1,
433 GTK_FILL, GTK_SHRINK, 0, 0);
435 model = prefs_filtering_action_create_model();
436 action_combo = gtk_combo_box_new_with_model(model);
437 gtk_size_group_add_widget(size_action, action_combo);
439 renderer = gtk_cell_renderer_text_new();
440 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(action_combo), renderer, TRUE);
441 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(action_combo), renderer,
442 "text", ACTION_COMBO_TEXT,
444 gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(action_combo), renderer,
445 cell_is_sensitive, NULL, NULL);
447 combobox_select_by_data(GTK_COMBO_BOX(action_combo), ACTION_MOVE);
448 g_signal_connect(G_OBJECT(action_combo), "changed",
449 G_CALLBACK(prefs_filtering_action_type_selection_changed),
451 gtk_box_pack_start(GTK_BOX(hbox1), action_combo, FALSE, FALSE, 0);
452 gtk_box_pack_start(GTK_BOX(hbox1), gtk_label_new(""), TRUE, TRUE, 0);
456 hbox1 = gtk_hbox_new (FALSE, 0);
457 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 1, 2,
458 GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
460 account_combo = gtk_combo_box_new_text ();
461 gtk_size_group_add_widget(size_action, account_combo);
463 for (accounts = account_get_list() ; accounts != NULL;
464 accounts = accounts->next) {
465 PrefsAccount *ac = (PrefsAccount *)accounts->data;
466 gchar *name = g_strdup(ac->account_name);
467 gtk_combo_box_append_text(GTK_COMBO_BOX(account_combo), (gpointer) name);
471 prefs_filtering_action_check_widget_width(account_combo);
472 gtk_combo_box_set_active(GTK_COMBO_BOX(account_combo), 0);
473 gtk_box_pack_start (GTK_BOX (hbox1), account_combo,
478 header_combo = combobox_text_new(TRUE, "From", "To", "Cc", "Reply-To", "Sender", NULL);
479 gtk_size_group_add_widget(size_action, header_combo);
480 gtk_box_pack_start (GTK_BOX (hbox1), header_combo,
482 header_entry = GTK_BIN(header_combo)->child;
486 hbox1 = gtk_hbox_new (FALSE, 0);
487 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 2, 3,
488 GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
490 dest_entry = gtk_entry_new ();
491 gtk_box_pack_start (GTK_BOX (hbox1), dest_entry, TRUE, TRUE, 0);
493 score_entry = gtk_spin_button_new_with_range(-1000, 1000, 1);
494 gtk_box_pack_start(GTK_BOX(hbox1), score_entry, FALSE, FALSE, 0);
496 color_optmenu = gtk_option_menu_new();
497 gtk_size_group_add_widget(size_action, color_optmenu);
498 gtk_option_menu_set_menu(GTK_OPTION_MENU(color_optmenu),
499 colorlabel_create_color_menu());
500 prefs_filtering_action_check_widget_width(color_optmenu);
501 gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, FALSE, FALSE, 0);
503 tags_combo = gtk_combo_box_new_text ();
504 gtk_size_group_add_widget(size_action, tags_combo);
506 for (tmp = tags = tags_get_list() ; tmp != NULL;
508 gchar *name = g_strdup(tags_get_tag(GPOINTER_TO_INT(tmp->data)));
510 gtk_combo_box_append_text(GTK_COMBO_BOX(tags_combo), (gpointer) name);
514 prefs_filtering_action_check_widget_width(tags_combo);
515 gtk_combo_box_set_active(GTK_COMBO_BOX(tags_combo), 0);
516 gtk_box_pack_start (GTK_BOX (hbox1), tags_combo,
519 hbox1 = gtk_hbox_new (FALSE, 0);
520 gtk_table_attach(GTK_TABLE(table), hbox1, 2, 3, 2, 3,
521 GTK_FILL, GTK_SHRINK, 0, 0);
523 dest_btn = gtk_button_new_with_label (_("Select ..."));
524 gtk_box_pack_start (GTK_BOX (hbox1), dest_btn, FALSE, FALSE, 0);
525 g_signal_connect (G_OBJECT (dest_btn), "clicked",
526 G_CALLBACK(prefs_filtering_action_select_dest),
529 addressbook_btn = gtk_button_new_with_label (_("Select ..."));
530 gtk_box_pack_start (GTK_BOX (hbox1), addressbook_btn, FALSE, FALSE, 0);
531 g_signal_connect (G_OBJECT (addressbook_btn), "clicked",
532 G_CALLBACK(prefs_filtering_action_select_addressbook),
535 #if GTK_CHECK_VERSION(2, 8, 0)
536 exec_btn = gtk_button_new_from_stock(GTK_STOCK_INFO);
538 exec_btn = gtk_button_new_with_label (_("Info..."));
540 gtk_box_pack_start (GTK_BOX (hbox1), exec_btn, FALSE, FALSE, 0);
541 g_signal_connect (G_OBJECT (exec_btn), "clicked",
542 G_CALLBACK(prefs_filtering_action_exec_info),
545 /* register / substitute / delete */
547 reg_hbox = gtk_hbox_new(FALSE, 4);
548 gtk_box_pack_start(GTK_BOX(vbox1), reg_hbox, FALSE, FALSE, 0);
550 arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
551 gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0);
552 gtk_widget_set_size_request(arrow, -1, 16);
554 btn_hbox = gtk_hbox_new(TRUE, 4);
555 gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0);
557 reg_btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
558 gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0);
559 g_signal_connect(G_OBJECT(reg_btn), "clicked",
560 G_CALLBACK(prefs_filtering_action_register_cb), NULL);
562 subst_btn = gtkut_get_replace_btn(_("Replace"));
563 gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0);
564 g_signal_connect(G_OBJECT(subst_btn), "clicked",
565 G_CALLBACK(prefs_filtering_action_substitute_cb),
568 del_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
569 gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
570 g_signal_connect(G_OBJECT(del_btn), "clicked",
571 G_CALLBACK(prefs_filtering_action_delete_cb), NULL);
573 action_hbox = gtk_hbox_new(FALSE, 8);
574 gtk_box_pack_start(GTK_BOX(vbox1), action_hbox, TRUE, TRUE, 0);
576 action_scrolledwin = gtk_scrolled_window_new(NULL, NULL);
577 gtk_widget_set_size_request(action_scrolledwin, -1, 150);
578 gtk_box_pack_start(GTK_BOX(action_hbox), action_scrolledwin,
580 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(action_scrolledwin),
581 GTK_SHADOW_ETCHED_IN);
582 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(action_scrolledwin),
583 GTK_POLICY_AUTOMATIC,
584 GTK_POLICY_AUTOMATIC);
586 action_list_view = prefs_filtering_action_list_view_create();
587 gtk_container_add(GTK_CONTAINER(action_scrolledwin), action_list_view);
589 btn_vbox = gtk_vbox_new(FALSE, 8);
590 gtk_box_pack_start(GTK_BOX(action_hbox), btn_vbox, FALSE, FALSE, 0);
592 up_btn = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
593 gtk_box_pack_start(GTK_BOX(btn_vbox), up_btn, FALSE, FALSE, 0);
594 g_signal_connect(G_OBJECT(up_btn), "clicked",
595 G_CALLBACK(prefs_filtering_action_up), NULL);
597 down_btn = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
598 gtk_box_pack_start(GTK_BOX(btn_vbox), down_btn, FALSE, FALSE, 0);
599 g_signal_connect(G_OBJECT(down_btn), "clicked",
600 G_CALLBACK(prefs_filtering_action_down), NULL);
602 if (!geometry.min_height) {
603 geometry.min_width = 490;
604 geometry.min_height = 348;
607 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
609 gtk_widget_set_size_request(window, prefs_common.filteringactionwin_width,
610 prefs_common.filteringactionwin_height);
612 gtk_widget_show_all(window);
614 filtering_action.window = window;
615 filtering_action.label1 = label1;
616 filtering_action.label2 = label2;
617 filtering_action.label3 = label3;
618 filtering_action.action_combo = action_combo;
619 filtering_action.account_combo = account_combo;
620 filtering_action.tags_combo = tags_combo;
621 filtering_action.dest_entry = dest_entry;
622 filtering_action.dest_btn = dest_btn;
623 filtering_action.exec_btn = exec_btn;
624 filtering_action.color_optmenu = color_optmenu;
625 filtering_action.score_entry = score_entry;
626 filtering_action.header_combo = header_combo;
627 filtering_action.header_entry = header_entry;
628 filtering_action.addressbook_btn = addressbook_btn;
629 filtering_action.ok_btn = ok_btn;
630 filtering_action.action_list_view = action_list_view;
632 prefs_filtering_action_type_selection_changed(NULL, NULL);
636 *\brief Set the contents of a row
638 *\param row Index of row to set
639 *\param prop Condition to set
642 static void prefs_filtering_action_list_view_set_row(GtkTreeIter *row,
643 FilteringAction *action)
647 if (row == NULL && action == NULL) {
648 prefs_filtering_action_list_view_insert_action
649 (filtering_action.action_list_view,
650 NULL, _("(New)"), FALSE);
654 filteringaction_to_string(buf, sizeof buf, action);
656 prefs_filtering_action_list_view_insert_action
657 (filtering_action.action_list_view,
662 *\brief Initializes dialog with a set of conditions
664 *\param matchers List of conditions
666 static void prefs_filtering_action_set_dialog(GSList *action_list)
670 gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model
671 (GTK_TREE_VIEW(filtering_action.action_list_view))));
673 prefs_filtering_action_list_view_set_row(NULL, NULL);
674 if (action_list != NULL) {
675 for (cur = action_list; cur != NULL;
676 cur = g_slist_next(cur)) {
677 FilteringAction *action;
678 action = (FilteringAction *) cur->data;
679 prefs_filtering_action_list_view_set_row(NULL, action);
683 prefs_filtering_action_reset_dialog();
687 *\brief Converts current actions in list box in
688 * an action list used by the filtering system.
690 *\return GSList * List of actions.
692 static GSList *prefs_filtering_action_get_list(void)
698 GtkTreeView *list_view = GTK_TREE_VIEW(filtering_action.action_list_view);
699 GtkTreeModel *model = gtk_tree_view_get_model(list_view);
704 while (gtk_tree_model_iter_nth_child(model, &iter, NULL, row)) {
706 gtk_tree_model_get(model, &iter,
707 PFA_ACTION, &action_str,
708 PFA_VALID_ACTION, &is_valid,
712 GSList * tmp_action_list;
713 tmp_action_list = matcher_parser_get_action_list(action_str);
715 if (tmp_action_list == NULL) {
720 action_list = g_slist_concat(action_list,
734 *\brief Returns account ID from the given list index
736 *\return gint account ID
738 static gint get_account_id_from_list_id(gint list_id)
742 for (accounts = account_get_list() ; accounts != NULL;
743 accounts = accounts->next) {
744 PrefsAccount *ac = (PrefsAccount *)accounts->data;
747 return ac->account_id;
754 *\brief Returns list index from the given account ID
756 *\return gint list index
758 static gint get_list_id_from_account_id(gint account_id)
763 for (accounts = account_get_list() ; accounts != NULL;
764 accounts = accounts->next) {
765 PrefsAccount *ac = (PrefsAccount *)accounts->data;
767 if (account_id == ac->account_id)
776 *\brief Returns parser action ID from internal action ID
778 *\return gint parser action ID
780 static gint prefs_filtering_action_get_matching_from_action(Action action_id)
784 return MATCHACTION_MOVE;
786 return MATCHACTION_SET_TAG;
787 case ACTION_UNSET_TAG:
788 return MATCHACTION_UNSET_TAG;
789 case ACTION_CLEAR_TAGS:
790 return MATCHACTION_CLEAR_TAGS;
792 return MATCHACTION_COPY;
794 return MATCHACTION_DELETE;
796 return MATCHACTION_MARK;
798 return MATCHACTION_UNMARK;
800 return MATCHACTION_LOCK;
802 return MATCHACTION_UNLOCK;
803 case ACTION_MARK_AS_READ:
804 return MATCHACTION_MARK_AS_READ;
805 case ACTION_MARK_AS_UNREAD:
806 return MATCHACTION_MARK_AS_UNREAD;
807 case ACTION_MARK_AS_SPAM:
808 return MATCHACTION_MARK_AS_SPAM;
809 case ACTION_MARK_AS_HAM:
810 return MATCHACTION_MARK_AS_HAM;
812 return MATCHACTION_FORWARD;
813 case ACTION_FORWARD_AS_ATTACHMENT:
814 return MATCHACTION_FORWARD_AS_ATTACHMENT;
815 case ACTION_REDIRECT:
816 return MATCHACTION_REDIRECT;
818 return MATCHACTION_EXECUTE;
820 return MATCHACTION_COLOR;
822 return MATCHACTION_HIDE;
824 return MATCHACTION_IGNORE;
826 return MATCHACTION_WATCH;
828 return MATCHACTION_STOP;
829 case ACTION_CHANGE_SCORE:
830 return MATCHACTION_CHANGE_SCORE;
831 case ACTION_SET_SCORE:
832 return MATCHACTION_SET_SCORE;
833 case ACTION_ADD_TO_ADDRESSBOOK:
834 return MATCHACTION_ADD_TO_ADDRESSBOOK;
841 *\brief Returns action from the content of the dialog
843 *\param alert specifies whether alert dialog boxes should be shown
846 *\return FilteringAction * action entered in the dialog box.
848 static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
854 gchar * destination = NULL;
856 FilteringAction * action;
858 gchar * header = NULL;
860 action_id = combobox_get_active_data(GTK_COMBO_BOX(filtering_action.action_combo));
861 action_type = prefs_filtering_action_get_matching_from_action(action_id);
862 list_id = gtk_combo_box_get_active(GTK_COMBO_BOX(filtering_action.account_combo));
863 account_id = get_account_id_from_list_id(list_id);
871 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
872 if (*destination == '\0') {
874 alertpanel_error(action_id == ACTION_EXECUTE
875 ? _("Command line not set")
876 : _("Destination is not set."));
882 case ACTION_FORWARD_AS_ATTACHMENT:
883 case ACTION_REDIRECT:
884 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
885 if (*destination == '\0') {
887 alertpanel_error(_("Recipient is not set."));
893 labelcolor = colorlabel_get_color_menu_active_item(
894 gtk_option_menu_get_menu(GTK_OPTION_MENU(filtering_action.color_optmenu)));
897 case ACTION_CHANGE_SCORE:
898 case ACTION_SET_SCORE:
899 score = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(
900 filtering_action.score_entry));
901 if (!score && action_id == ACTION_CHANGE_SCORE) {
903 alertpanel_error(_("Score is not set"));
907 case ACTION_ADD_TO_ADDRESSBOOK:
908 header = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.header_entry), 0, -1);
909 if (*header == '\0') {
911 alertpanel_error(_("Header is not set."));
915 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
916 if (*destination == '\0') {
918 alertpanel_error(_("Target addressbook/folder is not set."));
924 case ACTION_UNSET_TAG:
925 destination = gtk_combo_box_get_active_text(GTK_COMBO_BOX(filtering_action.tags_combo));
926 if (!destination || *destination == '\0') {
928 alertpanel_error(_("Tag name is empty."));
942 case ACTION_MARK_AS_READ:
943 case ACTION_MARK_AS_UNREAD:
944 case ACTION_MARK_AS_SPAM:
945 case ACTION_MARK_AS_HAM:
946 case ACTION_CLEAR_TAGS:
950 action = filteringaction_new(action_type, account_id,
951 destination, labelcolor, score, header);
958 *\brief Signal handler for register button
960 static void prefs_filtering_action_register_cb(void)
962 FilteringAction *action;
964 action = prefs_filtering_action_dialog_to_action(TRUE);
968 prefs_filtering_action_list_view_set_row(NULL, action);
970 filteringaction_free(action);
972 * (presumably gtk_list_select_item(), called by
973 * prefs_filtering_action_reset_dialog() activates
974 * what seems to be a bug. this causes any other
975 * list items to be unselectable)
976 * prefs_filtering_action_reset_dialog(); */
977 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo), 0);
978 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.tags_combo), 0);
979 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
983 *\brief Signal handler for substitute button
985 static void prefs_filtering_action_substitute_cb(void)
987 GtkTreeView *list_view = GTK_TREE_VIEW
988 (filtering_action.action_list_view);
989 GtkTreeSelection *selection = gtk_tree_view_get_selection(list_view);
993 FilteringAction *action;
995 if (!gtk_tree_selection_get_selected(selection, &model, &row))
998 gtk_tree_model_get(model, &row, PFA_VALID_ACTION, &is_valid, -1);
1002 action = prefs_filtering_action_dialog_to_action(TRUE);
1006 prefs_filtering_action_list_view_set_row(&row, action);
1008 filteringaction_free(action);
1010 prefs_filtering_action_reset_dialog();
1014 *\brief Signal handler for delete button
1016 static void prefs_filtering_action_delete_cb(void)
1018 GtkTreeView *list_view = GTK_TREE_VIEW
1019 (filtering_action.action_list_view);
1020 GtkTreeSelection *selection = gtk_tree_view_get_selection(list_view);
1021 GtkTreeModel *model;
1025 if (!gtk_tree_selection_get_selected(selection, &model, &row))
1028 gtk_tree_model_get(model, &row, PFA_VALID_ACTION, &is_valid, -1);
1032 gtk_list_store_remove(GTK_LIST_STORE(model), &row);
1034 prefs_filtering_action_reset_dialog();
1038 *\brief Signal handler for 'move up' button
1040 static void prefs_filtering_action_up(void)
1042 GtkTreePath *prev, *sel, *try;
1044 GtkListStore *store = NULL;
1045 GtkTreeModel *model = NULL;
1048 if (!gtk_tree_selection_get_selected
1049 (gtk_tree_view_get_selection
1050 (GTK_TREE_VIEW(filtering_action.action_list_view)),
1054 store = (GtkListStore *)model;
1055 sel = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &isel);
1059 /* no move if we're at row 0 or 1, looks phony, but other
1060 * solutions are more convoluted... */
1061 try = gtk_tree_path_copy(sel);
1062 if (!gtk_tree_path_prev(try) || !gtk_tree_path_prev(try)) {
1063 gtk_tree_path_free(try);
1064 gtk_tree_path_free(sel);
1067 gtk_tree_path_free(try);
1069 prev = gtk_tree_path_copy(sel);
1070 if (gtk_tree_path_prev(prev)) {
1071 gtk_tree_model_get_iter(GTK_TREE_MODEL(store),
1073 gtk_list_store_swap(store, &iprev, &isel);
1074 /* XXX: GTK2 select row?? */
1077 gtk_tree_path_free(sel);
1078 gtk_tree_path_free(prev);
1082 *\brief Signal handler for 'move down' button
1084 static void prefs_filtering_action_down(void)
1086 GtkListStore *store = NULL;
1087 GtkTreeModel *model = NULL;
1088 GtkTreeIter next, sel;
1091 if (!gtk_tree_selection_get_selected
1092 (gtk_tree_view_get_selection
1093 (GTK_TREE_VIEW(filtering_action.action_list_view)),
1097 store = (GtkListStore *)model;
1098 try = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &sel);
1102 /* move when not at row 0 ... */
1103 if (gtk_tree_path_prev(try)) {
1105 if (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &next))
1106 gtk_list_store_swap(store, &next, &sel);
1109 gtk_tree_path_free(try);
1113 *\brief Handle key press
1115 *\param widget Widget receiving key press
1116 *\param event Key event
1117 *\param data User data
1119 static gboolean prefs_filtering_action_key_pressed(GtkWidget *widget,
1120 GdkEventKey *event, gpointer data)
1122 if (event && event->keyval == GDK_Escape) {
1123 prefs_filtering_action_cancel();
1130 *\brief Cancel matcher dialog
1132 static void prefs_filtering_action_cancel(void)
1134 gtk_widget_destroy(filtering_action.window);
1135 filtering_action.window = NULL;
1140 *\brief Accept current matchers
1142 static void prefs_filtering_action_ok(void)
1144 GSList * action_list;
1147 action_list = prefs_filtering_action_get_list();
1149 if (action_list == NULL) {
1150 alertpanel_error(_("No action was defined."));
1154 if (filtering_action_callback != NULL)
1155 filtering_action_callback(action_list);
1156 for(cur = action_list ; cur != NULL ; cur = cur->next) {
1157 filteringaction_free(cur->data);
1159 g_slist_free(action_list);
1161 gtk_widget_destroy(filtering_action.window);
1162 filtering_action.window = NULL;
1167 *\brief Called when closing dialog box
1169 *\param widget Dialog widget
1170 *\param event Event info
1171 *\param data User data
1175 static gint prefs_filtering_action_deleted(GtkWidget *widget,
1176 GdkEventAny *event, gpointer data)
1178 prefs_filtering_action_cancel();
1183 * Strings describing exec format strings
1185 * When adding new lines, remember to put 2 strings for each line
1187 static gchar *exec_desc_strings[] = {
1188 "%%", N_("literal %"),
1189 "%s", N_("Subject"),
1194 "%i", N_("Message-ID"),
1195 "%n", N_("Newsgroups"),
1196 "%r", N_("References"),
1197 "%F", N_("filename (should not be modified)"),
1198 "\\n", N_("new line"),
1199 "\\", N_("escape character for quotes"),
1200 "\\\"", N_("quote character"),
1204 static DescriptionWindow exec_desc_win = {
1208 N_("Filtering Action: 'Execute'"),
1209 N_("'Execute' allows you to send a message or message element "
1210 "to an external program or script.\n"
1211 "The following symbols can be used:"),
1216 *\brief Show Execute action's info
1218 static void prefs_filtering_action_exec_info(void)
1220 description_window_create(&exec_desc_win);
1223 static void prefs_filtering_action_select_dest(void)
1228 dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
1231 path = folder_item_get_identifier(dest);
1233 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), path);
1237 static void prefs_filtering_action_select_addressbook(void)
1239 const gchar *folderpath = NULL;
1240 gchar *new_path = NULL;
1242 folderpath = gtk_entry_get_text(GTK_ENTRY(filtering_action.dest_entry));
1243 new_path = addressbook_folder_selection(folderpath);
1245 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), new_path);
1250 static void prefs_filtering_action_enable_widget(GtkWidget* widget, const gboolean enable)
1252 g_return_if_fail(widget != NULL);
1256 if(GTK_IS_COMBO_BOX(widget) || GTK_IS_COMBO_BOX_ENTRY(widget))
1257 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
1258 else if(GTK_IS_SPIN_BUTTON(widget))
1259 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), 0);
1260 else if(GTK_IS_ENTRY(widget)) {
1261 gtk_entry_set_text(GTK_ENTRY(widget), "");
1262 } else if(GTK_IS_OPTION_MENU(widget))
1263 gtk_option_menu_set_history(GTK_OPTION_MENU(widget), 0);
1265 gtk_widget_set_sensitive(widget, TRUE);
1266 gtk_widget_show(widget);
1268 gtk_widget_set_sensitive(widget, FALSE);
1269 gtk_widget_hide(widget);
1273 #define ACTION_SEND(x) (x == ACTION_FORWARD || x == ACTION_REDIRECT || \
1274 x == ACTION_FORWARD_AS_ATTACHMENT)
1275 #define ACTION_SCORE(x) (x == ACTION_CHANGE_SCORE || x == ACTION_SET_SCORE)
1276 #define ACTION_TAG(x) (x == ACTION_SET_TAG || x == ACTION_UNSET_TAG)
1277 #define ACTION_FILEOP(x) (x == ACTION_MOVE || x == ACTION_COPY)
1279 static void prefs_filtering_action_type_selection_changed(GtkWidget *combo,
1284 value = combobox_get_active_data(GTK_COMBO_BOX(filtering_action.action_combo));
1286 if (filtering_action.current_action != value) {
1287 if (ACTION_SEND(filtering_action.current_action)) {
1288 debug_print("unregistering address completion entry\n");
1289 address_completion_unregister_entry(GTK_ENTRY(filtering_action.dest_entry));
1290 address_completion_end(filtering_action.window);
1292 if (ACTION_SEND(value)) {
1293 debug_print("registering address completion entry\n");
1294 address_completion_start(filtering_action.window);
1295 address_completion_register_entry(
1296 GTK_ENTRY(filtering_action.dest_entry),
1299 filtering_action.current_action = value;
1302 prefs_filtering_action_enable_widget(filtering_action.label2,
1303 (ACTION_SEND(value) || value == ACTION_ADD_TO_ADDRESSBOOK));
1305 prefs_filtering_action_enable_widget(filtering_action.label3,
1306 (ACTION_SEND(value) || ACTION_TAG(value) ||
1307 ACTION_SCORE(value) || ACTION_FILEOP(value) ||
1308 value == ACTION_COLOR || value == ACTION_EXECUTE ||
1309 value == ACTION_ADD_TO_ADDRESSBOOK));
1311 prefs_filtering_action_enable_widget(filtering_action.account_combo,
1312 ACTION_SEND(value));
1314 prefs_filtering_action_enable_widget(filtering_action.tags_combo,
1317 prefs_filtering_action_enable_widget(filtering_action.dest_entry,
1318 (ACTION_FILEOP(value) || value == ACTION_EXECUTE ||
1319 ACTION_SEND(value) || value == ACTION_ADD_TO_ADDRESSBOOK));
1321 prefs_filtering_action_enable_widget(filtering_action.dest_btn,
1322 ACTION_FILEOP(value));
1324 prefs_filtering_action_enable_widget(filtering_action.exec_btn,
1325 (value == ACTION_EXECUTE));
1327 prefs_filtering_action_enable_widget(filtering_action.color_optmenu,
1328 (value == ACTION_COLOR));
1330 prefs_filtering_action_enable_widget(filtering_action.header_combo,
1331 (value == ACTION_ADD_TO_ADDRESSBOOK));
1333 prefs_filtering_action_enable_widget(filtering_action.addressbook_btn,
1334 (value == ACTION_ADD_TO_ADDRESSBOOK));
1336 prefs_filtering_action_enable_widget(filtering_action.score_entry,
1337 ACTION_SCORE(value));
1340 case ACTION_FORWARD:
1341 case ACTION_FORWARD_AS_ATTACHMENT:
1342 case ACTION_REDIRECT:
1343 gtk_label_set_text(GTK_LABEL(filtering_action.label2), _("Account"));
1344 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Recipient"));
1346 case ACTION_ADD_TO_ADDRESSBOOK:
1347 gtk_label_set_text(GTK_LABEL(filtering_action.label2), _("Header Name"));
1348 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Book/Folder"));
1352 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Destination"));
1355 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Color"));
1357 case ACTION_EXECUTE:
1358 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Execute"));
1360 case ACTION_SET_SCORE:
1361 case ACTION_CHANGE_SCORE:
1362 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Score"));
1364 case ACTION_SET_TAG:
1365 case ACTION_UNSET_TAG:
1366 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Tag"));
1371 static void prefs_filtering_action_reset_dialog(void)
1373 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo), ACTION_MOVE);
1374 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo), 0);
1375 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
1376 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry), 0);
1379 static GtkListStore* prefs_filtering_action_create_data_store(void)
1381 return gtk_list_store_new(N_PFA_COLUMNS,
1387 static void prefs_filtering_action_list_view_insert_action(GtkWidget *list_view,
1389 const gchar *action,
1392 GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model
1393 (GTK_TREE_VIEW(list_view)));
1397 /* see if row exists, if not append */
1399 gtk_list_store_append(store, &iter);
1403 gtk_list_store_set(store, &iter,
1405 PFA_VALID_ACTION, is_valid,
1409 static GtkWidget *prefs_filtering_action_list_view_create(void)
1411 GtkTreeView *list_view;
1412 GtkTreeModel *model;
1413 GtkTreeSelection *selector;
1415 model = GTK_TREE_MODEL(prefs_filtering_action_create_data_store());
1416 list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
1417 g_object_unref(model);
1419 gtk_tree_view_set_rules_hint(list_view, prefs_common.use_stripes_everywhere);
1421 selector = gtk_tree_view_get_selection(list_view);
1422 gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
1423 gtk_tree_selection_set_select_function
1424 (selector, prefs_filtering_actions_selected, NULL, NULL);
1426 /* create the columns */
1427 prefs_filtering_action_create_list_view_columns(list_view);
1429 return GTK_WIDGET(list_view);
1432 static void prefs_filtering_action_create_list_view_columns(GtkTreeView *list_view)
1434 GtkTreeViewColumn *column;
1435 GtkCellRenderer *renderer;
1437 renderer = gtk_cell_renderer_text_new();
1438 column = gtk_tree_view_column_new_with_attributes
1439 (_("Current action list"),
1443 gtk_tree_view_append_column(list_view, column);
1446 static gboolean prefs_filtering_actions_selected
1447 (GtkTreeSelection *selector,
1448 GtkTreeModel *model,
1450 gboolean currently_selected,
1454 FilteringAction *action;
1455 GSList * action_list;
1460 if (currently_selected)
1463 if (!gtk_tree_model_get_iter(model, &iter, path))
1466 gtk_tree_model_get(model, &iter,
1467 PFA_VALID_ACTION, &is_valid,
1471 prefs_filtering_action_reset_dialog();
1475 gtk_tree_model_get(model, &iter,
1476 PFA_ACTION, &action_str,
1479 action_list = matcher_parser_get_action_list(action_str);
1482 if (action_list == NULL)
1485 action = action_list->data;
1486 g_slist_free(action_list);
1488 if (action->destination)
1489 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), action->destination);
1491 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
1493 switch(action->type) {
1494 case MATCHACTION_MOVE:
1495 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1498 case MATCHACTION_COPY:
1499 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1502 case MATCHACTION_DELETE:
1503 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1506 case MATCHACTION_MARK:
1507 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1510 case MATCHACTION_UNMARK:
1511 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1514 case MATCHACTION_LOCK:
1515 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1518 case MATCHACTION_UNLOCK:
1519 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1522 case MATCHACTION_MARK_AS_READ:
1523 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1524 ACTION_MARK_AS_READ);
1526 case MATCHACTION_MARK_AS_UNREAD:
1527 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1528 ACTION_MARK_AS_UNREAD);
1530 case MATCHACTION_MARK_AS_SPAM:
1531 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1532 ACTION_MARK_AS_SPAM);
1534 case MATCHACTION_MARK_AS_HAM:
1535 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1536 ACTION_MARK_AS_HAM);
1538 case MATCHACTION_FORWARD:
1539 list_id = get_list_id_from_account_id(action->account_id);
1540 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1542 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1545 case MATCHACTION_FORWARD_AS_ATTACHMENT:
1546 list_id = get_list_id_from_account_id(action->account_id);
1547 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1548 ACTION_FORWARD_AS_ATTACHMENT);
1549 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1552 case MATCHACTION_REDIRECT:
1553 list_id = get_list_id_from_account_id(action->account_id);
1554 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1556 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1559 case MATCHACTION_EXECUTE:
1560 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1563 case MATCHACTION_COLOR:
1564 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1566 gtk_option_menu_set_history(GTK_OPTION_MENU(filtering_action.color_optmenu),
1567 action->labelcolor);
1569 case MATCHACTION_CHANGE_SCORE:
1570 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1571 ACTION_CHANGE_SCORE);
1572 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry),
1575 case MATCHACTION_SET_SCORE:
1576 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1578 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry),
1581 case MATCHACTION_STOP:
1582 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1585 case MATCHACTION_HIDE:
1586 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1589 case MATCHACTION_IGNORE:
1590 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1593 case MATCHACTION_WATCH:
1594 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1597 case MATCHACTION_ADD_TO_ADDRESSBOOK:
1599 gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), action->header);
1601 gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), "");
1602 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1603 ACTION_ADD_TO_ADDRESSBOOK);
1606 filteringaction_free(action); /* XXX: memleak */