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
This commit is contained in:
Derek Atkins 2007-04-05 02:43:38 +00:00
parent 292cf31279
commit 1449cd97d1
2 changed files with 39 additions and 9 deletions

View File

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

View File

@ -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
@{ */