change AccountGroup to use gncObject for initialization, dirty flag, teardown.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8561 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-06-10 20:22:01 +00:00
parent ed48a82dd9
commit a01a217180
5 changed files with 69 additions and 9 deletions

View File

@ -3146,6 +3146,7 @@ xaccAccountFindTransByDesc(Account *account, const char *description)
return( trans );
}
/* ================================================================ */
/* gncObject function implementation and registration */
static void

View File

@ -38,6 +38,7 @@
#include "gnc-engine-util.h"
#include "gnc-event-p.h"
#include "gnc-numeric.h"
#include "gncObject.h"
static short module = MOD_ENGINE;
@ -1275,4 +1276,66 @@ xaccGroupForEachAccount (AccountGroup *grp,
return(NULL);
}
/* ============================================================== */
/* gncObject function implementation and registration */
static void
group_foreach (GNCBook *book, foreachObjectCB cb, gpointer ud)
{
// GNCEntityTable *et;
g_return_if_fail (book);
g_return_if_fail (cb);
printf ("duude calling group foreach \n");
/*
et = gnc_book_get_entity_table (book);
xaccForeachEntity (et, GNC_ID_GROUP, cb, ud);
*/
}
static void
group_book_begin (GNCBook *book)
{
printf ("duude call group book begin \n");
xaccSetAccountGroup (book, xaccMallocAccountGroup(book));
}
static void
group_book_end (GNCBook *book)
{
xaccSetAccountGroup (book, NULL);
}
static gboolean
group_is_dirty (GNCBook *book)
{
return xaccGroupNotSaved(xaccGetAccountGroup(book));
}
static void
group_mark_clean(GNCBook *book)
{
xaccGroupMarkSaved(xaccGetAccountGroup(book));
}
static GncObject_t group_object_def =
{
interface_version: GNC_OBJECT_VERSION,
name: GNC_ID_GROUP,
type_label: "AccountGroup",
book_begin: group_book_begin,
book_end: group_book_end,
is_dirty: group_is_dirty,
mark_clean: group_mark_clean,
foreach: group_foreach,
printable: NULL,
};
gboolean
xaccGroupRegister (void)
{
return gncObjectRegister (&group_object_def);
}
/* ========================= END OF FILE ======================== */

View File

@ -97,4 +97,6 @@ void xaccFreeAccountGroup (AccountGroup *account_group);
/* Set the top-level group in the book */
void xaccSetAccountGroup (GNCBook *book, AccountGroup *grp);
gboolean xaccGroupRegister (void);
#endif

View File

@ -118,7 +118,6 @@ gnc_book_mark_saved(GNCBook *book)
book->dirty = FALSE;
xaccGroupMarkSaved(xaccGetAccountGroup(book));
gnc_pricedb_mark_clean(gnc_pricedb_get_db(book));
xaccGroupMarkSaved(gnc_book_get_template_group(book));
@ -145,8 +144,6 @@ gnc_book_populate (GNCBook *book)
}
gnc_commodity_table_set_table (book, ct);
xaccSetAccountGroup (book, xaccMallocAccountGroup(book));
gnc_pricedb_set_db (book, gnc_pricedb_create(book));
gnc_book_set_schedxactions (book, NULL);
@ -157,9 +154,6 @@ gnc_book_populate (GNCBook *book)
static void
gnc_book_depopulate (GNCBook *book)
{
/* unhook the top-level group */
xaccSetAccountGroup (book, NULL);
/* unhook the prices */
gnc_pricedb_set_db (book, NULL);
@ -178,8 +172,6 @@ gnc_book_not_saved(GNCBook *book)
if (!book) return FALSE;
return(book->dirty
||
xaccGroupNotSaved(xaccGetAccountGroup(book))
||
gnc_pricedb_dirty(gnc_book_get_pricedb(book))
||

View File

@ -31,8 +31,9 @@
#include "gnc-engine.h"
#include "gnc-engine-util.h"
#include "TransactionP.h"
#include "AccountP.h"
#include "GroupP.h"
#include "TransactionP.h"
#include "gnc-book-p.h"
#include "gnc-lot-p.h"
@ -83,6 +84,7 @@ gnc_engine_init(int argc, char ** argv)
xaccSplitRegister ();
xaccTransRegister ();
xaccAccountRegister ();
xaccGroupRegister ();
gnc_book_register ();
gnc_lot_register ();