#include "addr_compl.h"
#include "colorlabel.h"
+#include "matcher_parser.h"
+
static struct Filtering {
GtkWidget *window;
gint current_action;
} filtering;
-#define VSPACING 12
-#define VSPACING_NARROW 4
-#define DEFAULT_ENTRY_WIDTH 80
-#define PREFSBUFSIZE 1024
-
/* widget creating functions */
static void prefs_filtering_create (void);
static void prefs_filtering_reset_dialog(void);
+static FolderItem * cur_item = NULL;
+
enum {
ACTION_MOVE = 0,
ACTION_COPY = 1,
ACTION_MARK_AS_UNREAD = 6,
ACTION_FORWARD = 7,
ACTION_FORWARD_AS_ATTACHMENT = 8,
- ACTION_EXECUTE = 9,
- ACTION_COLOR = 10
+ ACTION_BOUNCE = 9,
+ ACTION_EXECUTE = 10,
+ ACTION_COLOR = 11,
};
static gint get_sel_from_list(GtkList * list)
{
switch(action_id) {
case ACTION_MOVE:
- return MATCHING_ACTION_MOVE;
+ return MATCHACTION_MOVE;
case ACTION_COPY:
- return MATCHING_ACTION_COPY;
+ return MATCHACTION_COPY;
case ACTION_DELETE:
- return MATCHING_ACTION_DELETE;
+ return MATCHACTION_DELETE;
case ACTION_MARK:
- return MATCHING_ACTION_MARK;
+ return MATCHACTION_MARK;
case ACTION_UNMARK:
- return MATCHING_ACTION_UNMARK;
+ return MATCHACTION_UNMARK;
case ACTION_MARK_AS_READ:
- return MATCHING_ACTION_MARK_AS_READ;
+ return MATCHACTION_MARK_AS_READ;
case ACTION_MARK_AS_UNREAD:
- return MATCHING_ACTION_MARK_AS_UNREAD;
+ return MATCHACTION_MARK_AS_UNREAD;
case ACTION_FORWARD:
- return MATCHING_ACTION_FORWARD;
+ return MATCHACTION_FORWARD;
case ACTION_FORWARD_AS_ATTACHMENT:
- return MATCHING_ACTION_FORWARD_AS_ATTACHMENT;
+ return MATCHACTION_FORWARD_AS_ATTACHMENT;
+ case ACTION_BOUNCE:
+ return MATCHACTION_BOUNCE;
case ACTION_EXECUTE:
- return MATCHING_EXECUTE;
+ return MATCHACTION_EXECUTE;
case ACTION_COLOR:
- return MATCHING_ACTION_COLOR;
+ return MATCHACTION_COLOR;
default:
return -1;
}
N_("Mark as unread"),
N_("Forward"),
N_("Forward as attachment"),
+ N_("Bounce"),
N_("Execute"),
N_("Color")
};
-void prefs_filtering_open(void)
+void prefs_filtering_open(FolderItem * item)
{
if (prefs_rc_is_readonly(FILTERING_RC))
return;
- inc_autocheck_timer_remove();
+ inc_lock();
if (!filtering.window) {
prefs_filtering_create();
manage_window_set_transient(GTK_WINDOW(filtering.window));
gtk_widget_grab_focus(filtering.ok_btn);
+ cur_item = item;
+
prefs_filtering_set_dialog();
gtk_widget_show(filtering.window);
end_address_completion();
gtk_widget_hide(filtering.window);
+ inc_unlock();
}
static void prefs_filtering_create(void)
cond_entry = gtk_entry_new ();
gtk_widget_show (cond_entry);
-// gtk_widget_set_usize (cond_entry, 200, -1);
gtk_box_pack_start (GTK_BOX (hbox1), cond_entry, TRUE, TRUE, 0);
cond_btn = gtk_button_new_with_label (_("Define ..."));
action_combo = gtk_combo_new ();
gtk_widget_show (action_combo);
-// gtk_widget_set_usize (action_combo, 200, -1);
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(action_combo)->entry),
FALSE);
dest_entry = gtk_entry_new ();
gtk_widget_show (dest_entry);
-// gtk_widget_set_usize (dest_entry, 200, -1);
gtk_box_pack_start (GTK_BOX (hbox1), dest_entry, TRUE, TRUE, 0);
color_optmenu = gtk_option_menu_new();
gtk_option_menu_set_menu(GTK_OPTION_MENU(color_optmenu),
colorlabel_create_color_menu());
-// gtk_widget_set_usize(color_optmenu, -1, -1);
gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, TRUE, TRUE, 0);
dest_btn = gtk_button_new_with_label (_("Select ..."));
GTK_SIGNAL_FUNC (prefs_matcher_exec_info),
NULL);
-// dummy = gtk_label_new("");
-// gtk_widget_show (dummy);
-// gtk_box_pack_start(GTK_BOX (hbox1), dummy, FALSE, FALSE, 0);
-
-
/* register / substitute / delete */
reg_hbox = gtk_hbox_new (FALSE, 4);
{
GtkCList *clist = GTK_CLIST(filtering.cond_clist);
GSList *cur;
+ GSList * prefs_filtering;
gtk_clist_freeze(clist);
gtk_clist_clear(clist);
prefs_filtering_clist_set_row(-1, NULL);
+
+ if (cur_item == NULL)
+ prefs_filtering = global_processing;
+ else
+ prefs_filtering = cur_item->prefs->processing;
+
for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur)) {
FilteringProp * prop = (FilteringProp *) cur->data;
GSList * cur;
gchar * filtering_str;
gchar * tmp;
+ GSList * prefs_filtering;
+
+ if (cur_item == NULL)
+ prefs_filtering = global_processing;
+ else
+ prefs_filtering = cur_item->prefs->processing;
for(cur = prefs_filtering ; cur != NULL ; cur = g_slist_next(cur))
filteringprop_free((FilteringProp *) cur->data);
while (gtk_clist_get_text(GTK_CLIST(filtering.cond_clist),
row, 0, &filtering_str)) {
if (strcmp(filtering_str, _("(New)")) != 0) {
- tmp = filtering_str;
- prop = filteringprop_parse(&tmp);
+ /* tmp = filtering_str; */
+ prop = matcher_parser_get_filtering(filtering_str);
if (prop != NULL)
- prefs_filtering = g_slist_append(prefs_filtering,
- prop);
+ prefs_filtering =
+ g_slist_append(prefs_filtering, prop);
}
row++;
}
+
+ if (cur_item == NULL)
+ global_processing = prefs_filtering;
+ else
+ cur_item->prefs->processing = prefs_filtering;
}
static gint prefs_filtering_clist_set_row(gint row, FilteringProp * prop)
if (*cond_str != '\0') {
gchar * tmp;
- tmp = cond_str;
- matchers = matcherlist_parse(&tmp);
- if (tmp == NULL)
+ /* tmp = cond_str; */
+ matchers = matcher_parser_get_cond(cond_str);
+ if (matchers == NULL)
alertpanel_error(_("Match string is not valid."));
}
case ACTION_COPY:
case ACTION_FORWARD:
case ACTION_FORWARD_AS_ATTACHMENT:
+ case ACTION_BOUNCE:
case ACTION_EXECUTE:
destination = gtk_entry_get_text(GTK_ENTRY(filtering.dest_entry));
if (*destination == '\0') {
action = filteringaction_new(action_type, account_id, destination, labelcolor);
- tmp = cond_str;
- cond = matcherlist_parse(&tmp);
+ cond = matcher_parser_get_cond(cond_str);
- if (tmp == NULL) {
+ if (cond == NULL) {
alertpanel_error(_("Match string is not valid."));
filteringaction_free(action);
return NULL;
gtk_entry_set_text(GTK_ENTRY(filtering.dest_entry), "");
switch(action->type) {
- case MATCHING_ACTION_MOVE:
+ case MATCHACTION_MOVE:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_MOVE);
break;
- case MATCHING_ACTION_COPY:
+ case MATCHACTION_COPY:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_COPY);
break;
- case MATCHING_ACTION_DELETE:
+ case MATCHACTION_DELETE:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_DELETE);
break;
- case MATCHING_ACTION_MARK:
+ case MATCHACTION_MARK:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_MARK);
break;
- case MATCHING_ACTION_UNMARK:
+ case MATCHACTION_UNMARK:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_UNMARK);
break;
- case MATCHING_ACTION_MARK_AS_READ:
+ case MATCHACTION_MARK_AS_READ:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_MARK_AS_READ);
break;
- case MATCHING_ACTION_MARK_AS_UNREAD:
+ case MATCHACTION_MARK_AS_UNREAD:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_MARK_AS_UNREAD);
break;
- case MATCHING_ACTION_FORWARD:
+ case MATCHACTION_FORWARD:
+ list_id = get_list_id_from_account_id(action->account_id);
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_FORWARD);
- list_id = get_list_id_from_account_id(action->account_id);
gtk_list_select_item(GTK_LIST(filtering.account_list),
list_id);
break;
- case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
+ case MATCHACTION_FORWARD_AS_ATTACHMENT:
list_id = get_list_id_from_account_id(action->account_id);
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_FORWARD_AS_ATTACHMENT);
gtk_list_select_item(GTK_LIST(filtering.account_list),
list_id);
break;
- case MATCHING_EXECUTE:
+ case MATCHACTION_BOUNCE:
+ list_id = get_list_id_from_account_id(action->account_id);
+ gtk_list_select_item(GTK_LIST(filtering.action_list),
+ ACTION_BOUNCE);
+ gtk_list_select_item(GTK_LIST(filtering.account_list),
+ list_id);
+ break;
+ case MATCHACTION_EXECUTE:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_EXECUTE);
break;
- case MATCHING_ACTION_COLOR:
+ case MATCHACTION_COLOR:
gtk_list_select_item(GTK_LIST(filtering.action_list),
ACTION_COLOR);
gtk_option_menu_set_history(GTK_OPTION_MENU(filtering.color_optmenu), action->labelcolor);
row, 0, &filtering_str))
return;
- tmp = filtering_str;
- prop = filteringprop_parse(&tmp);
- if (tmp == NULL)
+ prop = matcher_parser_get_filtering(filtering_str);
+ if (prop == NULL)
return;
prefs_filtering_select_set(prop);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_hide(filtering.color_label);
break;
+ case ACTION_BOUNCE:
+ gtk_widget_set_sensitive(filtering.account_combo, TRUE);
+ gtk_widget_show(filtering.dest_entry);
+ gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
+ gtk_widget_hide(filtering.dest_btn);
+ gtk_widget_show(filtering.dest_label);
+ gtk_widget_hide(filtering.exec_label);
+ gtk_widget_hide(filtering.exec_btn);
+ gtk_widget_hide(filtering.color_optmenu);
+ gtk_widget_hide(filtering.color_label);
+ break;
case ACTION_EXECUTE:
gtk_widget_set_sensitive(filtering.account_combo, FALSE);
gtk_widget_show(filtering.dest_entry);
gtk_widget_hide(filtering.dest_btn);
gtk_widget_hide(filtering.dest_label);
gtk_widget_show(filtering.exec_label);
- gtk_widget_set_sensitive(filtering.exec_btn, FALSE);
+ gtk_widget_set_sensitive(filtering.exec_btn, TRUE);
gtk_widget_show(filtering.exec_btn);
gtk_widget_hide(filtering.color_optmenu);
gtk_widget_hide(filtering.color_label);
static void prefs_filtering_ok(void)
{
prefs_filtering_set_list();
- prefs_filtering_write_config();
+ prefs_matcher_write_config();
prefs_filtering_close();
}
static void prefs_filtering_cancel(void)
{
- prefs_filtering_read_config();
+ prefs_matcher_read_config();
prefs_filtering_close();
}