30 #include "engine-helpers.h" 33 #include "gnc-session.h" 35 #include <qofbookslots.h> 41 #include "qofquery-p.h" 42 #include "qofquerycore-p.h" 44 #define FUNC_NAME G_STRFUNC 46 static QofLogModule log_module = GNC_MOD_ENGINE;
56 gnc_get_num_action (
const Transaction *trans,
const Split *split)
67 PERR(
"Session has no book but has a transaction or split!");
85 gnc_get_action_num (
const Transaction *trans,
const Split *split)
116 gnc_set_num_action (Transaction *trans, Split *split,
117 const char *num,
const char *action)
122 if (trans && num && !split && !action)
128 if (!trans && !num && split && action)
136 if (!num_action && num)
138 if (num_action && action)
144 if (!num_action && action)
146 if (num_action && num)
155 static GOnce bo_init_once = G_ONCE_INIT;
156 static GHashTable *bo_callback_hash = NULL;
157 static GHookList *bo_final_hook_list = NULL;
160 bo_init (gpointer unused)
162 bo_callback_hash = g_hash_table_new(g_str_hash, g_str_equal);
164 bo_final_hook_list = g_malloc(
sizeof(GHookList));
165 g_hook_list_init(bo_final_hook_list,
sizeof(GHook));
170 bo_call_hook (GHook *hook, gpointer data)
172 ((GFunc)hook->func)(data, hook->data);
178 gnc_book_option_num_field_source_change (gboolean num_action)
180 GHookList *hook_list;
181 const gchar *key = OPTION_NAME_NUM_FIELD_SOURCE;
183 g_once(&bo_init_once, bo_init, NULL);
185 hook_list = g_hash_table_lookup(bo_callback_hash, key);
186 if (hook_list != NULL)
187 g_hook_list_marshal(hook_list, TRUE, bo_call_hook, &num_action);
188 g_hook_list_invoke(bo_final_hook_list, TRUE);
192 gnc_book_option_register_cb (
const gchar *key, GncBOCb func, gpointer user_data)
194 GHookList *hook_list;
197 g_once(&bo_init_once, bo_init, NULL);
198 hook_list = g_hash_table_lookup(bo_callback_hash, key);
199 if (hook_list == NULL)
201 hook_list = g_malloc(
sizeof(GHookList));
202 g_hook_list_init(hook_list,
sizeof(GHook));
203 g_hash_table_insert(bo_callback_hash, (gpointer)key, hook_list);
206 hook = g_hook_find_func_data(hook_list, TRUE, func, user_data);
212 hook = g_hook_alloc(hook_list);
214 hook->data = user_data;
215 g_hook_append(hook_list, hook);
219 gnc_book_option_remove_cb (
const gchar *key, GncBOCb func, gpointer user_data)
221 GHookList *hook_list;
224 g_once(&bo_init_once, bo_init, NULL);
225 hook_list = g_hash_table_lookup(bo_callback_hash, key);
226 if (hook_list == NULL)
228 hook = g_hook_find_func_data(hook_list, TRUE, func, user_data);
232 g_hook_destroy_link(hook_list, hook);
233 if (hook_list->hooks == NULL)
235 g_hash_table_remove(bo_callback_hash, key);
void xaccSplitSetAction(Split *split, const char *actn)
The Action is an arbitrary user-assigned string.
Date and Time handling routines.
gboolean qof_book_use_split_action_for_num_field(const QofBook *book)
Returns TRUE if this book uses split action field as the 'Num' field, FALSE if it uses transaction nu...
void xaccTransSetNum(Transaction *trans, const char *xnum)
Sets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_set_num_action' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically.
const char * xaccTransGetNum(const Transaction *trans)
Gets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_get_num_action' and 'gnc_get_action_num' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically.
#define PERR(format, args...)
Log a serious error.
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
Account handling public routines.
All type declarations for the whole Gnucash engine.
const char * xaccSplitGetAction(const Split *split)
Returns the action string.