GnuCash  5.6-150-g038405b370+
search-param.h
1 /*
2  * search-param.h -- a container for a Search Parameter
3  * Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of
8  * the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, contact:
17  *
18  * Free Software Foundation Voice: +1-617-542-5942
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
20  * Boston, MA 02110-1301, USA gnu@gnu.org
21  */
22 
23 #ifndef _GNCSEARCH_PARAM_H
24 #define _GNCSEARCH_PARAM_H
25 
26 
27 #define GNC_TYPE_SEARCH_PARAM (gnc_search_param_get_type ())
28 G_DECLARE_DERIVABLE_TYPE (GNCSearchParam, gnc_search_param, GNC, SEARCH_PARAM, GObject)
29 
31 {
32  GObjectClass gobject_class;
33 
34  /* virtual methods */
35 
36  /* signals */
37 };
38 
39 #define GNC_TYPE_SEARCH_PARAM_SIMPLE (gnc_search_param_simple_get_type ())
40 G_DECLARE_FINAL_TYPE (GNCSearchParamSimple, gnc_search_param_simple, GNC, SEARCH_PARAM_SIMPLE, GNCSearchParam)
41 
42 #define GNC_TYPE_SEARCH_PARAM_COMPOUND (gnc_search_param_compound_get_type ())
43 G_DECLARE_FINAL_TYPE (GNCSearchParamCompound, gnc_search_param_compound, GNC, SEARCH_PARAM_COMPOUND, GNCSearchParam)
44 
45 typedef enum
46 {
47  SEARCH_PARAM_ELEM = 0,
48  SEARCH_PARAM_ANY = 1,
49  SEARCH_PARAM_ALL = 2
50 } GNCSearchParamKind;
51 
52 /* Create a new search param */
53 GNCSearchParamSimple * gnc_search_param_simple_new (void);
54 GNCSearchParamCompound * gnc_search_param_compound_new (void);
55 
56 /* use the param_path for this parameter. This will automatically
57  * compute the parameter type and the converter functions.
58  */
59 void gnc_search_param_set_param_path (GNCSearchParamSimple *param,
60  QofIdTypeConst search_type,
61  GSList *param_path);
62 
63 /* List is property of the caller */
64 GList * gnc_search_param_get_search (GNCSearchParamCompound *param);
65 GSList * gnc_search_param_get_param_path (GNCSearchParamSimple *param);
66 QofIdTypeConst gnc_search_param_get_param_type (GNCSearchParam *param);
67 const char *gnc_search_param_get_title (GNCSearchParam *param);
68 void gnc_search_param_set_title (GNCSearchParam *param,
69  const char *title);
70 GNCSearchParamKind gnc_search_param_get_kind (GNCSearchParam *param);
71 GtkJustification gnc_search_param_get_justify (GNCSearchParam *param);
72 void gnc_search_param_set_justify (GNCSearchParam *param,
73  GtkJustification justify);
74 gboolean gnc_search_param_get_passive (GNCSearchParam *param);
75 void gnc_search_param_set_passive (GNCSearchParam *param,
76  gboolean value);
77 gboolean gnc_search_param_get_non_resizeable (GNCSearchParam *param);
78 void gnc_search_param_set_non_resizeable (GNCSearchParam *param,
79  gboolean value);
80 gboolean gnc_search_param_type_match (GNCSearchParam *a,
81  GNCSearchParam *b);
82 
83 /* Return the list of QofAccessFunc functions for this parameter. This list
84  * is owned by the param object -- users should not change it */
85 GSList * gnc_search_param_get_converters (GNCSearchParamSimple *param);
86 
87 /* This will override the automatic param_type logic from "set_param_path()"
88  * so that the programmer can force a particular UI to appear for a given
89  * parameter path. This should be used with care -- if used improperly
90  * it could result in an invalid Query Term, where the path and the predicate
91  * don't match types properly.
92  */
93 void gnc_search_param_override_param_type (GNCSearchParamSimple *param,
94  QofIdTypeConst param_type);
95 
96 /*************************************************************
97  * Helper functions ..
98  */
99 
100 /* Create a parameter and prepend it to a GSList */
101 GList * gnc_search_param_prepend (GList *list, char const *title,
102  QofIdTypeConst type_override,
103  QofIdTypeConst search_type,
104  const char *param, ...);
105 
106 GList * gnc_search_param_prepend_with_justify (GList *list, char const *title,
107  GtkJustification justify,
108  QofIdTypeConst type_override,
109  QofIdTypeConst search_type,
110  const char *param, ...);
111 
112 GList * gnc_search_param_prepend_compound (GList *list, char const *title,
113  GList *param_list,
114  GtkJustification justify,
115  GNCSearchParamKind kind);
116 
117 /* set a lookup function for this parameter (in lieu of setting the
118  * param path) if you want to specify a direct lookup function when
119  * using the compute_value interface. Note that this won't work with
120  * sorting or other query interfaces, it's only useful for the
121  * query-list.
122  */
123 typedef gpointer (*GNCSearchParamFcn)(gpointer object, gpointer arg);
124 void gnc_search_param_set_param_fcn (GNCSearchParamSimple *param,
125  QofIdTypeConst param_type,
126  GNCSearchParamFcn fcn,
127  gpointer arg);
128 
129 /* check to see if this parameter is a lookup function */
130 gboolean gnc_search_param_has_param_fcn (GNCSearchParamSimple *param);
131 
132 /* Compute the value of this parameter for this object */
133 gpointer gnc_search_param_compute_value (GNCSearchParamSimple *param,
134  gpointer object);
135 
136 #endif /* _GNCSEARCH_PARAM_H */
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
Definition: qofid.h:82