aboutsummaryrefslogtreecommitdiff
path: root/src/prefs_filter_edit.h
blob: 1b748d852e0a1c6269231481261951e7de445f82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2012 Hiroyuki Yamamoto
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __PREFS_FILTER_EDIT_H__
#define __PREFS_FILTER_EDIT_H__

#include <gtk/gtkwidget.h>

#include "filter.h"

typedef struct _FilterCondEdit	FilterCondEdit;
typedef struct _CondHBox	CondHBox;
typedef struct _ActionHBox	ActionHBox;

typedef enum
{
	PF_COND_HEADER,
	PF_COND_TO_OR_CC,
	PF_COND_ANY_HEADER,
	PF_COND_BODY,
	PF_COND_CMD_TEST,
	PF_COND_SIZE,
	PF_COND_AGE,
	PF_COND_UNREAD,
	PF_COND_MARK,
	PF_COND_COLOR_LABEL,
	PF_COND_MIME,
	PF_COND_ACCOUNT,
	PF_COND_EDIT_HEADER,
	PF_COND_SEPARATOR,
	PF_COND_NONE
} CondMenuType;

typedef enum
{
	PF_MATCH_CONTAIN,
	PF_MATCH_NOT_CONTAIN,
	PF_MATCH_EQUAL,
	PF_MATCH_NOT_EQUAL,
	PF_MATCH_REGEX,
	PF_MATCH_NOT_REGEX,
	PF_MATCH_IN_ADDRESSBOOK,
	PF_MATCH_NOT_IN_ADDRESSBOOK,
	PF_MATCH_NONE
} MatchMenuType;

typedef enum
{
	PF_SIZE_LARGER,
	PF_SIZE_SMALLER
} SizeMatchType;

typedef enum
{
	PF_AGE_SHORTER,
	PF_AGE_LONGER
} AgeMatchType;

typedef enum
{
	PF_STATUS_MATCH,
	PF_STATUS_NOT_MATCH
} StatusMatchType;

typedef enum
{
	PF_ACTION_MOVE,
	PF_ACTION_COPY,
	PF_ACTION_NOT_RECEIVE,
	PF_ACTION_DELETE,
	PF_ACTION_EXEC,
	PF_ACTION_EXEC_ASYNC,
	PF_ACTION_MARK,
	PF_ACTION_COLOR_LABEL,
	PF_ACTION_MARK_READ,
	PF_ACTION_FORWARD,
	PF_ACTION_FORWARD_AS_ATTACHMENT,
	PF_ACTION_REDIRECT,
	PF_ACTION_STOP_EVAL,
	PF_ACTION_SEPARATOR,
	PF_ACTION_NONE
} ActionMenuType;

struct _FilterCondEdit {
	GtkWidget *cond_vbox;
	GSList *cond_hbox_list;

	GSList *hdr_list;
	GSList *rule_hdr_list;

	/* callback */
	void	(*add_hbox)	(CondHBox	*hbox);
};

struct _CondHBox {
	GtkWidget *hbox;

	GtkWidget *cond_type_optmenu;
	GtkWidget *match_type_optmenu;
	GtkWidget *size_match_optmenu;
	GtkWidget *age_match_optmenu;
	GtkWidget *status_match_optmenu;
	GtkWidget *key_entry;
	GtkWidget *spin_btn;
	GtkWidget *label;

	GtkWidget *match_menu_in_addr;
	GtkWidget *match_menu_not_in_addr;

	GtkWidget *del_btn;
	GtkWidget *add_btn;

	CondMenuType cur_type;
	gchar *cur_header_name;

	FilterCondEdit *cond_edit;
};

struct _ActionHBox {
	GtkWidget *hbox;

	GtkWidget *action_type_optmenu;
	GtkWidget *label;
	GtkWidget *folder_entry;
	GtkWidget *cmd_entry;
	GtkWidget *address_entry;
	GtkWidget *clabel_optmenu;

	GtkWidget *folder_sel_btn;

	GtkWidget *action_type_menu_items[PF_ACTION_NONE];

	GtkWidget *del_btn;
	GtkWidget *add_btn;
};


FilterRule *prefs_filter_edit_open	(FilterRule	*rule,
					 const gchar	*header,
					 const gchar	*key);

FilterCondEdit *prefs_filter_edit_cond_edit_create	(void);
void prefs_filter_edit_clear_cond_edit	(FilterCondEdit	*cond_edit);

void prefs_filter_edit_set_header_list	(FilterCondEdit	*cond_edit,
					 FilterRule	*rule);

CondHBox *prefs_filter_edit_cond_hbox_create
					(FilterCondEdit	*cond_edit);
ActionHBox *prefs_filter_edit_action_hbox_create	(void);

void prefs_filter_edit_cond_hbox_set	(CondHBox	*hbox,
					 FilterCond	*cond);
void prefs_filter_edit_action_hbox_set	(ActionHBox	*hbox,
					 FilterAction	*action);

void prefs_filter_edit_cond_hbox_select	(CondHBox	*hbox,
					 CondMenuType	 type,
					 const gchar	*header_name);

void prefs_filter_edit_set_cond_hbox_widgets	(CondHBox	*hbox,
						 CondMenuType	 type);
void prefs_filter_edit_set_action_hbox_widgets	(ActionHBox	*hbox,
						 ActionMenuType	 type);

void prefs_filter_edit_insert_cond_hbox		(FilterCondEdit	*cond_edit,
						 CondHBox	*hbox,
						 gint		 pos);

void prefs_filter_edit_add_rule_cond		(FilterCondEdit *cond_edit,
						 FilterRule	*rule);

FilterCond *prefs_filter_edit_cond_hbox_to_cond	(CondHBox	*hbox,
						 gboolean	 case_sens,
						 gchar	       **error_msg);

GSList *prefs_filter_edit_cond_edit_to_list	(FilterCondEdit	*cond_edit,
						 gboolean	 case_sens);

#endif /* __PREFS_FILTER_EDIT_H__ */