|
GnuCash 2.4.99
|
00001 /* 00002 * search-param.h -- a container for a Search Parameter 00003 * Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU> 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License as 00007 * published by the Free Software Foundation; either version 2 of 00008 * the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, contact: 00017 * 00018 * Free Software Foundation Voice: +1-617-542-5942 00019 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 00020 * Boston, MA 02110-1301, USA gnu@gnu.org 00021 */ 00022 00023 #ifndef _GNCSEARCH_PARAM_H 00024 #define _GNCSEARCH_PARAM_H 00025 00026 #include "GNCId.h" 00027 00028 #define GNC_TYPE_SEARCH_PARAM (gnc_search_param_get_type ()) 00029 #define GNC_SEARCH_PARAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SEARCH_PARAM, GNCSearchParam)) 00030 #define GNCSEARCH_PARAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_SEARCH_PARAM, GNCSearchParamClass) 00031 #define GNC_IS_SEARCH_PARAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SEARCH_PARAM)) 00032 00033 typedef struct _GNCSearchParam GNCSearchParam; 00034 typedef struct _GNCSearchParamClass GNCSearchParamClass; 00035 00036 struct _GNCSearchParam 00037 { 00038 GObject gobject; 00039 00040 const char * title; 00041 GtkJustification justify; 00042 gboolean passive; 00043 gboolean non_resizeable; 00044 }; 00045 00046 struct _GNCSearchParamClass 00047 { 00048 GObjectClass gobject_class; 00049 00050 /* virtual methods */ 00051 00052 /* signals */ 00053 }; 00054 00055 /* These are internal functions */ 00056 GType gnc_search_param_get_type (void); 00057 00058 /* Create a new search param */ 00059 GNCSearchParam * gnc_search_param_new (void); 00060 00061 /* use the param_path for this parameter. This will automatically 00062 * compute the parameter type and the converter functions. 00063 */ 00064 void gnc_search_param_set_param_path (GNCSearchParam *param, 00065 QofIdTypeConst search_type, 00066 GSList *param_path); 00067 00068 /* List is property of the caller */ 00069 GSList * gnc_search_param_get_param_path (GNCSearchParam *param); 00070 QofIdTypeConst gnc_search_param_get_param_type (GNCSearchParam *param); 00071 void gnc_search_param_set_title (GNCSearchParam *param, 00072 const char *title); 00073 void gnc_search_param_set_justify (GNCSearchParam *param, 00074 GtkJustification justify); 00075 void gnc_search_param_set_passive (GNCSearchParam *param, 00076 gboolean value); 00077 void gnc_search_param_set_non_resizeable (GNCSearchParam *param, 00078 gboolean value); 00079 gboolean gnc_search_param_type_match (GNCSearchParam *a, 00080 GNCSearchParam *b); 00081 00082 /* Return the list of QofAccessFunc functions for this parameter. This list 00083 * is owned by the param object -- users should not change it */ 00084 GSList * gnc_search_param_get_converters (GNCSearchParam *param); 00085 00086 /* This will override the automatic param_type logic from "set_param_path()" 00087 * so that the programmer can force a particular UI to appear for a given 00088 * parameter path. This should be used with care -- if used improperly 00089 * it could result in an invalid Query Term, where the path and the predicate 00090 * don't match types properly. 00091 */ 00092 void gnc_search_param_override_param_type (GNCSearchParam *param, 00093 QofIdTypeConst param_type); 00094 00095 00096 /************************************************************* 00097 * Helper functions .. 00098 */ 00099 00100 /* Create a paramter and prepend it to a GSList */ 00101 GList * gnc_search_param_prepend (GList *list, char const *title, 00102 QofIdTypeConst type_override, 00103 QofIdTypeConst search_type, 00104 const char *param, ...); 00105 00106 00107 GList * gnc_search_param_prepend_with_justify (GList *list, char const *title, 00108 GtkJustification justify, 00109 QofIdTypeConst type_override, 00110 QofIdTypeConst search_type, 00111 const char *param, ...); 00112 00113 /* set a lookup function for this parameter (in lieu of setting the 00114 * param path) if you want to specify a direct lookup function when 00115 * using the compute_value interface. Note that this wont work with 00116 * sorting or other query interfaces, it's only useful for the 00117 * query-list. 00118 */ 00119 typedef gpointer (*GNCSearchParamFcn)(gpointer object, gpointer arg); 00120 void gnc_search_param_set_param_fcn (GNCSearchParam *param, 00121 QofIdTypeConst param_type, 00122 GNCSearchParamFcn fcn, 00123 gpointer arg); 00124 00125 /* Compute the value of this parameter for this object */ 00126 gpointer gnc_search_param_compute_value (GNCSearchParam *param, gpointer object); 00127 00128 00129 #endif /* _GNCSEARCH_PARAM_H */
1.7.4