Convert Account object to GObject

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gobject-engine-dev-warlord@15785 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2007-04-03 22:58:42 +00:00
parent 5bee77e41a
commit 1bea96024f
3 changed files with 37 additions and 7 deletions

View File

@ -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);
}
/********************************************************************\

View File

@ -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

View File

@ -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.