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 (GtkWidget *widget,
99 *\brief UI data for matcher dialog
101 static struct FilteringAction_ {
106 GtkWidget *action_list_view;
110 GtkWidget *action_combo;
111 GtkWidget *account_combo;
112 GtkWidget *dest_entry;
115 GtkWidget *color_optmenu;
116 GtkWidget *header_combo;
117 GtkWidget *header_entry;
118 GtkWidget *addressbook_btn;
119 GtkWidget *score_entry;
120 GtkWidget *tags_combo;
126 typedef enum Action_ {
135 ACTION_MARK_AS_UNREAD,
139 ACTION_FORWARD_AS_ATTACHMENT,
151 ACTION_ADD_TO_ADDRESSBOOK,
153 /* add other action constants */
161 { NULL, N_("Move"), ACTION_MOVE },
162 { NULL, N_("Copy"), ACTION_COPY },
163 { NULL, N_("Delete"), ACTION_DELETE },
164 { NULL, N_("Hide"), ACTION_HIDE },
165 { N_("Message flags"), N_("Mark"), ACTION_MARK },
166 { N_("Message flags"), N_("Unmark"), ACTION_UNMARK },
167 { N_("Message flags"), N_("Lock"), ACTION_LOCK },
168 { N_("Message flags"), N_("Unlock"), ACTION_UNLOCK },
169 { N_("Message flags"), N_("Mark as read"), ACTION_MARK_AS_READ },
170 { N_("Message flags"), N_("Mark as unread"), ACTION_MARK_AS_UNREAD },
171 { N_("Message flags"), N_("Mark as spam"), ACTION_MARK_AS_SPAM },
172 { N_("Message flags"), N_("Mark as ham"), ACTION_MARK_AS_HAM },
173 { NULL, N_("Execute"), ACTION_EXECUTE },
174 { NULL, N_("Color label"), ACTION_COLOR },
175 { N_("Resend"), N_("Forward"), ACTION_FORWARD },
176 { N_("Resend"), N_("Forward as attachment"), ACTION_FORWARD_AS_ATTACHMENT },
177 { N_("Resend"), N_("Redirect"), ACTION_REDIRECT },
178 { N_("Score"), N_("Change score"), ACTION_CHANGE_SCORE },
179 { N_("Score"), N_("Set score"), ACTION_SET_SCORE },
180 { N_("Tags"), N_("Apply tag"), ACTION_SET_TAG },
181 { N_("Tags"), N_("Unset tag"), ACTION_UNSET_TAG },
182 { N_("Tags"), N_("Clear tags"), ACTION_CLEAR_TAGS },
183 { N_("Threads"), N_("Ignore thread"), ACTION_IGNORE },
184 { N_("Threads"), N_("Watch thread"), ACTION_WATCH },
185 { NULL, N_("Add to address book"), ACTION_ADD_TO_ADDRESSBOOK },
186 { NULL, N_("Stop filter"), ACTION_STOP },
199 static PrefsFilteringActionSignal *filtering_action_callback;
201 static GtkTreeModel *prefs_filtering_action_create_model(void)
203 GtkTreeIter iter, iter2;
205 gchar *curr_menu = NULL;
208 store = gtk_tree_store_new(N_ACTION_COMBO, G_TYPE_STRING, G_TYPE_INT);
210 for (i = 0; action_menu[i].menu || action_menu[i].text; i++)
212 if (action_menu[i].menu) {
213 if (!curr_menu || strcmp(action_menu[i].menu, curr_menu)) {
214 gtk_tree_store_append(store, &iter, NULL);
215 gtk_tree_store_set(store, &iter,
217 gettext(action_menu[i].menu),
219 curr_menu = action_menu[i].menu;
222 gtk_tree_store_append(store, &iter2, &iter);
223 gtk_tree_store_set(store, &iter2,
224 ACTION_COMBO_TEXT, gettext(action_menu[i].text),
225 ACTION_COMBO_DATA, action_menu[i].action,
230 gtk_tree_store_append(store, &iter, NULL);
231 gtk_tree_store_set(store, &iter,
232 ACTION_COMBO_TEXT, gettext(action_menu[i].text),
233 ACTION_COMBO_DATA, action_menu[i].action,
238 return GTK_TREE_MODEL(store);
241 static void cell_is_sensitive(GtkCellLayout *cell_layout,
242 GtkCellRenderer *cell,
243 GtkTreeModel *tree_model,
247 gboolean sensitive = !gtk_tree_model_iter_has_child (tree_model, iter);
248 g_object_set (cell, "sensitive", sensitive, NULL);
252 *\brief Opens the filtering action dialog with a list of actions
254 *\param matchers List of conditions
258 void prefs_filtering_action_open(GSList *action_list,
259 PrefsFilteringActionSignal *cb)
263 if (!filtering_action.window) {
264 prefs_filtering_action_create();
266 /* update color label menu */
267 gtk_option_menu_set_menu(GTK_OPTION_MENU(filtering_action.color_optmenu),
268 colorlabel_create_color_menu());
271 manage_window_set_transient(GTK_WINDOW(filtering_action.window));
272 gtk_widget_grab_focus(filtering_action.ok_btn);
274 filtering_action_callback = cb;
276 prefs_filtering_action_set_dialog(action_list);
278 gtk_widget_show(filtering_action.window);
282 *\brief Save Gtk object size to prefs dataset
284 static void prefs_filtering_action_size_allocate_cb(GtkWidget *widget,
285 GtkAllocation *allocation)
287 g_return_if_fail(allocation != NULL);
289 prefs_common.filteringactionwin_width = allocation->width;
290 prefs_common.filteringactionwin_height = allocation->height;
293 #define LABELS_WIDTH 80
294 #define SECOND_ROW_WIDTH 250
296 static void prefs_filtering_action_check_widget_width(GtkWidget *widget)
300 gtk_widget_size_request(widget, &req);
301 if(req.width > SECOND_ROW_WIDTH)
302 gtk_widget_set_size_request(widget, SECOND_ROW_WIDTH, -1);
306 *\brief Create the matcher dialog
308 static void prefs_filtering_action_create(void)
313 GtkWidget *cancel_btn;
314 GtkWidget *confirm_area;
324 GtkWidget *action_combo;
325 GtkWidget *account_combo;
326 GtkWidget *header_combo;
327 GtkWidget *header_entry;
328 GtkWidget *addressbook_btn;
329 GtkWidget *dest_entry;
331 GtkWidget *score_entry;
332 GtkWidget *tags_combo;
338 GtkWidget *subst_btn;
341 GtkWidget *action_hbox;
342 GtkWidget *action_scrolledwin;
343 GtkWidget *action_list_view;
351 GtkWidget *color_optmenu;
353 static GdkGeometry geometry;
358 GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
359 GtkSizeGroup *size_action = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
361 GtkCellRenderer *renderer;
363 debug_print("Creating matcher configuration window...\n");
365 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_filtering_action");
366 gtk_container_set_border_width(GTK_CONTAINER(window), VBOX_BORDER);
367 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
368 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
369 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
371 vbox = gtk_vbox_new(FALSE, 6);
372 gtk_container_add(GTK_CONTAINER(window), vbox);
374 gtkut_stock_button_set_create(&confirm_area,
375 &cancel_btn, GTK_STOCK_CANCEL,
376 &ok_btn, GTK_STOCK_OK,
378 gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
379 gtk_widget_grab_default(ok_btn);
381 gtk_window_set_title(GTK_WINDOW(window),
382 _("Filtering action configuration"));
383 g_signal_connect(G_OBJECT(window), "delete_event",
384 G_CALLBACK(prefs_filtering_action_deleted), NULL);
385 g_signal_connect(G_OBJECT(window), "size_allocate",
386 G_CALLBACK(prefs_filtering_action_size_allocate_cb), NULL);
387 g_signal_connect(G_OBJECT(window), "key_press_event",
388 G_CALLBACK(prefs_filtering_action_key_pressed), NULL);
389 MANAGE_WINDOW_SIGNALS_CONNECT(window);
390 g_signal_connect(G_OBJECT(ok_btn), "clicked",
391 G_CALLBACK(prefs_filtering_action_ok), NULL);
392 g_signal_connect(G_OBJECT(cancel_btn), "clicked",
393 G_CALLBACK(prefs_filtering_action_cancel), NULL);
395 vbox1 = gtk_vbox_new(FALSE, VSPACING);
396 gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
397 gtk_container_set_border_width(GTK_CONTAINER (vbox1), 2);
399 frame = gtk_frame_new(_("Rule"));
400 gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5);
401 gtk_box_pack_start (GTK_BOX (vbox1), frame, FALSE, FALSE, 0);
402 gtk_widget_set_size_request(frame, -1, 110);
404 table = gtk_table_new(3, 3, FALSE);
405 gtk_container_set_border_width(GTK_CONTAINER(table), 2);
406 gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
407 gtk_table_set_col_spacings (GTK_TABLE (table), HSPACING_NARROW);
408 gtk_container_add(GTK_CONTAINER(frame), table);
410 /* first row labels */
412 label1 = gtk_label_new (_("Action"));
413 gtk_widget_set_size_request(label1, LABELS_WIDTH, -1);
414 gtk_size_group_add_widget(size_group, label1);
415 gtk_misc_set_alignment (GTK_MISC (label1), 1, 0.5);
416 gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
417 GTK_FILL, GTK_SHRINK, 0, 0);
419 label2 = gtk_label_new ("");
420 gtk_size_group_add_widget(size_group, label2);
421 gtk_misc_set_alignment (GTK_MISC (label2), 1, 0.5);
422 gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
423 GTK_FILL, GTK_SHRINK, 0, 0);
425 label3 = gtk_label_new ("");
426 gtk_size_group_add_widget(size_group, label3);
427 gtk_misc_set_alignment (GTK_MISC (label3), 1, 0.5);
428 gtk_table_attach(GTK_TABLE(table), label3, 0, 1, 2, 3,
429 GTK_FILL, GTK_SHRINK, 0, 0);
433 hbox1 = gtk_hbox_new(FALSE, 0);
434 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 0, 1,
435 GTK_FILL, GTK_SHRINK, 0, 0);
437 model = prefs_filtering_action_create_model();
438 action_combo = gtk_combo_box_new_with_model(model);
439 gtk_size_group_add_widget(size_action, action_combo);
441 renderer = gtk_cell_renderer_text_new();
442 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(action_combo), renderer, TRUE);
443 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(action_combo), renderer,
444 "text", ACTION_COMBO_TEXT,
446 gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(action_combo), renderer,
447 cell_is_sensitive, NULL, NULL);
449 combobox_select_by_data(GTK_COMBO_BOX(action_combo), ACTION_MOVE);
450 g_signal_connect(G_OBJECT(action_combo), "changed",
451 G_CALLBACK(prefs_filtering_action_type_selection_changed),
453 gtk_box_pack_start(GTK_BOX(hbox1), action_combo, FALSE, FALSE, 0);
454 gtk_box_pack_start(GTK_BOX(hbox1), gtk_label_new(""), TRUE, TRUE, 0);
458 hbox1 = gtk_hbox_new (FALSE, 0);
459 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 1, 2,
460 GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
462 account_combo = gtk_combo_box_new_text ();
463 gtk_size_group_add_widget(size_action, account_combo);
465 for (accounts = account_get_list() ; accounts != NULL;
466 accounts = accounts->next) {
467 PrefsAccount *ac = (PrefsAccount *)accounts->data;
468 gchar *name = g_strdup(ac->account_name);
469 gtk_combo_box_append_text(GTK_COMBO_BOX(account_combo), (gpointer) name);
473 prefs_filtering_action_check_widget_width(account_combo);
474 gtk_combo_box_set_active(GTK_COMBO_BOX(account_combo), 0);
475 gtk_box_pack_start (GTK_BOX (hbox1), account_combo,
480 header_combo = combobox_text_new(TRUE, "From", "To", "Cc", "Reply-To", "Sender", NULL);
481 gtk_size_group_add_widget(size_action, header_combo);
482 gtk_box_pack_start (GTK_BOX (hbox1), header_combo,
484 header_entry = GTK_BIN(header_combo)->child;
488 hbox1 = gtk_hbox_new (FALSE, 0);
489 gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 2, 3,
490 GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
492 dest_entry = gtk_entry_new ();
493 gtk_box_pack_start (GTK_BOX (hbox1), dest_entry, TRUE, TRUE, 0);
495 score_entry = gtk_spin_button_new_with_range(-1000, 1000, 1);
496 gtk_box_pack_start(GTK_BOX(hbox1), score_entry, FALSE, FALSE, 0);
498 color_optmenu = gtk_option_menu_new();
499 gtk_size_group_add_widget(size_action, color_optmenu);
500 gtk_option_menu_set_menu(GTK_OPTION_MENU(color_optmenu),
501 colorlabel_create_color_menu());
502 prefs_filtering_action_check_widget_width(color_optmenu);
503 gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, FALSE, FALSE, 0);
505 tags_combo = gtk_combo_box_new_text ();
506 gtk_size_group_add_widget(size_action, tags_combo);
508 for (tmp = tags = tags_get_list() ; tmp != NULL;
510 gchar *name = g_strdup(tags_get_tag(GPOINTER_TO_INT(tmp->data)));
512 gtk_combo_box_append_text(GTK_COMBO_BOX(tags_combo), (gpointer) name);
516 prefs_filtering_action_check_widget_width(tags_combo);
517 gtk_combo_box_set_active(GTK_COMBO_BOX(tags_combo), 0);
518 gtk_box_pack_start (GTK_BOX (hbox1), tags_combo,
521 hbox1 = gtk_hbox_new (FALSE, 0);
522 gtk_table_attach(GTK_TABLE(table), hbox1, 2, 3, 2, 3,
523 GTK_FILL, GTK_SHRINK, 0, 0);
525 dest_btn = gtk_button_new_with_label (_("Select ..."));
526 gtk_box_pack_start (GTK_BOX (hbox1), dest_btn, FALSE, FALSE, 0);
527 g_signal_connect (G_OBJECT (dest_btn), "clicked",
528 G_CALLBACK(prefs_filtering_action_select_dest),
531 addressbook_btn = gtk_button_new_with_label (_("Select ..."));
532 gtk_box_pack_start (GTK_BOX (hbox1), addressbook_btn, FALSE, FALSE, 0);
533 g_signal_connect (G_OBJECT (addressbook_btn), "clicked",
534 G_CALLBACK(prefs_filtering_action_select_addressbook),
537 #if GTK_CHECK_VERSION(2, 8, 0)
538 exec_btn = gtk_button_new_from_stock(GTK_STOCK_INFO);
540 exec_btn = gtk_button_new_with_label (_("Info..."));
542 gtk_box_pack_start (GTK_BOX (hbox1), exec_btn, FALSE, FALSE, 0);
543 g_signal_connect (G_OBJECT (exec_btn), "clicked",
544 G_CALLBACK(prefs_filtering_action_exec_info),
547 /* register / substitute / delete */
549 reg_hbox = gtk_hbox_new(FALSE, 4);
550 gtk_box_pack_start(GTK_BOX(vbox1), reg_hbox, FALSE, FALSE, 0);
552 arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
553 gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0);
554 gtk_widget_set_size_request(arrow, -1, 16);
556 btn_hbox = gtk_hbox_new(TRUE, 4);
557 gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0);
559 reg_btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
560 gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0);
561 g_signal_connect(G_OBJECT(reg_btn), "clicked",
562 G_CALLBACK(prefs_filtering_action_register_cb), NULL);
564 subst_btn = gtkut_get_replace_btn(_("Replace"));
565 gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0);
566 g_signal_connect(G_OBJECT(subst_btn), "clicked",
567 G_CALLBACK(prefs_filtering_action_substitute_cb),
570 del_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
571 gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
572 g_signal_connect(G_OBJECT(del_btn), "clicked",
573 G_CALLBACK(prefs_filtering_action_delete_cb), NULL);
575 action_hbox = gtk_hbox_new(FALSE, 8);
576 gtk_box_pack_start(GTK_BOX(vbox1), action_hbox, TRUE, TRUE, 0);
578 action_scrolledwin = gtk_scrolled_window_new(NULL, NULL);
579 gtk_widget_set_size_request(action_scrolledwin, -1, 150);
580 gtk_box_pack_start(GTK_BOX(action_hbox), action_scrolledwin,
582 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(action_scrolledwin),
583 GTK_SHADOW_ETCHED_IN);
584 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(action_scrolledwin),
585 GTK_POLICY_AUTOMATIC,
586 GTK_POLICY_AUTOMATIC);
588 action_list_view = prefs_filtering_action_list_view_create();
589 gtk_container_add(GTK_CONTAINER(action_scrolledwin), action_list_view);
591 btn_vbox = gtk_vbox_new(FALSE, 8);
592 gtk_box_pack_start(GTK_BOX(action_hbox), btn_vbox, FALSE, FALSE, 0);
594 up_btn = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
595 gtk_box_pack_start(GTK_BOX(btn_vbox), up_btn, FALSE, FALSE, 0);
596 g_signal_connect(G_OBJECT(up_btn), "clicked",
597 G_CALLBACK(prefs_filtering_action_up), NULL);
599 down_btn = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
600 gtk_box_pack_start(GTK_BOX(btn_vbox), down_btn, FALSE, FALSE, 0);
601 g_signal_connect(G_OBJECT(down_btn), "clicked",
602 G_CALLBACK(prefs_filtering_action_down), NULL);
604 if (!geometry.min_height) {
605 geometry.min_width = 490;
606 geometry.min_height = 348;
609 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
611 gtk_widget_set_size_request(window, prefs_common.filteringactionwin_width,
612 prefs_common.filteringactionwin_height);
614 gtk_widget_show_all(window);
616 filtering_action.window = window;
617 filtering_action.label1 = label1;
618 filtering_action.label2 = label2;
619 filtering_action.label3 = label3;
620 filtering_action.action_combo = action_combo;
621 filtering_action.account_combo = account_combo;
622 filtering_action.tags_combo = tags_combo;
623 filtering_action.dest_entry = dest_entry;
624 filtering_action.dest_btn = dest_btn;
625 filtering_action.exec_btn = exec_btn;
626 filtering_action.color_optmenu = color_optmenu;
627 filtering_action.score_entry = score_entry;
628 filtering_action.header_combo = header_combo;
629 filtering_action.header_entry = header_entry;
630 filtering_action.addressbook_btn = addressbook_btn;
631 filtering_action.ok_btn = ok_btn;
632 filtering_action.action_list_view = action_list_view;
634 prefs_filtering_action_type_selection_changed(NULL, NULL);
638 *\brief Set the contents of a row
640 *\param row Index of row to set
641 *\param prop Condition to set
644 static void prefs_filtering_action_list_view_set_row(GtkTreeIter *row,
645 FilteringAction *action)
649 if (row == NULL && action == NULL) {
650 prefs_filtering_action_list_view_insert_action
651 (filtering_action.action_list_view,
652 NULL, _("(New)"), FALSE);
656 filteringaction_to_string(buf, sizeof buf, action);
658 prefs_filtering_action_list_view_insert_action
659 (filtering_action.action_list_view,
664 *\brief Initializes dialog with a set of conditions
666 *\param matchers List of conditions
668 static void prefs_filtering_action_set_dialog(GSList *action_list)
672 gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model
673 (GTK_TREE_VIEW(filtering_action.action_list_view))));
675 prefs_filtering_action_list_view_set_row(NULL, NULL);
676 if (action_list != NULL) {
677 for (cur = action_list; cur != NULL;
678 cur = g_slist_next(cur)) {
679 FilteringAction *action;
680 action = (FilteringAction *) cur->data;
681 prefs_filtering_action_list_view_set_row(NULL, action);
685 prefs_filtering_action_reset_dialog();
689 *\brief Converts current actions in list box in
690 * an action list used by the filtering system.
692 *\return GSList * List of actions.
694 static GSList *prefs_filtering_action_get_list(void)
700 GtkTreeView *list_view = GTK_TREE_VIEW(filtering_action.action_list_view);
701 GtkTreeModel *model = gtk_tree_view_get_model(list_view);
706 while (gtk_tree_model_iter_nth_child(model, &iter, NULL, row)) {
708 gtk_tree_model_get(model, &iter,
709 PFA_ACTION, &action_str,
710 PFA_VALID_ACTION, &is_valid,
714 GSList * tmp_action_list;
715 tmp_action_list = matcher_parser_get_action_list(action_str);
717 if (tmp_action_list == NULL) {
722 action_list = g_slist_concat(action_list,
736 *\brief Returns account ID from the given list index
738 *\return gint account ID
740 static gint get_account_id_from_list_id(gint list_id)
744 for (accounts = account_get_list() ; accounts != NULL;
745 accounts = accounts->next) {
746 PrefsAccount *ac = (PrefsAccount *)accounts->data;
749 return ac->account_id;
756 *\brief Returns list index from the given account ID
758 *\return gint list index
760 static gint get_list_id_from_account_id(gint account_id)
765 for (accounts = account_get_list() ; accounts != NULL;
766 accounts = accounts->next) {
767 PrefsAccount *ac = (PrefsAccount *)accounts->data;
769 if (account_id == ac->account_id)
778 *\brief Returns parser action ID from internal action ID
780 *\return gint parser action ID
782 static gint prefs_filtering_action_get_matching_from_action(Action action_id)
786 return MATCHACTION_MOVE;
788 return MATCHACTION_SET_TAG;
789 case ACTION_UNSET_TAG:
790 return MATCHACTION_UNSET_TAG;
791 case ACTION_CLEAR_TAGS:
792 return MATCHACTION_CLEAR_TAGS;
794 return MATCHACTION_COPY;
796 return MATCHACTION_DELETE;
798 return MATCHACTION_MARK;
800 return MATCHACTION_UNMARK;
802 return MATCHACTION_LOCK;
804 return MATCHACTION_UNLOCK;
805 case ACTION_MARK_AS_READ:
806 return MATCHACTION_MARK_AS_READ;
807 case ACTION_MARK_AS_UNREAD:
808 return MATCHACTION_MARK_AS_UNREAD;
809 case ACTION_MARK_AS_SPAM:
810 return MATCHACTION_MARK_AS_SPAM;
811 case ACTION_MARK_AS_HAM:
812 return MATCHACTION_MARK_AS_HAM;
814 return MATCHACTION_FORWARD;
815 case ACTION_FORWARD_AS_ATTACHMENT:
816 return MATCHACTION_FORWARD_AS_ATTACHMENT;
817 case ACTION_REDIRECT:
818 return MATCHACTION_REDIRECT;
820 return MATCHACTION_EXECUTE;
822 return MATCHACTION_COLOR;
824 return MATCHACTION_HIDE;
826 return MATCHACTION_IGNORE;
828 return MATCHACTION_WATCH;
830 return MATCHACTION_STOP;
831 case ACTION_CHANGE_SCORE:
832 return MATCHACTION_CHANGE_SCORE;
833 case ACTION_SET_SCORE:
834 return MATCHACTION_SET_SCORE;
835 case ACTION_ADD_TO_ADDRESSBOOK:
836 return MATCHACTION_ADD_TO_ADDRESSBOOK;
843 *\brief Returns action from the content of the dialog
845 *\param alert specifies whether alert dialog boxes should be shown
848 *\return FilteringAction * action entered in the dialog box.
850 static FilteringAction * prefs_filtering_action_dialog_to_action(gboolean alert)
856 gchar * destination = NULL;
858 FilteringAction * action;
860 gchar * header = NULL;
862 action_id = combobox_get_active_data(GTK_COMBO_BOX(filtering_action.action_combo));
863 action_type = prefs_filtering_action_get_matching_from_action(action_id);
864 list_id = gtk_combo_box_get_active(GTK_COMBO_BOX(filtering_action.account_combo));
865 account_id = get_account_id_from_list_id(list_id);
873 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
874 if (*destination == '\0') {
876 alertpanel_error(action_id == ACTION_EXECUTE
877 ? _("Command line not set")
878 : _("Destination is not set."));
884 case ACTION_FORWARD_AS_ATTACHMENT:
885 case ACTION_REDIRECT:
886 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
887 if (*destination == '\0') {
889 alertpanel_error(_("Recipient is not set."));
895 labelcolor = colorlabel_get_color_menu_active_item(
896 gtk_option_menu_get_menu(GTK_OPTION_MENU(filtering_action.color_optmenu)));
899 case ACTION_CHANGE_SCORE:
900 case ACTION_SET_SCORE:
901 score = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(
902 filtering_action.score_entry));
903 if (!score && action_id == ACTION_CHANGE_SCORE) {
905 alertpanel_error(_("Score is not set"));
909 case ACTION_ADD_TO_ADDRESSBOOK:
910 header = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.header_entry), 0, -1);
911 if (*header == '\0') {
913 alertpanel_error(_("Header is not set."));
917 destination = gtk_editable_get_chars(GTK_EDITABLE(filtering_action.dest_entry), 0, -1);
918 if (*destination == '\0') {
920 alertpanel_error(_("Target addressbook/folder is not set."));
926 case ACTION_UNSET_TAG:
927 destination = gtk_combo_box_get_active_text(GTK_COMBO_BOX(filtering_action.tags_combo));
928 if (!destination || *destination == '\0') {
930 alertpanel_error(_("Tag name is empty."));
944 case ACTION_MARK_AS_READ:
945 case ACTION_MARK_AS_UNREAD:
946 case ACTION_MARK_AS_SPAM:
947 case ACTION_MARK_AS_HAM:
948 case ACTION_CLEAR_TAGS:
952 action = filteringaction_new(action_type, account_id,
953 destination, labelcolor, score, header);
960 *\brief Signal handler for register button
962 static void prefs_filtering_action_register_cb(void)
964 FilteringAction *action;
966 action = prefs_filtering_action_dialog_to_action(TRUE);
970 prefs_filtering_action_list_view_set_row(NULL, action);
972 filteringaction_free(action);
974 * (presumably gtk_list_select_item(), called by
975 * prefs_filtering_action_reset_dialog() activates
976 * what seems to be a bug. this causes any other
977 * list items to be unselectable)
978 * prefs_filtering_action_reset_dialog(); */
979 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo), 0);
980 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.tags_combo), 0);
981 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
985 *\brief Signal handler for substitute button
987 static void prefs_filtering_action_substitute_cb(void)
989 GtkTreeView *list_view = GTK_TREE_VIEW
990 (filtering_action.action_list_view);
991 GtkTreeSelection *selection = gtk_tree_view_get_selection(list_view);
995 FilteringAction *action;
997 if (!gtk_tree_selection_get_selected(selection, &model, &row))
1000 gtk_tree_model_get(model, &row, PFA_VALID_ACTION, &is_valid, -1);
1004 action = prefs_filtering_action_dialog_to_action(TRUE);
1008 prefs_filtering_action_list_view_set_row(&row, action);
1010 filteringaction_free(action);
1012 prefs_filtering_action_reset_dialog();
1016 *\brief Signal handler for delete button
1018 static void prefs_filtering_action_delete_cb(void)
1020 GtkTreeView *list_view = GTK_TREE_VIEW
1021 (filtering_action.action_list_view);
1022 GtkTreeSelection *selection = gtk_tree_view_get_selection(list_view);
1023 GtkTreeModel *model;
1027 if (!gtk_tree_selection_get_selected(selection, &model, &row))
1030 gtk_tree_model_get(model, &row, PFA_VALID_ACTION, &is_valid, -1);
1034 gtk_list_store_remove(GTK_LIST_STORE(model), &row);
1036 prefs_filtering_action_reset_dialog();
1040 *\brief Signal handler for 'move up' button
1042 static void prefs_filtering_action_up(void)
1044 GtkTreePath *prev, *sel, *try;
1046 GtkListStore *store = NULL;
1047 GtkTreeModel *model = NULL;
1050 if (!gtk_tree_selection_get_selected
1051 (gtk_tree_view_get_selection
1052 (GTK_TREE_VIEW(filtering_action.action_list_view)),
1056 store = (GtkListStore *)model;
1057 sel = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &isel);
1061 /* no move if we're at row 0 or 1, looks phony, but other
1062 * solutions are more convoluted... */
1063 try = gtk_tree_path_copy(sel);
1064 if (!gtk_tree_path_prev(try) || !gtk_tree_path_prev(try)) {
1065 gtk_tree_path_free(try);
1066 gtk_tree_path_free(sel);
1069 gtk_tree_path_free(try);
1071 prev = gtk_tree_path_copy(sel);
1072 if (gtk_tree_path_prev(prev)) {
1073 gtk_tree_model_get_iter(GTK_TREE_MODEL(store),
1075 gtk_list_store_swap(store, &iprev, &isel);
1076 /* XXX: GTK2 select row?? */
1079 gtk_tree_path_free(sel);
1080 gtk_tree_path_free(prev);
1084 *\brief Signal handler for 'move down' button
1086 static void prefs_filtering_action_down(void)
1088 GtkListStore *store = NULL;
1089 GtkTreeModel *model = NULL;
1090 GtkTreeIter next, sel;
1093 if (!gtk_tree_selection_get_selected
1094 (gtk_tree_view_get_selection
1095 (GTK_TREE_VIEW(filtering_action.action_list_view)),
1099 store = (GtkListStore *)model;
1100 try = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &sel);
1104 /* move when not at row 0 ... */
1105 if (gtk_tree_path_prev(try)) {
1107 if (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &next))
1108 gtk_list_store_swap(store, &next, &sel);
1111 gtk_tree_path_free(try);
1115 *\brief Handle key press
1117 *\param widget Widget receiving key press
1118 *\param event Key event
1119 *\param data User data
1121 static gboolean prefs_filtering_action_key_pressed(GtkWidget *widget,
1122 GdkEventKey *event, gpointer data)
1124 if (event && event->keyval == GDK_Escape) {
1125 prefs_filtering_action_cancel();
1132 *\brief Cancel matcher dialog
1134 static void prefs_filtering_action_cancel(void)
1136 gtk_widget_destroy(filtering_action.window);
1137 filtering_action.window = NULL;
1142 *\brief Accept current matchers
1144 static void prefs_filtering_action_ok(void)
1146 GSList * action_list;
1149 action_list = prefs_filtering_action_get_list();
1151 if (action_list == NULL) {
1152 alertpanel_error(_("No action was defined."));
1156 if (filtering_action_callback != NULL)
1157 filtering_action_callback(action_list);
1158 for(cur = action_list ; cur != NULL ; cur = cur->next) {
1159 filteringaction_free(cur->data);
1161 g_slist_free(action_list);
1163 gtk_widget_destroy(filtering_action.window);
1164 filtering_action.window = NULL;
1169 *\brief Called when closing dialog box
1171 *\param widget Dialog widget
1172 *\param event Event info
1173 *\param data User data
1177 static gint prefs_filtering_action_deleted(GtkWidget *widget,
1178 GdkEventAny *event, gpointer data)
1180 prefs_filtering_action_cancel();
1185 * Strings describing exec format strings
1187 * When adding new lines, remember to put 2 strings for each line
1189 static gchar *exec_desc_strings[] = {
1190 "%%", N_("literal %"),
1191 "%s", N_("Subject"),
1196 "%i", N_("Message-ID"),
1197 "%n", N_("Newsgroups"),
1198 "%r", N_("References"),
1199 "%F", N_("filename (should not be modified)"),
1200 "\\n", N_("new line"),
1201 "\\", N_("escape character for quotes"),
1202 "\\\"", N_("quote character"),
1206 static DescriptionWindow exec_desc_win = {
1210 N_("Filtering Action: 'Execute'"),
1211 N_("'Execute' allows you to send a message or message element "
1212 "to an external program or script.\n"
1213 "The following symbols can be used:"),
1218 *\brief Show Execute action's info
1220 static void prefs_filtering_action_exec_info(GtkWidget *widget, GtkWidget *parent)
1222 exec_desc_win.parent = parent;
1223 description_window_create(&exec_desc_win);
1226 static void prefs_filtering_action_select_dest(void)
1231 dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE);
1234 path = folder_item_get_identifier(dest);
1236 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), path);
1240 static void prefs_filtering_action_select_addressbook(void)
1242 const gchar *folderpath = NULL;
1243 gchar *new_path = NULL;
1245 folderpath = gtk_entry_get_text(GTK_ENTRY(filtering_action.dest_entry));
1246 new_path = addressbook_folder_selection(folderpath);
1248 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), new_path);
1253 static void prefs_filtering_action_enable_widget(GtkWidget* widget, const gboolean enable)
1255 g_return_if_fail(widget != NULL);
1259 if(GTK_IS_COMBO_BOX(widget) || GTK_IS_COMBO_BOX_ENTRY(widget))
1260 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
1261 else if(GTK_IS_SPIN_BUTTON(widget))
1262 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), 0);
1263 else if(GTK_IS_ENTRY(widget)) {
1264 gtk_entry_set_text(GTK_ENTRY(widget), "");
1265 } else if(GTK_IS_OPTION_MENU(widget))
1266 gtk_option_menu_set_history(GTK_OPTION_MENU(widget), 0);
1268 gtk_widget_set_sensitive(widget, TRUE);
1269 gtk_widget_show(widget);
1271 gtk_widget_set_sensitive(widget, FALSE);
1272 gtk_widget_hide(widget);
1276 #define ACTION_SEND(x) (x == ACTION_FORWARD || x == ACTION_REDIRECT || \
1277 x == ACTION_FORWARD_AS_ATTACHMENT)
1278 #define ACTION_SCORE(x) (x == ACTION_CHANGE_SCORE || x == ACTION_SET_SCORE)
1279 #define ACTION_TAG(x) (x == ACTION_SET_TAG || x == ACTION_UNSET_TAG)
1280 #define ACTION_FILEOP(x) (x == ACTION_MOVE || x == ACTION_COPY)
1282 static void prefs_filtering_action_type_selection_changed(GtkWidget *combo,
1287 value = combobox_get_active_data(GTK_COMBO_BOX(filtering_action.action_combo));
1289 if (filtering_action.current_action != value) {
1290 if (ACTION_SEND(filtering_action.current_action)) {
1291 debug_print("unregistering address completion entry\n");
1292 address_completion_unregister_entry(GTK_ENTRY(filtering_action.dest_entry));
1293 address_completion_end(filtering_action.window);
1295 if (ACTION_SEND(value)) {
1296 debug_print("registering address completion entry\n");
1297 address_completion_start(filtering_action.window);
1298 address_completion_register_entry(
1299 GTK_ENTRY(filtering_action.dest_entry),
1302 filtering_action.current_action = value;
1305 prefs_filtering_action_enable_widget(filtering_action.label2,
1306 (ACTION_SEND(value) || value == ACTION_ADD_TO_ADDRESSBOOK));
1308 prefs_filtering_action_enable_widget(filtering_action.label3,
1309 (ACTION_SEND(value) || ACTION_TAG(value) ||
1310 ACTION_SCORE(value) || ACTION_FILEOP(value) ||
1311 value == ACTION_COLOR || value == ACTION_EXECUTE ||
1312 value == ACTION_ADD_TO_ADDRESSBOOK));
1314 prefs_filtering_action_enable_widget(filtering_action.account_combo,
1315 ACTION_SEND(value));
1317 prefs_filtering_action_enable_widget(filtering_action.tags_combo,
1320 prefs_filtering_action_enable_widget(filtering_action.dest_entry,
1321 (ACTION_FILEOP(value) || value == ACTION_EXECUTE ||
1322 ACTION_SEND(value) || value == ACTION_ADD_TO_ADDRESSBOOK));
1324 prefs_filtering_action_enable_widget(filtering_action.dest_btn,
1325 ACTION_FILEOP(value));
1327 prefs_filtering_action_enable_widget(filtering_action.exec_btn,
1328 (value == ACTION_EXECUTE));
1330 prefs_filtering_action_enable_widget(filtering_action.color_optmenu,
1331 (value == ACTION_COLOR));
1333 prefs_filtering_action_enable_widget(filtering_action.header_combo,
1334 (value == ACTION_ADD_TO_ADDRESSBOOK));
1336 prefs_filtering_action_enable_widget(filtering_action.addressbook_btn,
1337 (value == ACTION_ADD_TO_ADDRESSBOOK));
1339 prefs_filtering_action_enable_widget(filtering_action.score_entry,
1340 ACTION_SCORE(value));
1343 case ACTION_FORWARD:
1344 case ACTION_FORWARD_AS_ATTACHMENT:
1345 case ACTION_REDIRECT:
1346 gtk_label_set_text(GTK_LABEL(filtering_action.label2), _("Account"));
1347 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Recipient"));
1349 case ACTION_ADD_TO_ADDRESSBOOK:
1350 gtk_label_set_text(GTK_LABEL(filtering_action.label2), _("Header Name"));
1351 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Book/Folder"));
1355 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Destination"));
1358 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Color"));
1360 case ACTION_EXECUTE:
1361 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Execute"));
1363 case ACTION_SET_SCORE:
1364 case ACTION_CHANGE_SCORE:
1365 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Score"));
1367 case ACTION_SET_TAG:
1368 case ACTION_UNSET_TAG:
1369 gtk_label_set_text(GTK_LABEL(filtering_action.label3), _("Tag"));
1374 static void prefs_filtering_action_reset_dialog(void)
1376 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo), ACTION_MOVE);
1377 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo), 0);
1378 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
1379 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry), 0);
1382 static GtkListStore* prefs_filtering_action_create_data_store(void)
1384 return gtk_list_store_new(N_PFA_COLUMNS,
1390 static void prefs_filtering_action_list_view_insert_action(GtkWidget *list_view,
1392 const gchar *action,
1395 GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model
1396 (GTK_TREE_VIEW(list_view)));
1400 /* see if row exists, if not append */
1402 gtk_list_store_append(store, &iter);
1406 gtk_list_store_set(store, &iter,
1408 PFA_VALID_ACTION, is_valid,
1412 static GtkWidget *prefs_filtering_action_list_view_create(void)
1414 GtkTreeView *list_view;
1415 GtkTreeModel *model;
1416 GtkTreeSelection *selector;
1418 model = GTK_TREE_MODEL(prefs_filtering_action_create_data_store());
1419 list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
1420 g_object_unref(model);
1422 gtk_tree_view_set_rules_hint(list_view, prefs_common.use_stripes_everywhere);
1424 selector = gtk_tree_view_get_selection(list_view);
1425 gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
1426 gtk_tree_selection_set_select_function
1427 (selector, prefs_filtering_actions_selected, NULL, NULL);
1429 /* create the columns */
1430 prefs_filtering_action_create_list_view_columns(list_view);
1432 return GTK_WIDGET(list_view);
1435 static void prefs_filtering_action_create_list_view_columns(GtkTreeView *list_view)
1437 GtkTreeViewColumn *column;
1438 GtkCellRenderer *renderer;
1440 renderer = gtk_cell_renderer_text_new();
1441 column = gtk_tree_view_column_new_with_attributes
1442 (_("Current action list"),
1446 gtk_tree_view_append_column(list_view, column);
1449 static gboolean prefs_filtering_actions_selected
1450 (GtkTreeSelection *selector,
1451 GtkTreeModel *model,
1453 gboolean currently_selected,
1457 FilteringAction *action;
1458 GSList * action_list;
1463 if (currently_selected)
1466 if (!gtk_tree_model_get_iter(model, &iter, path))
1469 gtk_tree_model_get(model, &iter,
1470 PFA_VALID_ACTION, &is_valid,
1474 prefs_filtering_action_reset_dialog();
1478 gtk_tree_model_get(model, &iter,
1479 PFA_ACTION, &action_str,
1482 action_list = matcher_parser_get_action_list(action_str);
1485 if (action_list == NULL)
1488 action = action_list->data;
1489 g_slist_free(action_list);
1491 switch(action->type) {
1492 case MATCHACTION_MOVE:
1493 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1496 case MATCHACTION_COPY:
1497 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1500 case MATCHACTION_DELETE:
1501 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1504 case MATCHACTION_MARK:
1505 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1508 case MATCHACTION_UNMARK:
1509 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1512 case MATCHACTION_LOCK:
1513 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1516 case MATCHACTION_UNLOCK:
1517 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1520 case MATCHACTION_MARK_AS_READ:
1521 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1522 ACTION_MARK_AS_READ);
1524 case MATCHACTION_MARK_AS_UNREAD:
1525 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1526 ACTION_MARK_AS_UNREAD);
1528 case MATCHACTION_MARK_AS_SPAM:
1529 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1530 ACTION_MARK_AS_SPAM);
1532 case MATCHACTION_MARK_AS_HAM:
1533 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1534 ACTION_MARK_AS_HAM);
1536 case MATCHACTION_FORWARD:
1537 list_id = get_list_id_from_account_id(action->account_id);
1538 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1540 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1543 case MATCHACTION_FORWARD_AS_ATTACHMENT:
1544 list_id = get_list_id_from_account_id(action->account_id);
1545 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1546 ACTION_FORWARD_AS_ATTACHMENT);
1547 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1550 case MATCHACTION_REDIRECT:
1551 list_id = get_list_id_from_account_id(action->account_id);
1552 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1554 gtk_combo_box_set_active(GTK_COMBO_BOX(filtering_action.account_combo),
1557 case MATCHACTION_EXECUTE:
1558 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1561 case MATCHACTION_COLOR:
1562 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1564 gtk_option_menu_set_history(GTK_OPTION_MENU(filtering_action.color_optmenu),
1565 action->labelcolor);
1567 case MATCHACTION_CHANGE_SCORE:
1568 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1569 ACTION_CHANGE_SCORE);
1570 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry),
1573 case MATCHACTION_SET_SCORE:
1574 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1576 gtk_spin_button_set_value(GTK_SPIN_BUTTON(filtering_action.score_entry),
1579 case MATCHACTION_STOP:
1580 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1583 case MATCHACTION_HIDE:
1584 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1587 case MATCHACTION_IGNORE:
1588 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1591 case MATCHACTION_WATCH:
1592 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1595 case MATCHACTION_ADD_TO_ADDRESSBOOK:
1597 gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), action->header);
1599 gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), "");
1600 combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
1601 ACTION_ADD_TO_ADDRESSBOOK);
1603 if (action->destination)
1604 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), action->destination);
1606 gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), "");
1608 filteringaction_free(action); /* XXX: memleak */