No issues found
1 /*
2 *
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.
7 *
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.
12 *
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/>
15 *
16 *
17 * Authors:
18 * Not Zed <notzed@lostzed.mmc.com.au>
19 * Jeffrey Stedfast <fejj@ximian.com>
20 *
21 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
22 *
23 */
24
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
28
29 #include <string.h>
30
31 #include "em-search-context.h"
32 #include "filter/e-filter-rule.h"
33 #include "filter/e-filter-option.h"
34 #include "filter/e-filter-int.h"
35
36 G_DEFINE_TYPE (EMSearchContext, em_search_context, E_TYPE_RULE_CONTEXT)
37
38 static EFilterElement *
39 search_context_new_element (ERuleContext *context,
40 const gchar *type)
41 {
42 if (strcmp (type, "system-flag") == 0)
43 return (EFilterElement *) e_filter_option_new ();
44
45 if (strcmp (type, "score") == 0)
46 return (EFilterElement *) e_filter_int_new_type ("score", -3, 3);
47
48 /* Chain up to parent's new_element() method. */
49 return E_RULE_CONTEXT_CLASS (em_search_context_parent_class)->
50 new_element (context, type);
51 }
52
53 static void
54 em_search_context_class_init (EMSearchContextClass *class)
55 {
56 ERuleContextClass *rule_context_class;
57
58 rule_context_class = E_RULE_CONTEXT_CLASS (class);
59 rule_context_class->new_element = search_context_new_element;
60 }
61
62 static void
63 em_search_context_init (EMSearchContext *vc)
64 {
65 ERuleContext *rule_context;
66
67 rule_context = E_RULE_CONTEXT (vc);
68
69 rule_context->flags =
70 E_RULE_CONTEXT_THREADING |
71 E_RULE_CONTEXT_GROUPING;
72 }
73
74 ERuleContext *
75 em_search_context_new (void)
76 {
77 return g_object_new (EM_SEARCH_TYPE_CONTEXT, NULL);
78 }