GnuCash 2.4.99
dialog-search.h
00001 /*
00002  * dialog-search.h -- Search Dialog
00003  * Copyright (C) 2002 Derek Atkins
00004  * Author: Derek Atkins <warlord@MIT.EDU>
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, contact:
00018  *
00019  * Free Software Foundation           Voice:  +1-617-542-5942
00020  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
00021  * Boston, MA  02110-1301,  USA       gnu@gnu.org
00022  */
00023 
00024 #ifndef _GNC_DIALOG_SEARCH_H
00025 #define _GNC_DIALOG_SEARCH_H
00026 
00027 #include "GNCId.h"
00028 #include "qof.h"
00029 
00030 typedef struct _GNCSearchWindow GNCSearchWindow;
00031 
00032 /* The two types of callbacks.
00033  *
00034  * In the first callback, (used in the callback button list) the obj_p
00035  * argument will be a pointer to the selected item (if one is
00036  * selected).  The callback may change the value if they wish (note
00037  * that the display will not adjust to the new selected item)
00038  *
00039  * In the second callback, the query is the property of the search
00040  * dialog; the callback should copy it if they want to keep it.  The
00041  * result will be a pointer to the selected item (if one is selected)
00042  * and the callback may change the value.
00043  */
00044 typedef void (*GNCSearchCallback) (gpointer *obj_p, gpointer user_data);
00045 typedef void (*GNCSearchResultCB) (QofQuery *query, gpointer user_data,
00046                                    gpointer *result);
00047 
00048 /*
00049  * This callback will create a new item and return a handle to the
00050  * newly created item (even if it is not completely finished).  It
00051  * will be added to the query, but not selected.  This means the GncGUID
00052  * must be set.
00053  */
00054 typedef gpointer (*GNCSearchNewItemCB) (gpointer user_data);
00055 
00056 /* Free the general user_data object */
00057 typedef void (*GNCSearchFree) (gpointer user_data);
00058 
00063 typedef void (*GNCSearchSelectedCB) (gpointer selected_object,
00064                                      gpointer user_data);
00065 
00070 typedef void (*GNCSearchMultiSelectedCB) (GList *list_of_selected_objects,
00071         gpointer user_data);
00072 
00073 typedef struct
00074 {
00075     const char *                label;
00076     GNCSearchCallback   cb_fcn;
00077     GNCSearchMultiSelectedCB cb_multiselect_fn;
00078 
00082     gboolean sensitive_if_readonly;
00083 } GNCSearchCallbackButton;
00084 
00085 /* Caller MUST supply _EITHER_ a result_callback or a list of callback
00086  * buttons.  The caller MUST NOT supply both.
00087  *
00088  * Both the param_list and display_list are the property of the dialog
00089  * but will NOT be destroyed..  They should be a GList of
00090  * GNCSearchParam objects.  The display_list defines which paramters
00091  * of the found transactions are printed, and how.
00092  *
00093  * The start_query is the property of the caller and will only be copied.
00094  * The show_start_query, if it exists, will become the property of the
00095  * dialog and will be automatically destroyed.
00096  *
00097  * The user_data becomes the property of the search dialog and will
00098  * be freed via the callback when the dialog is closed.
00099  *
00100  * the type_label (if non-null) is the TRANSLATED string to use for
00101  * the type of object being searched.  This will be put in the Title
00102  * as well as into the "New" button.  If this string is NULL then
00103  * the dialog will use the obj_type instead.
00104  */
00105 GNCSearchWindow *
00106 gnc_search_dialog_create (QofIdTypeConst obj_type, const gchar *title,
00107                           GList *param_list,
00108                           GList *display_list,
00109                           QofQuery *start_query, QofQuery *show_start_query,
00110                           GNCSearchCallbackButton *callbacks,
00111                           GNCSearchResultCB result_callback,
00112                           GNCSearchNewItemCB new_item_cb,
00113                           gpointer user_data, GNCSearchFree free_user_data,
00114                           const gchar *gconf_section,
00115                           const gchar *type_label);
00116 
00117 void gnc_search_dialog_destroy (GNCSearchWindow *sw);
00118 void gnc_search_dialog_raise (GNCSearchWindow *sw);
00119 
00120 /* Register an on-close signal with the Search Dialog */
00121 guint gnc_search_dialog_connect_on_close (GNCSearchWindow *sw,
00122         GCallback func,
00123         gpointer user_data);
00124 
00125 /* Un-register the signal handlers with the Search Dialog */
00126 void gnc_search_dialog_disconnect (GNCSearchWindow *sw, gpointer user_data);
00127 
00128 /*
00129  * Set the select callback with this Search Window; setting it to NULL
00130  * will effectively clear it out.  If this is set, then a 'select'
00131  * button will show up.  If allow_clear is TRUE, then also allow
00132  * a 'clear' button which would allow the selected_cb to be called
00133  * with "NULL".
00134  */
00135 void gnc_search_dialog_set_select_cb (GNCSearchWindow *sw,
00136                                       GNCSearchSelectedCB selected_cb,
00137                                       gpointer user_data,
00138                                       gboolean allow_clear);
00139 
00140 /* Test the dialog */
00141 void gnc_search_dialog_test (void);
00142 
00143 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines