GnuCash c935c2f+
Loading...
Searching...
No Matches
dialog-search.h
1/*
2 * dialog-search.h -- Search Dialog
3 * Copyright (C) 2002 Derek Atkins
4 * Author: Derek Atkins <warlord@MIT.EDU>
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 gnu@gnu.org
22 */
23
24#ifndef GNC_DIALOG_SEARCH_H
25#define GNC_DIALOG_SEARCH_H
26
27#include "qof.h"
28
29typedef 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 */
43typedef void (*GNCSearchCallback) (GtkWindow *dialog, gpointer *obj_p, gpointer user_data);
44typedef 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 */
53typedef gpointer (*GNCSearchNewItemCB) (GtkWindow *dialog, gpointer user_data);
54
55/* Free the general user_data object */
56typedef void (*GNCSearchFree) (gpointer user_data);
57
62typedef void (*GNCSearchSelectedCB) (GtkWindow *dialog,
63 gpointer selected_object,
64 gpointer user_data);
65
70typedef void (*GNCSearchMultiSelectedCB) (GtkWindow *dialog,
71 GList *list_of_selected_objects,
72 gpointer user_data);
73
74typedef struct
75{
76 const char *label;
77 GNCSearchCallback cb_fcn;
78 GNCSearchMultiSelectedCB cb_multiselect_fn;
79
85
86/* Caller MUST supply _EITHER_ a result_callback or a list of callback
87 * buttons. The caller MUST NOT supply both.
88 *
89 * Both the param_list and display_list are the property of the dialog
90 * but will NOT be destroyed.. The param_list should be a GList of
91 * GNCSearchParam objects. The display_list should be a GList of
92 * GNCSearchParamSimple objects which defines which parameters
93 * of the found transactions are printed, and how.
94 *
95 * The start_query is the property of the caller and will only be copied.
96 * The show_start_query, if it exists, will become the property of the
97 * dialog and will be automatically destroyed.
98 *
99 * The user_data becomes the property of the search dialog and will
100 * be freed via the callback when the dialog is closed.
101 *
102 * the type_label (if non-null) is the TRANSLATED string to use for
103 * the type of object being searched. This will be put in the Title
104 * as well as into the "New" button. If this string is NULL then
105 * the dialog will use the obj_type instead.
106 */
107GNCSearchWindow *
108gnc_search_dialog_create (GtkWindow *parent,
109 QofIdTypeConst obj_type, const gchar *title,
110 GList *param_list,
111 GList *display_list,
112 QofQuery *start_query, QofQuery *show_start_query,
113 GNCSearchCallbackButton *callbacks,
114 GNCSearchResultCB result_callback,
115 GNCSearchNewItemCB new_item_cb,
116 gpointer user_data, GNCSearchFree free_user_data,
117 const gchar *prefs_group,
118 const gchar *type_label,
119 const gchar *style_class);
120
121void gnc_search_dialog_destroy (GNCSearchWindow *sw);
122void gnc_search_dialog_raise (GNCSearchWindow *sw);
123
124/* Register an on-close signal with the Search Dialog */
125guint gnc_search_dialog_connect_on_close (GNCSearchWindow *sw,
126 GCallback func,
127 gpointer user_data);
128
129/* Un-register the signal handlers with the Search Dialog */
130void gnc_search_dialog_disconnect (GNCSearchWindow *sw, gpointer user_data);
131
132/*
133 * Set the select callback with this Search Window; setting it to NULL
134 * will effectively clear it out. If this is set, then a 'select'
135 * button will show up. If allow_clear is TRUE, then also allow
136 * a 'clear' button which would allow the selected_cb to be called
137 * with "NULL".
138 */
139void gnc_search_dialog_set_select_cb (GNCSearchWindow *sw,
140 GNCSearchSelectedCB selected_cb,
141 gpointer user_data,
142 gboolean allow_clear);
143
144/* Test the dialog */
145void gnc_search_dialog_test (void);
146
147#endif /* GNC_DIALOG_SEARCH_H */
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
Definition qofid.h:82
gboolean sensitive_if_readonly
TRUE if this action should be sensitive even in a read-only book.
A Query.
Definition qofquery.cpp:75