Convert the Transaction object to GObject Initialization

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gobject-engine-dev-warlord@15808 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2007-04-05 00:23:58 +00:00
parent cb8f58790c
commit e097404f0b
4 changed files with 46 additions and 9 deletions

View File

@@ -108,6 +108,7 @@ mark_account (Account *acc)
/********************************************************************\
\********************************************************************/
/* GObject Initialization */
QOF_GOBJECT_IMPL(gnc_account, Account, QOF_TYPE_INSTANCE);
static void

View File

@@ -230,6 +230,20 @@ void gen_event_trans (Transaction *trans)
#endif
}
/* GObject Initialization */
QOF_GOBJECT_IMPL(gnc_transaction, Transaction, QOF_TYPE_INSTANCE);
static void
gnc_transaction_init(Transaction* txn)
{
}
static void
gnc_transaction_finalize_real(GObject* txnp)
{
}
/********************************************************************\
* xaccInitTransaction
* Initialize a transaction structure
@@ -258,7 +272,7 @@ xaccInitTransaction (Transaction * trans, QofBook *book)
trans->orig = NULL;
trans->idata = 0;
qof_instance_init (&trans->inst, GNC_ID_TRANS, book);
qof_instance_init_data (&trans->inst, GNC_ID_TRANS, book);
LEAVE (" ");
}
@@ -272,7 +286,7 @@ xaccMallocTransaction (QofBook *book)
g_return_val_if_fail (book, NULL);
trans = g_new(Transaction, 1);
trans = g_object_new(GNC_TYPE_TRANSACTION, NULL);
xaccInitTransaction (trans, book);
qof_event_gen (&trans->inst, QOF_EVENT_CREATE, NULL);
@@ -354,7 +368,7 @@ xaccDupeTransaction (const Transaction *t)
Transaction *trans;
GList *node;
trans = g_new0 (Transaction, 1);
trans = g_object_new (GNC_TYPE_TRANSACTION, NULL);
trans->num = CACHE_INSERT (t->num);
trans->description = CACHE_INSERT (t->description);
@@ -399,7 +413,7 @@ xaccTransClone (const Transaction *t)
GList *node;
qof_event_suspend();
trans = g_new0 (Transaction, 1);
trans = g_object_new (GNC_TYPE_TRANSACTION, NULL);
trans->date_entered = t->date_entered;
trans->date_posted = t->date_posted;
@@ -412,7 +426,7 @@ xaccTransClone (const Transaction *t)
trans->orig = NULL;
trans->idata = 0;
qof_instance_init (&trans->inst, GNC_ID_TRANS, t->inst.book);
qof_instance_init_data (&trans->inst, GNC_ID_TRANS, t->inst.book);
kvp_frame_delete (trans->inst.kvp_data);
trans->inst.kvp_data = kvp_frame_copy (t->inst.kvp_data);
@@ -475,8 +489,8 @@ xaccFreeTransaction (Transaction *trans)
trans->orig = NULL;
}
qof_instance_release (&trans->inst);
g_free(trans);
/* qof_instance_release (&trans->inst); */
g_object_unref(trans);
LEAVE ("(addr=%p)", trans);
}

View File

@@ -86,15 +86,32 @@ Splits plus the value of all of its sub-Accounts.
#ifndef XACC_TRANSACTION_H
#define XACC_TRANSACTION_H
typedef struct _TransactionClass TransactionClass;
#include <time.h>
#include "gnc-commodity.h"
#include "gnc-engine.h"
#include "Split.h"
/* --- type macros --- */
#define GNC_TYPE_TRANSACTION (gnc_transaction_get_type ())
#define GNC_TRANSACTION(o) \
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TRANSACTION, Transaction))
#define GNC_TRANSACTION_CLASS(k) \
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TRANSACTION, TransactionClass))
#define GNC_IS_TRANSACTION(o) \
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TRANSACTION))
#define GNC_IS_TRANSACTION_CLASS(k) \
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TRANSACTION))
#define GNC_TRANSACTION_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TRANSACTION, TransactionClass))
GType gnc_transaction_get_type(void);
/* FIXME: These macros are not consistent with the type name */
#define GNC_IS_TRANS(obj) (QOF_CHECK_TYPE((obj), GNC_ID_TRANS))
#define GNC_TRANS(obj) (QOF_CHECK_CAST((obj), GNC_ID_TRANS, Transaction))
#define GNC_IS_TRANS(obj) GNC_IS_TRANSACTION(obj)
#define GNC_TRANS(obj) GNC_TRANSACTION(obj)
/** @name Transaction Type field values
@{

View File

@@ -120,6 +120,11 @@ struct transaction_s
guint32 idata; /* used by the sql backend for kvp management */
};
struct _TransactionClass
{
QofInstanceClass parent_class;
};
/* Set the transaction's GUID. This should only be done when reading
* a transaction from a datafile, or some other external source. Never
* call this on an existing transaction! */