GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dialog-search.h
1 /*
2  * dialog-search.h -- Search Dialog
3  * Copyright (C) 2002 Derek Atkins
4  * Author: Derek Atkins <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, contact:
18  *
19  * Free Software Foundation Voice: +1-617-542-5942
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
21  * Boston, MA 02110-1301, USA [email protected]
22  */
23 
24 #ifndef GNC_DIALOG_SEARCH_H
25 #define GNC_DIALOG_SEARCH_H
26 
27 #include "qof.h"
28 
29 typedef struct _GNCSearchWindow GNCSearchWindow;
30 
31 /* The two types of callbacks.
32  *
33  * In the first callback, (used in the callback button list) the obj_p
34  * argument will be a pointer to the selected item (if one is
35  * selected). The callback may change the value if they wish (note
36  * that the display will not adjust to the new selected item)
37  *
38  * In the second callback, the query is the property of the search
39  * dialog; the callback should copy it if they want to keep it. The
40  * result will be a pointer to the selected item (if one is selected)
41  * and the callback may change the value.
42  */
43 typedef void (*GNCSearchCallback) (gpointer *obj_p, gpointer user_data);
44 typedef void (*GNCSearchResultCB) (QofQuery *query, gpointer user_data,
45  gpointer *result);
46 
47 /*
48  * This callback will create a new item and return a handle to the
49  * newly created item (even if it is not completely finished). It
50  * will be added to the query, but not selected. This means the GncGUID
51  * must be set.
52  */
53 typedef gpointer (*GNCSearchNewItemCB) (gpointer user_data);
54 
55 /* Free the general user_data object */
56 typedef void (*GNCSearchFree) (gpointer user_data);
57 
62 typedef void (*GNCSearchSelectedCB) (gpointer selected_object,
63  gpointer user_data);
64 
69 typedef void (*GNCSearchMultiSelectedCB) (GList *list_of_selected_objects,
70  gpointer user_data);
71 
72 typedef struct
73 {
74  const char *label;
75  GNCSearchCallback cb_fcn;
76  GNCSearchMultiSelectedCB cb_multiselect_fn;
77 
83 
84 /* Caller MUST supply _EITHER_ a result_callback or a list of callback
85  * buttons. The caller MUST NOT supply both.
86  *
87  * Both the param_list and display_list are the property of the dialog
88  * but will NOT be destroyed.. They should be a GList of
89  * GNCSearchParam objects. The display_list defines which paramters
90  * of the found transactions are printed, and how.
91  *
92  * The start_query is the property of the caller and will only be copied.
93  * The show_start_query, if it exists, will become the property of the
94  * dialog and will be automatically destroyed.
95  *
96  * The user_data becomes the property of the search dialog and will
97  * be freed via the callback when the dialog is closed.
98  *
99  * the type_label (if non-null) is the TRANSLATED string to use for
100  * the type of object being searched. This will be put in the Title
101  * as well as into the "New" button. If this string is NULL then
102  * the dialog will use the obj_type instead.
103  */
105 gnc_search_dialog_create (QofIdTypeConst obj_type, const gchar *title,
106  GList *param_list,
107  GList *display_list,
108  QofQuery *start_query, QofQuery *show_start_query,
109  GNCSearchCallbackButton *callbacks,
110  GNCSearchResultCB result_callback,
111  GNCSearchNewItemCB new_item_cb,
112  gpointer user_data, GNCSearchFree free_user_data,
113  const gchar *prefs_group,
114  const gchar *type_label);
115 
116 void gnc_search_dialog_destroy (GNCSearchWindow *sw);
117 void gnc_search_dialog_raise (GNCSearchWindow *sw);
118 
119 /* Register an on-close signal with the Search Dialog */
120 guint gnc_search_dialog_connect_on_close (GNCSearchWindow *sw,
121  GCallback func,
122  gpointer user_data);
123 
124 /* Un-register the signal handlers with the Search Dialog */
125 void gnc_search_dialog_disconnect (GNCSearchWindow *sw, gpointer user_data);
126 
127 /*
128  * Set the select callback with this Search Window; setting it to NULL
129  * will effectively clear it out. If this is set, then a 'select'
130  * button will show up. If allow_clear is TRUE, then also allow
131  * a 'clear' button which would allow the selected_cb to be called
132  * with "NULL".
133  */
134 void gnc_search_dialog_set_select_cb (GNCSearchWindow *sw,
135  GNCSearchSelectedCB selected_cb,
136  gpointer user_data,
137  gboolean allow_clear);
138 
139 /* Test the dialog */
140 void gnc_search_dialog_test (void);
141 
142 #endif /* GNC_DIALOG_SEARCH_H */
const gchar * QofIdTypeConst
Definition: qofid.h:87
struct _QofQuery QofQuery
Definition: qofquery.h:90