diff --git a/src/business/business-core/gncInvoice.c b/src/business/business-core/gncInvoice.c index 02fe43b033..1790178701 100644 --- a/src/business/business-core/gncInvoice.c +++ b/src/business/business-core/gncInvoice.c @@ -69,6 +69,11 @@ struct _gncInvoice GNCLot *posted_lot; }; +struct _gncInvoiceClass +{ + QofInstanceClass parent_class; +}; + static QofLogModule log_module = GNC_MOD_BUSINESS; #define _GNC_MOD_NAME GNC_ID_INVOICE @@ -100,16 +105,28 @@ QofBook * gncInvoiceGetBook(GncInvoice *x) } /* ================================================================== */ -/* Create/Destroy Functions */ +/* GObject Initialization */ +QOF_GOBJECT_IMPL(gnc_invoice, GncInvoice, QOF_TYPE_INSTANCE); +static void +gnc_invoice_init(GncInvoice* inv) +{ +} + +static void +gnc_invoice_finalize_real(GObject* invp) +{ +} + +/* Create/Destroy Functions */ GncInvoice *gncInvoiceCreate (QofBook *book) { GncInvoice *invoice; if (!book) return NULL; - invoice = g_new0 (GncInvoice, 1); - qof_instance_init (&invoice->inst, _GNC_MOD_NAME, book); + invoice = g_object_new (GNC_TYPE_INVOICE, NULL); + qof_instance_init_data (&invoice->inst, _GNC_MOD_NAME, book); invoice->id = CACHE_INSERT (""); invoice->notes = CACHE_INSERT (""); @@ -148,8 +165,8 @@ static void gncInvoiceFree (GncInvoice *invoice) if (invoice->terms) gncBillTermDecRef (invoice->terms); - qof_instance_release (&invoice->inst); - g_free (invoice); + /* qof_instance_release (&invoice->inst); */ + g_object_unref (invoice); } GncInvoice * @@ -160,8 +177,8 @@ gncCloneInvoice (GncInvoice *from, QofBook *book) if (!book) return NULL; - invoice = g_new0 (GncInvoice, 1); - qof_instance_init (&invoice->inst, _GNC_MOD_NAME, book); + invoice = g_object_new (GNC_TYPE_INVOICE, NULL); + qof_instance_init_data (&invoice->inst, _GNC_MOD_NAME, book); invoice->id = CACHE_INSERT (from->id); invoice->notes = CACHE_INSERT (from->notes); diff --git a/src/business/business-core/gncInvoice.h b/src/business/business-core/gncInvoice.h index 968328672d..3f93b6fdce 100644 --- a/src/business/business-core/gncInvoice.h +++ b/src/business/business-core/gncInvoice.h @@ -38,6 +38,7 @@ transaction and lot for the posted invoice. struct _gncInvoice; typedef struct _gncInvoice GncInvoice; +typedef struct _gncInvoiceClass GncInvoiceClass; #include "gncBillTerm.h" #include "gncEntry.h" @@ -46,8 +47,20 @@ typedef struct _gncInvoice GncInvoice; #include "qofbook.h" #define GNC_ID_INVOICE "gncInvoice" -#define GNC_IS_INVOICE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_INVOICE)) -#define GNC_INVOICE(obj) (QOF_CHECK_CAST((obj), GNC_ID_INVOICE, GncInvoice)) + +/* --- type macros --- */ +#define GNC_TYPE_INVOICE (gnc_invoice_get_type ()) +#define GNC_INVOICE(o) \ + (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_INVOICE, GncInvoice)) +#define GNC_INVOICE_CLASS(k) \ + (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_INVOICE, GncInvoiceClass)) +#define GNC_IS_INVOICE(o) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_INVOICE)) +#define GNC_IS_INVOICE_CLASS(k) \ + (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_INVOICE)) +#define GNC_INVOICE_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_INVOICE, GncInvoiceClass)) +GType gnc_invoice_get_type(void); /** @name Create/Destroy Functions @{ */