3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with the program; if not, see <http://www.gnu.org/licenses/>
18 * Not Zed <notzed@lostzed.mmc.com.au>
19 * Jeffrey Stedfast <fejj@ximian.com>
21 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
31 #include "em-vfolder-context.h"
32 #include "em-vfolder-rule.h"
33 #include "filter/e-filter-option.h"
34 #include "filter/e-filter-int.h"
36 #include "em-filter-folder-element.h"
38 #define EM_VFOLDER_CONTEXT_GET_PRIVATE(obj) \
39 (G_TYPE_INSTANCE_GET_PRIVATE \
40 ((obj), EM_TYPE_VFOLDER_CONTEXT, EMVFolderContextPrivate))
42 struct _EMVFolderContextPrivate
{
56 static EFilterElement
*
57 vfolder_context_new_element (ERuleContext
*context
,
60 if (strcmp (type
, "system-flag") == 0)
61 return e_filter_option_new ();
63 if (strcmp (type
, "score") == 0)
64 return e_filter_int_new_type("score", -3, 3);
66 if (strcmp (type
, "folder") == 0)
67 return em_filter_folder_element_new ();
69 /* XXX Legacy type name. Same as "folder" now. */
70 if (strcmp (type
, "folder-curi") == 0)
71 return em_filter_folder_element_new ();
73 return E_RULE_CONTEXT_CLASS (em_vfolder_context_parent_class
)->
74 new_element (context
, type
);
78 em_vfolder_context_class_init (EMVFolderContextClass
*class)
80 ERuleContextClass
*rule_context_class
;
82 g_type_class_add_private (class, sizeof (EMVFolderContextPrivate
));
84 rule_context_class
= E_RULE_CONTEXT_CLASS (class);
85 rule_context_class
->new_element
= vfolder_context_new_element
;
89 em_vfolder_context_init (EMVFolderContext
*context
)
91 context
->priv
= EM_VFOLDER_CONTEXT_GET_PRIVATE (context
);
93 e_rule_context_add_part_set (
94 E_RULE_CONTEXT (context
), "partset", E_TYPE_FILTER_PART
,
95 (ERuleContextPartFunc
) e_rule_context_add_part
,
96 (ERuleContextNextPartFunc
) e_rule_context_next_part
);
98 e_rule_context_add_rule_set (
99 E_RULE_CONTEXT (context
), "ruleset", EM_TYPE_VFOLDER_RULE
,
100 (ERuleContextRuleFunc
) e_rule_context_add_rule
,
101 (ERuleContextNextRuleFunc
) e_rule_context_next_rule
);
103 E_RULE_CONTEXT (context
)->flags
=
104 E_RULE_CONTEXT_THREADING
| E_RULE_CONTEXT_GROUPING
;
108 em_vfolder_context_new ()
110 return g_object_new (
111 EM_TYPE_VFOLDER_CONTEXT
, NULL
);