diff --git a/src/engine/Account.c b/src/engine/Account.c index 107d799b65..95963bbe3b 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -108,11 +108,23 @@ mark_account (Account *acc) /********************************************************************\ \********************************************************************/ +QOF_GOBJECT_IMPL(gnc_account, Account, QOF_TYPE_INSTANCE); + +static void +gnc_account_init(Account* acc) +{ +} + +static void +gnc_account_finalize_real(GObject* acctp) +{ +} + static void xaccInitAccount (Account * acc, QofBook *book) { ENTER ("book=%p\n", book); - qof_instance_init (&acc->inst, GNC_ID_ACCOUNT, book); + qof_instance_init_data (&acc->inst, GNC_ID_ACCOUNT, book); acc->parent = NULL; acc->children = NULL; @@ -231,7 +243,7 @@ xaccMallocAccount (QofBook *book) g_return_val_if_fail (book, NULL); - acc = g_new (Account, 1); + acc = g_object_new (GNC_TYPE_ACCOUNT, NULL); xaccInitAccount (acc, book); qof_event_gen (&acc->inst, QOF_EVENT_CREATE, NULL); @@ -260,7 +272,7 @@ xaccCloneAccountCommon(const Account *from, QofBook *book) if (!from || !book) return NULL; ENTER (" "); - ret = g_new (Account, 1); + ret = g_object_new (GNC_TYPE_ACCOUNT, NULL); g_return_val_if_fail (ret, NULL); xaccInitAccount (ret, book); @@ -412,8 +424,8 @@ xaccFreeAccount (Account *acc) acc->balance_dirty = FALSE; acc->sort_dirty = FALSE; - qof_instance_release (&acc->inst); - g_free(acc); + /* qof_instance_release (&acc->inst); */ + g_object_unref(acc); } /********************************************************************\ diff --git a/src/engine/Account.h b/src/engine/Account.h index fe4a751a4b..599c8c3eef 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -59,8 +59,21 @@ typedef gnc_numeric (*xaccGetBalanceAsOfDateFn) ( typedef void (*AccountCb)(Account *a, gpointer data); typedef gpointer (*AccountCb2)(Account *a, gpointer data); -#define GNC_IS_ACCOUNT(obj) (QOF_CHECK_TYPE((obj), GNC_ID_ACCOUNT)) -#define GNC_ACCOUNT(obj) (QOF_CHECK_CAST((obj), GNC_ID_ACCOUNT, Account)) +typedef struct _AccountClass AccountClass; + +/* --- type macros --- */ +#define GNC_TYPE_ACCOUNT (gnc_account_get_type ()) +#define GNC_ACCOUNT(o) \ + (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ACCOUNT, Account)) +#define GNC_ACCOUNT_CLASS(k) \ + (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ACCOUNT, AccountClass)) +#define GNC_IS_ACCOUNT(o) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ACCOUNT)) +#define GNC_IS_ACCOUNT_CLASS(k) \ + (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ACCOUNT)) +#define GNC_ACCOUNT_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ACCOUNT, AccountClass)) +GType gnc_account_get_type(void); /** The account types are used to determine how the transaction data * in the account is displayed. These values can be safely changed diff --git a/src/engine/AccountP.h b/src/engine/AccountP.h index 993fc41583..42da43a57c 100644 --- a/src/engine/AccountP.h +++ b/src/engine/AccountP.h @@ -133,6 +133,11 @@ struct account_s guint32 idata; /* used by the sql backend for kvp management */ }; +struct _AccountClass +{ + QofInstanceClass parent_class; +}; + /* The xaccAccountSortSplits() routine will resort the account's * splits if the sort is dirty. If 'force' is true, the account * is sorted even if the editlevel is not zero.