2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2003-2007 the Claws Mail team
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 label"), 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,
216 gettext(action_menu[i].menu),
218 curr_menu = action_menu[i].menu;
221 gtk_tree_store_append(store, &iter2, &iter);
222 gtk_tree_store_set(store, &iter2,
223 ACTION_COMBO_TEXT, gettext(action_menu[i].text),
224 ACTION_COMBO_DATA, action_menu[i].action,
229 gtk_tree_store_append(store, &iter, NULL);
230 gtk_tree_store_set(store, &iter,
231 ACTION_COMBO_TEXT, gettext(action_menu[i].text),
232 ACTION_COMBO_DATA, action_menu[i].action,
237 return GTK_TREE_MODEL(store);
240 static void cell_is_sensitive(GtkCellLayout *cell_layout,
241 GtkCellRenderer *cell,
242 GtkTreeModel *tree_model,
246 gboolean sensitive = !gtk_tree_model_iter_has_child (tree_model, iter);
247 g_object_set (cell, "sensitive", sensitive, NULL);
251 *\brief Opens the filtering action dialog with a list of actions
253 *\param matchers List of conditions
257 void prefs_filtering_action_open(GSList *action_list,
258 PrefsFilteringActionSignal *cb)
262 if (!filtering_action.window) {
263 prefs_filtering_action_create();
265 /* update color label menu */
266 gtk_option_menu_set_menu(GTK_OPTION_MENU(filtering_action.color_optmenu),
267 colorlabel_create_color_menu());
270 manage_window_set_transient(GTK_WINDOW(filtering_action.window));
271 gtk_widget_grab_focus(filtering_action.ok_btn);
273 filtering_action_callback = cb;
275 prefs_filtering_action_set_dialog(action_list);
277 gtk_widget_show(filtering_action.window);
281 *\brief Save Gtk object size to prefs dataset
283 static void prefs_filtering_action_size_allocate_cb(GtkWidget *widget,
284 GtkAllocation *allocation)
286 g_return_if_fail(allocation != NULL);
288 prefs_common.filteringactionwin_width = allocation->width;
289 prefs_common.filteringactionwin_height = allocation->height;
292 #define LABELS_WIDTH 80
293 #define SECOND_ROW_WIDTH 250
295 static void prefs_filtering_action_check_widget_width(GtkWidget *widget)
299 gtk_widget_size_request(widget, &req);
300 if(req.width > SECOND_ROW_WIDTH)
301 gtk_widget_set_size_request(widget, SECOND_ROW_WIDTH, -1);
305 *\brief Create the matcher dialog
307 static void prefs_filtering_action_create(void)
312 GtkWidget *cancel_btn;
313 GtkWidget *confirm_area;
323 GtkWidget *action_combo;
324 GtkWidget *account_combo;
325 GtkWidget *header_combo;
326 GtkWidget *header_entry;
327 GtkWidget *addressbook_btn;
328 GtkWidget *dest_entry;
330 GtkWidget *score_entry;
331 GtkWidget *tags_combo;
337 GtkWidget *subst_btn;
340 GtkWidget *action_hbox;
341 GtkWidget *action_scrolledwin;
342 GtkWidget *action_list_view;
350 GtkWidget *color_optmenu;
352 static GdkGeometry geometry;
357 GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
358 GtkSizeGroup *size_action = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
360 GtkCellRenderer *renderer;
362 debug_print("Creating matcher configuration window...\n");
364 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_filtering_action");
365 gtk_container_set_border_width(GTK_CONTAINER(window), VBOX_BORDER);
366 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
367 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
368 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
370 vbox = gtk_vbox_new(FALSE, 6);
371 gtk_container_add(GTK_CONTAINER(window), vbox);
373 gtkut_stock_button_set_create(&confirm_area,
374 &cancel_btn, GTK_STOCK_CANCEL,
375 &ok_btn, GTK_STOCK_OK,
377 gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
378 gtk_widget_grab_default(ok_btn);
380 gtk_window_set_title(GTK_WINDOW(window),
381 _("Filtering action configuration"));
382 g_signal_connect(G_OBJECT(window), "delete_event",
383 G_CALLBACK(prefs_filtering_action_deleted), NULL);
384 g_signal_connect(G_OBJECT(window), "size_allocate",
385 G_CALLBACK(prefs_filtering_action_size_allocate_cb), NULL);
386 g_signal_connect(G_OBJECT(window), "key_press_event",
387 G_CALLBACK(prefs_filtering_action_key_pressed), NULL);
388 MANAGE_WINDOW_SIGNALS_CONNECT(window);
389 g_signal_connect(G_OBJECT(ok_btn), "clicked",
390 G_CALLBACK(prefs_filtering_action_ok), NULL);
391 g_signal_connect(G_OBJECT(cancel_btn), "clicked",
392 G_CALLBACK(prefs_filtering_action_cancel), NULL);
394 vbox1 = gtk_vbox_new(FALSE, VSPACING);
395 gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
396 gtk_container_set_border_width(GTK_CONTAINER (vbox1), 2);
398 frame = gtk_frame_new(_("Rule"));
399 gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5);
400 gtk_box_pack_start (GTK_BOX (vbox1), frame, FALSE, FALSE, 0);
401 gtk_widget_set_size_request(frame, -1, 110);
403 table = gtk_table_new(3, 3, FALSE);
404 gtk_container_set_border_width(GTK_CONTAINER(table), 2);
405 gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
406 gtk_table_set_col_spacings (GTK_TABLE (table), HSPACING_NARROW);
407 gtk_container_add(GTK_CONTAINER(frame), table);
409 /* first row labels */
411 label1 = gtk_label_new (_("Action"));
412 gtk_widget_set_size_request(label1, LABELS_WIDTH, -1);
413 gtk_size_group_add_widget(size_group, label1);
414 gtk_misc_set_alignment (GTK_MISC (label1), 1, 0.5);
415 gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
416 GTK_FILL, GTK_SHRINK, 0, 0);
418 label2 = gtk_label_new ("");
419 gtk_size_group_add_widget(size_group, label2);
420 gtk_misc_set_alignment (GTK_MISC (label2), 1, 0.5);
421 gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
422 GTK_FILL, GTK_SHRINK, 0, 0);
424 label3 = gtk_label_new ("");
425 gtk_size_group_add_widget(size_group, label3);
426 gtk_misc_set_alignment (GTK_MISC (label3), 1, 0.5);
427 gtk_table_attach(GTK_TABLE(table), label3, 0, 1, 2, 3,
428 GTK_FILL, GTK_SHRINK, 0, 0);
432 hbox1 = gtk_hbox_new(FALSE, 0);
433 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 0, 1,
434 GTK_FILL, GTK_SHRINK, 0, 0);
436 model = prefs_filtering_action_create_model();
437 action_combo = gtk_combo_box_new_with_model(model);
438 gtk_size_group_add_widget(size_action, action_combo);
440 renderer = gtk_cell_renderer_text_new();
441 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(action_combo), renderer, TRUE);
442 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(action_combo), renderer,
443 "text", ACTION_COMBO_TEXT,
445 gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(action_combo), renderer,
446 cell_is_sensitive, NULL, NULL);
448 combobox_select_by_data(GTK_COMBO_BOX(action_combo), ACTION_MOVE);
449 g_signal_connect(G_OBJECT(action_combo), "changed",
450 G_CALLBACK(prefs_filtering_action_type_selection_changed),
452 gtk_box_pack_start(GTK_BOX(hbox1), action_combo, FALSE, FALSE, 0);
453 gtk_box_pack_start(GTK_BOX(hbox1), gtk_label_new(""), TRUE, TRUE, 0);
457 hbox1 = gtk_hbox_new (FALSE, 0);
458 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 1, 2,
459 GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
461 account_combo = gtk_combo_box_new_text ();
462 gtk_size_group_add_widget(size_action, account_combo);
464 for (accounts = account_get_list() ; accounts != NULL;
465 accounts = accounts->next) {
466 PrefsAccount *ac = (PrefsAccount *)accounts->data;
467 gchar *name = g_strdup(ac->account_name);
468 gtk_combo_box_append_text(GTK_COMBO_BOX(account_combo), (gpointer) name);
472 prefs_filtering_action_check_widget_width(account_combo);
473 gtk_combo_box_set_active(GTK_COMBO_BOX(account_combo), 0);
474 gtk_box_pack_start (GTK_BOX (hbox1), account_combo,
479 header_combo = combobox_text_new(TRUE, "From", "To", "Cc", "Reply-To", "Sender", NULL);
480 gtk_size_group_add_widget(size_action, header_combo);
481 gtk_box_pack_start (GTK_BOX (hbox1), header_combo,
483 header_entry = GTK_BIN(header_combo)->child;
487 hbox1 = gtk_hbox_new (FALSE, 0);
488 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 2, 3,
489 GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
491 dest_entry = gtk_entry_new ();
492 gtk_box_pack_start (GTK_BOX (hbox1), dest_entry, TRUE, TRUE, 0);
494 score_entry = gtk_spin_button_new_with_range(-1000, 1000, 1);
495 gtk_box_pack_start(GTK_BOX(hbox1), score_entry, FALSE, FALSE, 0);
497 color_optmenu = gtk_option_menu_new();
498 gtk_size_group_add_widget(size_action, color_optmenu);
499 gtk_option_menu_set_menu(GTK_OPTION_MENU(color_optmenu),
500 colorlabel_create_color_menu());
501 prefs_filtering_action_check_widget_width(color_optmenu);
502 gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, FALSE, FALSE, 0);
504 tags_combo = gtk_combo_box_new_text ();
505 gtk_size_group_add_widget(size_action, tags_combo);
507 for (tmp = tags = tags_get_list() ; tmp != NULL;
509 gchar *name = g_strdup(tags_get_tag(GPOINTER_TO_INT(tmp->data)));
511 gtk_combo_box_append_text(GTK_COMBO_BOX(tags_combo), (gpointer) name);
515 prefs_filtering_action_check_widget_width(tags_combo);
516 gtk_combo_box_set_active(GTK_COMBO_BOX(tags_combo), 0);
517 gtk_box_pack_start (GTK_BOX (hbox1), tags_combo,
520 hbox1 = gtk_hbox_new (FALSE, 0);
521 gtk_table_attach(GTK_TABLE(table), hbox1, 2, 3, 2, 3,
522 GTK_FILL, GTK_SHRINK, 0, 0);
524 dest_btn = gtk_button_new_with_label (_("Select ..."));
525 gtk_box_pack_start (GTK_BOX (hbox1), dest_btn, FALSE, FALSE, 0);
526 g_signal_connect (G_OBJECT (dest_btn), "clicked",
527 G_CALLBACK(prefs_filtering_action_select_dest),
530 addressbook_btn = gtk_button_new_with_label (_("Select ..."));
531 gtk_box_pack_start (GTK_BOX (hbox1), addressbook_btn, FALSE, FALSE, 0);
532 g_signal_connect (G_OBJECT (addressbook_btn), "clicked",
533 G_CALLBACK(prefs_filtering_action_select_addressbook),
536 #if GTK_CHECK_VERSION(2, 8, 0)
537 exec_btn = gtk_button_new_from_stock(GTK_STOCK_INFO);
539 exec_btn = gtk_button_new_with_label (_("Info..."));
541 gtk_box_pack_start (GTK_BOX (hbox1), exec_btn, FALSE, FALSE, 0);
542 g_signal_connect (G_OBJECT (exec_btn), "clicked",
543 G_CALLBACK(prefs_filtering_action_exec_info),
546 /* register / substitute / delete */
548 reg_hbox = gtk_hbox_new(FALSE, 4);
549 gtk_box_pack_start(GTK_BOX(vbox1), reg_hbox, FALSE, FALSE, 0);
551 arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
552 gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0);
553 gtk_widget_set_size_request(arrow, -1, 16);
555 btn_hbox = gtk_hbox_new(TRUE, 4);
556 gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0);
558 reg_btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
559 gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0);
560 g_signal_connect(G_OBJECT(reg_btn), "clicked",
561 G_CALLBACK(prefs_filtering_action_register_cb), NULL);
563 subst_btn = gtkut_get_replace_btn(_("Replace"));
564 gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0);
565 g_signal_connect(G_OBJECT(subst_btn), "clicked",
566 G_CALLBACK(prefs_filtering_action_substitute_cb),
569 del_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
570 gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
571 g_signal_connect(G_OBJECT(del_btn), "clicked",
572 G_CALLBACK(prefs_filtering_action_delete_cb), NULL);
574 action_hbox = gtk_hbox_new(FALSE, 8);
575 gtk_box_pack_start(GTK_BOX(vbox1), action_hbox, TRUE, TRUE, 0);
577 action_scrolledwin = gtk_scrolled_window_new(NULL, NULL);
578 gtk_widget_set_size_request(action_scrolledwin, -1, 150);
579 gtk_box_pack_start(GTK_BOX(action_hbox), action_scrolledwin,
581 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(action_scrolledwin),
582 GTK_SHADOW_ETCHED_IN);
583 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(action_scrolledwin),
584 GTK_POLICY_AUTOMATIC,
585 GTK_POLICY_AUTOMATIC);
587 action_list_view = prefs_filtering_action_list_view_create();
588 gtk_container_add(GTK_CONTAINER(action_scrolledwin), action_list_view);
590 btn_vbox = gtk_vbox_new(FALSE, 8);
591 gtk_box_pack_start(GTK_BOX(action_hbox), btn_vbox, FALSE, FALSE, 0);
593 up_btn = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
594 gtk_box_pack_start(GTK_BOX(btn_vbox), up_btn, FALSE, FALSE, 0);
595 g_signal_connect(G_OBJECT(up_btn), "clicked",
596 G_CALLBACK(prefs_filtering_action_up), NULL);
598 down_btn = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
599 gtk_box_pack_start(GTK_BOX(btn_vbox), down_btn, FALSE, FALSE, 0);
600 g_signal_connect(G_OBJECT(down_btn), "clicked",
601 G_CALLBACK(prefs_filtering_action_down), NULL);
603 if (!geometry.min_height) {
604 geometry.min_width = 490;
605 geometry.min_height = 348;
608 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
610 gtk_widget_set_size_request(window, prefs_common.filteringactionwin_width,
611 prefs_common.filteringactionwin_height);
613 gtk_widget_show_all(window);
615 filtering_action.window = window;
616 filtering_action.label1 = label1;
617 filtering_action.label2 = label2;
618 filtering_action.label3 = label3;
619 filtering_action.action_combo = action_combo;
620 filtering_action.account_combo = account_combo;
621 filtering_action.tags_combo = tags_combo;
622 filtering_action.dest_entry = dest_entry;
623 filtering_action.dest_btn = dest_btn;
624 filtering_action.exec_btn = exec_btn;
625 filtering_action.color_optmenu = color_optmenu;
626 filtering_action.score_entry = score_entry;
627 filtering_action.header_combo = header_combo;
628 filtering_action.header_entry = header_entry;
629 filtering_action.addressbook_btn = addressbook_btn;
630 filtering_action.ok_btn = ok_btn;
631 filtering_action.action_list_view = action_list_view;
633 prefs_filtering_action_type_selection_changed(NULL, NULL);
637 *\brief Set the contents of a row
639 *\param row Index of row to set
640 *\param prop Condition to set
643 static void prefs_filtering_action_list_view_set_row(GtkTreeIter *row,
644 FilteringAction *action)
648 if (row == NULL && action == NULL) {
649 prefs_filtering_action_list_view_insert_action
650 (filtering_action.action_list_view,
651 NULL, _("(New)"), FALSE);
655 filteringaction_to_string(buf, sizeof buf, action);
657 prefs_filtering_action_list_view_insert_action
658 (filtering_action.action_list_view,
663 *\brief Initializes dialog with a set of conditions
665 *\param matchers List of conditions
667 static void prefs_filtering_action_set_dialog(GSList *action_list)
671 gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model
672 (GTK_TREE_VIEW(filtering_action.action_list_view))));
674 prefs_filtering_action_list_view_set_row(NULL, NULL);
675 if (action_list != NULL) {
676 for (cur = action_list; cur != NULL;
677 cur = g_slist_next(cur)) {
678 FilteringAction *action;
679 action = (FilteringAction *) cur->data;
680 prefs_filtering_action_list_view_set_row(NULL, action);
684 prefs_filtering_action_reset_dialog();
688 *\brief Converts current actions in list box in
689 * an action list used by the filtering system.
691 *\return GSList * List of actions.
693 static GSList *prefs_filtering_action_get_list(void)
699 GtkTreeView *list_view = GTK_TREE_VIEW(filtering_action.action_list_view);
700 GtkTreeModel *model = gtk_tree_view_get_model(list_view);
705 while (gtk_tree_model_iter_nth_child(model, &iter, NULL, row)) {
707 gtk_tree_model_get(model, &iter,
708 PFA_ACTION, &action_str,
709 PFA_VALID_ACTION, &is_valid,
713 GSList * tmp_action_list;
714 tmp_action_list = matcher_parser_get_action_list(action_str);
716 if (tmp_action_list == NULL) {
721 action_list = g_slist_concat(action_list,
735 *\brief Returns account ID from the given list index
737 *\return gint account ID
739 static gint get_account_id_from_list_id(gint list_id)
743 for (accounts = account_get_list() ; accounts != NULL;
744 accounts = accounts->next) {
745 PrefsAccount *ac = (PrefsAccount *)accounts->data;
748 return ac->account_id;
755 *\brief Returns list index from the given account ID
757 *\return gint list index
759 static gint get_list_id_from_account_id(gint account_id)
764 for (accounts = account_get_list() ; accounts != NULL;
765 accounts = accounts->next) {
766 PrefsAccount *ac = (PrefsAccount *)accounts->data;
768 if (account_id == ac->account_id)
777 *\brief Returns parser action ID from internal action ID
779 *\return gint parser action ID
781 static gint prefs_filtering_action_get_matching_from_action(Action action_id)
785 return MATCHACTION_MOVE;
787 return MATCHACTION_SET_TAG;
788 case ACTION_UNSET_TAG:
789 return MATCHACTION_UNSET_TAG;
790 case ACTION_CLEAR_TAGS:
791 return MATCHACTION_CLEAR_TAGS;
793 return MATCHACTION_COPY;
795 return MATCHACTION_DELETE;
797 return MATCHACTION_MARK;
799 return MATCHACTION_UNMARK;
801 return MATCHACTION_LOCK;
803 return MATCHACTION_UNLOCK;
804 case ACTION_MARK_AS_READ:
805 return MATCHACTION_MARK_AS_READ;
806 case ACTION_MARK_AS_UNREAD:
807 return MATCHACTION_MARK_AS_UNREAD;
808 case ACTION_MARK_AS_SPAM:
809 return MATCHACTION_MARK_AS_SPAM;
810 case ACTION_MARK_AS_HAM:
811 return MATCHACTION_MARK_AS_HAM;
813 return MATCHACTION_FORWARD;
814 case ACTION_FORWARD_AS_ATTACHMENT:
815 return MATCHACTION_FORWARD_AS_ATTACHMENT;
816 case ACTION_REDIRECT:
817 return MATCHACTION_REDIRECT;
819 return MATCHACTION_EXECUTE;
821 return MATCHACTION_COLOR;
823 return MATCHACTION_HIDE;
825 return MATCHACTION_IGNORE;
827 return MATCHACTION_WATCH;
829 return MATCHACTION_STOP;
830 case ACTION_CHANGE_SCORE:
831 return MATCHACTION_CHANGE_SCORE;
832 case ACTION_SET_SCORE:
833 return MATCHACTION_SET_SCORE;
834 case ACTION_ADD_TO_ADDRESSBOOK:
835 return MATCHACTION_ADD_TO_ADDRESSBOOK;
842 *\brief Returns action from the content of the dialog
844 *\param alert specifies whether alert dialog boxes should be shown
847 *\return FilteringAction * action entered in the dialog box.
849 static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
855 gchar * destination = NULL;
857 FilteringAction * action;
859 gchar * header = NULL;
861 action_id = combobox_get_active_data(GTK_COMBO_BOX(filtering_action.action_combo));
862 action_type = prefs_filtering_action_get_matching_from_action(action_id);
863 list_id = gtk_combo_box_get_active(GTK_COMBO_BOX(filtering_action.account_combo));
864 account_id = get_account_id_from_list_id(list_id);
872 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
873 if (*destination == '\0') {
875 alertpanel_error(action_id == ACTION_EXECUTE
876 ? _("Command line not set")
877 : _("Destination is not set."));
883 case ACTION_FORWARD_AS_ATTACHMENT:
884 case ACTION_REDIRECT:
885 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
886 if (*destination == '\0') {
888 alertpanel_error(_("Recipient is not set."));
894 labelcolor = colorlabel_get_color_menu_active_item(
895 gtk_option_menu_get_menu(GTK_OPTION_MENU(filtering_action.color_optmenu)));
898 case ACTION_CHANGE_SCORE:
899 case ACTION_SET_SCORE:
900 score = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(
901 filtering_action.score_entry));
902 if (!score && action_id == ACTION_CHANGE_SCORE) {
904 alertpanel_error(_("Score is not set"));
908 case ACTION_ADD_TO_ADDRESSBOOK:
909 header = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.header_entry), 0, -1);
910 if (*header == '\0') {
912 alertpanel_error(_("Header is not set."));
916 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
917 if (*destination == '\0') {
919 alertpanel_error(_("Target addressbook/folder is not set."));
925 case ACTION_UNSET_TAG:
926 destination = gtk_combo_box_get_active_text(GTK_COMBO_BOX(filtering_action.tags_combo));
927 if (!destination || *destination == '\0') {
929 alertpanel_error(_("Tag name is empty."));
943 case ACTION_MARK_AS_READ:
944 case ACTION_MARK_AS_UNREAD:
945 case ACTION_MARK_AS_SPAM:
946 case ACTION_MARK_AS_HAM:
947 case ACTION_CLEAR_TAGS:
951 action = filteringaction_new(action_type, account_id,
952 destination, labelcolor, score, header);
959 *\brief Signal handler for register button
961 static void prefs_filtering_action_register_cb(void)
963 FilteringAction *action;
965 action = prefs_filtering_action_dialog_to_action(TRUE);
969 prefs_filtering_action_list_view_set_row(NULL, action);
971 filteringaction_free(action);
973 * (presumably gtk_list_select_item(), called by
974 * prefs_filtering_action_reset_dialog() activates
975 * what seems to be a bug. this causes any other
976 * list items to be unselectable)
977 * prefs_filtering_action_reset_dialog(); */
978 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo), 0);
979 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.tags_combo), 0);
980 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
984 *\brief Signal handler for substitute button
986 static void prefs_filtering_action_substitute_cb(void)
988 GtkTreeView *list_view = GTK_TREE_VIEW
989 (filtering_action.action_list_view);
990 GtkTreeSelection *selection = gtk_tree_view_get_selection(list_view);
994 FilteringAction *action;
996 if (!gtk_tree_selection_get_selected(selection, &model, &row))
999 gtk_tree_model_get(model, &row, PFA_VALID_ACTION, &is_valid, -1);
1003 action = prefs_filtering_action_dialog_to_action(TRUE);
1007 prefs_filtering_action_list_view_set_row(&row, action);
1009 filteringaction_free(action);
1011 prefs_filtering_action_reset_dialog();
1015 *\brief Signal handler for delete button
1017 static void prefs_filtering_action_delete_cb(void)
1019 GtkTreeView *list_view = GTK_TREE_VIEW
1020 (filtering_action.action_list_view);
1021 GtkTreeSelection *selection = gtk_tree_view_get_selection(list_view);
1022 GtkTreeModel *model;
1026 if (!gtk_tree_selection_get_selected(selection, &model, &row))
1029 gtk_tree_model_get(model, &row, PFA_VALID_ACTION, &is_valid, -1);
1033 gtk_list_store_remove(GTK_LIST_STORE(model), &row);
1035 prefs_filtering_action_reset_dialog();
1039 *\brief Signal handler for 'move up' button
1041 static void prefs_filtering_action_up(void)
1043 GtkTreePath *prev, *sel, *try;
1045 GtkListStore *store = NULL;
1046 GtkTreeModel *model = NULL;
1049 if (!gtk_tree_selection_get_selected
1050 (gtk_tree_view_get_selection
1051 (GTK_TREE_VIEW(filtering_action.action_list_view)),
1055 store = (GtkListStore *)model;
1056 sel = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &isel);
1060 /* no move if we're at row 0 or 1, looks phony, but other
1061 * solutions are more convoluted... */
1062 try = gtk_tree_path_copy(sel);
1063 if (!gtk_tree_path_prev(try) || !gtk_tree_path_prev(try)) {
1064 gtk_tree_path_free(try);
1065 gtk_tree_path_free(sel);
1068 gtk_tree_path_free(try);
1070 prev = gtk_tree_path_copy(sel);
1071 if (gtk_tree_path_prev(prev)) {
1072 gtk_tree_model_get_iter(GTK_TREE_MODEL(store),
1074 gtk_list_store_swap(store, &iprev, &isel);
1075 /* XXX: GTK2 select row?? */
1078 gtk_tree_path_free(sel);
1079 gtk_tree_path_free(prev);
1083 *\brief Signal handler for 'move down' button
1085 static void prefs_filtering_action_down(void)
1087 GtkListStore *store = NULL;
1088 GtkTreeModel *model = NULL;
1089 GtkTreeIter next, sel;
1092 if (!gtk_tree_selection_get_selected
1093 (gtk_tree_view_get_selection
1094 (GTK_TREE_VIEW(filtering_action.action_list_view)),
1098 store = (GtkListStore *)model;
1099 try = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &sel);
1103 /* move when not at row 0 ... */
1104 if (gtk_tree_path_prev(try)) {
1106 if (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &next))
1107 gtk_list_store_swap(store, &next, &sel);
1110 gtk_tree_path_free(try);
1114 *\brief Handle key press
1116 *\param widget Widget receiving key press
1117 *\param event Key event
1118 *\param data User data
1120 static gboolean prefs_filtering_action_key_pressed(GtkWidget *widget,
1121 GdkEventKey *event, gpointer data)
1123 if (event && event->keyval == GDK_Escape) {
1124 prefs_filtering_action_cancel();
1131 *\brief Cancel matcher dialog
1133 static void prefs_filtering_action_cancel(void)
1135 gtk_widget_destroy(filtering_action.window);
1136 filtering_action.window = NULL;
1141 *\brief Accept current matchers
1143 static void prefs_filtering_action_ok(void)
1145 GSList * action_list;
1148 action_list = prefs_filtering_action_get_list();
1150 if (action_list == NULL) {
1151 alertpanel_error(_("No action was defined."));
1155 if (filtering_action_callback != NULL)
1156 filtering_action_callback(action_list);
1157 for(cur = action_list ; cur != NULL ; cur = cur->next) {
1158 filteringaction_free(cur->data);
1160 g_slist_free(action_list);
1162 gtk_widget_destroy(filtering_action.window);
1163 filtering_action.window = NULL;
1168 *\brief Called when closing dialog box
1170 *\param widget Dialog widget
1171 *\param event Event info
1172 *\param data User data
1176 static gint prefs_filtering_action_deleted(GtkWidget *widget,
1177 GdkEventAny *event, gpointer data)
1179 prefs_filtering_action_cancel();
1184 * Strings describing exec format strings
1186 * When adding new lines, remember to put 2 strings for each line
1188 static gchar *exec_desc_strings[] = {
1189 "%%", N_("literal %"),
1190 "%s", N_("Subject"),
1195 "%i", N_("Message-ID"),
1196 "%n", N_("Newsgroups"),
1197 "%r", N_("References"),
1198 "%F", N_("filename (should not be modified)"),
1199 "\\n", N_("new line"),
1200 "\\", N_("escape character for quotes"),
1201 "\\\"", N_("quote character"),
1205 static DescriptionWindow exec_desc_win = {
1209 N_("Filtering Action: 'Execute'"),
1210 N_("'Execute' allows you to send a message or message element "
1211 "to an external program or script.\n"
1212 "The following symbols can be used:"),
1217 *\brief Show Execute action's info
1219 static void prefs_filtering_action_exec_info(void)
1221 description_window_create(&exec_desc_win);
1224 static void prefs_filtering_action_select_dest(void)
1229 dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
1232 path = folder_item_get_identifier(dest);
1234 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), path);
1238 static void prefs_filtering_action_select_addressbook(void)
1240 const gchar *folderpath = NULL;
1241 gchar *new_path = NULL;
1243 folderpath = gtk_entry_get_text(GTK_ENTRY(filtering_action.dest_entry));
1244 new_path = addressbook_folder_selection(folderpath);
1246 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), new_path);
1251 static void prefs_filtering_action_enable_widget(GtkWidget* widget, const gboolean enable)
1253 g_return_if_fail(widget != NULL);
1257 if(GTK_IS_COMBO_BOX(widget) || GTK_IS_COMBO_BOX_ENTRY(widget))
1258 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
1259 else if(GTK_IS_SPIN_BUTTON(widget))
1260 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), 0);
1261 else if(GTK_IS_ENTRY(widget)) {
1262 gtk_entry_set_text(GTK_ENTRY(widget), "");
1263 } else if(GTK_IS_OPTION_MENU(widget))
1264 gtk_option_menu_set_history(GTK_OPTION_MENU(widget), 0);
1266 gtk_widget_set_sensitive(widget, TRUE);
1267 gtk_widget_show(widget);
1269 gtk_widget_set_sensitive(widget, FALSE);
1270 gtk_widget_hide(widget);
1274 #define ACTION_SEND(x) (x == ACTION_FORWARD || x == ACTION_REDIRECT || \
1275 x == ACTION_FORWARD_AS_ATTACHMENT)
1276 #define ACTION_SCORE(x) (x == ACTION_CHANGE_SCORE || x == ACTION_SET_SCORE)
1277 #define ACTION_TAG(x) (x == ACTION_SET_TAG || x == ACTION_UNSET_TAG)
1278 #define ACTION_FILEOP(x) (x == ACTION_MOVE || x == ACTION_COPY)
1280 static void prefs_filtering_action_type_selection_changed(GtkWidget *combo,
1285 value = combobox_get_active_data(GTK_COMBO_BOX(filtering_action.action_combo));
1287 if (filtering_action.current_action != value) {
1288 if (ACTION_SEND(filtering_action.current_action)) {
1289 debug_print("unregistering address completion entry\n");
1290 address_completion_unregister_entry(GTK_ENTRY(filtering_action.dest_entry));
1291 address_completion_end(filtering_action.window);
1293 if (ACTION_SEND(value)) {
1294 debug_print("registering address completion entry\n");
1295 address_completion_start(filtering_action.window);
1296 address_completion_register_entry(
1297 GTK_ENTRY(filtering_action.dest_entry),
1300 filtering_action.current_action = value;
1303 prefs_filtering_action_enable_widget(filtering_action.label2,
1304 (ACTION_SEND(value) || value == ACTION_ADD_TO_ADDRESSBOOK));
1306 prefs_filtering_action_enable_widget(filtering_action.label3,
1307 (ACTION_SEND(value) || ACTION_TAG(value) ||
1308 ACTION_SCORE(value) || ACTION_FILEOP(value) ||
1309 value == ACTION_COLOR || value == ACTION_EXECUTE ||
1310 value == ACTION_ADD_TO_ADDRESSBOOK));
1312 prefs_filtering_action_enable_widget(filtering_action.account_combo,
1313 ACTION_SEND(value));
1315 prefs_filtering_action_enable_widget(filtering_action.tags_combo,
1318 prefs_filtering_action_enable_widget(filtering_action.dest_entry,
1319 (ACTION_FILEOP(value) || value == ACTION_EXECUTE ||
1320 ACTION_SEND(value) || value == ACTION_ADD_TO_ADDRESSBOOK));
1322 prefs_filtering_action_enable_widget(filtering_action.dest_btn,
1323 ACTION_FILEOP(value));
1325 prefs_filtering_action_enable_widget(filtering_action.exec_btn,
1326 (value == ACTION_EXECUTE));
1328 prefs_filtering_action_enable_widget(filtering_action.color_optmenu,
1329 (value == ACTION_COLOR));
1331 prefs_filtering_action_enable_widget(filtering_action.header_combo,
1332 (value == ACTION_ADD_TO_ADDRESSBOOK));
1334 prefs_filtering_action_enable_widget(filtering_action.addressbook_btn,
1335 (value == ACTION_ADD_TO_ADDRESSBOOK));
1337 prefs_filtering_action_enable_widget(filtering_action.score_entry,
1338 ACTION_SCORE(value));
1341 case ACTION_FORWARD:
1342 case ACTION_FORWARD_AS_ATTACHMENT:
1343 case ACTION_REDIRECT:
1344 gtk_label_set_text(GTK_LABEL(filtering_action.label2), _("Account"));
1345 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Recipient"));
1347 case ACTION_ADD_TO_ADDRESSBOOK:
1348 gtk_label_set_text(GTK_LABEL(filtering_action.label2), _("Header Name"));
1349 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Book/Folder"));
1353 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Destination"));
1356 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Color"));
1358 case ACTION_EXECUTE:
1359 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Execute"));
1361 case ACTION_SET_SCORE:
1362 case ACTION_CHANGE_SCORE:
1363 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Score"));
1365 case ACTION_SET_TAG:
1366 case ACTION_UNSET_TAG:
1367 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Tag"));
1372 static void prefs_filtering_action_reset_dialog(void)
1374 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo), ACTION_MOVE);
1375 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo), 0);
1376 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
1377 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry), 0);
1380 static GtkListStore* prefs_filtering_action_create_data_store(void)
1382 return gtk_list_store_new(N_PFA_COLUMNS,
1388 static void prefs_filtering_action_list_view_insert_action(GtkWidget *list_view,
1390 const gchar *action,
1393 GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model
1394 (GTK_TREE_VIEW(list_view)));
1398 /* see if row exists, if not append */
1400 gtk_list_store_append(store, &iter);
1404 gtk_list_store_set(store, &iter,
1406 PFA_VALID_ACTION, is_valid,
1410 static GtkWidget *prefs_filtering_action_list_view_create(void)
1412 GtkTreeView *list_view;
1413 GtkTreeModel *model;
1414 GtkTreeSelection *selector;
1416 model = GTK_TREE_MODEL(prefs_filtering_action_create_data_store());
1417 list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
1418 g_object_unref(model);
1420 gtk_tree_view_set_rules_hint(list_view, prefs_common.use_stripes_everywhere);
1422 selector = gtk_tree_view_get_selection(list_view);
1423 gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
1424 gtk_tree_selection_set_select_function
1425 (selector, prefs_filtering_actions_selected, NULL, NULL);
1427 /* create the columns */
1428 prefs_filtering_action_create_list_view_columns(list_view);
1430 return GTK_WIDGET(list_view);
1433 static void prefs_filtering_action_create_list_view_columns(GtkTreeView *list_view)
1435 GtkTreeViewColumn *column;
1436 GtkCellRenderer *renderer;
1438 renderer = gtk_cell_renderer_text_new();
1439 column = gtk_tree_view_column_new_with_attributes
1440 (_("Current action list"),
1444 gtk_tree_view_append_column(list_view, column);
1447 static gboolean prefs_filtering_actions_selected
1448 (GtkTreeSelection *selector,
1449 GtkTreeModel *model,
1451 gboolean currently_selected,
1455 FilteringAction *action;
1456 GSList * action_list;
1461 if (currently_selected)
1464 if (!gtk_tree_model_get_iter(model, &iter, path))
1467 gtk_tree_model_get(model, &iter,
1468 PFA_VALID_ACTION, &is_valid,
1472 prefs_filtering_action_reset_dialog();
1476 gtk_tree_model_get(model, &iter,
1477 PFA_ACTION, &action_str,
1480 action_list = matcher_parser_get_action_list(action_str);
1483 if (action_list == NULL)
1486 action = action_list->data;
1487 g_slist_free(action_list);
1489 if (action->destination)
1490 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), action->destination);
1492 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
1494 switch(action->type) {
1495 case MATCHACTION_MOVE:
1496 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1499 case MATCHACTION_COPY:
1500 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1503 case MATCHACTION_DELETE:
1504 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1507 case MATCHACTION_MARK:
1508 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1511 case MATCHACTION_UNMARK:
1512 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1515 case MATCHACTION_LOCK:
1516 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1519 case MATCHACTION_UNLOCK:
1520 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1523 case MATCHACTION_MARK_AS_READ:
1524 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1525 ACTION_MARK_AS_READ);
1527 case MATCHACTION_MARK_AS_UNREAD:
1528 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1529 ACTION_MARK_AS_UNREAD);
1531 case MATCHACTION_MARK_AS_SPAM:
1532 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1533 ACTION_MARK_AS_SPAM);
1535 case MATCHACTION_MARK_AS_HAM:
1536 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1537 ACTION_MARK_AS_HAM);
1539 case MATCHACTION_FORWARD:
1540 list_id = get_list_id_from_account_id(action->account_id);
1541 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1543 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1546 case MATCHACTION_FORWARD_AS_ATTACHMENT:
1547 list_id = get_list_id_from_account_id(action->account_id);
1548 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1549 ACTION_FORWARD_AS_ATTACHMENT);
1550 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1553 case MATCHACTION_REDIRECT:
1554 list_id = get_list_id_from_account_id(action->account_id);
1555 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1557 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1560 case MATCHACTION_EXECUTE:
1561 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1564 case MATCHACTION_COLOR:
1565 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1567 gtk_option_menu_set_history(GTK_OPTION_MENU(filtering_action.color_optmenu),
1568 action->labelcolor);
1570 case MATCHACTION_CHANGE_SCORE:
1571 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1572 ACTION_CHANGE_SCORE);
1573 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry),
1576 case MATCHACTION_SET_SCORE:
1577 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1579 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry),
1582 case MATCHACTION_STOP:
1583 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1586 case MATCHACTION_HIDE:
1587 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1590 case MATCHACTION_IGNORE:
1591 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1594 case MATCHACTION_WATCH:
1595 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1598 case MATCHACTION_ADD_TO_ADDRESSBOOK:
1600 gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), action->header);
1602 gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), "");
1603 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1604 ACTION_ADD_TO_ADDRESSBOOK);
1607 filteringaction_free(action); /* XXX: memleak */