46 #include "SX-book-p.h"
48 #include <qofinstance-p.h>
51 #define G_LOG_DOMAIN "gnc.engine.sx"
59 gnc_collection_get_template_root(
const QofCollection *col )
68 if (!book)
return NULL;
70 return gnc_collection_get_template_root (col);
74 gnc_collection_set_template_root (QofCollection *col,
80 old_root = gnc_collection_get_template_root (col);
81 if (old_root == templateRoot)
return;
83 qof_collection_set_data (col, templateRoot);
99 if (templateRoot && gnc_account_get_book(templateRoot) != book)
101 g_critical(
"cannot mix and match books freely!");
106 gnc_collection_set_template_root (col, templateRoot);
114 sxtg_book_begin (
QofBook *book)
122 qof_instance_set_dirty (QOF_INSTANCE (root));
124 gnc_book_set_template_root (book, root);
134 sxtg_is_dirty(
const QofCollection *col)
137 GList *descendants, *node;
138 gboolean dirty = FALSE;
140 root = gnc_collection_get_template_root(col);
142 for (node = descendants; node; node = g_list_next(node))
150 g_list_free(descendants);
156 extern void qof_instance_mark_clean (
QofInstance *);
159 sxtg_mark_clean(QofCollection *col)
164 root = gnc_collection_get_template_root(col);
168 g_list_foreach(descendants, (GFunc)qof_instance_mark_clean, NULL);
169 g_list_free(descendants);
182 DI(.e_type = ) GNC_ID_SXTG,
183 DI(.type_label = ) "Scheduled
Transaction Templates",
185 DI(.book_begin = ) sxtg_book_begin,
186 DI(.book_end = ) sxtg_book_end,
187 DI(.is_dirty = ) sxtg_is_dirty,
188 DI(.mark_clean = ) sxtg_mark_clean,
189 DI(.foreach = ) NULL,
190 DI(.printable = ) NULL,
196 gnc_collection_get_schedxactions(const QofCollection *col)
204 gnc_book_get_schedxactions(
QofBook *book)
208 return gnc_collection_get_schedxactions(col);
214 if (g_list_find(sxes->sx_list, sx) != NULL)
216 sxes->sx_list = g_list_append(sxes->sx_list, sx);
224 to_remove = g_list_find(sxes->sx_list, sx);
225 if (to_remove == NULL)
227 sxes->sx_list = g_list_delete_link(sxes->sx_list, to_remove);
228 qof_event_gen(&sxes->inst, GNC_EVENT_ITEM_REMOVED, (gpointer)sx);
235 QOF_GOBJECT_IMPL(gnc_schedxactions,
SchedXactions, QOF_TYPE_INSTANCE);
243 gnc_schedxactions_dispose_real (GObject *sxsp)
248 gnc_schedxactions_finalize_real(GObject* sxsp)
253 mark_sx_clean(gpointer data, gpointer user_data)
256 qof_instance_mark_clean (QOF_INSTANCE(sx));
266 sxes = g_object_new (GNC_TYPE_SCHEDXACTIONS, NULL);
269 sxes->sx_list = NULL;
270 sxes->sx_notsaved = TRUE;
271 qof_collection_set_data(col, sxes);
284 g_object_unref(sxes);
285 qof_collection_set_data(col, NULL);
290 book_sxns_mark_saved(QofCollection *col)
293 sxl = gnc_collection_get_schedxactions(col);
296 sxl->sx_notsaved = FALSE;
297 g_list_foreach(sxl->sx_list,
303 book_sxlist_notsaved(
const QofCollection *col)
308 sxl = gnc_collection_get_schedxactions(col);
309 if (!sxl)
return FALSE;
310 if (sxl->sx_notsaved)
return TRUE;
312 for (sxlist = sxl->sx_list;
314 sxlist = g_list_next(sxlist))
328 DI(.e_type = ) GNC_ID_SXES,
329 DI(.type_label = ) "Scheduled Transactions List",
331 DI(.book_begin = ) book_sxes_setup,
332 DI(.book_end = ) book_sxes_end,
333 DI(.is_dirty = ) book_sxlist_notsaved,
334 DI(.mark_clean = ) book_sxns_mark_saved,
335 DI(.foreach = ) NULL,
336 DI(.printable = ) NULL,
337 DI(.version_cmp = ) NULL
343 DI(.e_type = ) GNC_ID_SXTT,
344 DI(.type_label = ) "Scheduled
Transaction Templates",
346 DI(.book_begin = ) NULL,
347 DI(.book_end = ) NULL,
348 DI(.is_dirty = ) NULL,
349 DI(.mark_clean = ) NULL,
350 DI(.foreach = ) NULL,
351 DI(.printable = ) NULL,
352 DI(.version_cmp = ) NULL,
356 gnc_sxtt_register (
void)
372 g_return_val_if_fail( sxactions != NULL, rtn);
373 for (sx_list = sxactions->sx_list; sx_list != NULL; sx_list = sx_list->next)
376 GList *splits = xaccSchedXactionGetSplits(sx);
377 for (; splits != NULL; splits = splits->next)
384 rtn = g_list_append(rtn, sx);
void xaccAccountSetType(Account *acc, GNCAccountType tip)
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
#define qof_instance_is_dirty
Account * gnc_book_get_template_root(const QofBook *book)
API for Transactions and Splits (journal entries)
#define QOF_OBJECT_VERSION
GList * gnc_sx_get_sxes_referencing_account(QofBook *book, Account *acct)
void xaccAccountDestroy(Account *acc)
void qof_instance_init_data(QofInstance *, QofIdType, QofBook *)
Account handling public routines.
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Anchor Scheduled Transaction info in a book. See src/doc/books.txt for design overview.
#define xaccSchedXactionIsDirty(X)
void qof_collection_mark_clean(QofCollection *)
Additional event handling code.
All type declarations for the whole Gnucash engine.
const GncGUID * qof_entity_get_guid(gconstpointer)
GList * gnc_account_get_descendants(const Account *account)
void xaccAccountBeginEdit(Account *acc)
Account * xaccMallocAccount(QofBook *book)
QofCollection * qof_book_get_collection(const QofBook *, QofIdType)
gboolean qof_object_register(const QofObject *object)
gpointer qof_collection_get_data(const QofCollection *col)
void qof_event_gen(QofInstance *entity, QofEventId event_type, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Scheduled Transactions public handling routines.
#define GNC_EVENT_ITEM_ADDED
void xaccAccountCommitEdit(Account *acc)
void xaccAccountSetName(Account *acc, const char *str)