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
46static QofLogModule log_module = GNC_MOD_ENGINE;
56gnc_get_num_action (
const Transaction *trans,
const Split *split)
67 PERR(
"Session has no book but has a transaction or split!");
85gnc_get_action_num (
const Transaction *trans,
const Split *split)
116gnc_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)
155static GOnce bo_init_once = G_ONCE_INIT;
156static GHashTable *bo_callback_hash = NULL;
157static GHookList *bo_final_hook_list = NULL;
160bo_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));
170bo_call_hook (GHook *hook, gpointer data)
172 ((GFunc)hook->func)(data, hook->data);
178gnc_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);
192gnc_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);
219gnc_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);
Account handling public routines.
Date and Time handling routines.
All type declarations for the whole Gnucash engine.
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
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,...
const char * xaccTransGetNum(const Transaction *trans)
Gets the transaction Number (or ID) field; rather than use this function directly,...
#define PERR(format, args...)
Log a serious error.
const char * xaccSplitGetAction(const Split *split)
Returns the action string.
void xaccSplitSetAction(Split *split, const char *actn)
The Action is an arbitrary user-assigned string.