From 1449cd97d1b2cc443ec2b128ea78e190f5df89a1 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Thu, 5 Apr 2007 02:43:38 +0000 Subject: [PATCH] convert GncEmployee to GObject initialzation. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gobject-engine-dev-warlord@15819 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-core/gncEmployee.c | 31 ++++++++++++++++++------ src/business/business-core/gncEmployee.h | 17 +++++++++++-- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/business/business-core/gncEmployee.c b/src/business/business-core/gncEmployee.c index cbee5fdf95..68b2cc692b 100644 --- a/src/business/business-core/gncEmployee.c +++ b/src/business/business-core/gncEmployee.c @@ -54,6 +54,11 @@ struct _gncEmployee Account * ccard_acc; }; +struct _gncEmployeeClass +{ + QofInstanceClass parent_class; +}; + static QofLogModule log_module = GNC_MOD_BUSINESS; #define _GNC_MOD_NAME GNC_ID_EMPLOYEE @@ -66,16 +71,28 @@ void mark_employee (GncEmployee *employee) } /* ============================================================== */ -/* Create/Destroy Functions */ +/* GObject Initialization */ +QOF_GOBJECT_IMPL(gnc_employee, GncEmployee, QOF_TYPE_INSTANCE); +static void +gnc_employee_init(GncEmployee* emp) +{ +} + +static void +gnc_employee_finalize_real(GObject* empp) +{ +} + +/* Create/Destroy Functions */ GncEmployee *gncEmployeeCreate (QofBook *book) { GncEmployee *employee; if (!book) return NULL; - employee = g_new0 (GncEmployee, 1); - qof_instance_init (&employee->inst, _GNC_MOD_NAME, book); + employee = g_object_new (GNC_TYPE_EMPLOYEE, NULL); + qof_instance_init_data (&employee->inst, _GNC_MOD_NAME, book); employee->id = CACHE_INSERT (""); employee->username = CACHE_INSERT (""); @@ -110,8 +127,8 @@ static void gncEmployeeFree (GncEmployee *employee) CACHE_REMOVE (employee->acl); gncAddressDestroy (employee->addr); - qof_instance_release (&employee->inst); - g_free (employee); + /* qof_instance_release (&employee->inst); */ + g_object_unref (employee); } GncEmployee * @@ -120,8 +137,8 @@ gncCloneEmployee (GncEmployee *from, QofBook *book) GncEmployee *employee; if (!book || !from) return NULL; - employee = g_new0 (GncEmployee, 1); - qof_instance_init(&employee->inst, _GNC_MOD_NAME, book); + employee = g_object_new (GNC_TYPE_EMPLOYEE, NULL); + qof_instance_init_data(&employee->inst, _GNC_MOD_NAME, book); qof_instance_gemini (&employee->inst, &from->inst); employee->id = CACHE_INSERT (from->id); diff --git a/src/business/business-core/gncEmployee.h b/src/business/business-core/gncEmployee.h index 8a0651bbe5..03e83229d8 100644 --- a/src/business/business-core/gncEmployee.h +++ b/src/business/business-core/gncEmployee.h @@ -32,13 +32,26 @@ #define GNC_EMPLOYEE_H_ typedef struct _gncEmployee GncEmployee; +typedef struct _gncEmployeeClass GncEmployeeClass; #include "gncAddress.h" #include "Account.h" #define GNC_ID_EMPLOYEE "gncEmployee" -#define GNC_IS_EMPLOYEE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_EMPLOYEE)) -#define GNC_EMPLOYEE(obj) (QOF_CHECK_CAST((obj), GNC_ID_EMPLOYEE, GncEmployee)) + +/* --- type macros --- */ +#define GNC_TYPE_EMPLOYEE (gnc_employee_get_type ()) +#define GNC_EMPLOYEE(o) \ + (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_EMPLOYEE, GncEmployee)) +#define GNC_EMPLOYEE_CLASS(k) \ + (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_EMPLOYEE, GncEmployeeClass)) +#define GNC_IS_EMPLOYEE(o) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_EMPLOYEE)) +#define GNC_IS_EMPLOYEE_CLASS(k) \ + (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_EMPLOYEE)) +#define GNC_EMPLOYEE_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_EMPLOYEE, GncEmployeeClass)) +GType gnc_employee_get_type(void); /** @name Create/Destroy Functions @{ */