GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
search-param.h
1 /*
2  * search-param.h -- a container for a Search Parameter
3  * Copyright (C) 2002 Derek Atkins <[email protected]>
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 [email protected]
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 #define GNC_SEARCH_PARAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SEARCH_PARAM, GNCSearchParam))
29 #define GNCSEARCH_PARAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_SEARCH_PARAM, GNCSearchParamClass)
30 #define GNC_IS_SEARCH_PARAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SEARCH_PARAM))
31 
32 typedef struct _GNCSearchParam GNCSearchParam;
34 
36 {
37  GObject gobject;
38 
39  const char * title;
40  GtkJustification justify;
41  gboolean passive;
42  gboolean non_resizeable;
43 };
44 
46 {
47  GObjectClass gobject_class;
48 
49  /* virtual methods */
50 
51  /* signals */
52 };
53 
54 /* These are internal functions */
55 GType gnc_search_param_get_type (void);
56 
57 /* Create a new search param */
58 GNCSearchParam * gnc_search_param_new (void);
59 
60 /* use the param_path for this parameter. This will automatically
61  * compute the parameter type and the converter functions.
62  */
63 void gnc_search_param_set_param_path (GNCSearchParam *param,
64  QofIdTypeConst search_type,
65  GSList *param_path);
66 
67 /* List is property of the caller */
68 GSList * gnc_search_param_get_param_path (GNCSearchParam *param);
69 QofIdTypeConst gnc_search_param_get_param_type (GNCSearchParam *param);
70 void gnc_search_param_set_title (GNCSearchParam *param,
71  const char *title);
72 void gnc_search_param_set_justify (GNCSearchParam *param,
73  GtkJustification justify);
74 void gnc_search_param_set_passive (GNCSearchParam *param,
75  gboolean value);
76 void gnc_search_param_set_non_resizeable (GNCSearchParam *param,
77  gboolean value);
78 gboolean gnc_search_param_type_match (GNCSearchParam *a,
79  GNCSearchParam *b);
80 
81 /* Return the list of QofAccessFunc functions for this parameter. This list
82  * is owned by the param object -- users should not change it */
83 GSList * gnc_search_param_get_converters (GNCSearchParam *param);
84 
85 /* This will override the automatic param_type logic from "set_param_path()"
86  * so that the programmer can force a particular UI to appear for a given
87  * parameter path. This should be used with care -- if used improperly
88  * it could result in an invalid Query Term, where the path and the predicate
89  * don't match types properly.
90  */
91 void gnc_search_param_override_param_type (GNCSearchParam *param,
92  QofIdTypeConst param_type);
93 
94 
95 /*************************************************************
96  * Helper functions ..
97  */
98 
99 /* Create a paramter and prepend it to a GSList */
100 GList * gnc_search_param_prepend (GList *list, char const *title,
101  QofIdTypeConst type_override,
102  QofIdTypeConst search_type,
103  const char *param, ...);
104 
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 /* set a lookup function for this parameter (in lieu of setting the
113  * param path) if you want to specify a direct lookup function when
114  * using the compute_value interface. Note that this wont work with
115  * sorting or other query interfaces, it's only useful for the
116  * query-list.
117  */
118 typedef gpointer (*GNCSearchParamFcn)(gpointer object, gpointer arg);
119 void gnc_search_param_set_param_fcn (GNCSearchParam *param,
120  QofIdTypeConst param_type,
121  GNCSearchParamFcn fcn,
122  gpointer arg);
123 
124 /* Compute the value of this parameter for this object */
125 gpointer gnc_search_param_compute_value (GNCSearchParam *param, gpointer object);
126 
127 
128 #endif /* _GNCSEARCH_PARAM_H */
const gchar * QofIdTypeConst
Definition: qofid.h:87