1 /*
2  * This program is free software; you can redistribute it and/or modify it
3  * under the terms of the GNU Lesser General Public License as published by
4  * the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9  * for more details.
10  *
11  * You should have received a copy of the GNU Lesser General Public License
12  * along with this program; if not, see <http://www.gnu.org/licenses/>.
13  *
14  *
15  * Authors:
16  *		Not Zed <notzed@lostzed.mmc.com.au>
17  *      Jeffrey Stedfast <fejj@ximian.com>
18  *
19  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
20  *
21  */
22 
23 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
24 #error "Only <e-util/e-util.h> should be included directly."
25 #endif
26 
27 #ifndef E_FILTER_PART_H
28 #define E_FILTER_PART_H
29 
30 #include <gtk/gtk.h>
31 #include <libxml/parser.h>
32 #include <libxml/xmlmemory.h>
33 
34 #include <e-util/e-alert.h>
35 #include <e-util/e-filter-element.h>
36 
37 /* Standard GObject macros */
38 #define E_TYPE_FILTER_PART \
39 	(e_filter_part_get_type ())
40 #define E_FILTER_PART(obj) \
41 	(G_TYPE_CHECK_INSTANCE_CAST \
42 	((obj), E_TYPE_FILTER_PART, EFilterPart))
43 #define E_FILTER_PART_CLASS(cls) \
44 	(G_TYPE_CHECK_CLASS_CAST \
45 	((cls), E_TYPE_FILTER_PART, EFilterPartClass))
46 #define E_IS_FILTER_PART(obj) \
47 	(G_TYPE_CHECK_INSTANCE_TYPE \
48 	((obj), E_TYPE_FILTER_PART))
49 #define E_IS_FILTER_PART_CLASS(cls) \
50 	(G_TYPE_CHECK_CLASS_TYPE \
51 	((cls), E_TYPE_FILTER_PART))
52 #define E_FILTER_PART_GET_CLASS(obj) \
53 	(G_TYPE_INSTANCE_GET_CLASS \
54 	((obj), E_TYPE_FILTER_PART, EFilterPartClass))
55 
56 G_BEGIN_DECLS
57 
58 struct _ERuleContext;
59 
60 typedef struct _EFilterPart EFilterPart;
61 typedef struct _EFilterPartClass EFilterPartClass;
62 typedef struct _EFilterPartPrivate EFilterPartPrivate;
63 
64 struct _EFilterPart {
65 	GObject parent;
66 	EFilterPartPrivate *priv;
67 
68 	gchar *name;
69 	gchar *title;
70 	gchar *code;
71 	GList *elements;
72 };
73 
74 struct _EFilterPartClass {
75 	GObjectClass parent_class;
76 };
77 
78 GType		e_filter_part_get_type		(void) G_GNUC_CONST;
79 EFilterPart *	e_filter_part_new		(void);
80 gboolean	e_filter_part_validate		(EFilterPart *part,
81 						 EAlert **alert);
82 gint		e_filter_part_eq		(EFilterPart *part_a,
83 						 EFilterPart *part_b);
84 gint		e_filter_part_xml_create	(EFilterPart *part,
85 						 xmlNodePtr node,
86 						 struct _ERuleContext *rc);
87 xmlNodePtr	e_filter_part_xml_encode	(EFilterPart *fe);
88 gint		e_filter_part_xml_decode	(EFilterPart *fe,
89 						 xmlNodePtr node);
90 EFilterPart *	e_filter_part_clone		(EFilterPart *part);
91 void		e_filter_part_copy_values	(EFilterPart *dst_part,
92 						 EFilterPart *src_part);
93 EFilterElement *e_filter_part_find_element	(EFilterPart *part,
94 						 const gchar *name);
95 GtkWidget *	e_filter_part_get_widget	(EFilterPart *part);
96 void		e_filter_part_describe		(EFilterPart *part,
97 						 GString *out);
98 void		e_filter_part_build_code	(EFilterPart *part,
99 						 GString *out);
100 void		e_filter_part_expand_code	(EFilterPart *part,
101 						 const gchar *str,
102 						 GString *out);
103 
104 void		e_filter_part_build_code_list	(GList *list,
105 						 GString *out);
106 EFilterPart *	e_filter_part_find_list		(GList *list,
107 						 const gchar *name);
108 EFilterPart *	e_filter_part_next_list		(GList *list,
109 						 EFilterPart *last);
110 
111 G_END_DECLS
112 
113 #endif /* E_FILTER_PART_H */
114