r15690 - gnucash/branches/gobject-engine-dev - LibQof now use GType to manages objects, sustituting the actual strig type based; this means less memory and faster object type test and memory usage.

Daniel Espinosa esodan at cvs.gnucash.org
Thu Mar 8 08:23:27 EST 2007


Author: esodan
Date: 2007-03-08 08:23:14 -0500 (Thu, 08 Mar 2007)
New Revision: 15690
Trac: http://svn.gnucash.org/trac/changeset/15690

Modified:
   gnucash/branches/gobject-engine-dev/ChangeLog
   gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-backend.c
   gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml-map.c
   gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml.c
   gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/Makefile.am
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-date.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-numeric.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-numeric.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/guid.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/guid.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/kvp_frame.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/kvp_frame.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qof.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend-p.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbookmerge.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbookmerge.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofchoice.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofchoice.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofclass.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofclass.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofevent-p.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofevent.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquery.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquery.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquerycore-p.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquerycore.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofreference.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofreference.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession-p.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession.h
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.c
   gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.h
   gnucash/branches/gobject-engine-dev/src/app-utils/gnc-component-manager.c
   gnucash/branches/gobject-engine-dev/src/engine/Account.c
   gnucash/branches/gobject-engine-dev/src/engine/Account.h
   gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.c
   gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.h
   gnucash/branches/gobject-engine-dev/src/engine/FreqSpecP.h
   gnucash/branches/gobject-engine-dev/src/engine/Group.c
   gnucash/branches/gobject-engine-dev/src/engine/Group.h
   gnucash/branches/gobject-engine-dev/src/engine/GroupP.h
   gnucash/branches/gobject-engine-dev/src/engine/SX-book.c
   gnucash/branches/gobject-engine-dev/src/engine/SX-book.h
   gnucash/branches/gobject-engine-dev/src/engine/Split.h
   gnucash/branches/gobject-engine-dev/src/engine/SplitP.h
   gnucash/branches/gobject-engine-dev/src/engine/Transaction.c
   gnucash/branches/gobject-engine-dev/src/engine/Transaction.h
   gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.h
   gnucash/branches/gobject-engine-dev/src/engine/gnc-engine.h
   gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.h
   gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.c
   gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.h
   gnucash/branches/gobject-engine-dev/src/gnome-utils/gnc-main-window.c
Log:
LibQof now use GType to manages objects, sustituting the actual strig type based; this means less memory and faster object type test and memory usage.

QofBackend now use GError to store backend erros, you need to call commit and begin edit with a parameter GError** to get any error in these calls, or use 
the QofBackend's API to set and delete this errors.

QofEntity and QofInstance have been merged together and now QofInstance (may in the future GncObject) manages the GUID and the book the object belongs to.
The type system use the GObject's GType system to know the object's types.

QofObject and QofClass have been modified in order to fit in the new type system, but the work pretends in the next milestones deprecate them and eventualy delete
from the GC code.

KvpValue and KvpFrame doesn't change to much, just a few to fit in the new type system; but now we can sustitud KvpValue with GValue with out afect KvpFrame,
even better, this will save too many code here and there to manage the KvpValue type system (this is diferent from the Qof object type system), and get unifed type
system using just GType. All the objects managed by KvpValue has its own GType, some derived from GObject, some from QofInstance (derived from GObject too), 
and some derived from a GBoxed (any struct type).

The file backend, has been changed in order to fit in the new type system too, but actualy it breaks the load of previews files saved in the old type system,
becouse when you save a file some data is saved with its type's name, but I'll add code to manage this converting the old type names to the new type's name. The
names used in GType is in order to avoid any problem with any previews existing one, just using a prefix Gnc or Qof in each name, this is a practice in GLib and I think we need to follow, i. e. the a type name "book" is "QofBook" and "account" is "GncAccount", this is for all the objects derived from GObject and GBoxed.


Modified: gnucash/branches/gobject-engine-dev/ChangeLog
===================================================================
--- gnucash/branches/gobject-engine-dev/ChangeLog	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/ChangeLog	2007-03-08 13:23:14 UTC (rev 15690)
@@ -1,3 +1,8 @@
+2007-03-03  Daniel Espinosa <esodan at gmail.com>
+  * lib/libqof/qof: 
+  * src/engine/:
+  First milestone to use GObject in QOF and GC's objects
+  
 2006-11-24  Christian Stimming <stimming at tuhh.de>
 
 	* src/engine/gnc-path.c: Fix gnc_path_get_localedir() because

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-backend.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-backend.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-backend.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -40,9 +40,9 @@
 #include "strptime.h"
 #endif
 
-#define QSF_TYPE_BINARY "binary"
-#define QSF_TYPE_GLIST  "glist"
-#define QSF_TYPE_FRAME  "frame"
+#define QSF_TYPE_BINARY GNC_TYPE_BINARY
+#define QSF_TYPE_GLIST  GNC_TYPE_GLIST
+#define QSF_TYPE_FRAME  GNC_TYPE_KVP_FRAME
 
 static QofLogModule log_module = QOF_MOD_QSF;
 static void qsf_object_commitCB(gpointer key, gpointer value, gpointer data);
@@ -172,18 +172,18 @@
 	params->qsf_define_hash = g_hash_table_new(g_str_hash, g_str_equal);
 	params->qsf_calculate_hash = g_hash_table_new(g_str_hash, g_str_equal);
 	params->referenceList = NULL;
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_STRING);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_GUID);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_BOOLEAN);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_NUMERIC);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_DATE);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_INT32);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_INT64);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_DOUBLE);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_CHAR);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_KVP);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_COLLECT);
-	params->supported_types = g_slist_append(params->supported_types, QOF_TYPE_CHOICE);
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_STRING));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_GUID));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_BOOLEAN));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_NUMERIC));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_DATE));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_INT32));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_INT64));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_DOUBLE));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_CHAR));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_KVP));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_COLLECT));
+	params->supported_types = g_slist_append(params->supported_types, GINT_TO_POINTER (QOF_TYPE_CHOICE));
 	qsf_time_precision = "%j";
 	qsf_time_now_t = time(NULL);
 	qsf_ts = g_new(Timespec, 1);
@@ -295,12 +295,12 @@
 }
 
 static void
-ent_ref_cb (QofEntity* ent, gpointer user_data)
+ent_ref_cb (QofInstance* ent, gpointer user_data)
 {
 	qsf_param *params;
-	QofEntityReference *ref;
-	void (*reference_setter) (QofEntity*, QofEntity*);
-	QofEntity *reference;
+	QofInstanceReference *ref;
+	void (*reference_setter) (QofInstance*, QofInstance*);
+	QofInstance *reference;
 	QofCollection *coll;
 	QofIdType type;
 
@@ -308,12 +308,12 @@
 	g_return_if_fail(params);
 	while(params->referenceList)
 	{
-		ref = (QofEntityReference*)params->referenceList->data;
-		if(qof_object_is_choice(ent->e_type)) { type = ref->choice_type; }
+		ref = (QofInstanceReference*)params->referenceList->data;
+		if(qof_object_is_choice(G_OBJECT_TYPE (ent))) { type = ref->choice_type; }
 		else { type = ref->type; }
 		coll = qof_book_get_collection(params->book, type);
-		reference = qof_collection_lookup_entity(coll, ref->ref_guid);
-		reference_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
+		reference = qof_collection_lookup_element (coll, ref->ref_guid);
+		reference_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
 		if(reference_setter != NULL)
 		{
 			qof_begin_edit((QofInstance*)ent);
@@ -337,7 +337,7 @@
 }
 
 /*================================================
-	Load QofEntity into QofBook from XML in memory
+	Load QofInstance into QofBook from XML in memory
 ==================================================*/
 
 static gboolean
@@ -370,7 +370,7 @@
 		if(!qof_class_is_registered(params->object_set->object_type)) { continue; }
 		inst = (QofInstance*)qof_object_new_instance(params->object_set->object_type, book);
 		g_return_val_if_fail(inst != NULL, FALSE);
-		params->qsf_ent = &inst->entity;
+		params->qsf_ent = inst;
 		qof_begin_edit(inst);
 		g_hash_table_foreach(params->qsf_parameter_hash, qsf_object_commitCB, params);
 		qof_commit_edit(inst);
@@ -513,19 +513,19 @@
 	checklist = g_slist_copy(params->supported_types);
 	for(result = checklist; result != NULL; result = result->next)
 	{
-		if(0 == safe_strcmp((QofIdType)result->data, qof_param->param_type))
+		if((QofIdType)result->data == qof_param->param_type)
 		{
 			params->knowntype = TRUE;
 		}
 	}
 	g_slist_free(checklist);
-	if(0 == safe_strcmp(qof_param->param_type, params->qof_type))
+	if(qof_param->param_type == params->qof_type)
 	{
 		params->qsf_sequence = g_slist_append(params->qsf_sequence, qof_param);
 		params->knowntype = TRUE;
 	}
 	/* handle params->qof_type = QOF_TYPE_GUID and qof_param->param_type != known type */
-	if(0 == safe_strcmp(params->qof_type, QOF_TYPE_GUID)
+	if((params->qof_type == QOF_TYPE_GUID)
 		&& (params->knowntype == FALSE))
 	{
 		params->qsf_sequence = g_slist_append(params->qsf_sequence, qof_param);
@@ -544,7 +544,7 @@
 
 	g_return_if_fail(user_data != NULL);
 	params = (qsf_param*) user_data;
-	params->qof_type = (QofIdType)type;
+	params->qof_type = GPOINTER_TO_INT (type);
 	params->knowntype = FALSE;
 	qof_class_param_foreach(params->qof_obj_type, qsf_object_sequence, params);
 }
@@ -552,15 +552,15 @@
 static KvpValueType
 qsf_to_kvp_helper(const char *type_string)
 {
-	if(0 == safe_strcmp(QOF_TYPE_INT64,   type_string)) { return KVP_TYPE_GINT64;   }
-	if(0 == safe_strcmp(QOF_TYPE_DOUBLE,  type_string)) { return KVP_TYPE_DOUBLE;   }
-	if(0 == safe_strcmp(QOF_TYPE_NUMERIC, type_string)) { return KVP_TYPE_NUMERIC;  }
-	if(0 == safe_strcmp(QOF_TYPE_STRING,  type_string)) { return KVP_TYPE_STRING;   }
-	if(0 == safe_strcmp(QOF_TYPE_GUID,    type_string)) { return KVP_TYPE_GUID;     }
-	if(0 == safe_strcmp(QOF_TYPE_DATE,    type_string)) { return KVP_TYPE_TIMESPEC; }
-	if(0 == safe_strcmp(QSF_TYPE_BINARY,  type_string)) { return KVP_TYPE_BINARY;   }
-	if(0 == safe_strcmp(QSF_TYPE_GLIST,   type_string)) { return KVP_TYPE_GLIST;    }
-	if(0 == safe_strcmp(QSF_TYPE_FRAME,   type_string)) { return KVP_TYPE_FRAME;    }
+	if(0 == safe_strcmp(g_type_name(QOF_TYPE_INT64),   type_string)) { return KVP_TYPE_GINT64;   }
+	if(0 == safe_strcmp(g_type_name(QOF_TYPE_DOUBLE),  type_string)) { return KVP_TYPE_DOUBLE;   }
+	if(0 == safe_strcmp(g_type_name(QOF_TYPE_NUMERIC), type_string)) { return KVP_TYPE_NUMERIC;  }
+	if(0 == safe_strcmp(g_type_name(QOF_TYPE_STRING),  type_string)) { return KVP_TYPE_STRING;   }
+	if(0 == safe_strcmp(g_type_name(QOF_TYPE_GUID),    type_string)) { return KVP_TYPE_GUID;     }
+	if(0 == safe_strcmp(g_type_name(QOF_TYPE_DATE),    type_string)) { return KVP_TYPE_TIMESPEC; }
+	if(0 == safe_strcmp(g_type_name(QSF_TYPE_BINARY),  type_string)) { return KVP_TYPE_BINARY;   }
+	if(0 == safe_strcmp(g_type_name(QSF_TYPE_GLIST),   type_string)) { return KVP_TYPE_GLIST;    }
+	if(0 == safe_strcmp(g_type_name(QSF_TYPE_FRAME),   type_string)) { return KVP_TYPE_FRAME;    }
 	return 0;
 }
 
@@ -578,7 +578,7 @@
 		case KVP_TYPE_BINARY   : { return QSF_TYPE_BINARY;  break; }
 		case KVP_TYPE_GLIST    : { return QSF_TYPE_GLIST;   break; }
 		case KVP_TYPE_FRAME    : { return QSF_TYPE_FRAME;   break; }
-		default : { return NULL; }
+		default : { return G_TYPE_INVALID; }
 	}
 }
 
@@ -612,12 +612,12 @@
 			node = xmlAddChild(params->output_node, xmlNewNode(params->qsf_ns,
 				BAD_CAST qof_param->param_type));
 			xmlNodeAddContent(node, BAD_CAST kvp_value_to_bare_string(content));
-			xmlNewProp(node, BAD_CAST QSF_OBJECT_TYPE, BAD_CAST qof_param->param_name);
+			xmlNewProp(node, BAD_CAST g_type_name (QSF_OBJECT_TYPE), BAD_CAST qof_param->param_name);
 			full_path = g_strconcat(params->full_kvp_path, "/", path, NULL);
 			xmlNewProp(node, BAD_CAST QSF_OBJECT_KVP, BAD_CAST full_path);
 			xmlNewProp(node, BAD_CAST QSF_OBJECT_VALUE, 
 				BAD_CAST kvp_value_to_qof_type_helper(n));
-			PINFO (" set %s", kvp_value_to_qof_type_helper(n));
+			PINFO (" set %s", g_type_name (kvp_value_to_qof_type_helper(n)));
 			break;
 		}
 		case KVP_TYPE_FRAME:
@@ -644,7 +644,7 @@
 }
 
 static void
-qsf_from_coll_cb (QofEntity *ent, gpointer user_data)
+qsf_from_coll_cb (QofInstance *ent, gpointer user_data)
 {
 	qsf_param *params;
 	QofParam *qof_param;
@@ -654,11 +654,11 @@
 	params = (qsf_param*)user_data;
 	if(!ent || !params) { return; }
 	qof_param = params->qof_param;
-	guid_to_string_buff(qof_entity_get_guid(ent), qsf_guid);
+	guid_to_string_buff(qof_instance_get_guid(ent), qsf_guid);
 	node = xmlAddChild(params->output_node, xmlNewNode(params->qsf_ns,
 		BAD_CAST qof_param->param_type));
 	xmlNodeAddContent(node, BAD_CAST qsf_guid);
-	xmlNewProp(node, BAD_CAST QSF_OBJECT_TYPE, BAD_CAST qof_param->param_name);
+	xmlNewProp(node, BAD_CAST g_type_name (QSF_OBJECT_TYPE), BAD_CAST qof_param->param_name);
 }
 
 /******* reference handling ***********/
@@ -666,28 +666,28 @@
 static gint
 qof_reference_list_cb(gconstpointer a, gconstpointer b)
 {
-	const QofEntityReference *aa;
-	const QofEntityReference *bb;
+	const QofInstanceReference *aa;
+	const QofInstanceReference *bb;
 
-	aa = (QofEntityReference*) a;
-	bb = (QofEntityReference*) b;
+	aa = (QofInstanceReference*) a;
+	bb = (QofInstanceReference*) b;
 	if(aa == NULL) { return 1; }
 	g_return_val_if_fail((bb != NULL), 1);
-	g_return_val_if_fail((aa->type != NULL), 1);
-	if((0 == guid_compare(bb->ent_guid, aa->ent_guid))
-		&&(0 == safe_strcmp(bb->type, aa->type))
-		&&(0 == safe_strcmp(bb->param->param_name, aa->param->param_name)))
+	g_return_val_if_fail((aa->type != G_TYPE_INVALID), 1);
+	if((0 == guid_compare(bb->inst_guid, aa->inst_guid))
+		&&((bb->type == aa->type))
+		&&(bb->param->param_name == aa->param->param_name))
 	{
 		return 0;
 	}
 	return 1;
 }
 
-static QofEntityReference*
-qof_reference_lookup(GList *referenceList, QofEntityReference *find)
+static QofInstanceReference*
+qof_reference_lookup(GList *referenceList, QofInstanceReference *find)
 {
 	GList *single_ref;
-	QofEntityReference *ent_ref;
+	QofInstanceReference *ent_ref;
 
 	if(referenceList == NULL) { return NULL; }
 	g_return_val_if_fail(find != NULL, NULL);
@@ -695,7 +695,7 @@
 	ent_ref = NULL;
 	single_ref = g_list_find_custom(referenceList, find, qof_reference_list_cb);
 	if(single_ref == NULL) { return ent_ref; }
-	ent_ref = (QofEntityReference*)single_ref->data;
+	ent_ref = (QofInstanceReference*)single_ref->data;
 	g_list_free(single_ref);
 	return ent_ref;
 }
@@ -703,9 +703,9 @@
 static void
 reference_list_lookup(gpointer data, gpointer user_data)
 {
-	QofEntity *ent;
+	QofInstance *ent;
 	QofParam *ref_param;
-	QofEntityReference *reference, *starter;
+	QofInstanceReference *reference, *starter;
 	qsf_param  *params;
 	const GUID *guid;
 	xmlNodePtr node, object_node;
@@ -718,9 +718,9 @@
 	object_node = params->output_node;
 	ent = params->qsf_ent;
 	ns = params->qsf_ns;
-	starter = g_new(QofEntityReference, 1);
-	starter->ent_guid = qof_entity_get_guid(ent);
-	starter->type = g_strdup(ent->e_type);
+	starter = g_new(QofInstanceReference, 1);
+	starter->inst_guid = qof_instance_get_guid(ent);
+	starter->type = G_OBJECT_TYPE (ent);
 	starter->param = ref_param;
 	starter->ref_guid = NULL;
 	copy_list = g_list_copy(params->referenceList);
@@ -739,25 +739,25 @@
 		g_free(ref_name);
 	}
 	else {
-		ent = (QofEntity*)ref_param->param_getfcn(ent, ref_param);
+		ent = (QofInstance*)ref_param->param_getfcn(ent, ref_param);
 		if(!ent) { return; }
-		if((0 == safe_strcmp(ref_param->param_type, QOF_TYPE_COLLECT)) ||
-			(0 == safe_strcmp(ref_param->param_type, QOF_TYPE_CHOICE)))
+		if((ref_param->param_type == QOF_TYPE_COLLECT) ||
+			(ref_param->param_type == QOF_TYPE_CHOICE))
 		{ return; }
 		node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST QOF_TYPE_GUID));
-		guid = qof_entity_get_guid(ent);
+		guid = qof_instance_get_guid(ent);
 		guid_to_string_buff(guid, qsf_guid);
 		xmlNodeAddContent(node, BAD_CAST qsf_guid);
-		xmlNewProp(node, BAD_CAST QSF_OBJECT_TYPE, BAD_CAST ref_param->param_name);
+		xmlNewProp(node, BAD_CAST g_type_name (QSF_OBJECT_TYPE), BAD_CAST ref_param->param_name);
 	}
 }
 
 /*=====================================
-	Convert QofEntity to QSF XML node
+	Convert QofInstance to QSF XML node
 qof_param holds the parameter sequence.
 =======================================*/
 static void
-qsf_entity_foreach(QofEntity *ent, gpointer data)
+qsf_entity_foreach(QofInstance *ent, gpointer data)
 {
 	qsf_param  *params;
 	GSList     *param_list, *supported;
@@ -766,7 +766,7 @@
 	xmlNsPtr   ns;
 	gchar      *string_buffer;
 	QofParam   *qof_param;
-	QofEntity  *choice_ent;
+	QofInstance  *choice_ent;
 	KvpFrame   *qsf_kvp;
 	QofCollection *qsf_coll;
 	gint        param_count;
@@ -783,7 +783,7 @@
 	choice_ent = NULL;
 	object_node = xmlNewChild(params->book_node, params->qsf_ns,
 		BAD_CAST QSF_OBJECT_TAG, NULL);
-	xmlNewProp(object_node, BAD_CAST QSF_OBJECT_TYPE, BAD_CAST ent->e_type);
+	xmlNewProp(object_node, BAD_CAST g_type_name (QSF_OBJECT_TYPE), BAD_CAST G_OBJECT_TYPE (ent));
 	string_buffer = g_strdup_printf("%i", param_count);
 	xmlNewProp(object_node, BAD_CAST QSF_OBJECT_COUNT, BAD_CAST string_buffer);
 	g_free(string_buffer);
@@ -791,27 +791,27 @@
 	while(param_list != NULL) {
 		qof_param = (QofParam*)param_list->data;
 		g_return_if_fail(qof_param != NULL);
-		if(0 == safe_strcmp(qof_param->param_type, QOF_TYPE_GUID))
+		if(qof_param->param_type == QOF_TYPE_GUID)
 		{
 			if(!own_guid)
 			{
-				cm_guid = qof_entity_get_guid(ent);
+				cm_guid = qof_instance_get_guid(ent);
 				node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST QOF_TYPE_GUID));
 				guid_to_string_buff(cm_guid, cm_sa);
 				string_buffer = g_strdup(cm_sa);
 				xmlNodeAddContent(node, BAD_CAST string_buffer);
-				xmlNewProp(node, BAD_CAST QSF_OBJECT_TYPE , BAD_CAST QOF_PARAM_GUID);
+				xmlNewProp(node, BAD_CAST g_type_name (QSF_OBJECT_TYPE) , BAD_CAST QOF_PARAM_GUID);
 				g_free(string_buffer);
 				own_guid = TRUE;
 			}
 			params->qsf_ent = ent;
 			params->output_node = object_node;
-			ref = qof_class_get_referenceList(ent->e_type);
+			ref = qof_class_get_referenceList(G_OBJECT_TYPE (ent));
 			if(ref != NULL) {
 				g_list_foreach(ref, reference_list_lookup, params);
 			}
 		}
-		if(0 == safe_strcmp(qof_param->param_type, QOF_TYPE_COLLECT))
+		if(qof_param->param_type == QOF_TYPE_COLLECT)
 		{
 			qsf_coll = qof_param->param_getfcn(ent, qof_param);
 			if(qsf_coll) {
@@ -824,26 +824,26 @@
 			param_list = g_slist_next(param_list);
 			continue;
 		}
-		if(0 == safe_strcmp(qof_param->param_type, QOF_TYPE_CHOICE))
+		if(qof_param->param_type == QOF_TYPE_CHOICE)
 		{
 			/** \todo use the reference list here. */
-			choice_ent = (QofEntity*)qof_param->param_getfcn(ent, qof_param);
+			choice_ent = (QofInstance*)qof_param->param_getfcn(ent, qof_param);
 			if(!choice_ent) {
 				param_list = g_slist_next(param_list);
 				continue;
 			}
 			node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST qof_param->param_type));
-			cm_guid = qof_entity_get_guid(choice_ent);
+			cm_guid = qof_instance_get_guid(choice_ent);
 			guid_to_string_buff(cm_guid, cm_sa);
 			string_buffer = g_strdup(cm_sa);
 			xmlNodeAddContent(node, BAD_CAST string_buffer);
-			xmlNewProp(node, BAD_CAST QSF_OBJECT_TYPE, BAD_CAST qof_param->param_name);
-			xmlNewProp(node, BAD_CAST "name", BAD_CAST choice_ent->e_type);
+			xmlNewProp(node, BAD_CAST g_type_name (QSF_OBJECT_TYPE), BAD_CAST qof_param->param_name);
+			xmlNewProp(node, BAD_CAST "name", BAD_CAST g_type_name (G_OBJECT_TYPE (choice_ent)));
 			g_free(string_buffer);
 			param_list = g_slist_next(param_list);
 			continue;
 		}
-		if(0 == safe_strcmp(qof_param->param_type, QOF_TYPE_KVP))
+		if(qof_param->param_type == QOF_TYPE_KVP)
 		{
 			qsf_kvp = (KvpFrame*)qof_param->param_getfcn(ent,qof_param);
 			if(kvp_frame_is_empty(qsf_kvp))	{ LEAVE(" "); return; }
@@ -861,7 +861,7 @@
 					node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST qof_param->param_type));
 					string_buffer = g_strdup(qof_book_merge_param_as_string(qof_param, ent));
 					xmlNodeAddContent(node, BAD_CAST string_buffer);
-					xmlNewProp(node, BAD_CAST QSF_OBJECT_TYPE, BAD_CAST qof_param->param_name);
+					xmlNewProp(node, BAD_CAST g_type_name (QSF_OBJECT_TYPE), BAD_CAST qof_param->param_name);
 					g_free(string_buffer);
 				}
 			}
@@ -881,7 +881,7 @@
 	params = (qsf_param*) data;
 	/* Skip unsupported objects */
 	if((qsf_obj->create == NULL)||(qsf_obj->foreach == NULL)){
-		PINFO (" qsf_obj QOF support failed %s", qsf_obj->e_type);
+		PINFO (" qsf_obj QOF support failed %s", g_type_name (qsf_obj->e_type));
 		return;
 	}
 	params->qof_obj_type = qsf_obj->e_type;
@@ -889,7 +889,7 @@
 	book = params->book;
 	support = g_slist_copy(params->supported_types);
 	g_slist_foreach(support,qsf_supported_parameters, params);
-	qof_object_foreach(qsf_obj->e_type, book, qsf_entity_foreach, params);
+	qof_book_foreach( book, qsf_obj->e_type, qsf_entity_foreach, params);
 }
 
 /*=====================================================
@@ -916,7 +916,7 @@
 	node = xmlNewChild(top_node, params->qsf_ns, BAD_CAST QSF_BOOK_TAG, NULL);
 	params->book_node = node;
 	xmlNewProp(node, BAD_CAST QSF_BOOK_COUNT, BAD_CAST "1");
-	book_guid = qof_book_get_guid(book);
+	book_guid = qof_instance_get_guid(QOF_INSTANCE (book));
 	guid_to_string_buff(book_guid, buffer);
 	xmlNewChild(params->book_node, params->qsf_ns, 
 		BAD_CAST QSF_BOOK_GUID, BAD_CAST buffer);
@@ -1047,7 +1047,7 @@
 }
 
 /* ======================================================
-	Commit XML data from file to QofEntity in a QofBook
+	Commit XML data from file to QofInstance in a QofBook
 ========================================================= */
 void
 qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
@@ -1055,8 +1055,8 @@
 	qsf_param          *params;
 	qsf_objects        *object_set;
 	xmlNodePtr         node;
-	QofEntityReference *reference;
-	QofEntity          *qsf_ent;
+	QofInstanceReference *reference;
+	QofInstance          *qsf_ent;
 	QofBook            *targetBook;
 	const char         *qof_type, *parameter_name, *timechk;
 	QofIdType          obj_type, reference_type;
@@ -1077,14 +1077,14 @@
 	KvpValueType   cm_type;
 	QofSetterFunc  cm_setter;
 	const QofParam *cm_param;
-	void (*string_setter)    (QofEntity*, const gchar*);
-	void (*date_setter)      (QofEntity*, Timespec);
-	void (*numeric_setter)   (QofEntity*, gnc_numeric);
-	void (*double_setter)    (QofEntity*, double);
-	void (*boolean_setter)   (QofEntity*, gboolean);
-	void (*i32_setter)       (QofEntity*, gint32);
-	void (*i64_setter)       (QofEntity*, gint64);
-	void (*char_setter)      (QofEntity*, gchar);
+	void (*string_setter)    (QofInstance*, const gchar*);
+	void (*date_setter)      (QofInstance*, Timespec);
+	void (*numeric_setter)   (QofInstance*, gnc_numeric);
+	void (*double_setter)    (QofInstance*, double);
+	void (*boolean_setter)   (QofInstance*, gboolean);
+	void (*i32_setter)       (QofInstance*, gint32);
+	void (*i64_setter)       (QofInstance*, gint64);
+	void (*char_setter)      (QofInstance*, gchar);
 
 	g_return_if_fail(data && value && key);
 	params = (qsf_param*)data;
@@ -1096,17 +1096,18 @@
 	memset (&qsf_time, '\0', sizeof(qsf_time));
 	cm_date.tv_nsec = 0;
 	cm_date.tv_sec = 0;
-	obj_type = (gchar*)xmlGetProp(node->parent, BAD_CAST QSF_OBJECT_TYPE);
-	if(0 == safe_strcasecmp(obj_type, parameter_name)) { return; }
+	obj_type = g_type_from_name (xmlGetProp(node->parent, BAD_CAST g_type_name (QSF_OBJECT_TYPE)));
+	/*FIXME: verify parameter_name is the type name as in the old QOF type system, if not then make the correct comparation */
+	if(0 == safe_strcasecmp(g_type_name (obj_type), parameter_name)) { return; }
 	cm_setter = qof_class_get_parameter_setter(obj_type, parameter_name);
 	cm_param = qof_class_get_parameter(obj_type, parameter_name);
 	object_set = params->object_set;
-	if(safe_strcmp(qof_type, QOF_TYPE_STRING) == 0)  {
-		string_setter = (void(*)(QofEntity*, const gchar*))cm_setter;
+	if(g_type_from_name (qof_type) == QOF_TYPE_STRING)  {
+		string_setter = (void(*)(QofInstance*, const gchar*))cm_setter;
 		if(string_setter != NULL) { string_setter(qsf_ent, (gchar*)xmlNodeGetContent(node)); }
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_DATE) == 0) {
-		date_setter = (void(*)(QofEntity*, Timespec))cm_setter;
+	if(g_type_from_name (qof_type) == QOF_TYPE_DATE) {
+		date_setter = (void(*)(QofInstance*, Timespec))cm_setter;
 		timechk = NULL;
 		timechk = strptime((char*)xmlNodeGetContent(node), QSF_XSD_TIME, &qsf_time);
 		g_return_if_fail(timechk != NULL);
@@ -1117,69 +1118,69 @@
 			if(date_setter != NULL) { date_setter(qsf_ent, cm_date); }
 		}
 	}
-	if((safe_strcmp(qof_type, QOF_TYPE_NUMERIC) == 0)  ||
-	(safe_strcmp(qof_type, QOF_TYPE_DEBCRED) == 0)) {
-		numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_setter;
+	if((g_type_from_name (qof_type) == QOF_TYPE_NUMERIC)  ||
+	(g_type_from_name (qof_type) == QOF_TYPE_DEBCRED)) {
+		numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_setter;
 		string_to_gnc_numeric((char*)xmlNodeGetContent(node), &cm_numeric);
 		if(numeric_setter != NULL) { numeric_setter(qsf_ent, cm_numeric); }
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_GUID) == 0) {
+	if(g_type_from_name (qof_type) == QOF_TYPE_GUID) {
 		cm_guid = g_new(GUID, 1);
 		if(TRUE != string_to_guid((char*)xmlNodeGetContent(node), cm_guid))
 		{
 			qof_backend_set_error(params->be, ERR_QSF_BAD_OBJ_GUID);
 			PINFO (" string to guid conversion failed for %s:%s:%s",
-				xmlNodeGetContent(node), obj_type, qof_type);
+				xmlNodeGetContent(node), g_type_name (obj_type), qof_type);
 			return;
 		}
-		reference_type = (char*)xmlGetProp(node, BAD_CAST QSF_OBJECT_TYPE);
-		if(0 == safe_strcmp(QOF_PARAM_GUID, reference_type))
+		reference_type = g_type_from_name (xmlGetProp(node, BAD_CAST g_type_name (QSF_OBJECT_TYPE)));
+		if(QOF_PARAM_GUID == reference_type)
 		{
-			qof_entity_set_guid(qsf_ent, cm_guid);
+			qof_instance_set_guid(qsf_ent, cm_guid);
 		}
 		else {
-			reference = qof_entity_get_reference_from(qsf_ent, cm_param);
+			reference = qof_instance_get_reference_from(qsf_ent, cm_param);
 			if(reference) {
 				params->referenceList = g_list_append(params->referenceList, reference);
 			}
 		}
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_INT32) == 0) {
+	if(g_type_from_name (qof_type) == QOF_TYPE_INT32) {
 		errno = 0;
 		cm_i32 = (gint32)strtol ((char*)xmlNodeGetContent(node), &tail, 0);
 		if(errno == 0) {
-			i32_setter = (void(*)(QofEntity*, gint32))cm_setter;
+			i32_setter = (void(*)(QofInstance*, gint32))cm_setter;
 			if(i32_setter != NULL) { i32_setter(qsf_ent, cm_i32); }
 		}
 		else { qof_backend_set_error(params->be, ERR_QSF_OVERFLOW); }
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_INT64) == 0) {
+	if(g_type_from_name (qof_type) == QOF_TYPE_INT64) {
 		errno = 0;
 		cm_i64 = strtoll((gchar*)xmlNodeGetContent(node), &tail, 0);
 		if(errno == 0) {
-			i64_setter = (void(*)(QofEntity*, gint64))cm_setter;
+			i64_setter = (void(*)(QofInstance*, gint64))cm_setter;
 			if(i64_setter != NULL) { i64_setter(qsf_ent, cm_i64); }
 		}
 		else { qof_backend_set_error(params->be, ERR_QSF_OVERFLOW); }
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_DOUBLE) == 0) {
+	if(g_type_from_name (qof_type) == QOF_TYPE_DOUBLE) {
 		errno = 0;
 		cm_double = strtod((gchar*)xmlNodeGetContent(node), &tail);
 		if(errno == 0) {
-			double_setter = (void(*)(QofEntity*, double))cm_setter;
+			double_setter = (void(*)(QofInstance*, double))cm_setter;
 			if(double_setter != NULL) { double_setter(qsf_ent, cm_double); }
 		}
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_BOOLEAN) == 0){
+	if(g_type_from_name (qof_type) == QOF_TYPE_BOOLEAN){
 		if(0 == safe_strcasecmp((gchar*)xmlNodeGetContent(node), 
 				QSF_XML_BOOLEAN_TEST)) {
 			cm_boolean = TRUE;
 		}
 		else { cm_boolean = FALSE; }
-		boolean_setter = (void(*)(QofEntity*, gboolean))cm_setter;
+		boolean_setter = (void(*)(QofInstance*, gboolean))cm_setter;
 		if(boolean_setter != NULL) { boolean_setter(qsf_ent, cm_boolean); }
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_KVP) == 0) {
+	if(g_type_from_name (qof_type) == QOF_TYPE_KVP) {
 		cm_type = qsf_to_kvp_helper((gchar*)xmlGetProp(node, BAD_CAST QSF_OBJECT_VALUE));
 		if(!cm_type) { return; }
 		cm_value = string_to_kvp_value((gchar*)xmlNodeGetContent(node), cm_type);
@@ -1187,14 +1188,14 @@
 		cm_kvp = kvp_frame_set_value(cm_kvp, (gchar*)xmlGetProp(node, 
 			BAD_CAST QSF_OBJECT_KVP), cm_value);
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_COLLECT) == 0) {
+	if(g_type_from_name (qof_type) == QOF_TYPE_COLLECT) {
 		QofCollection *qsf_coll;
 		QofIdType type;
-		QofEntityReference *reference;
+		QofInstanceReference *reference;
 		QofParam *copy_param;
 		/* retrieve the *type* of the collection, ignore any contents. */
 		qsf_coll = cm_param->param_getfcn(qsf_ent, cm_param);
-		type = qof_collection_get_type(qsf_coll);
+		type = qof_collection_get_g_type(qsf_coll);
 		cm_guid = g_new(GUID, 1);
 		if(TRUE != string_to_guid((gchar*)xmlNodeGetContent(node), cm_guid))
 		{
@@ -1202,24 +1203,24 @@
 			PINFO (" string to guid collect failed for %s", xmlNodeGetContent(node));
 			return;
 		}
-		/* create a QofEntityReference with this type and GUID.
+		/* create a QofInstanceReference with this type and GUID.
 		 there is only one entity each time.
 		 cm_guid contains the GUID of the reference.
 		 type is the type of the reference. */
-		reference = g_new0(QofEntityReference, 1);
-		reference->type = g_strdup(qsf_ent->e_type);
+		reference = g_new0(QofInstanceReference, 1);
+		reference->type = G_OBJECT_TYPE (qsf_ent);
 		reference->ref_guid = cm_guid;
-		reference->ent_guid = &qsf_ent->guid;
+		reference->inst_guid = qof_instance_get_guid (qsf_ent);
 		copy_param = g_new0(QofParam, 1);
 		copy_param->param_name = g_strdup(cm_param->param_name);
-		copy_param->param_type = g_strdup(cm_param->param_type);
+		copy_param->param_type = cm_param->param_type;
 		reference->param = copy_param;
 		params->referenceList = g_list_append(params->referenceList, reference);
 	}
-	if(safe_strcmp(qof_type, QOF_TYPE_CHAR) == 0) {
+	if(g_type_from_name (qof_type) == QOF_TYPE_CHAR) {
 		char_getter = (gchar (*)(xmlNodePtr))xmlNodeGetContent;
 		cm_char = char_getter(node);
-		char_setter = (void(*)(QofEntity*, gchar))cm_setter;
+		char_setter = (void(*)(QofInstance*, gchar))cm_setter;
 		if(char_setter != NULL) { char_setter(qsf_ent, cm_char); }
 	}
 }

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml-map.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml-map.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml-map.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -100,16 +100,16 @@
 	}
 	if(qsf_is_element(child, ns, MAP_OBJECT_TAG)) {
 		match = NULL;
-		obj_type = xmlGetProp(child, BAD_CAST MAP_TYPE_ATTR);
-		match = BAD_CAST g_hash_table_lookup( valid->validation_table, obj_type);
+		obj_type = g_type_from_name (xmlGetProp(child, BAD_CAST MAP_TYPE_ATTR));
+		match = BAD_CAST g_hash_table_lookup( valid->validation_table, GINT_TO_POINTER (obj_type));
 		if(match) {
 			valid->map_calculated_count++;
 			if(TRUE == qof_class_is_registered((QofIdTypeConst) obj_type))
 			{
 				valid->qof_registered_count++;
-				PINFO (" %s is to be calculated", obj_type);
+				PINFO (" %s is to be calculated", g_type_name (obj_type));
 			}
-			else { PINFO (" %s to be mapped", obj_type); }
+			else { PINFO (" %s to be mapped", g_type_name (obj_type)); }
 		}
 	}
 }
@@ -340,7 +340,7 @@
         iterate = xmlGetProp(child, MAP_ITERATE_ATTR);
         if(qof_util_bool_to_int(iterate) == 1) 
         {
-            params->qof_foreach = xmlGetProp(child, BAD_CAST MAP_E_TYPE);
+            params->qof_foreach = g_type_from_name (xmlGetProp(child, BAD_CAST MAP_E_TYPE));
         }
 		if(NULL == g_hash_table_lookup(params->qsf_define_hash,
 			xmlGetProp(child, BAD_CAST MAP_E_TYPE)))
@@ -646,7 +646,10 @@
 static gint
 identify_source_func(gconstpointer qsf_object, gconstpointer map)
 {
-	return safe_strcmp(((qsf_objects*)qsf_object)->object_type, (QofIdType)map);
+	if(((qsf_objects*)qsf_object)->object_type == (QofIdType) map)
+	  return TRUE;
+	else
+	  return FALSE;
 }
 
 static void
@@ -739,13 +742,13 @@
 static void
 iterator_cb(xmlNodePtr child, xmlNsPtr ns, qsf_param *params)
 {
-	gchar *object_name;
+	QofIdType object_name;
 
 	/* count the number of iterators in the QSF file */
 	if(qsf_is_element(child, ns, QSF_OBJECT_TAG))
 	{
-		object_name = xmlGetProp(child, QSF_OBJECT_TYPE);
-		if(0 == safe_strcmp(object_name, params->qof_foreach))
+		object_name = g_type_from_name (xmlGetProp(child, g_type_name (QSF_OBJECT_TYPE)));
+		if(object_name == params->qof_foreach)
 		{
 			params->foreach_limit++;
 		}
@@ -793,8 +796,8 @@
 
 			params->lister = NULL;
 			/* cur_node describes the target object */
-			if(!qof_class_is_registered(BAD_CAST 
-				xmlGetProp(cur_node, MAP_TYPE_ATTR))) { continue; }
+			if(!qof_class_is_registered(g_type_from_name (BAD_CAST 
+				xmlGetProp(cur_node, MAP_TYPE_ATTR)))) { continue; }
 			qsf_add_object_tag(params, params->count);
 			params->count++;
 			iter.ns = params->map_ns;

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -242,7 +242,7 @@
 		return FALSE;
 	}
 	/* skip validation if is_our_qsf_object has already been called. */
-	if(ERR_QSF_INVALID_OBJ == qof_backend_get_error(params->be)) { return FALSE; }
+	if(ERR_QSF_INVALID_OBJ == qof_backend_get_error_code (params->be)) { return FALSE; }
 	if(params->file_type == QSF_UNDEF)
 	{
 		doc = xmlParseFile(path);
@@ -262,7 +262,7 @@
 	{
         QofBackendError err;
 		result = is_qsf_object_with_map_be(maps->data, params);
-        err = qof_backend_get_error(params->be);
+        err = qof_backend_get_error_code (params->be);
         if((err == ERR_BACKEND_NO_ERR) && result) 
         {
             params->map_path = maps->data;
@@ -315,7 +315,7 @@
 		params->object_set = object_set;
 		object_set->object_count = 0;
 		object_set->parameters = g_hash_table_new(g_str_hash, g_str_equal);
-		object_set->object_type = g_strdup((gchar*)xmlGetProp(child, 
+		object_set->object_type = g_type_from_name ((gchar*)xmlGetProp(child, 
 			BAD_CAST QSF_OBJECT_TYPE));
 		object_count_s = g_strdup((gchar*)xmlGetProp(child, 
 			BAD_CAST QSF_OBJECT_COUNT));
@@ -355,7 +355,7 @@
 			DEBUG (" trying to set book GUID");
 			buffer = g_strdup((gchar*)xmlNodeGetContent(child_node));
 			g_return_if_fail(TRUE == string_to_guid(buffer, &book_guid));
-			qof_entity_set_guid((QofEntity*)params->book, &book_guid);
+			qof_instance_set_guid((QofInstance*)params->book, &book_guid);
 			xmlNewChild(params->output_node, params->qsf_ns, 
 			BAD_CAST QSF_BOOK_GUID, BAD_CAST buffer);
 			g_free(buffer);

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/backend/file/qsf-xml.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -81,7 +81,7 @@
 					described by this QSF object file */
 #define QSF_BOOK_COUNT	"count"     /**< Sequential counter of each book in this file */
 #define QSF_OBJECT_TAG	"object"    /**< Second level child: object tag */
-#define QSF_OBJECT_TYPE	"type"      /**< QSF parameter name for object type specifiers */
+#define QSF_OBJECT_TYPE	G_TYPE_GTYPE      /**< QSF parameter name for object type specifiers */
 #define QSF_OBJECT_COUNT "count"    /**< Sequential counter for each QSF object
 					in this file */
 #define QSF_XML_VERSION  "1.0"      /**< The current XML version. */
@@ -358,11 +358,11 @@
 	xmlNodePtr book_node;        /**< Node for the book. */
 	xmlNodePtr lister;           /**< Comparison node for map defaults. */
 	xmlNsPtr qsf_ns, map_ns;     /**< Separate namespaces for QSF objects and QSF maps. */
-	const gchar *qof_type;       /**< Holds details of the QOF_TYPE */
+	QofIdType qof_type;       /**< Holds details of the QOF_TYPE */
 	QofIdType qof_obj_type;	     /**< current QofObject type (e_type) for the parameters. */
 	QofIdType qof_foreach;       /**< How to iterate over hierarchical entities. */
 	gint foreach_limit;          /**< How many iterations are found in the QSF */
-	QofEntity *qsf_ent;          /**< Current entity in the book. */
+	QofInstance *qsf_ent;          /**< Current entity in the book. */
 	QofBackend *be;              /**< the current QofBackend for this operation. */
 	gboolean knowntype;          /**< detect references by comparing with known QOF types. */
 	QofParam *qof_param;         /**< used by kvp to handle the frame hash table */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/Makefile.am
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/Makefile.am	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/Makefile.am	2007-03-08 13:23:14 UTC (rev 15690)
@@ -21,7 +21,7 @@
    qofbackend.c      \
    qofclass.c        \
    qofchoice.c       \
-   qofid.c           \
+   qofid.c   \
    qofinstance.c     \
    qofquery.c        \
    qofbook.c         \
@@ -51,7 +51,7 @@
    qofchoice.h       \
    qofevent.h        \
    qofgobj.h         \
-   qofid.h           \
+   qofid.h   \
    qofid-p.h         \
    qofinstance-p.h   \
    qofinstance.h     \

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-date.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-date.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-date.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -84,6 +84,7 @@
 
 #define QOF_UTC_DATE_FORMAT     "%Y-%m-%dT%H:%M:%SZ"
 
+
 /** Enum for determining a date format */
 typedef enum
 {

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-numeric.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-numeric.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-numeric.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -33,6 +33,96 @@
 #include "gnc-numeric.h"
 #include "qofmath128.c"
 
+/***************************/
+static gpointer
+gnc_numeric_copy (gpointer boxed)
+{
+	GncNumeric *src = (GncNumeric*) boxed;
+	GncNumeric *copy = NULL;
+
+	g_return_val_if_fail (src, NULL);
+
+	copy = g_new0 (GncNumeric, 1);
+	copy->num = src->num;
+	copy->denom = src->denom;
+	
+	return copy;
+}
+
+
+static void 
+string_to_numeric (const GValue *src, GValue *dest) 
+{
+	/* FIXME: add more checks*/
+	GncNumeric *numeric;
+	const gchar *as_string;
+	
+	g_return_if_fail (G_VALUE_HOLDS_STRING (src) &&
+			  GNC_VALUE_HOLDS_NUMERIC (dest));
+	
+	as_string = g_value_get_string (src);
+	
+	numeric = g_new0 (GncNumeric, 1);
+	string_to_gnc_numeric(as_string, numeric);
+	
+	g_value_take_boxed (dest, numeric);
+}
+
+static void 
+numeric_to_string (const GValue *src, GValue *dest) 
+{
+	gchar *str;
+	
+	g_return_if_fail (G_VALUE_HOLDS_STRING (dest) &&
+			  GNC_VALUE_HOLDS_NUMERIC (src));
+	
+	str = gnc_numeric_to_string(*gnc_value_get_numeric (src));
+	
+	g_value_set_string (dest, str);
+}
+
+GType
+gnc_numeric_get_type (void)
+{
+	static GType type = 0;
+	
+	if (G_UNLIKELY (type == 0)) {
+		type = g_boxed_type_register_static ("GncNumeric",
+						     (GBoxedCopyFunc) gnc_numeric_copy,
+						     NULL);
+		
+		g_value_register_transform_func (G_TYPE_STRING,
+						 type,
+						 string_to_numeric);
+		
+		g_value_register_transform_func (type, 
+						 G_TYPE_STRING,
+						 numeric_to_string);
+	}
+	
+	return type;
+}
+
+
+/**
+ * gnc_value_get_numeric
+ * @value: a #GValue whose value we want to get.
+ *
+ * Returns: the value stored in @value.
+ */
+G_CONST_RETURN GncNumeric *
+gnc_value_get_numeric (const GValue *value)
+{
+	GncNumeric *val;
+
+	g_return_val_if_fail (value && G_IS_VALUE (value), NULL);
+	g_return_val_if_fail (GNC_VALUE_HOLDS_NUMERIC (value), NULL);
+
+	val = (GncNumeric*) g_value_get_boxed (value);
+
+	return val;
+}
+
 /* static short module = MOD_ENGINE; */
 
 /* =============================================================== */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-numeric.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-numeric.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/gnc-numeric.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -49,8 +49,18 @@
 
 #ifndef GNC_NUMERIC_H
 #define GNC_NUMERIC_H
+#include <glib-object.h>
 
-struct _gnc_numeric 
+#define GNC_TYPE_NUMERIC (gnc_numeric_get_type())
+#define GNC_VALUE_HOLDS_NUMERIC(value) G_VALUE_HOLDS(value, GNC_TYPE_NUMERIC)
+
+
+typedef struct _GncNumeric GncNumeric;
+
+GType 												gnc_numeric_get_type (void);
+G_CONST_RETURN GncNumeric*		gnc_value_get_numeric (const GValue *value);
+
+struct _GncNumeric
 {
   gint64  num;
   gint64  denom;
@@ -59,7 +69,7 @@
 /** @brief An rational-number type
  *
  * This is a rational number, defined by numerator and denominator. */
-typedef struct _gnc_numeric gnc_numeric;
+typedef GncNumeric gnc_numeric;//Backward compatibility
 
 /** @name Arguments Standard Arguments to most functions
 
@@ -238,8 +248,8 @@
 */
 /** Make a gnc_numeric from numerator and denominator */
 static inline 
-gnc_numeric gnc_numeric_create(gint64 num, gint64 denom) {
-  gnc_numeric out;
+GncNumeric gnc_numeric_create(gint64 num, gint64 denom) {
+  GncNumeric out;
   out.num = num;
   out.denom = denom;
   return out;
@@ -247,7 +257,7 @@
 
 /** create a zero-value gnc_numeric */
 static inline
-gnc_numeric gnc_numeric_zero(void) { return gnc_numeric_create(0, 1); }
+GncNumeric gnc_numeric_zero(void) { return gnc_numeric_create(0, 1); }
 
 /** Convert a floating-point number to a gnc_numeric. 
  *  Both 'denom' and 'how' are used as in arithmetic, 
@@ -273,10 +283,10 @@
 */
 /** Return numerator */
 static inline 
-gint64 gnc_numeric_num(gnc_numeric a) { return a.num; }
+gint64 gnc_numeric_num(GncNumeric a) { return a.num; }
 /** Return denominator */
 static inline 
-gint64 gnc_numeric_denom(gnc_numeric a) { return a.denom; }
+gint64 gnc_numeric_denom(GncNumeric a) { return a.denom; }
 
 /** Convert numeric to floating-point value. */
 gdouble      gnc_numeric_to_double(gnc_numeric in);
@@ -377,7 +387,7 @@
  *                        GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
  */
 static inline
-gnc_numeric gnc_numeric_add_fixed(gnc_numeric a, gnc_numeric b) {
+GncNumeric gnc_numeric_add_fixed(GncNumeric a, GncNumeric b) {
    return gnc_numeric_add(a, b, GNC_DENOM_AUTO,
                          GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
 }
@@ -387,7 +397,7 @@
  *                        GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
  */
 static inline 
-gnc_numeric gnc_numeric_sub_fixed(gnc_numeric a, gnc_numeric b) {
+GncNumeric gnc_numeric_sub_fixed(GncNumeric a, GncNumeric b) {
   return gnc_numeric_sub(a, b, GNC_DENOM_AUTO,
                          GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
 }

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/guid.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/guid.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/guid.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -60,6 +60,103 @@
 static GMemChunk *guid_memchunk = NULL;
 #endif
 
+/***************************/
+static gpointer
+gnc_guid_copy (gpointer boxed)
+{
+	GUID *src = (GUID*) boxed;
+	GUID *copy = NULL;
+
+	g_return_val_if_fail (src, NULL);
+
+	
+	copy = g_memdup (src, sizeof (GUID));
+	
+	return copy;
+}
+
+static void
+gnc_guid_free (gpointer boxed)
+{
+  GUID *guid = (GUID*) boxed;
+  guid_free (guid);
+}
+
+static void 
+gnc_string_to_guid (const GValue *src, GValue *dest) 
+{
+	/* FIXME: add more checks*/
+	GUID *guid;
+	const gchar *as_string;
+	
+	g_return_if_fail (G_VALUE_HOLDS_STRING (src) &&
+			  GNC_VALUE_HOLDS_GUID (dest));
+	
+	as_string = g_value_get_string (src);
+	
+	guid = g_new0 (GUID, 1);
+	string_to_guid(as_string, guid);	
+	
+	g_value_take_boxed (dest, guid);
+}
+
+static void 
+gnc_guid_to_string (const GValue *src, GValue *dest) 
+{
+	const gchar *str;
+	
+	g_return_if_fail (G_VALUE_HOLDS_STRING (dest) &&
+			  GNC_VALUE_HOLDS_GUID (src));
+	
+	str = guid_to_string(gnc_value_get_guid (src));
+	
+	g_value_set_string (dest, str);
+}
+
+GType
+gnc_guid_get_type (void)
+{
+	static GType type = 0;
+	
+	if (G_UNLIKELY (type == 0)) {
+		type = g_boxed_type_register_static ("GUID",
+						     (GBoxedCopyFunc) gnc_guid_copy,
+						     (GBoxedFreeFunc) gnc_guid_free);
+		
+		g_value_register_transform_func (G_TYPE_STRING,
+						 type,
+						 gnc_string_to_guid);
+		
+		g_value_register_transform_func (type, 
+						 G_TYPE_STRING,
+						 gnc_guid_to_string);
+	}
+	
+	return type;
+}
+
+
+/**
+ * gnc_value_get_guid
+ * @value: a #GValue whose value we want to get.
+ *
+ * Returns: the value stored in @value.
+ */
+G_CONST_RETURN GUID*
+gnc_value_get_guid (const GValue *value)
+{
+	GUID *val;
+
+	g_return_val_if_fail (value && G_IS_VALUE (value), NULL);
+	g_return_val_if_fail (GNC_VALUE_HOLDS_GUID (value), NULL);
+
+	val = (GUID*) g_value_get_boxed (value);
+
+	return val;
+}
+
+
+
 /* This static indicates the debugging module that this .o belongs to.  */
 static QofLogModule log_module = QOF_MOD_ENGINE;
 

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/guid.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/guid.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/guid.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -25,6 +25,7 @@
 #define GUID_H 
 
 #include <stddef.h>
+#include <glib-object.h>
 
 /** @addtogroup Entity
     @{ */
@@ -59,6 +60,14 @@
 } GUID;
 
 
+#define GNC_TYPE_GUID (gnc_guid_get_type())
+#define GNC_VALUE_HOLDS_GUID(value) G_VALUE_HOLDS(value, GNC_TYPE_GUID)
+
+GType 									gnc_guid_get_type (void);
+G_CONST_RETURN GUID*		gnc_value_get_guid (const GValue *value);
+
+
+
 /** number of characters needed to encode a guid as a string
  * not including the null terminator. */
 #define GUID_ENCODING_LENGTH 32

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/kvp_frame.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/kvp_frame.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/kvp_frame.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -67,10 +67,151 @@
 /* This static indicates the debugging module that this .o belongs to.  */
 static QofLogModule log_module = QOF_MOD_KVP;
 
+/********************************************
+ * Binary Type register
+*********************************************/
+
+static gpointer
+gnc_binary_copy (gpointer boxed)
+{
+	KvpValueBinaryData *src = (KvpValueBinaryData*) boxed;
+	KvpValueBinaryData *copy = NULL;
+
+	g_return_val_if_fail (src, NULL);
+
+	copy = g_new0 (KvpValueBinaryData, 1);
+	copy->data = g_memdup (src->data, src->datasize);
+	copy->datasize = src->datasize;
+	
+	return copy;
+}
+
+static void
+gnc_binary_free (gpointer boxed)
+{
+  KvpValueBinaryData *binary = (KvpValueBinaryData*) boxed;
+  
+  g_free (binary->data);
+  g_free (binary);
+}
+
+GType
+gnc_binary_get_type (void)
+{
+	static GType type = 0;
+	
+	if (G_UNLIKELY (type == 0)) {
+		type = g_boxed_type_register_static ("GncBinary",
+						     (GBoxedCopyFunc) gnc_binary_copy,
+						     (GBoxedFreeFunc) gnc_binary_free);
+	}
+	
+	return type;
+}
+
+/********************************************
+ * GList Type register
+*********************************************/
+
+static gpointer
+gnc_glist_copy (gpointer boxed)
+{
+	GList *src = (GList*) boxed;
+	GList *copy = NULL;
+
+	g_return_val_if_fail (src, NULL);
+
+	copy = g_list_copy (src);
+	
+	return copy;
+}
+
+static void
+gnc_glist_free (gpointer boxed)
+{
+  GList *list = (GList*) boxed;
+  
+  g_list_free (list);
+}
+
+GType
+gnc_glist_get_type (void)
+{
+	static GType type = 0;
+	
+	if (G_UNLIKELY (type == 0)) {
+		type = g_boxed_type_register_static ("GncGList",
+						     (GBoxedCopyFunc) gnc_glist_copy,
+						     (GBoxedFreeFunc) gnc_glist_free);
+	}
+	
+	return type;
+}
+
+
 /* *******************************************************************
  * KvpFrame functions
  ********************************************************************/
 
+static gpointer
+gnc_kvp_frame_copy (gpointer boxed)
+{
+	KvpFrame *src = (KvpFrame*) boxed;
+	KvpFrame *copy = NULL;
+
+	g_return_val_if_fail (src, NULL);
+
+	copy = kvp_frame_copy(src);;
+	
+	return copy;
+}
+
+static void
+gnc_kvp_frame_free (gpointer boxed)
+{
+	KvpFrame *frame = (KvpFrame*) boxed;
+	
+	g_return_if_fail (frame);
+	
+	kvp_frame_delete (frame);
+}
+
+GType
+gnc_kvp_frame_get_type (void)
+{
+	static GType type = 0;
+	
+	if (G_UNLIKELY (type == 0)) {
+		type = g_boxed_type_register_static ("KvpFrame",
+						     (GBoxedCopyFunc) gnc_kvp_frame_copy,
+						     (GBoxedFreeFunc) gnc_kvp_frame_free);
+	}
+	
+	return type;
+}
+
+
+/**
+ * gnc_value_get_numeric
+ * @value: a #GValue whose value we want to get.
+ *
+ * Returns: the value stored in @value.
+ */
+G_CONST_RETURN KvpFrame*
+gnc_value_get_kvp_frame (const GValue *value)
+{
+	KvpFrame *val;
+
+	g_return_val_if_fail (value && G_IS_VALUE (value), NULL);
+	g_return_val_if_fail (GNC_VALUE_HOLDS_KVP_FRAME (value), NULL);
+
+	val = (KvpFrame*) g_value_get_boxed (value);
+
+	return val;
+}
+
+
+/***/
 static guint 
 kvp_hash_func(gconstpointer v) 
 {

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/kvp_frame.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/kvp_frame.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/kvp_frame.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -65,11 +65,27 @@
 #include "gnc-numeric.h"
 #include "guid.h"
 
+
+
 #define QOF_MOD_KVP "qof-kvp"
 
+#define GNC_TYPE_BINARY (gnc_binary_get_type())
+#define GNC_TYPE_GLIST (gnc_glist_get_type())
+
+
+GType gnc_binary_get_type (void);
+GType gnc_glist_get_type (void);
+
 /** Opaque frame structure */
 typedef struct _KvpFrame KvpFrame;
 
+#define GNC_TYPE_KVP_FRAME (gnc_kvp_frame_get_type())
+#define GNC_VALUE_HOLDS_KVP_FRAME(value) G_VALUE_HOLDS(value, GNC_TYPE_KVP_FRAME)
+
+
+GType 											gnc_kvp_frame_get_type (void);
+G_CONST_RETURN KvpFrame*		gnc_value_get_kvp_frame (const GValue *value);
+
 /** A KvpValue is a union with possible types enumerated in the
  * KvpValueType enum. */
 typedef struct _KvpValue KvpValue;

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qof.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qof.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qof.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -77,7 +77,7 @@
 /** @} */
 
 #include <glib.h>
-#include "qofid.h"
+#include "qofinstance.h"
 #include "qoflog.h"
 #include "gnc-date.h"
 #include "gnc-numeric.h"
@@ -102,6 +102,7 @@
 #include "qofreference.h"
 #include "deprecated.h"
 
+
 /** allow easy logging of QSF debug messages */
 #define QOF_MOD_QSF "gncqof-backend-qsf"
 /** allow easy loading of the QSF backend */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend-p.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend-p.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -328,6 +328,8 @@
    * data loss, otherwise FALSE.
    */
   gboolean (*save_may_clobber_data) (QofBackend *);
+  
+  GError *error;
 
   KvpFrame* backend_configuration;
   gint config_count;
@@ -371,7 +373,7 @@
 /** The qof_backend_get_message() pops the error message string from
  *  the Backend.  This string should be freed with g_free().
  */
-char * qof_backend_get_message(QofBackend *be);
+gchar * qof_backend_get_message(QofBackend *be);
 
 void qof_backend_init(QofBackend *be);
 

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -46,111 +46,6 @@
 #define QOF_CONFIG_DESC    "desc"
 #define QOF_CONFIG_TIP     "tip"
 
-static GHashTable *backend_data = NULL;
-
-gboolean qof_backend_register (GType type,
-                                   const char *backend_name,
-                                   gpointer be_data)
-{
-  GHashTable *ht;
-  g_return_val_if_fail (object_is_initialized, FALSE);
-
-  if (!type_name || *type_name == '\0' ||
-      !backend_name || *backend_name == '\0' ||
-      !be_data)
-    return FALSE;
-
-  ht = g_hash_table_lookup (backend_data, backend_name);
-
-  /* If it doesn't already exist, create a new table for this backend */
-  if (!ht) {
-    ht = g_hash_table_new (g_str_hash, g_str_equal);
-    g_hash_table_insert (backend_data, (char *)backend_name, ht);
-  }
-
-  /* Now insert the data */
-  g_hash_table_insert (ht, (char *)type_name, be_data);
-
-  return TRUE;
-}
-
-
-
-/* *******************************************************************\
- * error handling                                                   *
-\********************************************************************/
-
-
-/*
-	THE ERROR HANDLING WILL BE USING GERROR, THIS FUNCTIONS ARE DEPRECATED
-*/
-
-void 
-qof_backend_set_error (QofBackend *be, QofBackendError err)
-{
-   if (!be) return;
-
-   /* use stack-push semantics. Only the earliest error counts */
-   if (ERR_BACKEND_NO_ERR != be->last_err) return;
-   be->last_err = err;
-}
-
-QofBackendError 
-qof_backend_get_error (QofBackend *be)
-{
-   QofBackendError err;
-   if (!be) return ERR_BACKEND_NO_BACKEND;
-
-   /* use 'stack-pop' semantics */
-   err = be->last_err;
-   be->last_err = ERR_BACKEND_NO_ERR;
-   return err;
-}
-
-void
-qof_backend_set_message (QofBackend *be, const char *format, ...) 
-{
-   va_list args;
-   char * buffer;
-   
-   if (!be) return;
-  
-   /* If there's already something here, free it */
-   if (be->error_msg) g_free(be->error_msg);
-
-   if (!format) {
-       be->error_msg = NULL;
-       return;
-   }
-
-   va_start(args, format);
-   buffer = (char *)g_strdup_vprintf(format, args);
-   va_end(args);
-
-   be->error_msg = buffer;
-}
-
-char *
-qof_backend_get_message (QofBackend *be) 
-{
-   char * msg;
-   
-   if (!be) return g_strdup("ERR_BACKEND_NO_BACKEND");
-   if (!be->error_msg) return NULL;
-
-   /* 
-    * Just return the contents of the error_msg and then set it to
-    * NULL. This is necessary, because the Backends don't seem to
-    * have a destroy_backend function to take care of freeing stuff
-    * up. The calling function should free the copy.
-    * Also, this is consistent with the qof_backend_get_error() popping.
-    */
-
-   msg = be->error_msg;
-   be->error_msg = NULL;
-   return msg;
-}
-
 /***********************************************************************/
 /* Get a clean backend */
 void
@@ -176,9 +71,6 @@
     be->events_pending = NULL;
     be->process_events = NULL;
 
-    be->last_err = ERR_BACKEND_NO_ERR;
-    if (be->error_msg) g_free (be->error_msg);
-    be->error_msg = NULL;
     be->percentage = NULL;
     be->backend_configuration = kvp_frame_new();
 
@@ -188,7 +80,7 @@
 }
 
 void
-qof_backend_run_begin(QofBackend *be, QofInstance *inst, GError *error)
+qof_backend_run_begin(QofBackend *be, QofInstance *inst, GError **error)
 {
 	if(!be || !inst) { return; }
 	if(!be->begin) { return; }
@@ -203,7 +95,7 @@
 }
 
 void
-qof_backend_run_commit(QofBackend *be, QofInstance *inst, GError *error)
+qof_backend_run_commit(QofBackend *be, QofInstance *inst, GError **error)
 {
 	if(!be || !inst) { return; }
 	if(!be->commit) { return; }
@@ -445,4 +337,40 @@
 	return TRUE;
 }
 
+GError* 
+qof_backend_get_error (QofBackend *be)
+{
+  if (be->error)
+    return be->error;
+  else
+    return NULL;
+}
+
+
+QofBackendError 
+qof_backend_get_error_code (QofBackend *be)
+{
+  if (be->error)
+    return be->error->code;
+  else
+    return ERR_BACKEND_NO_ERR;
+}
+
+
+void 
+qof_backend_error_free (QofBackend *be)
+{
+  if(be->error)
+    g_error_free (be->error);
+}
+
+void
+qof_backend_set_error (QofBackend *be, QofBackendError code)
+{
+  g_return_if_fail (code == ERR_BACKEND_NO_ERR);
+  
+  /*FIXME: Add conditionals to set error messages depending on error's code */  
+  be->error = g_error_new (QOF_BACKEND_ERROR, code, "BackendError");
+}
+
 /************************* END OF FILE ********************************/

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -186,13 +186,18 @@
 /** The qof_backend_set_error() routine pushes an error code onto the error
  *  stack. (FIXME: the stack is 1 deep in current implementation).
  */
-//void qof_backend_set_error (QofBackend *be, QofBackendError err);
+void qof_backend_set_error (QofBackend *be, QofBackendError err);
 
 /** The qof_backend_get_error() routine pops an error code off the error stack.
  	YOU NEED TO PASS A GError* pointer to get the errors in each call
  */
-//QofBackendError qof_backend_get_error (QofBackend *be);
+GError* qof_backend_get_error (QofBackend *be);
 
+QofBackendError qof_backend_get_error_code (QofBackend *be);
+
+void qof_backend_error_free (QofBackend *be);
+
+
 /** @name Backend Configuration using KVP
 
 The backend uses qof_backend_get_config to pass back a KvpFrame of QofBackendOption

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -42,18 +42,26 @@
 #include "qof.h"
 #include "qofevent-p.h"
 #include "qofbackend-p.h"
+#include "qofbook.h"
 #include "qofbook-p.h"
 #include "qofid-p.h"
 //#include "qofobject-p.h"
 
 static QofLogModule log_module = QOF_MOD_ENGINE;
 
+static void coll_destroy(gpointer col);
+static void book_final (gpointer key, gpointer value, gpointer booq);
+
+
 /* GObject declarations */
 
 static void qof_book_class_init(QofBookClass *klass);
-static void qof_book_init(QofBook *sp);
+static void qof_book_init(QofBook *book);
 static void qof_book_finalize(GObject *object);
+static void qof_book_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec);
+static void qof_book_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 
+
 /* Book structure */
 struct _QofBookPrivate
 {
@@ -87,8 +95,9 @@
   /* state flag: 'y' means 'open for editing',
    * 'n' means 'book is closed'
    * xxxxx shouldn't this be replaced by the instance editlevel ???
+   * Why this isn't a gboolean??????? well changing... :-)
    */
-  char book_open;
+  gboolean book_open;
 
   /* a flag denoting whether the book is closing down, used to
    * help the QOF objects shut down cleanly without maintaining
@@ -116,6 +125,7 @@
 
 enum _QofBookSignalType {
 	/* Signals */
+	FIRST_SIGNAL,
 	LAST_SIGNAL
 };
 
@@ -133,7 +143,7 @@
 static GObjectClass *parent_class = NULL;
 
 GType
-qof_book_get_type()
+qof_book_get_type(void)
 {
 	static GType type = 0;
 
@@ -174,44 +184,48 @@
 }
 
 static void
-qof_book_init(QofBook *obj)
+qof_book_init(QofBook *book)
 {
+  
 	/* Initialize private members, etc. */
 
-  book->hash_of_collections = g_hash_table_new_full(
+  book->priv->hash_of_collections = g_hash_table_new_full(
       g_int_hash, g_int_equal, NULL,  /* key_destroy_func   */
       coll_destroy);                            /* value_destroy_func */
 
-  book->data_tables = g_hash_table_new (g_str_hash, g_str_equal);
-  book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal);
+  book->priv->data_tables = g_hash_table_new (g_str_hash, g_str_equal);
+  book->priv->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal);
   
-  book->book_open = 'y';
-  book->version = 0;
-  book->idata = 0;
+  book->priv->book_open = TRUE;
+  book->priv->version = 0;
+  book->priv->idata = 0;
 
 }
 
 static void
 qof_book_finalize(GObject *object)
 {
+	QofBook *book;
 	
+	book = QOF_BOOK (object);
+	
 	/* Free private members, etc. */
 
-  book->shutting_down = TRUE;
-  qof_event_force (&book->inst.entity, QOF_EVENT_DESTROY, NULL); // signal emit with confirmation?
+  book->priv->shutting_down = TRUE;
+  qof_event_force ((QofEntity*) QOF_INSTANCE (object), QOF_EVENT_DESTROY, NULL); // signal emit with confirmation?
 
   /* Call the list of finalizers, let them do their thing. 
    * Do this before tearing into the rest of the book.
    */
-  g_hash_table_foreach (book->data_table_finalizers, book_final, book);
+  g_hash_table_foreach (book->priv->data_table_finalizers, book_final, book);
 
-  g_hash_table_destroy (book->data_table_finalizers);
-  book->data_table_finalizers = NULL;
-  g_hash_table_destroy (book->data_tables);
-  book->data_tables = NULL;
+  g_hash_table_destroy (book->priv->data_table_finalizers);
+  book->priv->data_table_finalizers = NULL;
+  g_hash_table_destroy (book->priv->data_tables);
+  book->priv->data_tables = NULL;
 
-  g_hash_table_destroy (book->hash_of_collections);
-  book->hash_of_collections = NULL;
+  g_hash_table_destroy (book->priv->hash_of_collections);
+  book->priv->hash_of_collections = NULL;
 
 	G_OBJECT_CLASS(parent_class)->finalize(object);
 }
@@ -228,7 +242,7 @@
 	switch (param_id) {		
 		default:
    			/* We don't have any other property... */
-    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,param_id,pspec);
     	break;
 	}
 }
@@ -260,10 +274,6 @@
   qof_collection_destroy((QofCollection *) col);
 }
 
-static void
-qof_book_init (QofBook *book)
-{
-  }
 
 QofBook *
 qof_book_new (void)
@@ -273,11 +283,14 @@
   ENTER (" ");
   book = QOF_BOOK (g_object_new (QOF_TYPE_BOOK, NULL));
   
-  qof_object_book_begin (book);
+  /* FIXME: If book needs KvpFrame, a GUID, but why needs a pointer to himself? */
+  
+  qof_instance_set_book (QOF_INSTANCE (book), book);
+  
 
-  qof_event_gen (&book->inst.entity, QOF_EVENT_CREATE, NULL);
+  qof_event_gen ((QofEntity*) QOF_INSTANCE (book), QOF_EVENT_CREATE, NULL);
   
-  g_signal_emit_by_name ( QOF_ENTITY (book), "created");
+  g_signal_emit_by_name ( QOF_INSTANCE (book), "created");
   
   LEAVE ("book=%p", book);
   return book;
@@ -289,15 +302,10 @@
   QofBookFinalCB cb = value;
   QofBook *book = booq;
 
-  gpointer user_data = g_hash_table_lookup (book->data_tables, key);
+  gpointer user_data = g_hash_table_lookup (book->priv->data_tables, key);
   (*cb) (book, key, user_data);
 }
 
-void
-qof_book_destroy (QofBook *book) 
-{
-  g_object_unref (G_OBJECT (book));
-}
 
 /* ====================================================================== */
 /* XXX this should probably be calling is_equal callbacks on gncObject */
@@ -317,7 +325,7 @@
 {
   if (!book) return FALSE;
 
-  return(book->inst.dirty || qof_object_is_dirty (book));
+  return (qof_instance_is_dirty ( QOF_INSTANCE (book)));
 }
 
 void
@@ -327,35 +335,37 @@
 
   if (!book) return;
 
-  was_dirty = book->inst.dirty;
-  book->inst.dirty = FALSE;
-  book->dirty_time = 0;
-  qof_object_mark_clean (book);
+  was_dirty = qof_instance_is_dirty (QOF_INSTANCE (book));
+  
+  qof_instance_set_dirty (QOF_INSTANCE (book), TRUE);
+  book->priv->dirty_time = 0;
+  qof_instance_mark_clean (QOF_INSTANCE (book));
   if (was_dirty) {
-    if (book->dirty_cb)
-      book->dirty_cb(book, FALSE, book->dirty_data);
+    if (book->priv->dirty_cb)
+      book->priv->dirty_cb(book, FALSE, book->priv->dirty_data);
   }
 }
 
-void qof_book_mark_dirty (QofBook *book)
+void 
+qof_book_mark_dirty (QofBook *book)
 {
   gboolean was_dirty;
 
   g_return_if_fail (QOF_IS_BOOK(book));
 
-  was_dirty = book->inst.dirty;
-  book->inst.dirty = TRUE;
+  was_dirty = qof_instance_is_dirty (QOF_INSTANCE (book));
+  qof_instance_set_dirty (QOF_INSTANCE (book), TRUE);
   if (!was_dirty) {
-    book->dirty_time = time(NULL);
-    if (book->dirty_cb)
-      book->dirty_cb(book, TRUE, book->dirty_data);
+    book->priv->dirty_time = time(NULL);
+    if (book->priv->dirty_cb)
+      book->priv->dirty_cb(book, TRUE, book->priv->dirty_data);
   }
 }
 
 void
 qof_book_print_dirty (const QofBook *book)
 {
-  if (book->inst.dirty)
+  if (qof_instance_is_dirty (QOF_INSTANCE (book)))
     printf("book is dirty.\n");
   qof_book_foreach_collection
     (book, (QofCollectionForeachCB)qof_collection_print_dirty, NULL);
@@ -364,14 +374,14 @@
 time_t
 qof_book_get_dirty_time (const QofBook *book)
 {
-  return book->dirty_time;
+  return book->priv->dirty_time;
 }
 
 void
 qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data)
 {
-  book->dirty_data = user_data;
-  book->dirty_cb = cb;
+  book->priv->dirty_data = user_data;
+  book->priv->dirty_cb = cb;
 }
 
 /* ====================================================================== */
@@ -381,14 +391,14 @@
 qof_book_get_backend (const QofBook *book)
 {
    if (!book) return NULL;
-   return book->backend;
+   return book->priv->backend;
 }
 
 gboolean
 qof_book_shutting_down (const QofBook *book)
 {
   if (!book) return FALSE;
-  return book->shutting_down;
+  return book->priv->shutting_down;
 }
 
 /* ====================================================================== */
@@ -399,7 +409,7 @@
 {
   if (!book) return;
   ENTER ("book=%p be=%p", book, be);
-  book->backend = be;
+  book->priv->backend = be;
   LEAVE (" ");
 }
 
@@ -412,31 +422,36 @@
 
 /* Store arbitrary pointers in the QofBook for data storage extensibility */
 /* XXX if data is NULL, we should remove the key from the hash table!
- */
+
+** DEPRECATED FUNCTIONS: use the GObject functions: g_object_set_data, g_object_set_data_full and g_object_get_data
+
 void 
 qof_book_set_data (QofBook *book, const char *key, gpointer data)
 {
   if (!book || !key) return;
-  g_hash_table_insert (book->data_tables, (gpointer)key, data);
+  g_hash_table_insert (book->priv->data_tables, (gpointer)key, data);
 }
 
 void 
 qof_book_set_data_fin (QofBook *book, const char *key, gpointer data, QofBookFinalCB cb)
 {
-  if (!book || !key) return;
-  g_hash_table_insert (book->data_tables, (gpointer)key, data);
+  g_return_if_fail (QOF_IS_BOOK(book) && key);
+  
+  g_hash_table_insert (book->priv->data_tables, (gpointer)key, data);
 
   if (!cb) return;
-  g_hash_table_insert (book->data_table_finalizers, (gpointer)key, cb);
+  g_hash_table_insert (book->priv->data_table_finalizers, (gpointer)key, cb);
 }
 
 gpointer 
 qof_book_get_data (const QofBook *book, const char *key)
 {
   if (!book || !key) return NULL;
-  return g_hash_table_lookup (book->data_tables, (gpointer)key);
+  return g_hash_table_lookup (book->priv->data_tables, (gpointer)key);
 }
+*/
 
+
 /* ====================================================================== */
 
 QofCollection *
@@ -446,12 +461,12 @@
 
   g_return_val_if_fail (QOF_IS_BOOK (book) || G_TYPE_IS_OBJECT (type), NULL);
 
-  col = g_hash_table_lookup (book->hash_of_collections, type);
+  col = g_hash_table_lookup (book->priv->hash_of_collections, GINT_TO_POINTER (type));
   
   if (!QOF_IS_COLLECTION(col)) {
       col = qof_collection_new (type);
-      g_hash_table_insert(book->hash_of_collections,
-          								type, col);
+      g_hash_table_insert(book->priv->hash_of_collections,
+          								GINT_TO_POINTER (type), col);
   }
   return col;
 }
@@ -479,7 +494,7 @@
 	QofCollection *coll;
 	gboolean res;
 	
-	g_return_val_if_fail (QOF_IS_BOOK (book) && QOF_IS_INSTANCE (inst));
+	g_return_val_if_fail (QOF_IS_BOOK (book) && QOF_IS_INSTANCE (inst), FALSE);
 	
 	coll = qof_book_get_collection (book, G_OBJECT_TYPE (inst));
 	
@@ -488,6 +503,17 @@
 	return res;
 }
 
+QofInstance*
+qof_book_get_element (QofBook *book, GType type, GUID *guid)
+{
+  QofCollection *col;
+  
+  col = qof_book_get_collection (book, type);
+  
+  return qof_collection_lookup_element (col, (const GUID*) guid);
+}
+
+
 struct _iterate {
   QofCollectionForeachCB  fn;
   gpointer                data;
@@ -502,10 +528,6 @@
   iter->fn (col, iter->data);
 }
 
-/** Invoke the indicated callback on each collection in the book. */
-typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
-void qof_book_foreach_collection (const QofBook *, QofCollectionForeachCB, gpointer);
-
 void 
 qof_book_foreach_collection (const QofBook *book, 
                              QofCollectionForeachCB cb, gpointer user_data)
@@ -518,7 +540,7 @@
   iter.fn = cb;
   iter.data = user_data;
 
-  g_hash_table_foreach (book->hash_of_collections, foreach_cb, &iter);
+  g_hash_table_foreach (book->priv->hash_of_collections, foreach_cb, &iter);
 }
 
 void
@@ -528,6 +550,7 @@
 	
 	col = qof_book_get_collection (book, type);
 	
+	/* By default execute cb in all the objects in the collection holding this object type */
 	qof_collection_foreach (col, cb, user_data);
 }
 
@@ -536,15 +559,16 @@
 void qof_book_mark_closed (QofBook *book)
 {
 	if(!book) { return; }
-	book->book_open = 'n';
+	book->priv->book_open = 'n';
 }
 
-gchar qof_book_get_open_marker (const QofBook *book)
+gboolean 
+qof_book_is_open (QofBook *book)
 {
 	if(!QOF_IS_BOOK(book))
-		return 'n';
+		return FALSE;
 	else
-		return book->book_open;
+		return book->priv->book_open;
 }
 
 gint32 qof_book_get_version (const QofBook *book)
@@ -552,7 +576,7 @@
 	if(!QOF_IS_BOOK (book)) 
 		return -1;
 	else
-		return book->version;
+		return book->priv->version;
 }
 
 guint32 qof_book_get_idata (const QofBook *book)
@@ -560,21 +584,21 @@
 	if(!QOF_IS_BOOK (book)) 
 		return 0;
 	else
-		return book->idata;
+		return book->priv->idata;
 }
 
 void qof_book_set_version (QofBook *book, gint32 version)
 {
 	g_return_if_fail (QOF_IS_BOOK (book) && version < 0);
 	
-	book->version = version;
+	book->priv->version = version;
 }
 
 void qof_book_set_idata(QofBook *book, guint32 idata)
 {
 	g_return_if_fail (QOF_IS_BOOK (book) && idata < 0);
 	
-	book->idata = idata;
+	book->priv->idata = idata;
 }
 
 gint64
@@ -596,7 +620,7 @@
   }
 
   /* If we've got a backend with a counter method, call it */
-  be = book->backend;
+  be = book->priv->backend;
   if (be && be->counter)
     return ((be->counter)(be, counter_name));
 
@@ -630,10 +654,12 @@
 }
 
 /* QofObject function implementation and registration */
+/* FIXME: This is broken for now; see if you can register param by param a qof_class; 
+ * or see if we can avoid to use this registration (GObject gives the GObjectClass framework)
 gboolean qof_book_register (void)
 {
   static QofParam params[] = {
-    { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
+    { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
     { QOF_PARAM_KVP,  QOF_TYPE_KVP,  (QofAccessFunc)qof_instance_get_slots, NULL },
     { NULL },
   };
@@ -642,5 +668,6 @@
 
   return TRUE;
 }
+*/
 
 /* ========================== END OF FILE =============================== */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -41,9 +41,12 @@
 #ifndef QOF_BOOK_H
 #define QOF_BOOK_H
 
-#include "qofid.h"
 #include "kvp_frame.h"
+#include <glib-object.h>
+#include "qofinstance.h"
 
+
+
 /* GObject declarations */
 
 #define QOF_TYPE_BOOK            (qof_book_get_type ())
@@ -56,7 +59,11 @@
 
 typedef struct _QofBookClass QofBookClass;
 typedef struct _QofBookPrivate QofBookPrivate;
+
+#ifndef QOF_BOOK_DEFINED
+#define QOF_BOOK_DEFINED
 typedef struct _QofBook QofBook;
+#endif
 
 struct _QofBook {
 	QofInstance inst;
@@ -70,7 +77,7 @@
 	/* Add Signal Functions Here */
 };
 
-GType   qof_book_get_type ();
+GType   qof_book_get_type (void);
 
 
 /** @brief Encapsulates all the information about a dataset
@@ -95,7 +102,7 @@
 /** End any editing sessions associated with book, and free all memory
     associated with it. */
 //void      qof_book_destroy (QofBook *book);
-#define qof_book_destroy (b) g_object_unref (b)
+#define qof_book_destroy(b) g_object_unref (b)
 
 /** Close a book to editing.
 
@@ -104,6 +111,8 @@
 */
 void qof_book_mark_closed (QofBook *book);
 
+gboolean qof_book_is_open (QofBook *book);
+
 /** Return The table of entities of the given type.
  *
  *  When an object's constructor calls qof_instance_init(), a
@@ -117,29 +126,19 @@
  *  a non-NULL value.  (Unless the system malloc failed (out of
  *  memory) in which case what happens??).
  */
-QofCollection  * qof_book_get_collection (const QofBook *, GType);
+QofCollection* qof_book_get_collection (const QofBook *book, GType type);
 
 /** Invoke the indicated callback on each collection in the book. */
-typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
-void qof_book_foreach_collection (const QofBook *, QofCollectionForeachCB, gpointer);
+typedef void (*QofCollectionForeachCB) (QofCollection *col, gpointer user_data);
+void qof_book_foreach_collection (const QofBook *book, QofCollectionForeachCB func, gpointer user_data);
 
 /** Callback type for qof_instance_foreach */
-typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
+typedef void (*QofBookForeachCB) (QofBook *book, gpointer user_data);
 
-void qof_book_foreach (const QofBook *book, GType type, QofInstanceForeachCB func, gpointer data);
+void qof_book_foreach (const QofBook *book, GType type, QofInstanceForeachCB cb, gpointer user_data);
 
-/* Deprecated */
-#define qof_object_foreach(type, book, cb, data) qof_book_foreach (book, type, cb, data)
+#define qof_object_foreach(t, b, f, d) qof_book_foreach(b, t, f, d);
 
-/** Return The kvp data for the book.
- *  Note that the book KVP data is persistent, and is stored/retrieved
- *  from the file/database.  Thus, the book KVP is the correct place to
- *  store data that needs to be persistent accross sessions (or shared
- *  between multiple users).  To store application runtime data, use
- *  qof_book_set_data() instead.
- */
-#define qof_book_get_slots(book) qof_instance_get_slots(QOF_INSTANCE(book))
-
 /** The qof_book_set_data() allows arbitrary pointers to structs
  *    to be stored in QofBook. This is the "preferred" method for
  *    extending QofBook to hold new data types.  This is also
@@ -185,8 +184,7 @@
  *    modified. It can be used by frontend when the used has made a
  *    change at the book level.
  */
-//void qof_book_mark_dirty(QofBook *book);
-#define qof_book_mark_dirty(b) qof_instance_set_dirty (QOF_INSTANCE (b), 	TRUE)	
+void qof_book_mark_dirty(QofBook *book);
 
 /** This debugging function can be used to traverse the book structure
  *    and all subsidiary structures, printing out which structures
@@ -219,11 +217,11 @@
 gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
 
 
-gboolean qof_book_remove_object (QofBook *book, QofInstance *inst);
+gboolean qof_book_remove_element (QofBook *book, QofInstance *inst);
 
-gboolean qof_book_insert_object (QofBook *book, QofInstance *inst);
+gboolean qof_book_insert_element (QofBook *book, QofInstance *inst);
 
-QofInstance qof_book_get_object (QofBook *book, GType type, GUID *guid);
+QofInstance* qof_book_get_element (QofBook *book, GType type, GUID *guid);
 
 
 

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbookmerge.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbookmerge.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbookmerge.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -74,7 +74,7 @@
 };
 
 static void
-collect_reference_cb (QofEntity *ent, gpointer user_data)
+collect_reference_cb (QofInstance *ent, gpointer user_data)
 {
 	struct collect_list_s *s;
 
@@ -89,7 +89,7 @@
 	QofBookMergeRule *currentRule;
 	QofCollection *mergeColl, *targetColl;
 	gchar      *stringImport, *stringTarget;
-	QofEntity  *mergeEnt, *targetEnt, *referenceEnt;
+	QofInstance  *mergeEnt, *targetEnt, *referenceEnt;
 	const GUID *guidImport, *guidTarget;
 	QofParam   *qtparam;
 	KvpFrame   *kvpImport, *kvpTarget;
@@ -97,13 +97,13 @@
 	QofType    mergeType;
 	GSList    *paramList;
 	gboolean  absolute, mergeError, knowntype, mergeMatch, booleanImport, booleanTarget,
-                                                 (*boolean_getter) (QofEntity*, QofParam*);
-	Timespec      tsImport, tsTarget,            (*date_getter)    (QofEntity*, QofParam*);
-	gnc_numeric   numericImport, numericTarget,  (*numeric_getter) (QofEntity*, QofParam*);
-	double        doubleImport, doubleTarget,    (*double_getter)  (QofEntity*, QofParam*);
-	gint32        i32Import, i32Target,          (*int32_getter)   (QofEntity*, QofParam*);
-	gint64        i64Import, i64Target,          (*int64_getter)   (QofEntity*, QofParam*);
-	gchar         charImport, charTarget,        (*char_getter)    (QofEntity*, QofParam*);
+                                                 (*boolean_getter) (QofInstance*, QofParam*);
+	Timespec      tsImport, tsTarget,            (*date_getter)    (QofInstance*, QofParam*);
+	gnc_numeric   numericImport, numericTarget,  (*numeric_getter) (QofInstance*, QofParam*);
+	double        doubleImport, doubleTarget,    (*double_getter)  (QofInstance*, QofParam*);
+	gint32        i32Import, i32Target,          (*int32_getter)   (QofInstance*, QofParam*);
+	gint64        i64Import, i64Target,          (*int64_getter)   (QofInstance*, QofParam*);
+	gchar         charImport, charTarget,        (*char_getter)    (QofInstance*, QofParam*);
 
 	g_return_val_if_fail((mergeData != NULL), -1);
 	currentRule = mergeData->currentRule;
@@ -123,10 +123,10 @@
 		mergeMatch = FALSE;
 		knowntype = FALSE;
 		qtparam = paramList->data;
-		mergeParamName = qtparam->param_name;
-		g_return_val_if_fail(mergeParamName != NULL, -1);
+		mergeParamName = qtparam->param_type;
+		g_return_val_if_fail(mergeParamName != G_TYPE_INVALID, -1);
 		mergeType = qtparam->param_type;
-		if(safe_strcmp(mergeType, QOF_TYPE_STRING) == 0)  { 
+		if(mergeType == QOF_TYPE_STRING)  { 
 			stringImport = qtparam->param_getfcn(mergeEnt,qtparam);
 			stringTarget = qtparam->param_getfcn(targetEnt,qtparam);
 			/* very strict string matches may need to be relaxed. */
@@ -139,8 +139,8 @@
 			stringImport = stringTarget = NULL;
 			knowntype= TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_DATE) == 0) {
-			date_getter = (Timespec (*)(QofEntity*, QofParam*))qtparam->param_getfcn;
+		if(mergeType == QOF_TYPE_DATE) {
+			date_getter = (Timespec (*)(QofInstance*, QofParam*))qtparam->param_getfcn;
 			tsImport = date_getter(mergeEnt, qtparam);
 			tsTarget = date_getter(targetEnt, qtparam);
 			if(timespec_cmp(&tsImport, &tsTarget) == 0) { mergeMatch = TRUE; }
@@ -148,9 +148,9 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT);
 			knowntype= TRUE;
 		}
-		if((safe_strcmp(mergeType, QOF_TYPE_NUMERIC) == 0)  ||
-		(safe_strcmp(mergeType, QOF_TYPE_DEBCRED) == 0)) { 
-			numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if((mergeType == QOF_TYPE_NUMERIC)  ||
+		(mergeType == QOF_TYPE_DEBCRED)) { 
+			numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			numericImport = numeric_getter(mergeEnt,qtparam);
 			numericTarget = numeric_getter(targetEnt,qtparam);
 			if(gnc_numeric_compare (numericImport, numericTarget) == 0) { mergeMatch = TRUE; }
@@ -158,7 +158,7 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT);
 			knowntype= TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_GUID) == 0) { 
+		if(mergeType == QOF_TYPE_GUID) { 
 			guidImport = qtparam->param_getfcn(mergeEnt,qtparam);
 			guidTarget = qtparam->param_getfcn(targetEnt,qtparam);
 			if(guid_compare(guidImport, guidTarget) == 0) { mergeMatch = TRUE; }
@@ -166,8 +166,8 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT);
 			knowntype= TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_INT32) == 0) { 
-			int32_getter = (gint32 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(mergeType == QOF_TYPE_INT32) { 
+			int32_getter = (gint32 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			i32Import = int32_getter(mergeEnt, qtparam);
 			i32Target = int32_getter(targetEnt, qtparam);
 			if(i32Target == i32Import) { mergeMatch = TRUE; }
@@ -175,8 +175,8 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT);
 			knowntype= TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_INT64) == 0) { 
-			int64_getter = (gint64 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(mergeType == QOF_TYPE_INT64) { 
+			int64_getter = (gint64 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			i64Import = int64_getter(mergeEnt, qtparam);
 			i64Target = int64_getter(targetEnt, qtparam);
 			if(i64Target == i64Import) { mergeMatch = TRUE; }
@@ -184,8 +184,8 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT); 
 			knowntype= TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_DOUBLE) == 0) { 
-			double_getter = (double (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(mergeType == QOF_TYPE_DOUBLE) { 
+			double_getter = (double (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			doubleImport = double_getter(mergeEnt, qtparam);
 			doubleTarget = double_getter(mergeEnt, qtparam);
 			if(doubleImport == doubleTarget) { mergeMatch = TRUE; }
@@ -193,8 +193,8 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT); 
 			knowntype= TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_BOOLEAN) == 0){ 
-			boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(mergeType == QOF_TYPE_BOOLEAN){ 
+			boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			booleanImport = boolean_getter(mergeEnt, qtparam);
 			booleanTarget = boolean_getter(targetEnt, qtparam);
 			if(booleanImport != FALSE && booleanImport != TRUE) { booleanImport = FALSE; }
@@ -204,7 +204,7 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT);
 			knowntype= TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_KVP) == 0) { 
+		if(mergeType == QOF_TYPE_KVP) { 
 			kvpImport = kvp_frame_copy(qtparam->param_getfcn(mergeEnt,qtparam));
 			kvpTarget = kvp_frame_copy(qtparam->param_getfcn(targetEnt,qtparam));
 			if(kvp_frame_compare(kvpImport, kvpTarget) == 0) { mergeMatch = TRUE; }
@@ -212,8 +212,8 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT); 
 			knowntype= TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_CHAR) == 0) { 
-			char_getter = (gchar (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(mergeType == QOF_TYPE_CHAR) { 
+			char_getter = (gchar (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			charImport = char_getter(mergeEnt, qtparam);
 			charTarget = char_getter(targetEnt, qtparam);
 			if(charImport == charTarget) { mergeMatch = TRUE; }
@@ -223,8 +223,8 @@
 		}
 		/* No object should have QofSetterFunc defined for the book,
         but just to be safe, do nothing. */
-		if(safe_strcmp(mergeType, QOF_ID_BOOK) == 0) { knowntype= TRUE; }
-		if(safe_strcmp(mergeType, QOF_TYPE_COLLECT) == 0) {
+		if(mergeType == QOF_ID_BOOK) { knowntype= TRUE; }
+		if(mergeType == QOF_TYPE_COLLECT) {
 			struct collect_list_s s;
 			s.linkedEntList = NULL;
 			mergeColl = qtparam->param_getfcn(mergeEnt, qtparam);
@@ -238,7 +238,7 @@
                 mergeMatch, DEFAULT_MERGE_WEIGHT);
 			knowntype = TRUE;
 		}
-		if(safe_strcmp(mergeType, QOF_TYPE_CHOICE) ==0) {
+		if(mergeType == QOF_TYPE_CHOICE) {
 			referenceEnt = qtparam->param_getfcn(mergeEnt, qtparam);
 			currentRule->linkedEntList = 
                 g_slist_prepend(currentRule->linkedEntList, referenceEnt);
@@ -249,7 +249,7 @@
 		if(knowntype == FALSE) {
 			referenceEnt = qtparam->param_getfcn(mergeEnt, qtparam);
 			if((referenceEnt != NULL)
-				&&(safe_strcmp(referenceEnt->e_type, mergeType) == 0)) {
+				&&(G_OBJECT_TYPE (G_OBJECT (referenceEnt)) == mergeType)) {
 					currentRule->linkedEntList = 
                         g_slist_prepend(currentRule->linkedEntList, referenceEnt);
 					if(referenceEnt == qtparam->param_getfcn(targetEnt, qtparam)) 
@@ -372,7 +372,7 @@
 {
 	GSList *orphans, *targets;
 	QofBookMergeRule *rule, *currentRule;
-	QofEntity *best_matchEnt;
+	QofInstance *best_matchEnt;
 	double difference;
 
 	g_return_if_fail(mergeData != NULL);
@@ -409,7 +409,7 @@
 }
 
 static void 
-qof_book_merge_foreach_target (QofEntity* targetEnt, gpointer user_data)
+qof_book_merge_foreach_target (QofInstance* targetEnt, gpointer user_data)
 {
 	QofBookMergeData *mergeData;
 
@@ -430,18 +430,18 @@
 	currentRule = mergeData->currentRule;
 	g_return_if_fail(currentRule != NULL);
 	g_return_if_fail(merge_obj != NULL);
-	if(safe_strcmp(merge_obj->e_type, currentRule->importEnt->e_type) == 0) {
-		qof_object_foreach(currentRule->importEnt->e_type, mergeData->targetBook, 
+	if(G_OBJECT_TYPE (G_OBJECT (merge_obj)) == G_OBJECT_TYPE (G_OBJECT (currentRule->importEnt))) {
+		qof_object_foreach(G_OBJECT_TYPE ( G_OBJECT (currentRule->importEnt)), mergeData->targetBook,
 			qof_book_merge_foreach_target, user_data);
 	}
 }
 
 static void 
-qof_book_merge_foreach ( QofEntity* mergeEnt, gpointer user_data) 
+qof_book_merge_foreach ( QofInstance* mergeEnt, gpointer user_data) 
 {
 	QofBookMergeRule *mergeRule, *currentRule;
 	QofBookMergeData *mergeData;
-	QofEntity *targetEnt, *best_matchEnt;
+	QofInstance *targetEnt, *best_matchEnt;
 	GUID *g;
 	double difference;
 	GSList *c;
@@ -452,21 +452,21 @@
 	currentRule = mergeData->currentRule;
 	g_return_if_fail(currentRule != NULL);
 	g = guid_malloc();
-	*g = mergeEnt->guid;
+	g = qof_instance_get_guid (mergeEnt);
 	mergeRule = g_new(QofBookMergeRule,1);
 	mergeRule->importEnt = 		mergeEnt;
 	mergeRule->difference = 	difference = 0;
 	mergeRule->mergeAbsolute = 	FALSE;
 	mergeRule->mergeResult = 	MERGE_UNDEF;
 	mergeRule->updated = 		FALSE;
-	mergeRule->mergeType = 		mergeEnt->e_type;
-	mergeRule->mergeLabel = 	qof_object_get_type_label(mergeEnt->e_type);
+	mergeRule->mergeType = 		G_OBJECT_TYPE (G_OBJECT (mergeEnt));
+	mergeRule->mergeLabel = 	qof_object_get_type_label(G_OBJECT_TYPE (G_OBJECT (mergeEnt)));
 	mergeRule->mergeParam = 	g_slist_copy(mergeData->mergeObjectParams);
 	mergeRule->linkedEntList =	NULL;
 	mergeData->currentRule = mergeRule;
 	targetEnt = best_matchEnt = NULL;
-	targetEnt = qof_collection_lookup_entity (
-		qof_book_get_collection (mergeData->targetBook, mergeEnt->e_type), g);
+	targetEnt = qof_collection_lookup_element (
+		qof_book_get_collection (mergeData->targetBook, G_OBJECT_TYPE (G_OBJECT (mergeEnt))), g);
 	if( targetEnt != NULL) { 
 		mergeRule->mergeAbsolute = TRUE;
 		mergeRule->targetEnt = targetEnt;
@@ -558,7 +558,7 @@
 	g_return_if_fail((merge_obj != NULL));
 	/* Skip unsupported objects */
 	if((merge_obj->create == NULL)||(merge_obj->foreach == NULL)){
-		DEBUG (" merge_obj QOF support failed %s", merge_obj->e_type);
+		DEBUG (" merge_obj QOF support failed %s", g_type_name (merge_obj->e_type));
 		return;
 	}
 	if(mergeData->mergeObjectParams != NULL) g_slist_free(mergeData->mergeObjectParams);
@@ -592,7 +592,7 @@
 { 
 	QofInstance *inst;
 	gboolean    registered_type;
-	QofEntity   *referenceEnt;
+	QofInstance   *referenceEnt;
 	/* cm_ prefix used for variables that hold the data to commit */
 	QofCollection *cm_coll;
 	QofParam    *cm_param;
@@ -600,26 +600,26 @@
 	const GUID  *cm_guid;
 	KvpFrame    *cm_kvp;
 	/* function pointers and variables for parameter getters that don't use pointers normally */
-	gnc_numeric  cm_numeric, (*numeric_getter)  (QofEntity*, QofParam*);
-	double       cm_double,  (*double_getter)   (QofEntity*, QofParam*);
-	gboolean     cm_boolean, (*boolean_getter)  (QofEntity*, QofParam*);
-	gint32       cm_i32,     (*int32_getter)    (QofEntity*, QofParam*);
-	gint64       cm_i64,     (*int64_getter)    (QofEntity*, QofParam*);
-	Timespec     cm_date,    (*date_getter)     (QofEntity*, QofParam*);
-	gchar        cm_char,    (*char_getter)     (QofEntity*, QofParam*);
+	gnc_numeric  cm_numeric, (*numeric_getter)  (QofInstance*, QofParam*);
+	double       cm_double,  (*double_getter)   (QofInstance*, QofParam*);
+	gboolean     cm_boolean, (*boolean_getter)  (QofInstance*, QofParam*);
+	gint32       cm_i32,     (*int32_getter)    (QofInstance*, QofParam*);
+	gint64       cm_i64,     (*int64_getter)    (QofInstance*, QofParam*);
+	Timespec     cm_date,    (*date_getter)     (QofInstance*, QofParam*);
+	gchar        cm_char,    (*char_getter)     (QofInstance*, QofParam*);
 	/* function pointers to the parameter setters */
-	void (*string_setter)    (QofEntity*, const gchar*);
-	void (*date_setter)      (QofEntity*, Timespec);
-	void (*numeric_setter)   (QofEntity*, gnc_numeric);
-	void (*guid_setter)      (QofEntity*, const GUID*);
-	void (*double_setter)    (QofEntity*, double);
-	void (*boolean_setter)   (QofEntity*, gboolean);
-	void (*i32_setter)       (QofEntity*, gint32);
-	void (*i64_setter)       (QofEntity*, gint64);
-	void (*char_setter)      (QofEntity*, gchar);
-	void (*kvp_frame_setter) (QofEntity*, KvpFrame*);
-	void (*reference_setter) (QofEntity*, QofEntity*);
-	void (*collection_setter)(QofEntity*, QofCollection*);
+	void (*string_setter)    (QofInstance*, const gchar*);
+	void (*date_setter)      (QofInstance*, Timespec);
+	void (*numeric_setter)   (QofInstance*, gnc_numeric);
+	void (*guid_setter)      (QofInstance*, const GUID*);
+	void (*double_setter)    (QofInstance*, double);
+	void (*boolean_setter)   (QofInstance*, gboolean);
+	void (*i32_setter)       (QofInstance*, gint32);
+	void (*i64_setter)       (QofInstance*, gint64);
+	void (*char_setter)      (QofInstance*, gchar);
+	void (*kvp_frame_setter) (QofInstance*, KvpFrame*);
+	void (*reference_setter) (QofInstance*, QofInstance*);
+	void (*collection_setter)(QofInstance*, QofCollection*);
 
 	g_return_if_fail(rule != NULL);
 	g_return_if_fail(mergeData != NULL);
@@ -628,10 +628,10 @@
 	/* create a new object for MERGE_NEW */
 	/* The new object takes the GUID from the import to retain an absolute match */
 	if(rule->mergeResult == MERGE_NEW) {
-		inst = (QofInstance*)qof_object_new_instance(rule->importEnt->e_type, mergeData->targetBook);
+		inst = (QofInstance*)qof_object_new_instance(G_OBJECT_TYPE (G_OBJECT (rule->importEnt)), mergeData->targetBook);
 		g_return_if_fail(inst != NULL);
-		rule->targetEnt = &inst->entity;
-		qof_entity_set_guid(rule->targetEnt, qof_entity_get_guid(rule->importEnt));
+		rule->targetEnt = inst;
+		qof_instance_set_guid(rule->targetEnt, qof_instance_get_guid(rule->importEnt));
 	}
 	/* currentRule->targetEnt is now set,
 		1. by an absolute GUID match or
@@ -643,83 +643,83 @@
 		g_return_if_fail(rule->mergeParam->data);
 		cm_param = rule->mergeParam->data;
 		rule->mergeType = cm_param->param_type;
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_STRING) == 0)  { 
+		if(rule->mergeType == QOF_TYPE_STRING)  { 
 			cm_string = cm_param->param_getfcn(rule->importEnt, cm_param);
-			string_setter = (void(*)(QofEntity*, const gchar*))cm_param->param_setfcn;
+			string_setter = (void(*)(QofInstance*, const gchar*))cm_param->param_setfcn;
 			if(string_setter != NULL) { string_setter(rule->targetEnt, cm_string); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_DATE) == 0) { 
-			date_getter = (Timespec (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
+		if(rule->mergeType == QOF_TYPE_DATE) { 
+			date_getter = (Timespec (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
 			cm_date = date_getter(rule->importEnt, cm_param);
-			date_setter = (void(*)(QofEntity*, Timespec))cm_param->param_setfcn;
+			date_setter = (void(*)(QofInstance*, Timespec))cm_param->param_setfcn;
 			if(date_setter != NULL) { date_setter(rule->targetEnt, cm_date); }
 			registered_type = TRUE;
 		}
-		if((safe_strcmp(rule->mergeType, QOF_TYPE_NUMERIC) == 0)  ||
-		(safe_strcmp(rule->mergeType, QOF_TYPE_DEBCRED) == 0)) { 
-			numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
+		if((rule->mergeType == QOF_TYPE_NUMERIC)  ||
+		(rule->mergeType == QOF_TYPE_DEBCRED)) { 
+			numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
 			cm_numeric = numeric_getter(rule->importEnt, cm_param);
-			numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_param->param_setfcn;
+			numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_param->param_setfcn;
 			if(numeric_setter != NULL) { numeric_setter(rule->targetEnt, cm_numeric); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_GUID) == 0) { 
+		if(rule->mergeType == QOF_TYPE_GUID) { 
 			cm_guid = cm_param->param_getfcn(rule->importEnt, cm_param);
-			guid_setter = (void(*)(QofEntity*, const GUID*))cm_param->param_setfcn;
+			guid_setter = (void(*)(QofInstance*, const GUID*))cm_param->param_setfcn;
 			if(guid_setter != NULL) { guid_setter(rule->targetEnt, cm_guid); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_INT32) == 0) { 
-			int32_getter = (gint32 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+		if(rule->mergeType == QOF_TYPE_INT32) { 
+			int32_getter = (gint32 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 			cm_i32 = int32_getter(rule->importEnt, cm_param);
-			i32_setter = (void(*)(QofEntity*, gint32))cm_param->param_setfcn;
+			i32_setter = (void(*)(QofInstance*, gint32))cm_param->param_setfcn;
 			if(i32_setter != NULL) { i32_setter(rule->targetEnt, cm_i32); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_INT64) == 0) { 
-			int64_getter = (gint64 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+		if(rule->mergeType == QOF_TYPE_INT64) { 
+			int64_getter = (gint64 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 			cm_i64 = int64_getter(rule->importEnt, cm_param);
-			i64_setter = (void(*)(QofEntity*, gint64))cm_param->param_setfcn;
+			i64_setter = (void(*)(QofInstance*, gint64))cm_param->param_setfcn;
 			if(i64_setter != NULL) { i64_setter(rule->targetEnt, cm_i64); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_DOUBLE) == 0) { 
-			double_getter = (double (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+		if(rule->mergeType == QOF_TYPE_DOUBLE) { 
+			double_getter = (double (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 			cm_double = double_getter(rule->importEnt, cm_param);
-			double_setter = (void(*)(QofEntity*, double))cm_param->param_setfcn;
+			double_setter = (void(*)(QofInstance*, double))cm_param->param_setfcn;
 			if(double_setter != NULL) { double_setter(rule->targetEnt, cm_double); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_BOOLEAN) == 0){ 
-			boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+		if(rule->mergeType == QOF_TYPE_BOOLEAN){ 
+			boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 			cm_boolean = boolean_getter(rule->importEnt, cm_param);
-			boolean_setter = (void(*)(QofEntity*, gboolean))cm_param->param_setfcn;
+			boolean_setter = (void(*)(QofInstance*, gboolean))cm_param->param_setfcn;
 			if(boolean_setter != NULL) { boolean_setter(rule->targetEnt, cm_boolean); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_KVP) == 0) { 
+		if(rule->mergeType == QOF_TYPE_KVP) { 
 			cm_kvp = kvp_frame_copy(cm_param->param_getfcn(rule->importEnt,cm_param));
-			kvp_frame_setter = (void(*)(QofEntity*, KvpFrame*))cm_param->param_setfcn;
+			kvp_frame_setter = (void(*)(QofInstance*, KvpFrame*))cm_param->param_setfcn;
 			if(kvp_frame_setter != NULL) { kvp_frame_setter(rule->targetEnt, cm_kvp); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_CHAR) == 0) { 
-			char_getter = (gchar (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+		if(rule->mergeType == QOF_TYPE_CHAR) { 
+			char_getter = (gchar (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 			cm_char = char_getter(rule->importEnt,cm_param);
-			char_setter = (void(*)(QofEntity*, gchar))cm_param->param_setfcn;
+			char_setter = (void(*)(QofInstance*, gchar))cm_param->param_setfcn;
 			if(char_setter != NULL) { char_setter(rule->targetEnt, cm_char); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_COLLECT) == 0) {
+		if(rule->mergeType== QOF_TYPE_COLLECT) {
 			cm_coll = cm_param->param_getfcn(rule->importEnt, cm_param);
-			collection_setter = (void(*)(QofEntity*, QofCollection*))cm_param->param_setfcn;
+			collection_setter = (void(*)(QofInstance*, QofCollection*))cm_param->param_setfcn;
 			if(collection_setter != NULL) { collection_setter(rule->targetEnt, cm_coll); }
 			registered_type = TRUE;
 		}
-		if(safe_strcmp(rule->mergeType, QOF_TYPE_CHOICE) == 0) {
+		if(rule->mergeType == QOF_TYPE_CHOICE) {
 			referenceEnt = cm_param->param_getfcn(rule->importEnt, cm_param);
-			reference_setter = (void(*)(QofEntity*, QofEntity*))cm_param->param_setfcn;
+			reference_setter = (void(*)(QofInstance*, QofInstance*))cm_param->param_setfcn;
 			if(reference_setter != NULL) 
 			{ 
 				reference_setter(rule->targetEnt, referenceEnt); 
@@ -729,7 +729,7 @@
 		if(registered_type == FALSE) {
 			referenceEnt = cm_param->param_getfcn(rule->importEnt, cm_param);
 			if(referenceEnt) {
-				reference_setter = (void(*)(QofEntity*, QofEntity*))cm_param->param_setfcn;
+				reference_setter = (void(*)(QofInstance*, QofInstance*))cm_param->param_setfcn;
 				if(reference_setter != NULL) 
 				{ 
 					reference_setter(rule->targetEnt, referenceEnt); 
@@ -819,69 +819,69 @@
 gchar* qof_class_get_param_as_string(QofIdTypeConst, QofInstance*); ?
 */
 gchar*
-qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
+qof_book_merge_param_as_string(QofParam *qtparam, QofInstance *qtEnt)
 {
 	gchar       *param_string, param_date[QOF_DATE_STRING_LENGTH];
 	gchar       param_sa[GUID_ENCODING_LENGTH + 1];
 	QofType     paramType;
 	const GUID *param_guid;
 	time_t      param_t;
-	gnc_numeric param_numeric,  (*numeric_getter) (QofEntity*, QofParam*);
-	Timespec    param_ts,       (*date_getter)    (QofEntity*, QofParam*);
-	double      param_double,   (*double_getter)  (QofEntity*, QofParam*);
-	gboolean    param_boolean,  (*boolean_getter) (QofEntity*, QofParam*);
-	gint32      param_i32,      (*int32_getter)   (QofEntity*, QofParam*);
-	gint64      param_i64,      (*int64_getter)   (QofEntity*, QofParam*);
-	gchar       param_char,     (*char_getter)    (QofEntity*, QofParam*);
+	gnc_numeric param_numeric,  (*numeric_getter) (QofInstance*, QofParam*);
+	Timespec    param_ts,       (*date_getter)    (QofInstance*, QofParam*);
+	double      param_double,   (*double_getter)  (QofInstance*, QofParam*);
+	gboolean    param_boolean,  (*boolean_getter) (QofInstance*, QofParam*);
+	gint32      param_i32,      (*int32_getter)   (QofInstance*, QofParam*);
+	gint64      param_i64,      (*int64_getter)   (QofInstance*, QofParam*);
+	gchar       param_char,     (*char_getter)    (QofInstance*, QofParam*);
 
 	param_string = NULL;
 	paramType = qtparam->param_type;
-	if(safe_strcmp(paramType, QOF_TYPE_STRING) == 0)  { 
+	if(paramType == QOF_TYPE_STRING)  { 
 			param_string = g_strdup(qtparam->param_getfcn(qtEnt,qtparam));
 			if(param_string == NULL) { param_string = ""; }
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_DATE) == 0) { 
-			date_getter = (Timespec (*)(QofEntity*, QofParam*))qtparam->param_getfcn;
+		if(paramType == QOF_TYPE_DATE) { 
+			date_getter = (Timespec (*)(QofInstance*, QofParam*))qtparam->param_getfcn;
 			param_ts = date_getter(qtEnt, qtparam);
 			param_t = timespecToTime_t(param_ts);
 			strftime(param_date, QOF_DATE_STRING_LENGTH, QOF_UTC_DATE_FORMAT, gmtime(&param_t));
 			param_string = g_strdup(param_date);
 			return param_string;
 		}
-		if((safe_strcmp(paramType, QOF_TYPE_NUMERIC) == 0)  ||
-		(safe_strcmp(paramType, QOF_TYPE_DEBCRED) == 0)) { 
-			numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if((paramType == QOF_TYPE_NUMERIC)  ||
+		(paramType == QOF_TYPE_DEBCRED)) { 
+			numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			param_numeric = numeric_getter(qtEnt,qtparam);
 			param_string = g_strdup(gnc_numeric_to_string(param_numeric));
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_GUID) == 0) { 
+		if(paramType == QOF_TYPE_GUID) { 
 			param_guid = qtparam->param_getfcn(qtEnt,qtparam);
 			guid_to_string_buff(param_guid, param_sa);
 			param_string = g_strdup(param_sa);
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_INT32) == 0) { 
-			int32_getter = (gint32 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(paramType == QOF_TYPE_INT32) { 
+			int32_getter = (gint32 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			param_i32 = int32_getter(qtEnt, qtparam);
 			param_string = g_strdup_printf("%d", param_i32);
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_INT64) == 0) { 
-			int64_getter = (gint64 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(paramType == QOF_TYPE_INT64) { 
+			int64_getter = (gint64 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			param_i64 = int64_getter(qtEnt, qtparam);
 			param_string = g_strdup_printf("%" G_GINT64_FORMAT, param_i64);
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_DOUBLE) == 0) { 
-			double_getter = (double (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(paramType == QOF_TYPE_DOUBLE) { 
+			double_getter = (double (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			param_double = double_getter(qtEnt, qtparam);
 			param_string = g_strdup_printf("%f", param_double);
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_BOOLEAN) == 0){ 
-			boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(paramType == QOF_TYPE_BOOLEAN){ 
+			boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			param_boolean = boolean_getter(qtEnt, qtparam);
 			/* Boolean values need to be lowercase for QSF validation. */
 			if(param_boolean == TRUE) { param_string = g_strdup("true"); }
@@ -889,9 +889,9 @@
 			return param_string;
 		}
 		/* "kvp" contains repeating values, cannot be a single string for the frame. */
-		if(safe_strcmp(paramType, QOF_TYPE_KVP) == 0) { return param_string; }
-		if(safe_strcmp(paramType, QOF_TYPE_CHAR) == 0) { 
-			char_getter = (gchar (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
+		if(paramType == QOF_TYPE_KVP) { return param_string; }
+		if(paramType == QOF_TYPE_CHAR) { 
+			char_getter = (gchar (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
 			param_char = char_getter(qtEnt, qtparam);
 			param_string = g_strdup_printf("%c", param_char);
 			return param_string;

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbookmerge.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbookmerge.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbookmerge.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -175,7 +175,7 @@
 	GSList *mergeParam;      /**< list of usable parameters for the object type */
 	GSList *linkedEntList;   /**< list of complex data types included in this object. 
 
-	linkedEntList contains an ::QofEntity reference to any parameter that is not
+	linkedEntList contains an ::QofInstance reference to any parameter that is not
 	one of the core QOF_TYPE data types. This entity must be already
     registered with QOF and the results of the comparison for the linked entity
     will modulate the mergeResult of this object. e.g. if an invoice is the
@@ -183,8 +183,8 @@
     MERGE_REPORT and the customer as MERGE_NEW.
 	*/
 	QofBookMergeResult mergeResult; /**< result of comparison with main ::QofBook */
-	QofEntity *importEnt;    /**< pointer to the current entity in the import book. */
-	QofEntity *targetEnt;    /**< pointer to the corresponding entity in the
+	QofInstance *importEnt;    /**< pointer to the current entity in the import book. */
+	QofInstance *targetEnt;    /**< pointer to the corresponding entity in the
                                 target book, if any. */
 }QofBookMergeRule;
 
@@ -194,7 +194,7 @@
 Used to dictate what to merge, how to merge it, where to get the new data and
 where to put the amended data. 
 
-Combines lists of \a ::QofParam, \a ::QofEntity and \a ::QofBookMergeRule
+Combines lists of \a ::QofParam, \a ::QofInstance and \a ::QofBookMergeRule
 into one struct that can be easily passed between callbacks. Also holds the
 pointers to the import and target ::QofBook structures.
 	
@@ -209,7 +209,7 @@
                                     parameter in the current object. */
 	GList 	*mergeList;          /**< GList of all ::qof_book_mergeRule rules
                                     for the merge operation. */
-	GSList 	*targetList;         /**< GSList of ::QofEntity * for each object
+	GSList 	*targetList;         /**< GSList of ::QofInstance * for each object
                                     of this type in the target book */
 	QofBook *mergeBook;          /**< pointer to the import book for this
                                     merge operation. */
@@ -218,9 +218,9 @@
 	gboolean abort;	             /**< set to TRUE if MERGE_INVALID is set. */
 	QofBookMergeRule *currentRule; /**< placeholder for the rule currently
                                     being tested or applied. */
-	GSList *orphan_list;         /**< List of QofEntity's that need to be rematched.
+	GSList *orphan_list;         /**< List of QofInstance's that need to be rematched.
 
-	When one QofEntity has a lower difference to the targetEnt than the
+	When one QofInstance has a lower difference to the targetEnt than the
     previous best_match, the new match takes precedence. This list holds those
     orphaned entities that are not a good enough match so that these can be
     rematched later. The ranking is handled using the private QofEntityRating
@@ -335,7 +335,7 @@
 routines for the target entity. The import entity is available for display.
 
 Uses ::qof_book_get_collection with the QofBookMergeRule::mergeType object
-type to return a collection of ::QofEntity entities from either the
+type to return a collection of ::QofInstance entities from either the
 QofBookMergeData::mergeBook or QofBookMergeData::targetBook. Then
 uses ::qof_collection_lookup_entity to lookup the QofBookMergeRule::importEnt
 and again the qof_book_mergeRule::targetEnt to return the two specific entities.
@@ -359,7 +359,7 @@
 parameter data.
 
 */
-gchar* qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt);
+gchar* qof_book_merge_param_as_string(QofParam *qtparam, QofInstance *qtEnt);
 
 /** \brief called by dialogue callback to set the result of user intervention
 

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofchoice.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofchoice.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofchoice.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -35,7 +35,7 @@
 {
 	if(!qof_choice_table)
 	{
-		qof_choice_table = g_hash_table_new(g_str_hash, g_str_equal);
+		qof_choice_table = g_hash_table_new(g_int_hash, g_int_equal);
 	}
 	if(!qof_choice_table) { return FALSE; }
 	return TRUE;
@@ -48,26 +48,25 @@
 	value = NULL;
 	check = NULL;
 	if(!qof_choice_is_initialized()) { return FALSE; }
-	g_return_val_if_fail(type != NULL, FALSE);
-	value = g_hash_table_lookup(qof_choice_table, type);
+
+	value = g_hash_table_lookup(qof_choice_table, GINT_TO_POINTER(type));
 	if((GHashTable*)value) { return TRUE; }
-	DEBUG (" QOF_TYPE_CHOICE setup failed for %s\n", type);
+	DEBUG (" QOF_TYPE_CHOICE setup failed for %s\n", g_type_name(type));
 	return FALSE;
 }
 
 gboolean
-qof_choice_create(char* type)
+qof_choice_create(QofIdType type)
 {
 	GHashTable *param_table;
 
-	g_return_val_if_fail(type != NULL, FALSE);
 	g_return_val_if_fail(qof_choice_is_initialized() == TRUE, FALSE);
 	param_table = g_hash_table_new(g_str_hash, g_str_equal);
-	g_hash_table_insert(qof_choice_table, type, param_table);
+	g_hash_table_insert(qof_choice_table, GINT_TO_POINTER(type), param_table);
 	return TRUE;
 }
 
-gboolean qof_choice_add_class(const char* select,
+gboolean qof_choice_add_class(QofIdType select,
 			      char* option,
 			      char* param_name)
 {
@@ -76,9 +75,9 @@
 
 	option_list = NULL;
 	param_table = NULL;
-	g_return_val_if_fail(select != NULL, FALSE);
+	
 	g_return_val_if_fail(qof_object_is_choice(select), FALSE);
-	param_table = (GHashTable*)g_hash_table_lookup(qof_choice_table, select);
+	param_table = (GHashTable*)g_hash_table_lookup(qof_choice_table, GINT_TO_POINTER(select));
 	g_return_val_if_fail(param_table, FALSE);
 	option_list = (GList*)g_hash_table_lookup(param_table, param_name);
 	option_list = g_list_append(option_list, option);
@@ -91,15 +90,14 @@
 	GList *choices;
 	GHashTable *param_table;
 
-	g_return_val_if_fail(type != NULL, NULL);
 	g_return_val_if_fail(qof_choice_is_initialized() == TRUE, FALSE);
 	choices = NULL;
-	param_table = g_hash_table_lookup(qof_choice_table, type);
+	param_table = g_hash_table_lookup(qof_choice_table, GINT_TO_POINTER(type));
 	choices = g_hash_table_lookup(param_table, param->param_name);
 	return choices;
 }
 
-gboolean qof_choice_check(const char* choice_obj,
+gboolean qof_choice_check(QofIdType choice_obj,
 			  const char *param_name,
 			  const char* choice )
 {
@@ -108,7 +106,7 @@
 
 	choices = result = NULL;
 	g_return_val_if_fail(qof_object_is_choice(choice_obj), FALSE);
-	param_table = g_hash_table_lookup(qof_choice_table, choice_obj);
+	param_table = g_hash_table_lookup(qof_choice_table, GINT_TO_POINTER(choice_obj));
 	choices = g_hash_table_lookup(param_table, param_name);
 	result = g_list_find(choices, choice);
 	if(!result) { return FALSE; }

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofchoice.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofchoice.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofchoice.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -99,8 +99,6 @@
 @{
 */
 
-/** \brief Identify an object as containing a choice. */
-#define QOF_TYPE_CHOICE "choice"
 
 /** \brief Does this object contain a choice parameter?
 
@@ -116,7 +114,7 @@
 gboolean qof_object_is_choice(QofIdTypeConst type);
 
 /** \brief Set an object as using QOF_TYPE_CHOICE. */
-gboolean  qof_choice_create(char* type);
+gboolean  qof_choice_create(QofIdType type);
 
 /** \brief Add the choices for this parameter to the object.
 
@@ -127,7 +125,7 @@
 @return FALSE if object is not a choice object or on error
 	otherwise TRUE.
 */
-gboolean qof_choice_add_class(const char* choice, char* add, char* param_name);
+gboolean qof_choice_add_class(QofIdType select, char* add, char* param_name);
 
 /** \brief Return the list of all object types usable with this parameter.
 
@@ -150,7 +148,7 @@
 @return TRUE if choice is found in the list of allowed choices for
 this parameter of this object. Otherwise, FALSE
 */
-gboolean qof_choice_check(const char* choice_obj,
+gboolean qof_choice_check(QofIdType choice_obj,
 			  const char *param_name,
 			  const char* choice);
 /** @} */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofclass.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofclass.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofclass.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -57,8 +57,8 @@
   if (initialized) return;
   initialized = TRUE;
 
-  classTable = g_hash_table_new (g_str_hash, g_str_equal);
-  sortTable = g_hash_table_new (g_str_hash, g_str_equal);
+  classTable = g_hash_table_new (g_int_hash, g_int_equal);
+  sortTable = g_hash_table_new (g_int_hash, g_int_equal);
 }
 
 void
@@ -75,8 +75,7 @@
 QofSortFunc
 qof_class_get_default_sort (QofIdTypeConst obj_name)
 {
-  if (!obj_name) return NULL;
-  return g_hash_table_lookup (sortTable, obj_name);
+  return g_hash_table_lookup (sortTable, GINT_TO_POINTER (obj_name));
 }
 
 /* *******************************************************************/
@@ -90,21 +89,20 @@
   GHashTable *ht;
   int i;
 
-  if (!obj_name) return;
   if (!check_init()) return;
 
   if (default_sort_function)
   {
-    g_hash_table_insert (sortTable, (char *)obj_name, default_sort_function);
+    g_hash_table_insert (sortTable, GINT_TO_POINTER (obj_name), default_sort_function);
   }
 
-  ht = g_hash_table_lookup (classTable, obj_name);
+  ht = g_hash_table_lookup (classTable, GINT_TO_POINTER (obj_name));
 
   /* If it doesn't already exist, create a new table for this object */
   if (!ht)
   {
     ht = g_hash_table_new (g_str_hash, g_str_equal);
-    g_hash_table_insert (classTable, (char *)obj_name, ht);
+    g_hash_table_insert (classTable, GINT_TO_POINTER (obj_name), ht);
   }
 
   /* At least right now, we allow dummy, parameterless objects,
@@ -115,36 +113,35 @@
   {
     for (i = 0; params[i].param_name; i++)
       g_hash_table_insert (ht,
-               (char *)params[i].param_name,
-               (gpointer)&(params[i]));
+               (gpointer) (params[i].param_name),
+               (gpointer) &(params[i]));
   }
 }
 
 gboolean
 qof_class_is_registered (QofIdTypeConst obj_name)
 {
-  if (!obj_name) return FALSE;
   if (!check_init()) return FALSE;
 
-  if (g_hash_table_lookup (classTable, obj_name)) return TRUE;
+  if (g_hash_table_lookup (classTable, GINT_TO_POINTER (obj_name))) return TRUE;
 
   return FALSE;
 }
 
 const QofParam *
 qof_class_get_parameter (QofIdTypeConst obj_name,
-                          const char *parameter)
+                          const gchar* parameter)
 {
   GHashTable *ht;
 
-  g_return_val_if_fail (obj_name, NULL);
   g_return_val_if_fail (parameter, NULL);
   if (!check_init()) return NULL;
 
-  ht = g_hash_table_lookup (classTable, obj_name);
+  ht = g_hash_table_lookup (classTable, GINT_TO_POINTER (obj_name));
+
   if (!ht)
   {
-    PWARN ("no object of type %s", obj_name);
+    PWARN ("no object of type %s", g_type_name (obj_name));
     return NULL;
   }
 
@@ -153,11 +150,10 @@
 
 QofAccessFunc
 qof_class_get_parameter_getter (QofIdTypeConst obj_name,
-                                 const char *parameter)
+                                 const gchar* parameter)
 {
   const QofParam *prm;
 
-  g_return_val_if_fail (obj_name, NULL);
   g_return_val_if_fail (parameter, NULL);
 
   prm = qof_class_get_parameter (obj_name, parameter);
@@ -169,11 +165,10 @@
 
 QofSetterFunc
 qof_class_get_parameter_setter (QofIdTypeConst obj_name,
-                                 const char *parameter)
+                                 const gchar* parameter)
 {
   const QofParam *prm;
 
-  g_return_val_if_fail (obj_name, NULL);
   g_return_val_if_fail (parameter, NULL);
 
   prm = qof_class_get_parameter (obj_name, parameter);
@@ -185,14 +180,12 @@
 
 QofType
 qof_class_get_parameter_type (QofIdTypeConst obj_name,
-                               const char *param_name)
+                               const gchar* param_name)
 {
   const QofParam *prm;
 
-  if (!obj_name || !param_name) return NULL;
-
   prm = qof_class_get_parameter (obj_name, param_name);
-  if (!prm) return NULL;
+  if (!prm) return G_TYPE_INVALID;
 
   return (prm->param_type);
 }
@@ -208,7 +201,7 @@
 class_foreach_cb (gpointer key, gpointer item, gpointer arg)
 {
   struct class_iterate *iter = arg;
-  QofIdTypeConst id = key;
+  QofIdTypeConst id = GPOINTER_TO_INT (key);
 
   iter->fcn (id, iter->data);
 }
@@ -250,9 +243,9 @@
   struct parm_iterate iter;
   GHashTable *param_ht;
 
-  if (!obj_name || !cb) return;
+  if (!cb) return;
   if (!classTable) return;
-  param_ht = g_hash_table_lookup (classTable, obj_name);
+  param_ht = g_hash_table_lookup (classTable, GINT_TO_POINTER (obj_name));
   if (!param_ht) return;
 
   iter.fcn = cb;
@@ -273,18 +266,18 @@
 
 	b = (struct param_ref_list*)user_data;
 	if((param->param_getfcn == NULL)||(param->param_setfcn == NULL)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_STRING)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_NUMERIC)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_DATE)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_CHAR)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_DEBCRED)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_GUID)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_INT32)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_INT64)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_DOUBLE)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_KVP)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_BOOLEAN)) { return; }
-	if(0 == safe_strcmp(param->param_type, QOF_ID_BOOK)) { return; }
+	if((param->param_type == QOF_TYPE_STRING)) { return; }
+	if((param->param_type == QOF_TYPE_NUMERIC)) { return; }
+	if((param->param_type == QOF_TYPE_DATE)) { return; }
+	if((param->param_type == QOF_TYPE_CHAR)) { return; }
+	if((param->param_type == QOF_TYPE_DEBCRED)) { return; }
+	if((param->param_type == QOF_TYPE_GUID)) { return; }
+	if((param->param_type == QOF_TYPE_INT32)) { return; }
+	if((param->param_type == QOF_TYPE_INT64)) { return; }
+	if((param->param_type == QOF_TYPE_DOUBLE)) { return; }
+	if((param->param_type == QOF_TYPE_KVP)) { return; }
+	if((param->param_type == QOF_TYPE_BOOLEAN)) { return; }
+	if((param->param_type == QOF_ID_BOOK)) { return; }
 	b->list = g_list_append(b->list, param);
 }
 

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofclass.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofclass.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofclass.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -82,18 +82,19 @@
  @{
  */
 
-#define QOF_TYPE_STRING    "string"
-#define QOF_TYPE_DATE      "date"
-#define QOF_TYPE_NUMERIC   "numeric"
-#define QOF_TYPE_DEBCRED   "debcred"
-#define QOF_TYPE_GUID      "guid"
-#define QOF_TYPE_INT32     "gint32"
-#define QOF_TYPE_INT64     "gint64"
-#define QOF_TYPE_DOUBLE    "double"
-#define QOF_TYPE_BOOLEAN   "boolean"
-#define QOF_TYPE_KVP       "kvp"
-#define QOF_TYPE_CHAR      "character"
-#define QOF_TYPE_COLLECT   "collection" /**< secondary collections
+#define QOF_TYPE_STRING    G_TYPE_CHAR
+#define QOF_TYPE_DATE      G_TYPE_DATE
+#define QOF_TYPE_NUMERIC   GNC_TYPE_NUMERIC  
+#define QOF_TYPE_DEBCRED   GNC_TYPE_NUMERIC  // Used in Split, QofQuery, Session and Util to get a gnc_numeric, then asigned to this type
+#define QOF_TYPE_GUID      GNC_TYPE_GUID
+#define QOF_TYPE_INT32     G_TYPE_INT
+#define QOF_TYPE_INT64     G_TYPE_INT64
+#define QOF_TYPE_DOUBLE    G_TYPE_DOUBLE
+#define QOF_TYPE_BOOLEAN   G_TYPE_BOOLEAN
+#define QOF_TYPE_KVP       GNC_TYPE_KVP_FRAME
+#define QOF_TYPE_CHAR      G_TYPE_CHAR
+#define QOF_TYPE_CHOICE    G_TYPE_GTYPE  // FIXME
+#define QOF_TYPE_COLLECT   QOF_TYPE_COLLECTION /**< secondary collections
 are used for one-to-many references between entities and are
 implemented using ::QofCollection.
 These are \b NOT the same as the main collections in the QofBook.
@@ -123,7 +124,7 @@
 */
 /** @} */
 /** Type of Paramters (String, Date, Numeric, GUID, etc.) */
-typedef const char * QofType;
+typedef GType QofType;
 
 typedef struct _QofParam QofParam;
 
@@ -178,7 +179,7 @@
  */
 struct _QofParam 
 {
-  const char       * param_name;
+  const gchar       * param_name;
   QofType            param_type;
   QofAccessFunc      param_getfcn;
   QofSetterFunc      param_setfcn;
@@ -232,19 +233,19 @@
 
 /** Return the core datatype of the specified object's parameter */
 QofType qof_class_get_parameter_type (QofIdTypeConst obj_name,
-                                      const char *param_name);
+                                      const gchar* param_name);
 
 /** Return the registered Parameter Definition for the requested parameter */
 const QofParam * qof_class_get_parameter (QofIdTypeConst obj_name,
-                                          const char *parameter);
+                                          const gchar* parameter);
 
 /** Return the object's parameter getter function */
 QofAccessFunc qof_class_get_parameter_getter (QofIdTypeConst obj_name,
-                                              const char *parameter);
+                                              const gchar* parameter);
 
 /** Return the object's parameter setter function */
 QofSetterFunc qof_class_get_parameter_setter (QofIdTypeConst obj_name,
-                                              const char *parameter);
+                                              const gchar* parameter);
 
 /** Type definition for the class callback function. */
 typedef void (*QofClassForeachCB) (QofIdTypeConst, gpointer);

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofevent-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofevent-p.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofevent-p.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -43,9 +43,10 @@
 to the QofInstance and locating the book, editlevel or dirty flag.
 Use qof_event_gen instead.
 */
+/*
 void
 qof_event_generate (const GUID *guid, QofIdType e_type, 
-					QofEventId event_id);
+					QofEventId event_id); */
 
 /* generates an event even when events are suspended! */
 void qof_event_force (QofEntity *entity, QofEventId event_id, gpointer event_data);

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofevent.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofevent.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofevent.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -231,15 +231,7 @@
     HandlerInfo *hi = node->data;
 
     next_node = node->next;
-#ifndef QOF_DISABLE_DEPRECATED
-    if ((hi->old_handler) && (use_old_handlers))
-    {
-      PINFO(" deprecated: id=%d hi=%p han=%p", hi->handler_id, hi, 
-            hi->old_handler);
-      hi->old_handler ((GUID *)&entity->guid, entity->e_type,
-                       event_id, hi->user_data);
-    }
-#endif
+
     if (hi->handler)
     {
       PINFO("id=%d hi=%p han=%p data=%p", hi->handler_id, hi, 
@@ -296,6 +288,7 @@
 }
 
 /* deprecated */
+/*
 void 
 qof_event_generate (const GUID *guid, QofIdType e_type, 
 					QofEventId event_id)
@@ -304,8 +297,9 @@
   ent.guid = *guid;
   ent.e_type = e_type;
   if (suspend_counter) return;
-  /* caution: this is an incomplete entity! */
+  // caution: this is an incomplete entity!
   qof_event_generate_internal (&ent, event_id, NULL);
 }
+*/
 
 /* =========================== END OF FILE ======================= */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -26,6 +26,7 @@
 
 #include <string.h>
 #include <glib.h>
+#include <glib/gi18n-lib.h>
 
 #include "qof.h"
 #include "qofid-p.h"
@@ -38,6 +39,8 @@
 static void qof_collection_class_init(QofCollectionClass *klass);
 static void qof_collection_init(QofCollection *sp);
 static void qof_collection_finalize(GObject *object);
+static void qof_collection_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec);
+static void qof_collection_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 
 struct _QofCollectionPrivate
 {
@@ -52,6 +55,7 @@
 
 enum _QofCollectionSignalType {
 	/* Signals */
+	FIRST_SIGNAL,
 	LAST_SIGNAL
 };
 
@@ -70,7 +74,7 @@
 static GObjectClass *parent_class = NULL;
 
 GType
-qof_collection_get_type()
+qof_collection_get_type(void)
 {
 	static GType type = 0;
 
@@ -107,33 +111,39 @@
 	/* Install properties */
 	
 	g_object_class_install_property (object_class, PROP_TYPE,
-					 g_param_spec_object ("type", _("Object's GType the Collection holds"), NULL,
-                                                              	G_TYPE_GTYPE,
+					 g_param_spec_int ("type", NULL, _("Object's GType the Collection holds"),
+                                   G_MININT, G_MAXINT, G_TYPE_INVALID,
 							       								(G_PARAM_READABLE | G_PARAM_WRITABLE |
 																			G_PARAM_CONSTRUCT_ONLY)));
 	/* Create signals here:*/
  	
 }
 
+static guint id_hash (gconstpointer key);
+static gboolean id_compare(gconstpointer key_1, gconstpointer key_2);
+
 static void
 qof_collection_init(QofCollection *obj)
 {
 	/* Initialize private members, etc. */
-  col->priv = g_new0 (QofCollectionPrivate, 1);
+  obj->priv = g_new0 (QofCollectionPrivate, 1);
   
-  col->priv->type = G_TYPE_INVALID;
-  col->priv->hash_of_entities = g_hash_table_new (id_hash, id_compare);
+  obj->priv->type = G_TYPE_INVALID;
+  obj->priv->hash_of_entities = g_hash_table_new (id_hash, id_compare);
 }
 
 static void
 qof_collection_finalize(GObject *object)
 {
 	
+	QofCollection *col;
+	
+	col = QOF_COLLECTION (object);
 	/* Free private members, etc. */
 
-  g_hash_table_destroy(col->hash_of_entities);
-  col->type = G_TYPE_INVALID;
-  col->hash_of_entities = NULL;
+  g_hash_table_destroy(col->priv->hash_of_entities);
+  col->priv->type = G_TYPE_INVALID;
+  col->priv->hash_of_entities = NULL;
   
 	G_OBJECT_CLASS(parent_class)->finalize(object);
 }
@@ -147,14 +157,15 @@
 	QofCollection *obj;
 	
 	obj = QOF_COLLECTION (object);
+	
 	switch (param_id) {	
 		case PROP_TYPE:
 			if (obj->priv->hash_of_entities == NULL)
-			obj->priv->type =  g_value_get_gtype (value));
+			  obj->priv->type =  g_value_get_gtype (value);
 			break;
 		default:
    			/* We don't have any other property... */
-    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,param_id,pspec);
     	break;
 	}
 }
@@ -180,15 +191,13 @@
   }
 }
 
-static guint id_hash (gconstpointer key);
-static gboolean id_compare(gconstpointer key_1, gconstpointer key_2);
 
 QofCollection *
 qof_collection_new (GType type)
 {
   QofCollection *col;
   
-  g_return_val_if_fail (G_TYPE_IS_OBJECT (type));
+  g_return_val_if_fail (G_TYPE_IS_OBJECT (type), NULL);
   
   col = QOF_COLLECTION (g_object_new (QOF_TYPE_COLLECTION, "type", type));
   
@@ -203,28 +212,30 @@
   g_object_unref (col);
 }
 
-const GType
-qof_collection_get_g_type (const QofInstance *entity)
+GType
+qof_collection_get_g_type (const QofCollection *col)
 {
-	return collection->priv->type;
+	return col->priv->type;
 }
 
 
-void
+gboolean
 qof_collection_remove_element (QofCollection *coll, QofInstance *inst)
 {
   QofInstance *obj;
   
-  g_return_if_fail (QOF_IS_COLLECTION (coll) && QOF_IS_INSTANCE (inst));
+  g_return_val_if_fail (QOF_IS_COLLECTION (coll) && QOF_IS_INSTANCE (inst), FALSE);
   
-  obj = qof_collection_get_element (coll, qof_collection_get_guid (inst));
+  obj = qof_collection_lookup_element (coll, qof_instance_get_guid (inst));
   
-  g_return_if_fail (QOF_IS_INSTANCE (col)); 
+  g_return_val_if_fail (QOF_IS_INSTANCE (obj), FALSE); 
   
-  g_hash_table_remove (col->priv->hash_of_entities, qof_instance_get_guid (inst));
+  g_hash_table_remove (coll->priv->hash_of_entities, (gpointer) qof_instance_get_guid (inst));
   
   if (!qof_alt_dirty_mode)
-    qof_collection_mark_dirty (col);
+    qof_collection_mark_dirty (coll);
+    
+  return TRUE;
 }
 
 
@@ -238,7 +249,7 @@
 									QOF_IS_INSTANCE (inst), 
 									FALSE);
 	
-	g_hash_table_insert (coll->hash_of_entities, qof_instance_get_guid (inst), inst);
+	g_hash_table_insert (coll->priv->hash_of_entities, (gpointer) qof_instance_get_guid (inst), (gpointer) inst);
 	
 	if (!qof_alt_dirty_mode)
 	  qof_collection_mark_dirty(coll);
@@ -291,7 +302,7 @@
 		return; 
 	}
 	
-	g_return_if_fail (target->type == G_OBJECT_TYPE (inst));
+	g_return_if_fail (target->priv->type == G_OBJECT_TYPE (inst));
 	
 	e = qof_collection_lookup_element (target, qof_instance_get_guid (inst));
 	
@@ -344,9 +355,9 @@
   
   if (guid == NULL) return NULL;
   
-  ent = g_hash_table_lookup (col->priv->hash_of_entities, guid);
+  inst = g_hash_table_lookup (col->priv->hash_of_entities, guid);
   
-  return ent;
+  return inst;
 }
 
 QofCollection *
@@ -356,7 +367,7 @@
 	QofInstance *ent;
 	GList *list;
 
-	coll = qof_collection_new (book, type);
+	coll = qof_collection_new (type);
 	
 	for(list = glist; list != NULL; list = list->next)
 	{
@@ -433,19 +444,21 @@
 void 
 qof_collection_mark_dirty (QofCollection *col)
 {
-   if (col) { 
-   		col->priv->is_dirty = TRUE;
-   		qof_collection_mark_dirty (col->priv->book);
-   	}
+  g_return_if_fail (QOF_IS_COLLECTION (col));
+
+  col->priv->is_dirty = TRUE;
+
 }
-
+/*
+* This code isn't used any where.... :-|?
 void
-qof_collection_print_dirty (const QofCollection *col, gpointer dummy)
+qof_collection_print_dirty (QofCollection *col, gpointer dummy)
 {
   if (col->priv->is_dirty)
-    printf("%s collection is dirty.\n", col->priv->e_type);
+    printf("%s collection is dirty.\n", g_type_name (col->priv->type));
   qof_collection_foreach(col, (QofInstanceForeachCB)qof_instance_print_dirty, NULL);
 }
+*/
 
 /* =============================================================== */
 
@@ -463,7 +476,7 @@
 }
 
 void
-qof_collection_foreach (const QofCollection *col, QofInstanceForeachCB cb_func, 
+qof_collection_foreach (QofCollection *col, QofInstanceForeachCB cb_func, 
                         gpointer user_data)
 {
   struct _iterate iter;

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -73,7 +73,7 @@
     @author Copyright (C) 2003 Linas Vepstas <linas at linas.org>
     @author Copyright (C) 2007 Daniel Espinosa <esodan at gmail.com>
 */
-
+#include "qofinstance.h"
 #include <string.h>
 #include <glib-object.h>
 #include "guid.h"
@@ -85,6 +85,17 @@
 /** QofLogModule declaration */
 typedef const gchar* QofLogModule;
 
+/** QofIdType declaration */
+typedef GType QofIdType;
+/** QofIdTypeConst declaration */
+typedef GType QofIdTypeConst;
+
+#define QOF_ID_NONE           G_TYPE_NONE
+#define QOF_ID_NULL           G_TYPE_INVALID
+#define QOF_ID_BOOK           QOF_TYPE_BOOK
+#define QOF_ID_SESSION        "Session"
+
+
 /* GObject declarations */
 
 #define QOF_TYPE_COLLECTION            (qof_collection_get_type ())
@@ -114,7 +125,7 @@
 };
 
 
-GType qof_entity_get_type ();
+GType qof_collection_get_type (void);
 
 /** create a new collection of entities of type */
 QofCollection * qof_collection_new (GType type);
@@ -122,17 +133,17 @@
 /** return the number of entities in the collection. */
 guint qof_collection_count (const QofCollection *col);
 
-/** destroy the collection */
 void qof_collection_destroy (QofCollection *col);
 
 /** return the type that the collection stores */
-GType qof_collection_get_g_type (const QofCollection *);
+GType qof_collection_get_g_type (const QofCollection *col);
 
+
 /** Find the entity going only from its guid */
-QofInstance * qof_collection_lookup_element (const QofCollection *, const GUID *);
+QofInstance* qof_collection_lookup_element (const QofCollection *col, const GUID *guid);
 
 /** Call the callback for each entity in the collection. */
-void qof_collection_foreach (const QofCollection *, QofEntityForeachCB, 
+void qof_collection_foreach (QofCollection *col, QofInstanceForeachCB cb_func, 
                              gpointer user_data);
 
 /** Store and retreive arbitrary object-defined data 
@@ -141,8 +152,8 @@
  * destroyed, so that the user has a chance to clean up anything
  * that was put in the 'data' member here.
  */
-gpointer qof_collection_get_data (const QofCollection *col);
-void qof_collection_set_data (QofCollection *col, gpointer user_data);
+#define qof_collection_get_data(col) (g_object_get_data(G_OBJECT(col), "SOME_DATA"))
+#define qof_collection_set_data(col, user_data) (g_object_set_data(G_OBJECT(col), "SOME_DATA", user_data))
 
 /** Return value of 'dirty' flag on collection */
 gboolean qof_collection_is_dirty (const QofCollection *col);
@@ -167,19 +178,18 @@
 by using ::qof_entity_insert_entity or ::qof_entity_remove_entity. 
 
 */
-gboolean
-qof_collection_add_element (QofCollection *coll, QofInstance *inst);
+gboolean qof_collection_add_element (QofCollection *coll, QofInstance *inst);
 
-gboolean
-qof_collection_remove_element (QofCollection *coll, QofInstance *ent);
+gboolean qof_collection_remove_element (QofCollection *coll, QofInstance *inst);
 
-/** \brief Merge two QOF_TYPE_COLLECT of the same type.
 
+/* \brief Merge two QOF_TYPE_COLLECT of the same type.
+
 \note \b NOT the same as the main collections in the book.
 
 QOF_TYPE_COLLECT uses a secondary collection, independent of
 those in the book. Entities will not be removed from the
-original collection as when using ::qof_entity_insert_entity
+original collection as when using ::qof_instance_insert_entity
 or ::qof_entity_remove_entity.
 
 */
@@ -211,7 +221,7 @@
 	on success.
 */
 QofCollection*
-qof_collection_from_glist (QofIdType type, GList *glist);
+qof_collection_from_glist (QofBook *book, GType      type, GList *glist);
 
 /******************************************************/
 

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -31,9 +31,13 @@
 #include <glib.h>
 #include "qof.h"
 #include "kvp-util-p.h"
+#include "qofbook.h"
 #include "qofbook-p.h"
+#include "qofid.h"
 #include "qofid-p.h"
 #include "qofinstance-p.h"
+#include <glib/gi18n-lib.h>
+#include "qofbackend.h"
 
 static QofLogModule log_module = QOF_MOD_ENGINE;
 
@@ -42,7 +46,10 @@
 static void qof_instance_class_init(QofInstanceClass *klass);
 static void qof_instance_init(QofInstance *sp);
 static void qof_instance_finalize(GObject *object);
+static void qof_instance_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec);
+static void qof_instance_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 
+
 struct _QofInstancePrivate
 {
 
@@ -86,6 +93,8 @@
 
 enum _QofInstanceSignalType {
 	/* Signals */
+	BEGIN_EDIT,
+	BEGIN_COMMIT,
 	COMMITED,
 	LAST_SIGNAL
 };
@@ -105,7 +114,7 @@
 static GObjectClass *parent_class = NULL;
 
 GType
-qof_instance_get_type()
+qof_instance_get_type(void)
 {
 	static GType type = 0;
 
@@ -122,7 +131,7 @@
 			(GInstanceInitFunc)qof_instance_init,
 		};
 
-		type = g_type_register_static(QOF_TYPE_ENTITY, 
+		type = g_type_register_static(G_TYPE_OBJECT, 
 			"QofInstance", &our_info, 0);
 	}
 
@@ -141,53 +150,70 @@
 
 	/* Install properties */
 	g_object_class_install_property (object_class, PROP_BOOK,
-					 g_param_spec_object ("book", _("Book"), NULL,
-                                                              	QOF_TYPE_BOOK,
+					 g_param_spec_object ("book", NULL, _("Book"), QOF_TYPE_BOOK,
 							       								(G_PARAM_READABLE | G_PARAM_WRITABLE |
 																			G_PARAM_CONSTRUCT_ONLY)));
 
 	/* Create signals here:*/
 	
 	qof_instance_signals[COMMITED] =
-			g_signal_new ("commited",
-				      GNC_TYPE_INSTANCE,
-				      G_SIGNAL_RUN_LAST,
-				      NULL, NULL, NULL,
+			g_signal_new ("commit:finished",
+				      QOF_TYPE_INSTANCE,
+				      G_SIGNAL_RUN_FIRST,
+				      0, NULL, NULL,
 				      g_cclosure_marshal_VOID__VOID,
 				      G_TYPE_NONE, 0, NULL);
  	
+ 	qof_instance_signals[BEGIN_COMMIT] =
+			g_signal_new ("commit:beginning",
+				      QOF_TYPE_INSTANCE,
+				      G_SIGNAL_RUN_FIRST,
+				      0, NULL, NULL,
+				      g_cclosure_marshal_VOID__VOID,
+				      G_TYPE_NONE, 0, NULL);
+ 	
+ 	qof_instance_signals[BEGIN_EDIT] =
+			g_signal_new ("begin_edit",
+				      QOF_TYPE_INSTANCE,
+				      G_SIGNAL_RUN_FIRST,
+				      0, NULL, NULL,
+				      g_cclosure_marshal_VOID__VOID,
+				      G_TYPE_NONE, 0, NULL);
+	
+				      
 }
 
 static void
 qof_instance_init(QofInstance *obj)
 {
+	
 	/* Initialize private members, etc. */
-	inst->priv = g_new0 (QofInstancePrivate, 1);
+	obj->priv = g_new0 (QofInstancePrivate, 1);
 	
-	inst->priv->book = NULL;
-	inst->priv->kvp_data = kvp_frame_new();
-	inst->priv->last_update.tv_sec = 0;
-	inst->priv->last_update.tv_nsec = -1;
-	inst->priv->editlevel = 0;
-	inst->priv->do_free = FALSE;
-	inst->priv->dirty = FALSE;
-	inst->priv->infant = TRUE;
-	inst->priv->guid = NULL;
+	obj->priv->book = NULL;
+	obj->priv->kvp_data = kvp_frame_new();
+	obj->priv->last_update.tv_sec = 0;
+	obj->priv->last_update.tv_nsec = -1;
+	obj->priv->editlevel = 0;
+	obj->priv->do_free = FALSE;
+	obj->priv->dirty = FALSE;
+	obj->priv->infant = TRUE;
+	obj->priv->guid = NULL;
 }
 
 static void
 qof_instance_finalize(GObject *object)
 {
-	
+	QofInstance *inst = QOF_INSTANCE (object);
 	/* Free private members, etc. */
 	kvp_frame_delete (inst->priv->kvp_data);
 	inst->priv->kvp_data = NULL;
 	inst->priv->editlevel = 0;
 	inst->priv->do_free = FALSE;
 	inst->priv->dirty = FALSE;
-	qof_book_remove_element (QOF_INSTANCE (object));
+	qof_book_remove_element (inst->priv->book, inst);
+	guid_free (inst->priv->guid);
 	
-	
 	G_OBJECT_CLASS(parent_class)->finalize(object);
 }
 
@@ -203,11 +229,12 @@
 	
 	switch (param_id) {		
 		case PROP_BOOK:
-			obj->priv->book = qof_instance_set_book (obj, QOF_BOOK (g_value_get_object (value)));
+			qof_instance_set_book (obj, QOF_BOOK (g_value_get_object (value)));
+			obj->priv->book = QOF_BOOK (g_value_get_object (value));
 			break;
 		default:
    			/* We don't have any other property... */
-    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,param_id,pspec);
     	break;
 	}
 }
@@ -228,7 +255,7 @@
   	break;
   default:
     /* We don't have any other property... */
-    G_OBJECT_WARNinst->priv = g_new0 (QofInstancePrivate, 1);
+    G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
     break;
   }
 }
@@ -239,20 +266,20 @@
 /* ========================================================== */
 
 void
-qof_instance_set_book (QofInstance *instance, QofBook *book)
+qof_instance_set_book (QofInstance *inst, QofBook *book)
 {
 	QofCollection *coll;
 		
 	g_return_if_fail (QOF_IS_BOOK (book));
 	
 	
-	if ( QOF_IS_BOOK (inst->book) && instance->priv->guid != NULL) 
+	if ( QOF_IS_BOOK (inst->priv->book) && inst->priv->guid != NULL) 
 	{		
-		if (QOF_IS_INSTANCE (qof_book_get_element (inst->book, G_OBJECT_TYPE (instance), ent->priv->guid)))
+		if (QOF_IS_INSTANCE (qof_book_get_element (inst->priv->book, G_OBJECT_TYPE (inst), inst->priv->guid)))
 		{
-			qof_collection_remove_element (qof_book_get_collection (ent->priv->book, 
-																										G_OBJECT_TYPE (instance)), 
-																										instance);
+			qof_collection_remove_element (qof_book_get_collection (inst->priv->book, 
+																										G_OBJECT_TYPE (inst)), 
+																										inst);
 		}
 		inst->priv->book = book;
 	}
@@ -271,7 +298,7 @@
   		{
    			 guid_new (guid);
 
-   			 if (NULL == qof_book_get_element (instance->priv->book, G_OBJECT_TYPE (instance), guid)) break;
+   			 if (NULL == qof_book_get_element (inst->priv->book, G_OBJECT_TYPE (inst), guid)) break;
 
     		PWARN("duplicate id created, trying again");
   		} while(1);
@@ -279,19 +306,14 @@
   		inst->priv->guid = guid;
   	}
   	
-  	qof_book_insert_element (instance->priv->book, instance);
+  	qof_book_insert_element (inst->priv->book, inst);
 }
 
-QofCollection* 
-qof_instance_get_collection (QofInstance *instance)
-{
-	return qof_book_get_collection (instance->priv->book, G_OBJECT_TYPE (instance));
-}
 
 /* This is a restricted function, should be used only during 
  * read from file */
 void
-qof_instance_set_guid (QofInstance *inst, const GUID *guid)
+qof_instance_set_guid (QofInstance *inst, GUID *guid)
 {
   if (guid_equal (guid, inst->priv->guid)) return;
 
@@ -311,20 +333,37 @@
 	return inst;
 }
 
-
 void
-qof_instance_destroy (QofInstance *inst)
+qof_instance_release (QofInstance *inst)
 {
-	qof_instance_begin_edit (inst);
-	qof_instance_commit_edit (inst);
 	g_object_unref (G_OBJECT (inst));
 }
 
-const GUID *
-qof_instance_get_guid (const QofInstance *inst)
+
+gboolean
+qof_instance_destroy (QofInstance *inst, GError **error)
 {
-	g_return_value_if_fail (QOF_IS_INSTANCE(inst), NULL);
+	qof_instance_begin_edit (inst, error);
+	if(error) {
+	  return FALSE;
+	}
+	qof_instance_commit_edit (inst, error);
+	if(error) {
+	/*FIXME: Add actions to cancel the commit if exist an error*/
+	  return FALSE;
+	}
+	
+	qof_event_gen (inst, QOF_EVENT_DESTROY, NULL);
+	
+	g_object_unref (G_OBJECT (inst));
+	return TRUE;
+}
 
+GUID *
+qof_instance_get_guid (QofInstance *inst)
+{
+	g_return_val_if_fail (QOF_IS_INSTANCE(inst), NULL);
+
 	return inst->priv->guid;
 }
 
@@ -359,34 +398,42 @@
 	if (!left && !right) return 0;
 	if (!left) return -1;
 	if (!right) return +1;
-	if (left->last_update.tv_sec < right->last_update.tv_sec) return -1;
-	if (left->last_update.tv_sec > right->last_update.tv_sec) return +1;
-	if (left->last_update.tv_nsec < right->last_update.tv_nsec) return -1;
-	if (left->last_update.tv_nsec > right->last_update.tv_nsec) return +1;
+	if (left->priv->last_update.tv_sec < right->priv->last_update.tv_sec) return -1;
+	if (left->priv->last_update.tv_sec > right->priv->last_update.tv_sec) return +1;
+	if (left->priv->last_update.tv_nsec < right->priv->last_update.tv_nsec) return -1;
+	if (left->priv->last_update.tv_nsec > right->priv->last_update.tv_nsec) return +1;
 	return 0;
 }
 
 void
-qof_instance_print_dirty (const QofEntity *entity, gpointer dummy)
+qof_instance_print_dirty (QofInstance *inst, gpointer dummy)
 {
-  QofInstance *inst = QOF_INSTANCE(entity);
 
   if (inst->priv->dirty)
-    printf("%s instance %s is dirty.\n", qof_entity_get_qof_type (QOF_ENTITY (inst),
-	   guid_to_string(qof_entity_get_guid (QOF_ENTITY (inst)))));
+    printf("%s instance %s is dirty.\n", g_type_name (G_OBJECT_TYPE (inst)),
+	   guid_to_string(qof_instance_get_guid (inst)));
 }
 
 gboolean
 qof_instance_is_dirty (QofInstance *inst)
 {
 	QofCollection *coll;
+  g_return_val_if_fail (QOF_IS_INSTANCE (inst), FALSE);
 
-	if (!inst) { return FALSE; }
 	if (qof_get_alt_dirty_mode())
+	{
 	  return inst->priv->dirty;
-	coll = qof_entity_get_collection (QOF_ENTITY (inst));
-	if(qof_collection_is_dirty(coll)) { return inst->priv->dirty; }
+	}
+	 
+	coll = qof_instance_get_collection (inst);
+	
+	if(qof_collection_is_dirty(coll)) 
+	{
+	  return inst->priv->dirty; 
+	}
+	
 	inst->priv->dirty = FALSE;
+	
 	return FALSE;
 }
 
@@ -398,8 +445,9 @@
 	if (value) {
 		inst->priv->dirty = TRUE;
 		if (!qof_get_alt_dirty_mode()) {
-		  coll = qof_entity_get_collection (QOF_ENTITY (inst));
+		  coll = qof_book_get_collection (inst->priv->book, G_OBJECT_TYPE (inst));
 		  qof_collection_mark_dirty(coll);
+		  qof_book_mark_dirty (inst->priv->book); // This actualy a macro becouse the QofBook is a QofInstane: TODO: Check if QofBook could be a GObject 
 		}
 	}
 	inst->priv->dirty = FALSE;
@@ -462,21 +510,21 @@
   time_t now;
 
   /* Books must differ for a gemini to be meaningful */
-  if (!from || !to || (from->book == to->book)) return;
+  if (!from || !to || (from->priv->book == to->priv->book)) return;
 
   now = time(0);
 
   /* Make a note of where the copy came from */
-  gnc_kvp_bag_add (to->kvp_data, "gemini", now,
-                                  "inst_guid", &from->entity.guid,
-                                  "book_guid", &from->book->inst.entity.guid,
+  gnc_kvp_bag_add (to->priv->kvp_data, "gemini", now,
+                                  "inst_guid", &from->priv->guid,
+                                  "book_guid", qof_instance_get_guid (QOF_INSTANCE (from->priv->book)),
                                   NULL);
-  gnc_kvp_bag_add (from->kvp_data, "gemini", now,
-                                  "inst_guid", &to->entity.guid,
-                                  "book_guid", &to->book->inst.entity.guid,
+  gnc_kvp_bag_add (from->priv->kvp_data, "gemini", now,
+                                  "inst_guid", &to->priv->guid,
+                                  "book_guid", qof_instance_get_guid (QOF_INSTANCE (to->priv->book)),
                                   NULL);
 
-  to->dirty = TRUE;
+  to->priv->dirty = TRUE;
 }
 
 QofInstance *
@@ -490,13 +538,13 @@
 	if (!src || !target_book) return NULL;
 	ENTER (" ");
 
-	fr = gnc_kvp_bag_find_by_guid (src->kvp_data, "gemini",
-	                             "book_guid", &target_book->inst.entity.guid);
+	fr = gnc_kvp_bag_find_by_guid (src->priv->kvp_data, "gemini",
+	                             "book_guid", qof_instance_get_guid (QOF_INSTANCE (target_book)));
 
 	twin_guid = kvp_frame_get_guid (fr, "inst_guid");
 
-	col = qof_book_get_collection (target_book, src->entity.e_type);
-	twin = (QofInstance *) qof_collection_lookup_entity (col, twin_guid);
+	col = qof_book_get_collection (target_book, G_OBJECT_TYPE (src));
+	twin = (QofInstance *) qof_collection_lookup_element (col, twin_guid);
 
 	LEAVE (" found twin=%p", twin);
 	return twin;
@@ -507,58 +555,96 @@
 KvpFrame* 
 qof_instance_get_kvp_data (const QofInstance *instance)
 {
-	return instance->kvp_data;
+	return instance->priv->kvp_data;
 }
 
 void			
 qof_instance_set_kvp_data (QofInstance *instance, KvpFrame *data)
 {
-	kvp_frame_delete (instance->kvp_data);
-	instance->kvp_data = kvp_frame_copy (data);
+	kvp_frame_delete (instance->priv->kvp_data);
+	instance->priv->kvp_data = kvp_frame_copy (data);
 }
 
+void
+qof_instance_delete_kvp_data (QofInstance *inst)
+{
+  kvp_frame_delete (inst->priv->kvp_data);
+}
+
 /* Gets the Instance's Edit Level*/
 gint qof_instance_get_edit_level (const QofInstance *instance)
 {
-	return instance->editlevel;
+	return instance->priv->editlevel;
 }
 
-void 		qof_instance_set_edit_level (QofInstance *instance, gint editlevel)
+void 		
+qof_instance_set_edit_level (QofInstance *instance, gint editlevel)
 {
-	instance->editlevel = editlevel;
+	instance->priv->editlevel = editlevel;
 }
 
-const char* qof_instance_printable (QofInstance *inst)
+
+void
+qof_instance_foreach (QofInstance *inst, 
+                      QofInstanceForeachCB cb_func, 
+                      gpointer user_data)
 {
-	g_return_if_fail (QOF_IS_INSTANCE (inst));
+  QofCollection *col;
+  
+  g_return_if_fail (QOF_IS_INSTANCE (inst));
 	
-	if (QOF_INSTANCE_GET_CLASS (inst)->printable)
-		(QOF_INSTANCE_GET_CLASS (inst)->printable) (inst);
+	if (QOF_INSTANCE_GET_CLASS (inst)->foreach)
+		(QOF_INSTANCE_GET_CLASS (inst)->foreach) (inst, cb_func, user_data);
 	else
+	{
+		g_warning ("%s() calling default handler\n", __FUNCTION__);
+		
+		col = qof_book_get_collection (inst->priv->book, G_OBJECT_TYPE (inst));
+		qof_collection_foreach (col, cb_func, user_data);
+	}
+}
+
+gchar*
+qof_instance_to_string (QofInstance *inst)
+{
+	gchar* ret = NULL;
+	
+	g_return_val_if_fail (QOF_IS_INSTANCE (inst), NULL);
+	
+	if (QOF_INSTANCE_GET_CLASS (inst)->to_string)
+	{
+	  ret = ((QOF_INSTANCE_GET_CLASS (inst)->to_string) (inst));
+		return ret;
+	}
+	else
+	{
 		g_warning ("%s() method not supported\n", __FUNCTION__);
+		return NULL;
+	}
 }
 
 gboolean
 qof_instance_begin_edit (QofInstance *inst, GError **error)
 {
   QofBackend * be;
-
-  g_return_val_if_fail (QOF_IS_INSTANCE (inst),FALSE);
   
+  g_return_val_if_fail (QOF_IS_INSTANCE (inst), FALSE);
+  
+  g_signal_emit_by_name (inst, "begin-edit");
+  
   inst->priv->editlevel++;
   
-  g_return_val_if_fail (1 < inst->priv->editlevel), FALSE);
+  g_return_val_if_fail ((1 < inst->priv->editlevel), FALSE);
   
-  if (0 >= inst->editlevel) 
-      inst->editlevel = 1;
+  if (0 >= inst->priv->editlevel) 
+      inst->priv->editlevel = 1;
 
   be = qof_book_get_backend (inst->priv->book);
   
-  if (QOF_IS_BACKEND (be) && qof_backend_begin_exists(be))
+  if (be && qof_backend_begin_exists(be))
       qof_backend_run_begin (be, inst, error);
   else
-      inst->priv->dirty = TRUE; 
-  
+      inst->priv->dirty = TRUE;
   return TRUE;
 }
 
@@ -568,11 +654,18 @@
   QofBackend * be;
   gboolean dirty;
 
-  g_return_val_if_fail(QOF_IS_INSTANCE(inst), FALSE);
+  g_return_val_if_fail (QOF_IS_INSTANCE(inst), FALSE);
   
+  /* 	IMPROVEMENT: call a callback with a return type to see if I can actualy commit or not
+  *	for example, in GncTransaction you can check if it is readonly, if you can't commit this function
+  *	must return and set the error variable with the error (even better the **error pointer could be
+  *	a parameter to the callback and set by it).
+  */  
+  g_signal_emit_by_name (inst, "commit:beginning");
+  
   inst->priv->editlevel--;
   
-  dirty = inst->dirty;
+  dirty = inst->priv->dirty;
   
   if (0 < inst->priv->editlevel) return FALSE;
 
@@ -582,16 +675,16 @@
     
     if (be && qof_backend_commit_exists(be)) {
 
-        qof_backend_run_commit(be, inst, &error);
+        qof_backend_run_commit(be, inst, error);
         
         if (error) {
             /* XXX Should perform a rollback here */
-            inst->do_free = FALSE;
+            inst->priv->do_free = FALSE;
 
             return FALSE;
         }   
         /* XXX the backend commit code should clear dirty!! */
-        inst->dirty = FALSE;
+        inst->priv->dirty = FALSE;
     
     }
   }
@@ -602,11 +695,11 @@
         	may be qof_book_mark_dirty (QofBook, GType) the you will mark the book and the
         	collection with that GType
         */
-      qof_collection_mark_dirty(qof_book_get_collection(inst->priv->book, 	G_TYPE_OBJECT(inst)));
+      qof_collection_mark_dirty(qof_book_get_collection(inst->priv->book, 	G_OBJECT_TYPE(inst)));
       qof_book_mark_dirty(inst->priv->book);
     }
     
-    inst->infant = FALSE;
+    inst->priv->infant = FALSE;
     
     if (0 > inst->priv->editlevel) { 
       
@@ -620,7 +713,9 @@
 	  }
 	  
 	  return FALSE;
-  	}  
+  	} 
+  	
+  	g_signal_emit_by_name (inst, "commit:finished"); 
     
     return TRUE;
 

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -36,12 +36,16 @@
 #ifndef QOF_INSTANCE_H
 #define QOF_INSTANCE_H
 
+#include <glib-object.h>
 #include "guid.h"
 #include "gnc-date.h"
 #include "kvp_frame.h"
-#include "qofbook.h"
-#include "qofid.h"
 
+#ifndef QOF_BOOK_H
+#define QOF_BOOK_DEFINED
+typedef struct _QofBook QofBook;
+#endif
+
 /* GObject declarations */
 
 #define QOF_TYPE_INSTANCE            (qof_instance_get_type ())
@@ -51,40 +55,46 @@
 #define QOF_IS_INSTANCE_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_INSTANCE))
 #define QOF_INSTANCE_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_INSTANCE, QofInstanceClass))
 
-
 typedef struct _QofInstanceClass QofInstanceClass;
 typedef struct _QofInstancePrivate QofInstancePrivate;
 typedef struct _QofInstance QofInstance;
+#define QofEntity QofInstance /* Backward compatibility, the QofEntity is now "part" of QofInstance */
 
 struct _QofInstance {
 	GObject object;
 	QofInstancePrivate *priv;
 };
 
+typedef void (*QofInstanceForeachCB) (QofInstance *inst, gpointer user_data);
+
+typedef QofInstanceForeachCB QofEntityForeachCB; /* Backward compatibility */
+
 struct _QofInstanceClass {
 	GObjectClass parent_class;
 	/* virtual table */
-	 void                	(*foreach)			(const QofCollection *, QofEntityForeachCB, gpointer);
-	 const char *      (*to_string)			(gpointer instance);
-	 void					(*commit)			(QofInstance* instance);
-	 void					
+	 void        (*foreach) 			(QofInstance *inst, QofInstanceForeachCB cb_func, gpointer user_data);
+	 gchar*      (*to_string)			(gpointer instance);
 	/* Add Signal Functions Here */
 };
 
-GType   qof_instance_get_type ();
+GType   qof_instance_get_type (void);
 
+
+
+
 /** Return the book pointer */
-QofBook * qof_instance_get_book (const QofInstance *);
+QofBook * qof_instance_get_book (const QofInstance *inst);
+void      qof_instance_set_book (QofInstance *inst, QofBook *book);
 
-QofCollection* qof_instance_get_collection (QofInstance *entity);
+#define qof_instance_get_collection(o) qof_book_get_collection(qof_instance_get_book(o), G_OBJECT_TYPE(o))
 
 /** Return the GUID of this instance */
-const GUID * qof_instance_get_guid (const QofInstance *);
+GUID* qof_instance_get_guid (QofInstance *inst);
 
 /** Set the ID of the entity, over-riding the previous ID. 
  *  Very dangerous, use only for file i/o work. 
  */
-void qof_entity_set_guid (QofInstance *inst, const GUID *guid);
+void qof_instance_set_guid (QofInstance *inst, GUID *guid);
 
 /** Return the pointer to the kvp_data */
 KvpFrame* qof_instance_get_slots (const QofInstance *);
@@ -106,7 +116,7 @@
  */
 int qof_instance_version_cmp (const QofInstance *left, const QofInstance *right);
 
-void qof_instance_print_dirty (const QofEntity *entity, gpointer dummy);
+void qof_instance_print_dirty (QofInstance *inst, gpointer dummy);
 
 /** Return value of is_dirty flag */
 gboolean qof_instance_is_dirty (QofInstance *);
@@ -125,10 +135,12 @@
 
 QofInstance* qof_instance_create (GType type, QofBook *book);
 
-void qof_instance_destroy (QofInstance *inst);
+gboolean qof_instance_destroy (QofInstance *inst, GError **error);
 
-#define qof_instance_release(instance) qof_instance_destroy(instance)
+void qof_instance_release (QofInstance *instance);
 
+#define qof_entity_release(obj) qof_instance_release (QOF_INSTANCE (obj))
+
 /** Pair things up.  This routine inserts a kvp value into each instance
  *  containing the guid of the other.  In this way, if one has one of the
  *  pair, one can always find the other by looking up it's guid.  Typically,
@@ -158,22 +170,36 @@
 
 KvpFrame* qof_instance_get_kvp_data (const QofInstance *instance);
 void			qof_instance_set_kvp_data (QofInstance *instance, KvpFrame *data);
+void      qof_instance_delete_kvp_data (QofInstance *inst);
 
 gint		 	qof_instance_get_edit_level (const QofInstance *instance);
 void 		qof_instance_set_edit_level (QofInstance *instance, gint editlevel);
 
-#define qof_object_new_instance (type, book) g_object_new (type, "book", book, NULL)
+#define qof_object_new_instance(type, book) g_object_new (type, "book", book, NULL)
 
-const char *      qof_instance_to_string			(QofInstance *instance);
+void    qof_instance_foreach			(QofInstance *inst, QofInstanceForeachCB cb_func, gpointer user_data);
 
-#define qof_object_printable (type, instance) qof_instance_to_string (instance)
 
-gboolean qof_instance_begin_edit (QofInstance *inst, GError *error);
+gchar *      qof_instance_to_string			(QofInstance *instance);
 
-gboolean qof_instance_commit_edit(QofInstance *inst, GError *error);
+#define qof_object_printable(type, instance) qof_instance_to_string (instance)
 
-gboolean qof_instance_destroy (QofInstance *inst);
+gboolean qof_instance_begin_edit (QofInstance *inst, GError **error);
 
+gboolean qof_instance_commit_edit(QofInstance *inst, GError **error);
+
+
+/** Return The kvp data for the book.
+ *  Note that the book KVP data is persistent, and is stored/retrieved
+ *  from the file/database.  Thus, the book KVP is the correct place to
+ *  store data that needs to be persistent accross sessions (or shared
+ *  between multiple users).  To store application runtime data, use
+ *  qof_book_set_data() instead.
+
+		DEPRECATED: use qof_instance_get_slots instead
+ */
+#define qof_book_get_slots(book) qof_instance_get_slots(QOF_INSTANCE(book))
+
 /* @} */
 /* @} */
 #endif /* QOF_INSTANCE_H */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -38,12 +38,13 @@
 static GList *book_list = NULL;
 static GHashTable *backend_data = NULL;
 
+/* DEPRACATED use g_object_new see qofinstance.h
 gpointer
 qof_object_new_instance (QofIdTypeConst type_name, QofBook *book)
 {
   const QofObject *obj;
 
-  if (!type_name) return NULL;
+  if (type_name == G_TYPE_INVALID) return NULL;
 
   obj = qof_object_lookup (type_name);
   if (!obj) return NULL;
@@ -53,6 +54,7 @@
 
   return NULL;
 }
+*/
 
 void qof_object_book_begin (QofBook *book)
 {
@@ -146,14 +148,14 @@
 	if((obj->create == NULL)||(obj->foreach == NULL)){
 		if(warn) 
 		{
-			PINFO (" Object type %s is not fully QOF compliant", obj->e_type);
+			PINFO (" Object type %s is not fully QOF compliant", g_type_name (obj->e_type));
 		}
 		return FALSE;
 	}
 	return TRUE;
 }
 
-
+/* DEPRACATED see qofinstance.h
 void 
 qof_object_foreach (QofIdTypeConst type_name, QofBook *book, 
                     QofEntityForeachCB cb, gpointer user_data)
@@ -179,6 +181,8 @@
   return;
 }
 
+
+
 const char *
 qof_object_printable (QofIdTypeConst type_name, gpointer obj)
 {
@@ -194,7 +198,7 @@
 
   return NULL;
 }
-
+*/
 const char * qof_object_get_type_label (QofIdTypeConst type_name)
 {
   const QofObject *obj;
@@ -213,10 +217,10 @@
   return TRUE;
 }
 
+
 /* INITIALIZATION and PRIVATE FUNCTIONS */
 
-void qof_object_initialize (void)
-{
+void qof_object_initialize (void){
   if (object_is_initialized) return;
   backend_data = g_hash_table_new (g_str_hash, g_str_equal);
   object_is_initialized = TRUE;
@@ -275,7 +279,7 @@
 
   for (iter = object_modules; iter; iter = iter->next) {
     obj = iter->data;
-    if (!safe_strcmp (obj->e_type, name))
+    if (obj->e_type == name)
       return obj;
   }
   return NULL;
@@ -288,7 +292,7 @@
   GHashTable *ht;
   g_return_val_if_fail (object_is_initialized, FALSE);
 
-  if (!type_name || *type_name == '\0' ||
+  if (!type_name || type_name == G_TYPE_INVALID ||
       !backend_name || *backend_name == '\0' ||
       !be_data)
     return FALSE;
@@ -297,12 +301,12 @@
 
   /* If it doesn't already exist, create a new table for this backend */
   if (!ht) {
-    ht = g_hash_table_new (g_str_hash, g_str_equal);
+    ht = g_hash_table_new (g_int_hash, g_int_equal);
     g_hash_table_insert (backend_data, (char *)backend_name, ht);
   }
 
   /* Now insert the data */
-  g_hash_table_insert (ht, (char *)type_name, be_data);
+  g_hash_table_insert (ht, GINT_TO_POINTER (type_name), be_data);
 
   return TRUE;
 }
@@ -312,7 +316,7 @@
 {
   GHashTable *ht;
 
-  if (!type_name || *type_name == '\0' ||
+  if (!type_name || type_name == G_TYPE_INVALID ||
       !backend_name || *backend_name == '\0')
     return NULL;
 
@@ -320,7 +324,7 @@
   if (!ht)
     return NULL;
 
-  return g_hash_table_lookup (ht, (char *)type_name);
+  return g_hash_table_lookup (ht, GINT_TO_POINTER (type_name));
 }
 
 struct foreach_data {
@@ -330,7 +334,7 @@
 
 static void foreach_backend (gpointer key, gpointer be_item, gpointer arg)
 {
-  char *data_type = key;
+  GType data_type = GPOINTER_TO_INT(key);
   struct foreach_data *cb_data = arg;
 
   g_return_if_fail (key && be_item && arg);

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofobject.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -48,6 +48,7 @@
 #ifndef QOF_OBJECT_H_
 #define QOF_OBJECT_H_
 
+#include <glib.h>
 #include "qofbook.h"
 #include "qofid.h"
 #include "qofchoice.h"
@@ -139,7 +140,7 @@
  *  instance.  This routine just calls the (*new) callback on the object
  *  definition.  
  */
-gpointer qof_object_new_instance (QofIdTypeConst type_name, QofBook *book);
+/* gpointer qof_object_new_instance (QofIdTypeConst type_name, QofBook *book); */
 
 /** Get the printable label for a type.  This label is *not*
  * translated; you must use _() on it if you want a translated version.
@@ -147,7 +148,7 @@
 const char * qof_object_get_type_label (QofIdTypeConst type_name);
 
 /** @return a Human-readable string name for an instance */
-const char * qof_object_printable (QofIdTypeConst type_name, gpointer instance);
+/* const char * qof_object_printable (QofIdTypeConst type_name, gpointer instance); */
 
 /** Invoke the callback 'cb' on every object class definition.
  *  The user_data pointer is passed back to the callback.
@@ -159,8 +160,8 @@
  *  identifies a colllection of instances; thus the callback will 
  *  be invoked only for those instances stored in the book.
  */
-void qof_object_foreach (QofIdTypeConst type_name, QofBook *book, 
-                         QofEntityForeachCB cb, gpointer user_data);
+/*void qof_object_foreach (QofIdTypeConst type_name, QofBook *book, 
+                         QofEntityForeachCB cb, gpointer user_data);*/
 
 /** Register and lookup backend-specific data for this particular object */
 gboolean qof_object_register_backend (QofIdTypeConst type_name,

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquery.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquery.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquery.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -422,14 +422,14 @@
   const QofParam *objDef = NULL;
   GSList *fcns = NULL;
 
-  ENTER ("param_list=%p id=%s", param_list, start_obj);
+  ENTER ("param_list=%p id=%s", param_list, g_type_name(start_obj));
   g_return_val_if_fail (param_list, NULL);
   g_return_val_if_fail (start_obj, NULL);
   g_return_val_if_fail (final, NULL);
 
   for (; param_list; param_list = param_list->next) 
   {
-    QofIdType param_name = param_list->data;
+    gchar* param_name = param_list->data; /*FIXME: Convert to QofParam pointer instead */
     objDef = qof_class_get_parameter (start_obj, param_name);
 
     /* If it doesn't exist, then we've reached the end */
@@ -454,7 +454,7 @@
 {
   const QofParam *resObj = NULL;
 
-  ENTER ("sort=%p id=%s params=%p", sort, obj, sort->param_list);
+  ENTER ("sort=%p id=%s params=%p", sort, g_type_name(obj), sort->param_list);
   sort->use_default = FALSE;
 
   g_slist_free (sort->param_fcns);
@@ -489,7 +489,7 @@
   {
     sort->use_default = TRUE;
   }
-  LEAVE ("sort=%p id=%s", sort, obj);
+  LEAVE ("sort=%p id=%s", sort, g_type_name(obj));
 }
 
 static void compile_terms (QofQuery *q)
@@ -533,7 +533,7 @@
   /* Now compile the backend instances */
   for (node = q->books; node; node = node->next) {
     QofBook *book = node->data;
-    QofBackend *be = book->backend;
+    QofBackend *be = qof_book_get_backend (book);
 
     if (be && be->compile_query) {
       gpointer result = (be->compile_query)(be, q);
@@ -595,7 +595,7 @@
 query_free_compiled (gpointer key, gpointer value, gpointer not_used)
 {
   QofBook* book = key;
-  QofBackend* be = book->backend;
+  QofBackend* be = qof_book_get_backend (book);
 
   if (be && be->free_query)
     (be->free_query)(be, value);
@@ -785,6 +785,7 @@
 static void qof_query_run_cb(QofQueryCB* qcb, gpointer cb_arg)
 {
   GList *node;
+  QofCollection *col;
 
   (void)cb_arg; /* unused */
   g_return_if_fail(qcb);
@@ -792,7 +793,7 @@
   for (node=qcb->query->books; node; node=node->next) 
   {
     QofBook *book = node->data;
-    QofBackend *be = book->backend;
+    QofBackend *be = qof_book_get_backend (book);
 
     /* run the query in the backend */
     if (be) 
@@ -807,8 +808,9 @@
     }
 
     /* And then iterate over all the objects */
-    qof_object_foreach (qcb->query->search_for, book,
-			(QofEntityForeachCB) check_item_cb, qcb);
+    col = qof_book_get_collection (book, qcb->query->search_for);
+    
+    qof_collection_foreach (col, (QofInstanceForeachCB) check_item_cb,  qcb);
   }
 }
 
@@ -835,8 +837,7 @@
   /* Make sure we're searching for the same thing */
   g_return_val_if_fail (subq->search_for, NULL);
   g_return_val_if_fail (primaryq->search_for, NULL);
-  g_return_val_if_fail(!safe_strcmp(subq->search_for, primaryq->search_for),
-		       NULL);
+  g_return_val_if_fail(!subq->search_for == primaryq->search_for, NULL);
 
   /* Perform the subquery */
   return qof_query_run_internal(subq, qof_query_run_subq_cb,
@@ -869,6 +870,7 @@
 {
   QofQuery *qp = g_new0 (QofQuery, 1);
   qp->be_compiled = g_hash_table_new (g_direct_hash, g_direct_equal);
+  qp->search_for = G_TYPE_INVALID;
   query_init (qp, NULL);
   return qp;
 }
@@ -878,7 +880,7 @@
   if (!q || !obj_type)
     return;
 
-  if (safe_strcmp (q->search_for, obj_type)) {
+  if (q->search_for == obj_type) {
     q->search_for = (QofIdType) obj_type;
     q->changed = 1;
   }
@@ -1086,7 +1088,9 @@
   if(!q2) return q1;
 
   if (q1->search_for && q2->search_for)
-    g_return_val_if_fail (safe_strcmp (q1->search_for, q2->search_for) == 0,
+    g_return_val_if_fail ((q1->search_for == q2->search_for) 
+                          || q1->search_for == G_TYPE_INVALID
+                          || q2->search_for == G_TYPE_INVALID,
                           NULL);
 
   search_for = (q1->search_for ? q1->search_for : q2->search_for);
@@ -1277,10 +1281,10 @@
   if (g_list_index (q->books, book) == -1)
     q->books = g_list_prepend (q->books, book);
 
-  slist = g_slist_prepend (slist, QOF_PARAM_GUID);
-  slist = g_slist_prepend (slist, QOF_PARAM_BOOK);
+  slist = g_slist_prepend (slist, GINT_TO_POINTER (QOF_PARAM_GUID));
+  slist = g_slist_prepend (slist, GINT_TO_POINTER (QOF_PARAM_BOOK));
   qof_query_add_guid_match (q, slist,
-                        qof_book_get_guid(book), QOF_QUERY_AND);
+                        qof_instance_get_guid(QOF_INSTANCE (book)), QOF_QUERY_AND);
 }
 
 GList * qof_query_get_books (QofQuery *q)
@@ -1324,7 +1328,7 @@
 
 QofIdType qof_query_get_search_for (QofQuery *q)
 {
-  if (!q) return NULL;
+  if (!q) return G_TYPE_INVALID;
   return q->search_for;
 }
 
@@ -1542,7 +1546,7 @@
 
   searchFor = qof_query_get_search_for (query);
   gs = g_string_new ("Query Object Type: ");
-  g_string_append (gs, (NULL == searchFor)? "(null)" : searchFor);
+  g_string_append (gs, (G_TYPE_INVALID == searchFor)? "(null)" : g_type_name (searchFor));
   output = g_list_append (output, gs);
 
   return output;
@@ -1604,7 +1608,7 @@
     if (gsl) g_string_append_printf (gs, " Param: ");
     for (n=gsl; n; n = n->next)
     {
-      QofIdType param_name = n->data;
+      gchar* param_name = n->data;
       if (gsl != n) g_string_append_printf (gs, " ");
       g_string_append_printf (gs, "%s", param_name);
     }
@@ -1683,8 +1687,8 @@
   g_string_append (gs, (gchar *) pd->type_name);
 
   /* Char Predicate and GUID predicate don't use the 'how' field. */
-  if (safe_strcmp (pd->type_name, QOF_TYPE_CHAR) &&
-      safe_strcmp (pd->type_name, QOF_TYPE_GUID))
+  if ((pd->type_name == QOF_TYPE_CHAR) &&
+      (pd->type_name == QOF_TYPE_GUID))
   {
     g_string_append_printf (gs, " how: %s",
                        qof_query_printStringForHow (pd->how));
@@ -1728,7 +1732,7 @@
 qof_query_printValueForParam (QofQueryPredData *pd, GString * gs)
 {
 
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_GUID))
+  if (pd->type_name == QOF_TYPE_GUID)
   {
     GList *node;
     query_guid_t pdata = (query_guid_t) pd;
@@ -1742,7 +1746,7 @@
     }
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_STRING))
+  if (pd->type_name == QOF_TYPE_STRING)
   {
     query_string_t pdata = (query_string_t) pd;
     g_string_append_printf (gs, " Match type %s",
@@ -1752,7 +1756,7 @@
                        pdata->matchstring);
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_NUMERIC))
+  if (pd->type_name == QOF_TYPE_NUMERIC)
   {
     query_numeric_t pdata = (query_numeric_t) pd;
     g_string_append_printf (gs, " Match type %s",
@@ -1761,7 +1765,7 @@
                        gnc_num_dbg_to_string (pdata->amount));
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_KVP))
+  if (pd->type_name == QOF_TYPE_KVP)
   {
     GSList *node;
     query_kvp_t pdata = (query_kvp_t) pd;
@@ -1774,25 +1778,25 @@
                          kvp_value_to_string (pdata->value));
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_INT64))
+  if (pd->type_name == QOF_TYPE_INT64)
   {
     query_int64_t pdata = (query_int64_t) pd;
     g_string_append_printf (gs, " int64: %" G_GINT64_FORMAT, pdata->val);
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_INT32))
+  if (pd->type_name == QOF_TYPE_INT32)
   {
     query_int32_t pdata = (query_int32_t) pd;
     g_string_append_printf (gs, " int32: %d", pdata->val);
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_DOUBLE))
+  if (pd->type_name == QOF_TYPE_DOUBLE)
   {
     query_double_t pdata = (query_double_t) pd;
     g_string_append_printf (gs, " double: %.18g", pdata->val);
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_DATE))
+  if (pd->type_name == QOF_TYPE_DATE)
   {
     query_date_t pdata = (query_date_t) pd;
     g_string_append_printf (gs, " Match type %s",
@@ -1800,7 +1804,7 @@
     g_string_append_printf (gs, " query_date: %s", gnc_print_date (pdata->date));
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_CHAR))
+  if (pd->type_name, QOF_TYPE_CHAR)
   {
     query_char_t pdata = (query_char_t) pd;
     g_string_append_printf (gs, " Match type %s",
@@ -1808,7 +1812,7 @@
     g_string_append_printf (gs, " char list: %s", pdata->char_list);
     return;
   }
-  if (!safe_strcmp (pd->type_name, QOF_TYPE_BOOLEAN))
+  if (pd->type_name == QOF_TYPE_BOOLEAN)
   {
     query_boolean_t pdata = (query_boolean_t) pd;
     g_string_append_printf (gs, " boolean: %s", pdata->val?"TRUE":"FALSE");

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquery.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquery.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquery.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -78,6 +78,7 @@
 #include "qofbook.h"
 #include "qofquerycore.h"
 #include "qofchoice.h"
+#include "qofid.h"
 
 #define QOF_MOD_QUERY "qof-query"
 
@@ -100,11 +101,11 @@
 #define QUERY_DEFAULT_SORT      "QofQueryDefaultSort"
 
 /** "Known" Object Parameters -- all objects must support these */
-#define QOF_PARAM_BOOK    "book"
-#define QOF_PARAM_GUID    "guid"
+#define QOF_PARAM_BOOK    QOF_TYPE_BOOK
+#define QOF_PARAM_GUID    GNC_TYPE_GUID
 
 /** "Known" Object Parameters -- some objects might support these */
-#define QOF_PARAM_KVP     "kvp" 
+#define QOF_PARAM_KVP     GNC_TYPE_KVP_FRAME
 #define QOF_PARAM_ACTIVE  "active" 
 #define QOF_PARAM_VERSION "version" 
 

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquerycore-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquerycore-p.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquerycore-p.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -46,8 +46,8 @@
 			       QofQueryPredData *pdata);
 
 /* Lookup functions */
-QofQueryPredicateFunc qof_query_core_get_predicate (gchar const *type);
-QofCompareFunc qof_query_core_get_compare (gchar const *type);
+QofQueryPredicateFunc qof_query_core_get_predicate (QofType type);
+QofCompareFunc qof_query_core_get_compare (QofType type);
 
 /* Compare two predicates */
 gboolean qof_query_core_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2);

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquerycore.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquerycore.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofquerycore.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -54,41 +54,41 @@
 
 /* Core Type Predicate helpers */
 typedef const char * (*query_string_getter) (gpointer, QofParam *);
-static const char * query_string_type = QOF_TYPE_STRING;
+#define query_string_type QOF_TYPE_STRING
 
 typedef Timespec (*query_date_getter) (gpointer, QofParam *);
-static const char * query_date_type = QOF_TYPE_DATE;
+#define query_date_type QOF_TYPE_DATE
 
 typedef gnc_numeric (*query_numeric_getter) (gpointer, QofParam *);
-static const char * query_numeric_type = QOF_TYPE_NUMERIC;
+#define  query_numeric_type QOF_TYPE_NUMERIC
 
 typedef GList * (*query_glist_getter) (gpointer, QofParam *);
 typedef const GUID * (*query_guid_getter) (gpointer, QofParam *);
-static const char * query_guid_type = QOF_TYPE_GUID;
+#define query_guid_type QOF_TYPE_GUID
 
 typedef gint32 (*query_int32_getter) (gpointer, QofParam *);
-static const char * query_int32_type = QOF_TYPE_INT32;
+#define query_int32_type QOF_TYPE_INT32
 
 typedef gint64 (*query_int64_getter) (gpointer, QofParam *);
-static const char * query_int64_type = QOF_TYPE_INT64;
+#define query_int64_type QOF_TYPE_INT64
 
 typedef double (*query_double_getter) (gpointer, QofParam *);
-static const char * query_double_type = QOF_TYPE_DOUBLE;
+#define query_double_type QOF_TYPE_DOUBLE
 
 typedef gboolean (*query_boolean_getter) (gpointer, QofParam *);
-static const char * query_boolean_type = QOF_TYPE_BOOLEAN;
+#define query_boolean_type QOF_TYPE_BOOLEAN
 
 typedef char (*query_char_getter) (gpointer, QofParam *);
-static const char * query_char_type = QOF_TYPE_CHAR;
+#define query_char_type QOF_TYPE_CHAR
 
 typedef KvpFrame * (*query_kvp_getter) (gpointer, QofParam *);
-static const char * query_kvp_type = QOF_TYPE_KVP;
+#define query_kvp_type QOF_TYPE_KVP
 
 typedef QofCollection * (*query_collect_getter) (gpointer, QofParam*);
-static const char * query_collect_type = QOF_TYPE_COLLECT;
+#define query_collect_type QOF_TYPE_COLLECT
 
 typedef const GUID * (*query_choice_getter) (gpointer, QofParam *);
-static const char * query_choice_type = QOF_TYPE_CHOICE;
+#define query_choice_type QOF_TYPE_CHOICE
 
 /* Tables for predicate storage and lookup */
 static gboolean initialized = FALSE;
@@ -102,23 +102,20 @@
 #define COMPARE_ERROR -3
 #define PREDICATE_ERROR -2
 
-#define VERIFY_PDATA(str) { \
+#define VERIFY_PDATA(type) { \
         g_return_if_fail (pd != NULL); \
-        g_return_if_fail (pd->type_name == str || \
-                        !safe_strcmp (str, pd->type_name)); \
+        g_return_if_fail (pd->type_name == type); \
 }
-#define VERIFY_PDATA_R(str) { \
+#define VERIFY_PDATA_R(type) { \
         g_return_val_if_fail (pd != NULL, NULL); \
-        g_return_val_if_fail (pd->type_name == str || \
-                                !safe_strcmp (str, pd->type_name), \
+        g_return_val_if_fail (pd->type_name == type, \
                                 NULL); \
 }
-#define VERIFY_PREDICATE(str) { \
+#define VERIFY_PREDICATE(type) { \
         g_return_val_if_fail (getter != NULL, PREDICATE_ERROR); \
         g_return_val_if_fail (getter->param_getfcn != NULL, PREDICATE_ERROR); \
         g_return_val_if_fail (pd != NULL, PREDICATE_ERROR); \
-        g_return_val_if_fail (pd->type_name == str || \
-                                !safe_strcmp (str, pd->type_name), \
+        g_return_val_if_fail (pd->type_name == type, \
                                 PREDICATE_ERROR); \
 }
 
@@ -1450,13 +1447,13 @@
 }
 
 static void
-query_collect_cb(QofEntity* ent, gpointer user_data)
+query_collect_cb(QofInstance* inst, gpointer user_data)
 {
 	query_coll_t pdata;
 	GUID *guid;
 
 	guid = guid_malloc();
-	guid = (GUID*)qof_entity_get_guid(ent);
+	guid = (GUID*)qof_instance_get_guid(inst);
 	pdata = (query_coll_t)user_data;
 	pdata->guids = g_list_append(pdata->guids, guid);
 }
@@ -1660,7 +1657,7 @@
                                 QueryPredicateEqual pred_equal)
 {
   g_return_if_fail (core_name);
-  g_return_if_fail (*core_name != '\0');
+  g_return_if_fail (core_name != G_TYPE_INVALID);
 
   if (pred)
     g_hash_table_insert (predTable, (char *)core_name, pred);
@@ -1752,7 +1749,7 @@
 {
   QueryPredicateCopyFunc rc;
   g_return_val_if_fail (type, NULL);
-  rc = g_hash_table_lookup (copyTable, type);
+  rc = g_hash_table_lookup (copyTable, GINT_TO_POINTER (type));
   return rc;
 }
 
@@ -1760,7 +1757,7 @@
 qof_query_predicate_free (QofType type)
 {
   g_return_val_if_fail (type, NULL);
-  return g_hash_table_lookup (freeTable, type);
+  return g_hash_table_lookup (freeTable, GINT_TO_POINTER (type));
 }
 
 /********************************************************************/
@@ -1773,12 +1770,12 @@
   initialized = TRUE;
 
   /* Create the tables */
-  predTable = g_hash_table_new (g_str_hash, g_str_equal);
-  cmpTable = g_hash_table_new (g_str_hash, g_str_equal);
-  copyTable = g_hash_table_new (g_str_hash, g_str_equal);
-  freeTable = g_hash_table_new (g_str_hash, g_str_equal);
-  toStringTable = g_hash_table_new (g_str_hash, g_str_equal);
-  predEqualTable = g_hash_table_new (g_str_hash, g_str_equal);
+  predTable = g_hash_table_new (g_int_hash, g_int_equal);
+  cmpTable = g_hash_table_new (g_int_hash, g_int_equal);
+  copyTable = g_hash_table_new (g_int_hash, g_int_equal);
+  freeTable = g_hash_table_new (g_int_hash, g_int_equal);
+  toStringTable = g_hash_table_new (g_int_hash, g_int_equal);
+  predEqualTable = g_hash_table_new (g_int_hash, g_int_equal);
 
   init_tables ();
 }
@@ -1800,14 +1797,14 @@
 qof_query_core_get_predicate (QofType type)
 {
   g_return_val_if_fail (type, NULL);
-  return g_hash_table_lookup (predTable, type);
+  return g_hash_table_lookup (predTable, GINT_TO_POINTER (type));
 }
 
 QofCompareFunc
 qof_query_core_get_compare (QofType type)
 {
   g_return_val_if_fail (type, NULL);
-  return g_hash_table_lookup (cmpTable, type);
+  return g_hash_table_lookup (cmpTable, GINT_TO_POINTER (type));
 }
 
 void
@@ -1844,7 +1841,7 @@
   g_return_val_if_fail (object, NULL);
   g_return_val_if_fail (getter, NULL);
 
-  toString = g_hash_table_lookup (toStringTable, type);
+  toString = g_hash_table_lookup (toStringTable, GINT_TO_POINTER (type));
   g_return_val_if_fail (toString, NULL);
 
   return toString (object, getter);
@@ -1859,9 +1856,9 @@
   if (!p1 || !p2) return FALSE;
 
   if (p1->how != p2->how) return FALSE;
-  if (safe_strcmp (p1->type_name, p2->type_name)) return FALSE;
+  if (p1->type_name != p2->type_name) return FALSE;
 
-  pred_equal = g_hash_table_lookup (predEqualTable, p1->type_name);
+  pred_equal = g_hash_table_lookup (predEqualTable, GINT_TO_POINTER (p1->type_name));
   g_return_val_if_fail (pred_equal, FALSE);
 
   return pred_equal (p1, p2);

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofreference.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofreference.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofreference.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -20,145 +20,154 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
+ 
+ /* DEPRECATED FILE
+ THIS FILE ISN'T USED ANY WHERE
+ */
 
 #include "config.h"
 #include <glib.h>
 #include "qofreference.h"
 
 static void
-entity_set_reference_cb(QofEntity *ent, gpointer user_data)
+instance_set_reference_cb(QofInstance *inst, gpointer user_data)
 {
-	void (*reference_setter) (QofEntity*, QofEntity*);
-	void (*choice_setter) (QofEntity*, QofEntity*);
-	void (*collect_setter)(QofEntity*, QofCollection*);
-	QofEntityReference *ref;
+	void (*reference_setter) (QofInstance*, QofInstance*);
+	void (*choice_setter) (QofInstance*, QofInstance*);
+	void (*collect_setter)(QofInstance*, QofCollection*);
+	QofInstanceReference *ref;
 	GList *book_ref_list;
 	QofCollection *coll;
 	QofIdType type;
-	QofEntity *reference;
+	QofInstance *reference;
 	QofBook *partial_book;
+	GError *error = NULL;
 	
 	partial_book = (QofBook*)user_data;
-	g_return_if_fail(partial_book || ent);
+	g_return_if_fail(partial_book || QOF_IS_INSTANCE (inst));
 	reference = NULL;
 	coll = NULL;
 	book_ref_list = qof_book_get_data(partial_book, ENTITYREFERENCE);
 	while(book_ref_list)
 	{
-		ref = (QofEntityReference*)book_ref_list->data;
-		if(0 == guid_compare(ref->ref_guid, qof_entity_get_guid(ent)))
+		ref = (QofInstanceReference*)book_ref_list->data;
+		if(0 == guid_compare(ref->ref_guid, qof_instance_get_guid(inst)))
 		{
-			/* avoid setting the entity's own guid as a reference. */
+			/* avoid setting the instance's own guid as a reference. */
 			book_ref_list = g_list_next(book_ref_list);
 			continue;
 		}
-		if(qof_object_is_choice(ent->e_type)) { type = ref->choice_type; }
+		if(qof_object_is_choice(G_OBJECT_TYPE ( G_OBJECT (inst)))) { type = ref->choice_type; }
 		type = ref->param->param_type;
 		coll = qof_book_get_collection(partial_book, type);
-		reference = qof_collection_lookup_entity(coll, ref->ref_guid);
-		reference_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
+		reference = qof_collection_lookup_element (coll, ref->ref_guid);
+		reference_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
 		if((reference) && (reference_setter))
 		{
-			qof_begin_edit((QofInstance*)ent);
+			qof_begin_edit(inst);
 			qof_begin_edit((QofInstance*)reference);
-			reference_setter(ent, reference);
-			qof_commit_edit((QofInstance*)ent);
-			qof_commit_edit((QofInstance*)reference);
+			reference_setter(inst, reference);
+			qof_commit_edit(inst);
+			qof_commit_edit(reference);
 		}
 		/* collect and choice handling */
-		collect_setter = (void(*)(QofEntity*, QofCollection*))ref->param->param_setfcn;
-		choice_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
-		if ((0 == safe_strcmp(ref->param->param_type, QOF_TYPE_COLLECT)) &&
-			(0 == guid_compare(qof_entity_get_guid(ent), ref->ent_guid)) &&
-			(0 == safe_strcmp(ref->type, ent->e_type)))
+		collect_setter = (void(*)(QofInstance*, QofCollection*))ref->param->param_setfcn;
+		choice_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
+		if ((ref->param->param_type == QOF_TYPE_COLLECT) &&
+			(0 == guid_compare(qof_instance_get_guid(inst), ref->inst_guid)) &&
+			(ref->type ==  G_OBJECT_TYPE (G_OBJECT (inst))))
 		{
 			QofCollection *temp_col;
 			char cm_sa[GUID_ENCODING_LENGTH + 1];
 			
-			temp_col = ref->param->param_getfcn(ent, ref->param);
+			temp_col = ref->param->param_getfcn(inst, ref->param);
 			coll = qof_book_get_collection(partial_book, 
-				qof_collection_get_type(temp_col));
+				qof_collection_get_g_type((const QofCollection*) temp_col));
 			guid_to_string_buff(ref->ref_guid, cm_sa);
-			reference = qof_collection_lookup_entity(coll, ref->ref_guid);
+			reference = qof_collection_lookup_element (coll, ref->ref_guid);
 			if(reference) {
-				qof_collection_add_entity(temp_col, reference);
-				qof_begin_edit((QofInstance*)ent);
-				qof_begin_edit((QofInstance*)reference);
-				if(collect_setter) { collect_setter(ent, temp_col); }
-				qof_commit_edit((QofInstance*)ent);
-				qof_commit_edit((QofInstance*)reference);
+				qof_collection_add_element(temp_col, reference);
+				qof_begin_edit(inst);
+				qof_begin_edit(reference);
+				if(collect_setter) { collect_setter(inst, temp_col); }
+				qof_commit_edit(inst);
+				qof_commit_edit(reference);
 				qof_collection_destroy(temp_col);
 			}
 		}
-		if(0 == safe_strcmp(ref->param->param_type, QOF_TYPE_CHOICE))
+		if(ref->param->param_type == QOF_TYPE_CHOICE)
 		{
 			coll = qof_book_get_collection(partial_book, ref->type);
-			reference = qof_collection_lookup_entity(coll, ref->ref_guid);
-			qof_begin_edit((QofInstance*)ent);
-			qof_begin_edit((QofInstance*)reference);
-			if(choice_setter) { choice_setter(ent, reference); }
-			qof_commit_edit((QofInstance*)ent);
-			qof_commit_edit((QofInstance*)reference);
+			reference = qof_collection_lookup_element (coll, ref->ref_guid);
+			qof_begin_edit(inst);
+			qof_begin_edit(reference);
+			if(choice_setter) { choice_setter(inst, reference); }
+			qof_commit_edit(inst);
+			qof_commit_edit(reference);
 		}
 		book_ref_list = g_list_next(book_ref_list);
 	}
 }
 
 static void
-set_each_type(QofObject *obj, gpointer user_data)
+set_each_type(QofCollection *col, gpointer user_data)
 {
 	QofBook *book;
+	book = (QofBook*)user_data;
+	qof_collection_foreach (col, instance_set_reference_cb, book);
 
-	book = (QofBook*)user_data;
-	qof_object_foreach(obj->e_type, book, entity_set_reference_cb, book);
 }
 
-static QofEntityReference*
-create_reference(QofEntity *ent, const QofParam *param)
+static QofInstanceReference*
+create_reference(QofInstance *inst, const QofParam *param)
 {
-	QofEntityReference *reference;
-	QofEntity          *ref_ent;
+	QofInstanceReference *reference;
+	QofInstance          *ref_inst;
 	const GUID         *cm_guid;
 	char                cm_sa[GUID_ENCODING_LENGTH + 1];
 	gchar              *cm_string;
 
-	ref_ent = (QofEntity*)param->param_getfcn(ent, param);
-	if(!ref_ent) { return NULL; }
-	reference = g_new0(QofEntityReference, 1);
-	reference->type = ent->e_type;
+	ref_inst = (QofInstance*)param->param_getfcn(inst, param);
+	if(!ref_inst) { return NULL; }
+	reference = g_new0(QofInstanceReference, 1);
+	reference->type = G_OBJECT_TYPE (G_OBJECT (inst));
 	reference->ref_guid = g_new(GUID, 1);
-	reference->ent_guid = &ent->guid;
-	if(qof_object_is_choice(ent->e_type)) 
+	reference->inst_guid = qof_instance_get_guid (inst);
+	if(qof_object_is_choice(G_OBJECT_TYPE (G_OBJECT (inst))))
 	{ 
-		reference->choice_type = ref_ent->e_type; 
+		reference->choice_type = G_OBJECT_TYPE (G_OBJECT (ref_inst)); 
 	}
 	reference->param = param;
-	cm_guid = qof_entity_get_guid(ref_ent);
+	cm_guid = qof_instance_get_guid(ref_inst);
 	guid_to_string_buff(cm_guid, cm_sa);
 	cm_string = g_strdup(cm_sa);
 	if(TRUE == string_to_guid(cm_string, reference->ref_guid)) {
 		g_free(cm_string);
 		return reference;
-	}
+	} 
 	g_free(cm_string);
 	return NULL;
 }
 
-QofEntityReference*
-qof_entity_get_reference_from(QofEntity *ent, const QofParam *param)
+QofInstanceReference*
+qof_instance_get_reference_from(QofInstance *inst, const QofParam *param)
 {
 	g_return_val_if_fail(param, NULL);
-	param = qof_class_get_parameter(ent->e_type, param->param_name);
-	g_return_val_if_fail(0 != safe_strcmp(param->param_type, QOF_TYPE_COLLECT), NULL);
-	return create_reference(ent, param);
+	param = qof_class_get_parameter(G_OBJECT_TYPE (G_OBJECT (inst)), param->param_name);
+	g_return_val_if_fail(param->param_type != QOF_TYPE_COLLECT, NULL);
+	return create_reference (inst, param);
 }
 
-void qof_book_set_references(QofBook *book)
+void 
+qof_book_set_references (QofBook *book)
 {
 	gboolean partial;
+	QofInstance *inst;
 
 	partial =
 	  (gboolean)GPOINTER_TO_INT(qof_book_get_data(book, PARTIAL_QOFBOOK));
+	
 	g_return_if_fail(partial);
-	qof_object_foreach_type(set_each_type, book);
+	
+	qof_book_foreach_collection (book, set_each_type, (gpointer) book);
 }

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofreference.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofreference.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofreference.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -21,6 +21,10 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
  
+  /* DEPRECATED FILE
+ THIS FILE ISN'T USED ANY WHERE
+ */
+ 
 #ifndef _QOFREFERENCE_H
 #define _QOFREFERENCE_H
 
@@ -102,7 +106,7 @@
 Creates a GList stored in the Book hashtable to contain
 repeated references for a single entity.
 */
-typedef struct qof_entity_reference {
+typedef struct qof_instance_reference {
 	QofIdType       choice_type;/**< Used when the reference is a QOF_TYPE_CHOICE type
 	- stores the actual type of the reference from the list of available choices. */
 	QofIdType       type;       /**< The type of the original entity -
@@ -111,8 +115,8 @@
 	GUID            *ref_guid;  /**< The GUID of the REFERENCE entity */
 	const QofParam  *param;      /**< The parameter of the original entity to use 
 	to get or set the reference. */
-	const GUID      *ent_guid;   /**< The GUID of the original entity. */
-}QofEntityReference;
+	const GUID      *inst_guid;   /**< The GUID of the original entity. */
+}QofInstanceReference;
 
 /** \brief Adds a new reference to the partial book data hash.
 
@@ -122,7 +126,7 @@
 partial.
 */
 void
-qof_session_update_reference_list(QofSession *session, QofEntityReference *reference);
+qof_session_update_reference_list(QofSession *session, QofInstanceReference *reference);
 
 /** Used as the key value for the QofBook data hash.
  *
@@ -201,8 +205,8 @@
 
 @return FALSE on error, otherwise a pointer to the QofEntityReference.
 */
-QofEntityReference*
-qof_entity_get_reference_from(QofEntity *ent, const QofParam *param);
+QofInstanceReference*
+qof_instance_get_reference_from(QofInstance *inst, const QofParam *param);
 
 /** @} */
 /** @} */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession-p.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession-p.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -37,8 +37,11 @@
   /* This is just a "fake" entry point to allow me to pass a Session as
    * an Entity.  NOTE:  THIS IS NOT AN ENTITY!  THE ONLY PART OF ENTITY
    * THAT IS VALID IS E_TYPE!
+   *
    */
-  QofEntity entity;
+  /* FIXME: if not an entity where is used as an entity????
+  * QofInstance entity;
+  */
 
   /* A book holds pointers to the various types of datasets.
    * A session may have multiple books. */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -110,19 +110,20 @@
 qof_session_clear_error (QofSession *session)
 {
   QofBackendError err;
+  GError *error;
 
   session->last_err = ERR_BACKEND_NO_ERR;
   g_free(session->error_message);
   session->error_message = NULL;
 
   /* pop the stack on the backend as well. */
+  
   if (session->backend)
   {
-    do
-    {
-       err = qof_backend_get_error (session->backend);
-    } while (ERR_BACKEND_NO_ERR != err);
+    qof_backend_error_free (session->backend);
+      
   }
+  
 }
 
 void
@@ -153,7 +154,7 @@
   /* maybe we should return a no-backend error ??? */
   if (! session->backend) return ERR_BACKEND_NO_ERR;
 
-  err = qof_backend_get_error (session->backend);
+  err = qof_backend_get_error_code (session->backend);
   session->last_err = err;
   return err;
 }
@@ -193,7 +194,7 @@
 {
   if (!session) return;
 
-  session->entity.e_type = QOF_ID_SESSION;
+  /*session->entity.e_type = QOF_ID_SESSION; FIXME: ????*/
   session->books = g_list_append (NULL, qof_book_new ());
   session->book_id = NULL;
   session->backend = NULL;
@@ -242,7 +243,7 @@
    for (node=session->books; node; node=node->next)
    {
       QofBook *book = node->data;
-      if ('y' == book->book_open) return book;
+      if (qof_book_is_open (book)) return book;
    }
    return NULL;
 }
@@ -262,7 +263,7 @@
      if (addbook == book) return;
   }
 
-  if ('y' == addbook->book_open)
+  if (qof_book_is_open (addbook))
   {
     /* hack alert -- someone should free all the books in the list,
      * but it should probably not be us ... since the books backends
@@ -306,14 +307,14 @@
 /* =============================================================== */
 
 typedef struct qof_entity_copy_data {
-	QofEntity *from;
-	QofEntity *to;
+	QofInstance *from;
+	QofInstance *to;
 	QofParam  *param;
 	GList  *referenceList;
 	GSList *param_list;
 	QofSession *new_session;
 	gboolean error;
-}QofEntityCopyData;
+}QofInstanceCopyData;
 
 static void
 qof_book_set_partial(QofBook *book)
@@ -328,7 +329,7 @@
 }
 
 void
-qof_session_update_reference_list(QofSession *session, QofEntityReference *reference)
+qof_session_update_reference_list(QofSession *session, QofInstanceReference *reference)
 {
 	QofBook  *book;
 	GList    *book_ref_list;
@@ -343,13 +344,13 @@
 static void
 qof_entity_param_cb(QofParam *param, gpointer data)
 {
-	QofEntityCopyData *qecd;
+	QofInstanceCopyData *qecd;
 
 	g_return_if_fail(data != NULL);
-	qecd = (QofEntityCopyData*)data;
+	qecd = (QofInstanceCopyData*)data;
 	g_return_if_fail(param != NULL);
 	/* KVP doesn't need a set routine to be copied. */
-	if(0 == safe_strcmp(param->param_type, QOF_TYPE_KVP)) {
+	if(param->param_type == QOF_TYPE_KVP) {
 		qecd->param_list = g_slist_prepend(qecd->param_list, param);
 		return;
 	}
@@ -359,24 +360,24 @@
 }
 
 static void
-col_ref_cb (QofEntity* ref_ent, gpointer user_data)
+col_ref_cb (QofInstance* ref_ent, gpointer user_data)
 {
-	QofEntityReference *ref;
-	QofEntityCopyData  *qecd;
-	QofEntity *ent;
+	QofInstanceReference *ref;
+	QofInstanceCopyData  *qecd;
+	QofInstance *ent;
 	const GUID   *cm_guid;
 	char         cm_sa[GUID_ENCODING_LENGTH + 1];
 	gchar        *cm_string;
 
-	qecd = (QofEntityCopyData*)user_data;
+	qecd = (QofInstanceCopyData*)user_data;
 	ent = qecd->from;
-	ref = g_new0(QofEntityReference, 1);
-	ref->type = ent->e_type;
+	ref = g_new0(QofInstanceReference, 1);
+	ref->type = G_OBJECT_TYPE (G_OBJECT (ent));
 	ref->ref_guid = g_new(GUID, 1);
-	ref->ent_guid = &ent->guid;
-	ref->param = qof_class_get_parameter(ent->e_type, 
+	ref->inst_guid = qof_instance_get_guid (ent);
+	ref->param = qof_class_get_parameter(G_OBJECT_TYPE (G_OBJECT (ent)), 
 		qecd->param->param_name);
-	cm_guid = qof_entity_get_guid(ref_ent);
+	cm_guid = qof_instance_get_guid(ref_ent);
 	guid_to_string_buff(cm_guid, cm_sa);
 	cm_string = g_strdup(cm_sa);
 	if(TRUE == string_to_guid(cm_string, ref->ref_guid)) {
@@ -388,9 +389,9 @@
 static void
 qof_entity_foreach_copy(gpointer data, gpointer user_data)
 {
-	QofEntity          *importEnt, *targetEnt/*, *referenceEnt*/;
-	QofEntityCopyData 	*context;
-	QofEntityReference  *reference;
+	QofInstance          *importEnt, *targetEnt/*, *referenceEnt*/;
+	QofInstanceCopyData 	*context;
+	QofInstanceReference  *reference;
 	gboolean		registered_type;
 	/* cm_ prefix used for variables that hold the data to commit */
 	QofParam 		*cm_param;
@@ -399,26 +400,26 @@
 	KvpFrame 		*cm_kvp;
 	QofCollection *cm_col;
 	/* function pointers and variables for parameter getters that don't use pointers normally */
-	gnc_numeric 	cm_numeric, (*numeric_getter)	(QofEntity*, QofParam*);
-	double 			cm_double, 	(*double_getter)	(QofEntity*, QofParam*);
-	gboolean 		cm_boolean, (*boolean_getter)	(QofEntity*, QofParam*);
-	gint32 			cm_i32, 	(*int32_getter)		(QofEntity*, QofParam*);
-	gint64 			cm_i64, 	(*int64_getter)		(QofEntity*, QofParam*);
-	Timespec 		cm_date, 	(*date_getter)		(QofEntity*, QofParam*);
+	gnc_numeric 	cm_numeric, (*numeric_getter)	(QofInstance*, QofParam*);
+	double 			cm_double, 	(*double_getter)	(QofInstance*, QofParam*);
+	gboolean 		cm_boolean, (*boolean_getter)	(QofInstance*, QofParam*);
+	gint32 			cm_i32, 	(*int32_getter)		(QofInstance*, QofParam*);
+	gint64 			cm_i64, 	(*int64_getter)		(QofInstance*, QofParam*);
+	Timespec 		cm_date, 	(*date_getter)		(QofInstance*, QofParam*);
 	/* function pointers to the parameter setters */
-	void	(*string_setter)	(QofEntity*, const char*);
-	void	(*date_setter)		(QofEntity*, Timespec);
-	void	(*numeric_setter)	(QofEntity*, gnc_numeric);
-	void	(*guid_setter)		(QofEntity*, const GUID*);
-	void	(*double_setter)	(QofEntity*, double);
-	void	(*boolean_setter)	(QofEntity*, gboolean);
-	void	(*i32_setter)		(QofEntity*, gint32);
-	void	(*i64_setter)		(QofEntity*, gint64);
-	void	(*char_setter)		(QofEntity*, char*);
-	void	(*kvp_frame_setter)	(QofEntity*, KvpFrame*);
+	void	(*string_setter)	(QofInstance*, const char*);
+	void	(*date_setter)		(QofInstance*, Timespec);
+	void	(*numeric_setter)	(QofInstance*, gnc_numeric);
+	void	(*guid_setter)		(QofInstance*, const GUID*);
+	void	(*double_setter)	(QofInstance*, double);
+	void	(*boolean_setter)	(QofInstance*, gboolean);
+	void	(*i32_setter)		(QofInstance*, gint32);
+	void	(*i64_setter)		(QofInstance*, gint64);
+	void	(*char_setter)		(QofInstance*, char*);
+	void	(*kvp_frame_setter)	(QofInstance*, KvpFrame*);
 	
 	g_return_if_fail(user_data != NULL);
-	context = (QofEntityCopyData*) user_data;
+	context = (QofInstanceCopyData*) user_data;
 	cm_date.tv_nsec = 0;
 	cm_date.tv_sec =  0;
 	importEnt = context->from;
@@ -427,84 +428,84 @@
 	cm_param = (QofParam*) data;
 	g_return_if_fail(cm_param != NULL);
 	context->param = cm_param;
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_STRING) == 0)  { 
+	if(cm_param->param_type == QOF_TYPE_STRING)  { 
 		cm_string = (gchar*)cm_param->param_getfcn(importEnt, cm_param);
 		if(cm_string) {
-		string_setter = (void(*)(QofEntity*, const char*))cm_param->param_setfcn;
+		string_setter = (void(*)(QofInstance*, const char*))cm_param->param_setfcn;
 		if(string_setter != NULL) {	string_setter(targetEnt, cm_string); }
 		}
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_DATE) == 0) { 
-		date_getter = (Timespec (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
+	if(cm_param->param_type == QOF_TYPE_DATE) { 
+		date_getter = (Timespec (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
 		cm_date = date_getter(importEnt, cm_param);
-		date_setter = (void(*)(QofEntity*, Timespec))cm_param->param_setfcn;
+		date_setter = (void(*)(QofInstance*, Timespec))cm_param->param_setfcn;
 		if(date_setter != NULL) { date_setter(targetEnt, cm_date); }
 		registered_type = TRUE;
 	}
-	if((safe_strcmp(cm_param->param_type, QOF_TYPE_NUMERIC) == 0)  ||
-	(safe_strcmp(cm_param->param_type, QOF_TYPE_DEBCRED) == 0)) { 
-		numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
+	if((cm_param->param_type == QOF_TYPE_NUMERIC)  ||
+	(cm_param->param_type == QOF_TYPE_DEBCRED)) { 
+		numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
 		cm_numeric = numeric_getter(importEnt, cm_param);
-		numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_param->param_setfcn;
+		numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_param->param_setfcn;
 		if(numeric_setter != NULL) { numeric_setter(targetEnt, cm_numeric); }
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_GUID) == 0) { 
+	if(cm_param->param_type == QOF_TYPE_GUID) { 
 		cm_guid = (const GUID*)cm_param->param_getfcn(importEnt, cm_param);
-		guid_setter = (void(*)(QofEntity*, const GUID*))cm_param->param_setfcn;
+		guid_setter = (void(*)(QofInstance*, const GUID*))cm_param->param_setfcn;
 		if(guid_setter != NULL) { guid_setter(targetEnt, cm_guid); }
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_INT32) == 0) { 
-		int32_getter = (gint32 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+	if(cm_param->param_type == QOF_TYPE_INT32) { 
+		int32_getter = (gint32 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 		cm_i32 = int32_getter(importEnt, cm_param);
-		i32_setter = (void(*)(QofEntity*, gint32))cm_param->param_setfcn;
+		i32_setter = (void(*)(QofInstance*, gint32))cm_param->param_setfcn;
 		if(i32_setter != NULL) { i32_setter(targetEnt, cm_i32); }
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_INT64) == 0) { 
-		int64_getter = (gint64 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+	if(cm_param->param_type == QOF_TYPE_INT64) { 
+		int64_getter = (gint64 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 		cm_i64 = int64_getter(importEnt, cm_param);
-		i64_setter = (void(*)(QofEntity*, gint64))cm_param->param_setfcn;
+		i64_setter = (void(*)(QofInstance*, gint64))cm_param->param_setfcn;
 		if(i64_setter != NULL) { i64_setter(targetEnt, cm_i64); }
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_DOUBLE) == 0) { 
-		double_getter = (double (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+	if(cm_param->param_type == QOF_TYPE_DOUBLE) { 
+		double_getter = (double (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 		cm_double = double_getter(importEnt, cm_param);
-		double_setter = (void(*)(QofEntity*, double))cm_param->param_setfcn;
+		double_setter = (void(*)(QofInstance*, double))cm_param->param_setfcn;
 		if(double_setter != NULL) { double_setter(targetEnt, cm_double); }
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_BOOLEAN) == 0){ 
-		boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
+	if(cm_param->param_type == QOF_TYPE_BOOLEAN){ 
+		boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
 		cm_boolean = boolean_getter(importEnt, cm_param);
-		boolean_setter = (void(*)(QofEntity*, gboolean))cm_param->param_setfcn;
+		boolean_setter = (void(*)(QofInstance*, gboolean))cm_param->param_setfcn;
 		if(boolean_setter != NULL) { boolean_setter(targetEnt, cm_boolean); }
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_KVP) == 0) { 
+	if(cm_param->param_type == QOF_TYPE_KVP) { 
 		cm_kvp = (KvpFrame*)cm_param->param_getfcn(importEnt,cm_param);
-		kvp_frame_setter = (void(*)(QofEntity*, KvpFrame*))cm_param->param_setfcn;
+		kvp_frame_setter = (void(*)(QofInstance*, KvpFrame*))cm_param->param_setfcn;
 		if(kvp_frame_setter != NULL) { kvp_frame_setter(targetEnt, cm_kvp); }
 		else
 		{
 			QofInstance *target_inst;
 
-			target_inst = (QofInstance*)targetEnt;
-			kvp_frame_delete(target_inst->kvp_data);
-			target_inst->kvp_data = kvp_frame_copy(cm_kvp);
+			target_inst = (QofInstance*) targetEnt;
+			qof_instance_delete_kvp_data (target_inst);
+			qof_instance_set_kvp_data (target_inst, cm_kvp);
 		}
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_CHAR) == 0) { 
+	if(cm_param->param_type == QOF_TYPE_CHAR) { 
 		cm_char = (gchar*)cm_param->param_getfcn(importEnt,cm_param);
-		char_setter = (void(*)(QofEntity*, char*))cm_param->param_setfcn;
+		char_setter = (void(*)(QofInstance*, char*))cm_param->param_setfcn;
 		if(char_setter != NULL) { char_setter(targetEnt, cm_char); }
 		registered_type = TRUE;
 	}
-	if(safe_strcmp(cm_param->param_type, QOF_TYPE_COLLECT) == 0) {
+	if(cm_param->param_type == QOF_TYPE_COLLECT) {
 		cm_col = (QofCollection*)cm_param->param_getfcn(importEnt, cm_param);
 		if(cm_col)
 		{
@@ -514,10 +515,10 @@
 		registered_type = TRUE;
 	}
 	if(registered_type == FALSE) {
-/*		referenceEnt = (QofEntity*)cm_param->param_getfcn(importEnt, cm_param);
+/*		referenceEnt = (QofInstance*)cm_param->param_getfcn(importEnt, cm_param);
 		if(!referenceEnt) { return; }
 		if(!referenceEnt->e_type) { return; }*/
-		reference = qof_entity_get_reference_from(importEnt, cm_param);
+		reference = qof_instance_get_reference_from(importEnt, cm_param);
 		if(reference) {
 			qof_session_update_reference_list(context->new_session, reference);
 		}
@@ -525,9 +526,9 @@
 }
 
 static gboolean
-qof_entity_guid_match(QofSession *new_session, QofEntity *original)
+qof_entity_guid_match(QofSession *new_session, QofInstance *original)
 {
-	QofEntity *copy;
+	QofInstance *copy;
 	const GUID *g;
 	QofIdTypeConst type;
 	QofBook *targetBook;
@@ -537,10 +538,10 @@
 	g_return_val_if_fail(original != NULL, FALSE);
 	targetBook = qof_session_get_book(new_session);
 	g_return_val_if_fail(targetBook != NULL, FALSE);
-	g = qof_entity_get_guid(original);
-	type = g_strdup(original->e_type);
+	g = qof_instance_get_guid(original);
+	type = G_OBJECT_TYPE (G_OBJECT (original));
 	coll = qof_book_get_collection(targetBook, type);
-	copy = qof_collection_lookup_entity(coll, g);
+	copy = qof_collection_lookup_element (coll, g);
 	if(copy) { return TRUE; }
 	return FALSE;	
 }
@@ -548,106 +549,106 @@
 static void
 qof_entity_list_foreach(gpointer data, gpointer user_data)
 {
-	QofEntityCopyData *qecd;
-	QofEntity *original;
+	QofInstanceCopyData *qecd;
+	QofInstance *original;
 	QofInstance *inst;
 	QofBook *book;
-	const GUID *g;
+	GUID *g;
 	
 	g_return_if_fail(data != NULL);
-	original = (QofEntity*)data;
+	original = (QofInstance*)data;
 	g_return_if_fail(user_data != NULL);
-	qecd = (QofEntityCopyData*)user_data;
+	qecd = (QofInstanceCopyData*)user_data;
 	if(qof_entity_guid_match(qecd->new_session, original)) { return; }
 	qecd->from = original;
-	if(!qof_object_compliance(original->e_type, FALSE)) 
+	if(!qof_object_compliance(G_OBJECT_TYPE (G_OBJECT (original)), FALSE)) 
 	{
 		qecd->error = TRUE;
 		return;
 	}
 	book = qof_session_get_book(qecd->new_session);
-	inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
+	inst = (QofInstance*)qof_object_new_instance(G_OBJECT_TYPE (G_OBJECT (original)), book);
 	if(!inst) 
 	{ 
-		PERR (" failed to create new entity type=%s.", original->e_type);
+		PERR (" failed to create new entity type=%s.", g_type_name (G_OBJECT_TYPE (G_OBJECT (original))));
 		qecd->error = TRUE;
 		return;
 	}
-	qecd->to = &inst->entity;
-	g = qof_entity_get_guid(original);
-	qof_entity_set_guid(qecd->to, g);
+	qecd->to = inst;
+	g = qof_instance_get_guid(original);
+	qof_instance_set_guid(qecd->to, g);
 	if(qecd->param_list != NULL) { 
 		g_slist_free(qecd->param_list);
 		qecd->param_list = NULL;
 	}
-	qof_class_param_foreach(original->e_type, qof_entity_param_cb, qecd);
+	qof_class_param_foreach(G_OBJECT_TYPE (G_OBJECT (original)), qof_entity_param_cb, qecd);
 	qof_begin_edit(inst);
 	g_slist_foreach(qecd->param_list, qof_entity_foreach_copy, qecd);
 	qof_commit_edit(inst);
 }
 
 static void
-qof_entity_coll_foreach(QofEntity *original, gpointer user_data)
+qof_entity_coll_foreach(QofInstance *original, gpointer user_data)
 {
-	QofEntityCopyData *qecd;
+	QofInstanceCopyData *qecd;
 	const GUID *g;
 	QofBook *targetBook;
 	QofCollection *coll;
-	QofEntity *copy;
+	QofInstance *copy;
 	
 	g_return_if_fail(user_data != NULL);
 	copy = NULL;
-	qecd = (QofEntityCopyData*)user_data;
+	qecd = (QofInstanceCopyData*)user_data;
 	targetBook = qof_session_get_book(qecd->new_session);
-	g = qof_entity_get_guid(original);
-	coll = qof_book_get_collection(targetBook, original->e_type);
-	copy = qof_collection_lookup_entity(coll, g);
+	g = qof_instance_get_guid(original);
+	coll = qof_book_get_collection(targetBook, G_OBJECT_TYPE (G_OBJECT (original)));
+	copy = qof_collection_lookup_element (coll, g);
 	if(copy) { qecd->error = TRUE; }
 }
 
 static void
-qof_entity_coll_copy(QofEntity *original, gpointer user_data)
+qof_entity_coll_copy(QofInstance *original, gpointer user_data)
 {
-	QofEntityCopyData *qecd;
+	QofInstanceCopyData *qecd;
 	QofBook *book;
 	QofInstance *inst;
-	const GUID *g;
+	GUID *g;
 	
 	g_return_if_fail(user_data != NULL);
-	qecd = (QofEntityCopyData*)user_data;
+	qecd = (QofInstanceCopyData*)user_data;
 	book = qof_session_get_book(qecd->new_session);
-	if(!qof_object_compliance(original->e_type, TRUE)) { return; }
-	inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
-	qecd->to = &inst->entity;
+	if(!qof_object_compliance(G_OBJECT_TYPE (G_OBJECT (original)), TRUE)) { return; }
+	inst = (QofInstance*)qof_object_new_instance(G_OBJECT_TYPE (G_OBJECT (original)), book);
+	qecd->to = inst;
 	qecd->from = original;
-	g = qof_entity_get_guid(original);
-	qof_entity_set_guid(qecd->to, g);
+	g = qof_instance_get_guid(original);
+	qof_instance_set_guid(qecd->to, g);
 	qof_begin_edit(inst);
 	g_slist_foreach(qecd->param_list, qof_entity_foreach_copy, qecd);
 	qof_commit_edit(inst);
 }
 
 gboolean 
-qof_entity_copy_to_session(QofSession* new_session, QofEntity* original)
+qof_entity_copy_to_session(QofSession* new_session, QofInstance* original)
 {
-	QofEntityCopyData qecd;
+	QofInstanceCopyData qecd;
 	QofInstance *inst;
 	QofBook *book;
 
 	if(!new_session || !original) { return FALSE; }
 	if(qof_entity_guid_match(new_session, original)) { return FALSE; }
-	if(!qof_object_compliance(original->e_type, TRUE)) { return FALSE; }
+	if(!qof_object_compliance(G_OBJECT_TYPE (G_OBJECT (original)), TRUE)) { return FALSE; }
 	qof_event_suspend();
 	qecd.param_list = NULL;
 	book = qof_session_get_book(new_session);
 	qecd.new_session = new_session;
 	qof_book_set_partial(book);
-	inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
-	qecd.to = &inst->entity;
+	inst = (QofInstance*)qof_object_new_instance(G_OBJECT_TYPE (G_OBJECT (original)), book);
+	qecd.to = inst;
 	qecd.from = original;
-	qof_entity_set_guid(qecd.to, qof_entity_get_guid(original));
+	qof_instance_set_guid(qecd.to, qof_instance_get_guid(original));
 	qof_begin_edit(inst);
-	qof_class_param_foreach(original->e_type, qof_entity_param_cb, &qecd);
+	qof_class_param_foreach(G_OBJECT_TYPE (G_OBJECT (original)), qof_entity_param_cb, &qecd);
 	qof_commit_edit(inst);
 	if(g_slist_length(qecd.param_list) == 0) { return FALSE; }
 	g_slist_foreach(qecd.param_list, qof_entity_foreach_copy, &qecd);
@@ -658,11 +659,11 @@
 
 gboolean qof_entity_copy_list(QofSession *new_session, GList *entity_list)
 {
-	QofEntityCopyData *qecd;
+	QofInstanceCopyData *qecd;
 
 	if(!new_session || !entity_list) { return FALSE; }
 	ENTER (" list=%d", g_list_length(entity_list));
-	qecd = g_new0(QofEntityCopyData, 1);
+	qecd = g_new0(QofInstanceCopyData, 1);
 	qof_event_suspend();
 	qecd->param_list = NULL;
 	qecd->new_session = new_session;
@@ -681,7 +682,7 @@
 gboolean 
 qof_entity_copy_coll(QofSession *new_session, QofCollection *entity_coll)
 {
-	QofEntityCopyData qecd;
+	QofInstanceCopyData qecd;
 
 	g_return_val_if_fail(new_session, FALSE);
 	if(!entity_coll) { return FALSE; }
@@ -690,7 +691,7 @@
 	qecd.new_session = new_session;
 	qof_book_set_partial(qof_session_get_book(qecd.new_session));
 	qof_collection_foreach(entity_coll, qof_entity_coll_foreach, &qecd);
-	qof_class_param_foreach(qof_collection_get_type(entity_coll), 
+	qof_class_param_foreach(qof_collection_get_g_type(entity_coll), 
 		qof_entity_param_cb, &qecd);
 	qof_collection_foreach(entity_coll, qof_entity_coll_copy, &qecd);
 	if(qecd.param_list != NULL) { g_slist_free(qecd.param_list); }
@@ -707,7 +708,7 @@
 };
 
 static void
-recurse_collection_cb (QofEntity *ent, gpointer user_data)
+recurse_collection_cb (QofInstance *ent, gpointer user_data)
 {
 	struct recurse_s *store;
 
@@ -721,11 +722,11 @@
 }
 
 static void
-recurse_ent_cb(QofEntity *ent, gpointer user_data)
+recurse_ent_cb(QofInstance *ent, gpointer user_data)
 {
 	GList      *ref_list, *i, *j, *ent_list, *child_list;
 	QofParam   *ref_param;
-	QofEntity  *ref_ent, *child_ent;
+	QofInstance  *ref_ent, *child_ent;
 	QofSession *session;
 	struct recurse_s *store;
 	gboolean   success;
@@ -747,7 +748,7 @@
 		if(i->data == NULL) { continue; }
 		ref_param = (QofParam*)i->data;
 		if(ref_param->param_name == NULL) { continue; }
-		if(0 == safe_strcmp(ref_param->param_type, QOF_TYPE_COLLECT)) {
+		if(ref_param->param_type == QOF_TYPE_COLLECT) {
 			QofCollection *col;
 
 			col = ref_param->param_getfcn(ent, ref_param);
@@ -756,8 +757,8 @@
 			}
 			continue;
 		}
-		ref_ent = (QofEntity*)ref_param->param_getfcn(ent, ref_param);
-		if((ref_ent)&&(ref_ent->e_type))
+		ref_ent = (QofInstance*)ref_param->param_getfcn(ent, ref_param);
+		if((ref_ent)&&(G_OBJECT_TYPE (G_OBJECT (ref_ent))))
 		{
 			store->success = qof_entity_copy_to_session(session, ref_ent);
 			if(store->success) { ent_list = g_list_append(ent_list, ref_ent); }
@@ -766,9 +767,9 @@
 	for(i = ent_list; i != NULL; i = i->next)
 	{
 		if(i->data == NULL) { continue; }
-		child_ent = (QofEntity*)i->data;
+		child_ent = (QofInstance*)i->data;
 		if(child_ent == NULL) { continue; }
-		ref_list = qof_class_get_referenceList(child_ent->e_type);
+		ref_list = qof_class_get_referenceList(G_OBJECT_TYPE (G_OBJECT (child_ent)));
 		for(j = ref_list; j != NULL; j = j->next)
 		{
 			if(j->data == NULL) { continue; }
@@ -784,9 +785,9 @@
 	for(i = child_list; i != NULL; i = i->next)
 	{
 		if(i->data == NULL) { continue; }
-		ref_ent = (QofEntity*)i->data;
+		ref_ent = (QofInstance*)i->data;
 		if(ref_ent == NULL) { continue; }
-		ref_list = qof_class_get_referenceList(ref_ent->e_type);
+		ref_list = qof_class_get_referenceList(G_OBJECT_TYPE (G_OBJECT (ref_ent)));
 		for(j = ref_list; j != NULL; j = j->next)
 		{
 			if(j->data == NULL) { continue; }
@@ -811,13 +812,13 @@
 	success = TRUE;
 	store.success = success;
 	store.ent_list = NULL;
-	store.ref_list = qof_class_get_referenceList(qof_collection_get_type(coll));
+	store.ref_list = qof_class_get_referenceList(qof_collection_get_g_type(coll));
 	success = qof_entity_copy_coll(new_session, coll);
 	if(success){ qof_collection_foreach(coll, recurse_ent_cb, &store); }
 	return success;
 }
 
-gboolean qof_entity_copy_one_r(QofSession *new_session, QofEntity *ent)
+gboolean qof_entity_copy_one_r(QofSession *new_session, QofInstance *ent)
 {
 	struct recurse_s store;
 	QofCollection *coll;
@@ -827,10 +828,10 @@
 	store.session = new_session;
 	success = TRUE;
 	store.success = success;
-	store.ref_list = qof_class_get_referenceList(ent->e_type);
+	store.ref_list = qof_class_get_referenceList(G_OBJECT_TYPE (G_OBJECT (ent)));
 	success = qof_entity_copy_to_session(new_session, ent);
 	if(success == TRUE) {
-		coll = qof_book_get_collection(qof_session_get_book(new_session), ent->e_type);
+		coll = qof_book_get_collection(qof_session_get_book(new_session), G_OBJECT_TYPE (G_OBJECT (ent)));
 		if(coll) { qof_collection_foreach(coll, recurse_ent_cb, &store); }
 	}
 	return success;
@@ -962,7 +963,7 @@
                    gboolean ignore_lock, gboolean create_if_nonexistent)
 {
   char *p, *access_method, *msg;
-  int err;
+  QofBackendError err;
 
   if (!session) return;
 
@@ -1045,7 +1046,7 @@
                                   session->book_id, ignore_lock,
                                   create_if_nonexistent);
       PINFO("Done running session_begin on backend");
-      err = qof_backend_get_error(session->backend);
+      err = qof_backend_get_error_code (session->backend);
       msg = qof_backend_get_message(session->backend);
       if (err != ERR_BACKEND_NO_ERR)
       {
@@ -1119,7 +1120,7 @@
 		if (be->load) 
 		{
 			be->load (be, newbook);
-			qof_session_push_error (session, qof_backend_get_error(be), NULL);
+			qof_session_push_error (session, qof_backend_get_error_code (be), NULL);
 		}
 	}
 
@@ -1170,8 +1171,8 @@
 static gboolean
 save_error_handler(QofBackend *be, QofSession *session)
 {
-    int err;
-    err = qof_backend_get_error(be);
+    QofBackendError err;
+    err = qof_backend_get_error_code (be);
     
     if (ERR_BACKEND_NO_ERR != err)
     {
@@ -1191,7 +1192,7 @@
 	QofBackendProvider *prov;
 	GSList *p;
 	QofBook *book, *abook;
-	int err;
+	QofBackendError err;
 	gint num;
 	char *msg, *book_id;
 
@@ -1255,7 +1256,7 @@
 					(session->backend->session_begin)(session->backend, session,
 						book_id, TRUE, TRUE);
 					PINFO("Done running session_begin on changed backend");
-					err = qof_backend_get_error(session->backend);
+					err = qof_backend_get_error_code (session->backend);
 					msg = qof_backend_get_message(session->backend);
 					if (err != ERR_BACKEND_NO_ERR)
 					{
@@ -1478,10 +1479,10 @@
 
   be->percentage = percentage_func;
   if (be->export) {
-      int err;
+      QofBackendError err;
 
       (be->export)(be, book);
-      err = qof_backend_get_error(be);
+      err = qof_backend_get_error_code (be);
     
       if (ERR_BACKEND_NO_ERR != err) { return FALSE; }
   }

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofsession.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -264,7 +264,7 @@
 
 Copied entities are identical to the source entity, all parameters
 defined with ::QofAccessFunc and ::QofSetterFunc in QOF are copied
-and the ::GUID of the original ::QofEntity is set in the new entity.
+and the ::GUID of the original ::QofInstance is set in the new entity.
 Sessions containing copied entities are intended for use
 as mechanisms for data export.
 
@@ -280,19 +280,19 @@
 
 */
 
-/** \brief Copy a single QofEntity to another session
+/** \brief Copy a single QofInstance to another session
  
 Checks first that no entity in the session book contains
 the GUID of the source entity. 
 
  @param new_session - the target session
- @param original - the QofEntity* to copy
+ @param original - the QofInstance* to copy
 
 @return FALSE without copying if the session contains an entity
 with the same GUID already, otherwise TRUE.
 */
 
-gboolean qof_entity_copy_to_session(QofSession* new_session, QofEntity* original);
+gboolean qof_entity_copy_to_session(QofSession* new_session, QofInstance* original);
 
 /** @brief Copy a GList of entities to another session
 
@@ -301,12 +301,12 @@
 no support for handling collisions, instead use \ref BookMerge
 
 Note that the GList (e.g. from ::qof_sql_query_run) can contain
-QofEntity pointers of any ::QofIdType, in any sequence. As long
-as all members of the list are ::QofEntity*, and all GUID's are
+QofInstance pointers of any ::QofIdType, in any sequence. As long
+as all members of the list are ::QofInstance*, and all GUID's are
 unique, the list can be copied.
 
  @param new_session - the target session
- @param entity_list - a GList of QofEntity pointers of any type(s).
+ @param entity_list - a GList of QofInstance pointers of any type(s).
 
 @return FALSE, without copying, if new_session contains any entities
 with the same GUID. Otherwise TRUE.
@@ -341,7 +341,7 @@
 Objects can be defined solely in terms of QOF data types or
 as a mix of data types and other objects, which may in turn
 include other objects. These references can be copied recursively
-down to the third level. See ::QofEntityReference.
+down to the third level. See ::QofInstanceReference.
 
 \note This is a deep recursive copy - every referenced entity is copied
 to the new session, including all parameters. The starting point is all
@@ -380,7 +380,7 @@
 one of the references fails to copy.
 */
 gboolean
-qof_entity_copy_one_r(QofSession *new_session, QofEntity *ent);
+qof_entity_copy_one_r(QofSession *new_session, QofInstance *ent);
 
 /** @} 
 */

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -303,7 +303,7 @@
 }
 
 gchar*
-qof_util_param_as_string(QofEntity *ent, QofParam *param)
+qof_util_param_as_string(QofInstance *ent, QofParam *param)
 {
 	gchar       *param_string, param_date[MAX_DATE_LENGTH];
 	gchar       param_sa[GUID_ENCODING_LENGTH + 1];
@@ -311,25 +311,25 @@
 	QofType     paramType;
 	const GUID *param_guid;
 	time_t      param_t;
-	gnc_numeric param_numeric,  (*numeric_getter) (QofEntity*, QofParam*);
-	Timespec    param_ts,       (*date_getter)    (QofEntity*, QofParam*);
-	double      param_double,   (*double_getter)  (QofEntity*, QofParam*);
-	gboolean    param_boolean,  (*boolean_getter) (QofEntity*, QofParam*);
-	gint32      param_i32,      (*int32_getter)   (QofEntity*, QofParam*);
-	gint64      param_i64,      (*int64_getter)   (QofEntity*, QofParam*);
-	gchar       param_char,     (*char_getter)    (QofEntity*, QofParam*);
+	gnc_numeric param_numeric,  (*numeric_getter) (QofInstance*, QofParam*);
+	Timespec    param_ts,       (*date_getter)    (QofInstance*, QofParam*);
+	double      param_double,   (*double_getter)  (QofInstance*, QofParam*);
+	gboolean    param_boolean,  (*boolean_getter) (QofInstance*, QofParam*);
+	gint32      param_i32,      (*int32_getter)   (QofInstance*, QofParam*);
+	gint64      param_i64,      (*int64_getter)   (QofInstance*, QofParam*);
+	gchar       param_char,     (*char_getter)    (QofInstance*, QofParam*);
 
 	param_string = NULL;
     known_type = FALSE;
 	paramType = param->param_type;
-	if(safe_strcmp(paramType, QOF_TYPE_STRING) == 0)  { 
+	if(paramType == QOF_TYPE_STRING)  { 
 			param_string = g_strdup(param->param_getfcn(ent, param));
 			if(param_string == NULL) { param_string = ""; }
             known_type = TRUE;
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_DATE) == 0) { 
-			date_getter = (Timespec (*)(QofEntity*, QofParam*))param->param_getfcn;
+		if(paramType == QOF_TYPE_DATE) { 
+			date_getter = (Timespec (*)(QofInstance*, QofParam*))param->param_getfcn;
 			param_ts = date_getter(ent, param);
 			param_t = timespecToTime_t(param_ts);
 			strftime(param_date, MAX_DATE_LENGTH, 
@@ -338,44 +338,44 @@
             known_type = TRUE;
 			return param_string;
 		}
-		if((safe_strcmp(paramType, QOF_TYPE_NUMERIC) == 0)  ||
-		(safe_strcmp(paramType, QOF_TYPE_DEBCRED) == 0)) { 
-			numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) param->param_getfcn;
+		if((paramType == QOF_TYPE_NUMERIC)  ||
+		(paramType == QOF_TYPE_DEBCRED)) { 
+			numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) param->param_getfcn;
 			param_numeric = numeric_getter(ent, param);
 			param_string = g_strdup(gnc_numeric_to_string(param_numeric));
             known_type = TRUE;
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_GUID) == 0) { 
+		if(paramType == QOF_TYPE_GUID) { 
 			param_guid = param->param_getfcn(ent, param);
 			guid_to_string_buff(param_guid, param_sa);
 			param_string = g_strdup(param_sa);
             known_type = TRUE;
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_INT32) == 0) { 
-			int32_getter = (gint32 (*)(QofEntity*, QofParam*)) param->param_getfcn;
+		if(paramType == QOF_TYPE_INT32) { 
+			int32_getter = (gint32 (*)(QofInstance*, QofParam*)) param->param_getfcn;
 			param_i32 = int32_getter(ent, param);
 			param_string = g_strdup_printf("%d", param_i32);
             known_type = TRUE;
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_INT64) == 0) { 
-			int64_getter = (gint64 (*)(QofEntity*, QofParam*)) param->param_getfcn;
+		if(paramType == QOF_TYPE_INT64) { 
+			int64_getter = (gint64 (*)(QofInstance*, QofParam*)) param->param_getfcn;
 			param_i64 = int64_getter(ent, param);
 			param_string = g_strdup_printf("%"G_GINT64_FORMAT, param_i64);
             known_type = TRUE;
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_DOUBLE) == 0) { 
-			double_getter = (double (*)(QofEntity*, QofParam*)) param->param_getfcn;
+		if(paramType == QOF_TYPE_DOUBLE) { 
+			double_getter = (double (*)(QofInstance*, QofParam*)) param->param_getfcn;
 			param_double = double_getter(ent, param);
 			param_string = g_strdup_printf("%f", param_double);
             known_type = TRUE;
 			return param_string;
 		}
-		if(safe_strcmp(paramType, QOF_TYPE_BOOLEAN) == 0){ 
-			boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) param->param_getfcn;
+		if(paramType == QOF_TYPE_BOOLEAN){ 
+			boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) param->param_getfcn;
 			param_boolean = boolean_getter(ent, param);
 			/* Boolean values need to be lowercase for QSF validation. */
 			if(param_boolean == TRUE) { param_string = g_strdup("true"); }
@@ -384,42 +384,42 @@
 			return param_string;
 		}
 		/* "kvp" contains repeating values, cannot be a single string for the frame. */
-		if(safe_strcmp(paramType, QOF_TYPE_KVP) == 0) {
+		if(paramType == QOF_TYPE_KVP) {
             KvpFrame *frame = NULL;
             frame = param->param_getfcn(ent, param);
             known_type = TRUE;
             if(!kvp_frame_is_empty(frame)) 
             {
                 GHashTable *hash = kvp_frame_get_hash(frame);
-                param_string = g_strdup_printf("%s(%d)", QOF_TYPE_KVP,
+                param_string = g_strdup_printf("%s(%d)", g_type_name (QOF_TYPE_KVP),
                     g_hash_table_size(hash));
             }
             return param_string; 
         }
-		if(safe_strcmp(paramType, QOF_TYPE_CHAR) == 0) { 
-			char_getter = (gchar (*)(QofEntity*, QofParam*)) param->param_getfcn;
+		if(paramType == QOF_TYPE_CHAR) { 
+			char_getter = (gchar (*)(QofInstance*, QofParam*)) param->param_getfcn;
 			param_char = char_getter(ent, param);
             known_type = TRUE;
 			return g_strdup_printf("%c", param_char);
 		}
 		/* "collect" contains repeating values, cannot be a single string. */
-        if(safe_strcmp(paramType, QOF_TYPE_COLLECT) == 0)
+        if(paramType == QOF_TYPE_COLLECT)
         {
             QofCollection *col = NULL;
             col = param->param_getfcn(ent, param);
             known_type = TRUE;
             return g_strdup_printf("%s(%d)", 
-                qof_collection_get_type(col), qof_collection_count(col));
+                g_type_name (qof_collection_get_g_type(col)), qof_collection_count(col));
         }
-        if(safe_strcmp(paramType, QOF_TYPE_CHOICE) == 0)
+        if(paramType == QOF_TYPE_CHOICE)
         {
-            QofEntity *child = NULL;
+            QofInstance *child = NULL;
             child = param->param_getfcn(ent, param);
             if(!child) { return param_string; }
             known_type = TRUE;
-            return g_strdup(qof_object_printable(child->e_type, child));
+            return g_strdup(qof_instance_to_string (child));
         }
-        if(safe_strcmp(paramType, QOF_PARAM_BOOK) == 0)
+        if(paramType == QOF_PARAM_BOOK)
         {
             QofBackend *be;
             QofBook *book;
@@ -428,11 +428,14 @@
             be = qof_book_get_backend(book);
             known_type = TRUE;
             PINFO (" backend=%p", be);
-            if(!be) { return QOF_PARAM_BOOK; }
+            if(!be) 
+            { 
+                return "book"; /* FIXME: could be used g_type_name (QOF_TYPE_BOOK) */ 
+            }
             param_string = g_strdup(be->fullpath);
             PINFO (" fullpath=%s", param_string);
             if(param_string) { return param_string; }
-			param_guid = qof_book_get_guid(book);
+			param_guid = qof_instance_get_guid(QOF_INSTANCE (book));
 			guid_to_string_buff(param_guid, param_sa);
             PINFO (" book GUID=%s", param_sa);
 			param_string = g_strdup(param_sa);
@@ -440,10 +443,10 @@
         }
         if(!known_type)
         {
-            QofEntity *child = NULL;
+            QofInstance *child = NULL;
             child = param->param_getfcn(ent, param);
             if(!child) { return param_string; }
-            return g_strdup(qof_object_printable(child->e_type, child));
+            return g_strdup(qof_instance_to_string (child));
         }
 	return g_strdup("");
 }
@@ -455,7 +458,7 @@
 	guid_init ();
 	qof_object_initialize ();
 	qof_query_init ();
-	qof_book_register ();
+	/*qof_book_register (); FIXME: This is broken for now but not needed... I think..*/
 }
 
 void

Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofutil.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -38,7 +38,6 @@
 #include "qofutil.h"
 #include "qofbackend.h"
 #include "qofclass.h"
-#include "qofbook.h"
 #include "qofinstance.h"
 
 /** Do not use these for printf, only scanf */
@@ -235,7 +234,7 @@
 
 The returned string must be freed by the caller.
 */
-gchar* qof_util_param_as_string(QofEntity *ent, QofParam *param);
+gchar* qof_util_param_as_string(QofInstance *ent, QofParam *param);
 
 /** The QOF String Cache:
  *

Modified: gnucash/branches/gobject-engine-dev/src/app-utils/gnc-component-manager.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/app-utils/gnc-component-manager.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/app-utils/gnc-component-manager.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -242,9 +242,8 @@
   mask = g_hash_table_lookup (cei->event_masks, entity_type);
   if (!mask)
   {
-    char * key = qof_util_string_cache_insert ((gpointer) entity_type);
     mask = g_new0 (QofEventId, 1);
-    g_hash_table_insert (cei->event_masks, key, mask);
+    g_hash_table_insert (cei->event_masks, entity_type, mask);
   }
 
   if (or_in)
@@ -259,7 +258,7 @@
                       gpointer user_data,
 		      gpointer event_data)
 {
-  const GUID *guid = qof_entity_get_guid(entity);
+  const GUID *guid = qof_instance_get_guid(entity);
 #if CM_DEBUG
   fprintf (stderr, "event_handler: event %d, entity %p, guid %s\n", event_type,
 	   entity, guid);
@@ -274,7 +273,7 @@
     add_event_type (&changes, GNC_ID_TRANS, QOF_EVENT_MODIFY, TRUE);
   }
   else
-    add_event_type (&changes, entity->e_type, event_type, TRUE);
+    add_event_type (&changes, G_OBJECT_TYPE (entity), event_type, TRUE);
 
   got_events = TRUE;
 
@@ -293,10 +292,10 @@
     return;
   }
 
-  changes.event_masks = g_hash_table_new (g_str_hash, g_str_equal);
+  changes.event_masks = g_hash_table_new (g_int_hash, g_int_equal);
   changes.entity_events = guid_hash_table_new ();
 
-  changes_backup.event_masks = g_hash_table_new (g_str_hash, g_str_equal);
+  changes_backup.event_masks = g_hash_table_new (g_int_hash, g_int_equal);
   changes_backup.entity_events = guid_hash_table_new ();
 
   handler_id = qof_event_register_handler (gnc_cm_event_handler, NULL);

Modified: gnucash/branches/gobject-engine-dev/src/engine/Account.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Account.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/Account.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -39,18 +39,23 @@
 #include "gnc-lot-p.h"
 #include "gnc-pricedb.h"
 #include "policy.h"
+#include "Split.h"
+#include "Transaction.h"
 
 static QofLogModule log_module = GNC_MOD_ACCOUNT;
 
 static gulong commit_event_handler = 0;
 
 static void gnc_account_bring_uptodate (GncAccount *acc);
+static void destroy_pending_splits_for_account(QofEntity *ent, gpointer acc);
+
 /* GObject declarations */
 
 static void gnc_account_class_init(GncAccountClass *klass);
 static void gnc_account_init(GncAccount *sp);
 static void gnc_account_finalize(GObject *object);
-
+static void gnc_account_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec);
+static void gnc_account_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 /** \struct Account */
 struct _GncAccountPrivate
 {
@@ -136,6 +141,7 @@
 
 enum _GncAccountSignalType {
 	/* Signals */
+	FIRST_SIGNAL,
 	LAST_SIGNAL
 };
 
@@ -153,7 +159,7 @@
 static GObjectClass *parent_class = NULL;
 
 GType
-gnc_account_get_type()
+gnc_account_get_type(void)
 {
 	static GType type = 0;
 
@@ -196,7 +202,7 @@
 }
 
 static void
-gnc_account_init(GncAccount *obj)
+gnc_account_init(GncAccount *acc)
 {
 	/* Initialize private members, etc. */
   acc->priv = g_new0 (GncAccountPrivate, 1);
@@ -233,18 +239,21 @@
   acc->priv->balance_dirty = FALSE;
   acc->priv->sort_dirty = FALSE;
 
-  commit_event_handler = g_signal_connect (obj, "commit", G_CALLBACK (gnc_account_bring_uptodate), obj, NULL);
+  commit_event_handler = g_signal_connect (acc, "commit:biginning", G_CALLBACK (gnc_account_bring_uptodate), acc);
 }
 
 static void
 gnc_account_finalize(GObject *object)
 {
 		
-	GList *lp, *slist;
-    QofCollection *col;
-
+  GncAccount *acc;
+  GList *lp, *slist;
+  QofCollection *col;
+    
+    acc = GNC_ACCOUNT (object);
+    
     /* First, recursively free children */
-    xaccFreeAccountGroup (acc);
+    acc->priv->parent = NULL;
     acc->priv->children = NULL;
 
     PINFO ("freeing splits for account %p (%s)",
@@ -256,7 +265,7 @@
     {
       Split *s;
       s = lp->data;
-      gnc_split_destroy ((GncSplit*) s);
+      xaccSplitDestroy ((GncSplit*) s);
     }
     
     g_list_free(slist); 
@@ -312,7 +321,7 @@
 	switch (param_id) {		
 		default:
    			/* We don't have any other property... */
-    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,param_id,pspec);
     	break;
 	}
 }
@@ -385,8 +394,12 @@
 void
 mark_account (GncAccount *acc)
 {
-  if (acc->priv->parent) acc->priv->parent->saved = FALSE;
-  qof_instance_set_dirty(QOF_INSTANCE (acc));
+  if (acc->priv->parent) 
+  {
+    gnc_account_group_set_saved (acc->priv->parent);
+    qof_instance_set_dirty (QOF_INSTANCE (acc), TRUE);
+  }
+  
 }
 
 /********************************************************************\
@@ -405,11 +418,17 @@
 
   acc = GNC_ACCOUNT (g_object_new (GNC_TYPE_ACCOUNT, "book", book, NULL));
 
-  qof_event_gen (&acc->inst.entity, QOF_EVENT_CREATE, NULL);
+  qof_event_gen (QOF_INSTANCE (acc), QOF_EVENT_CREATE, NULL);
 
   return acc;
 }
 
+GncAccount *
+xaccMallocAccount (QofBook *book)
+{
+	return gnc_account_new (book);
+}
+
 static GncAccount *
 xaccCloneAccountCommon(const GncAccount *from, QofBook *book)
 {
@@ -421,26 +440,25 @@
     ret = GNC_ACCOUNT (g_object_new (GNC_TYPE_ACCOUNT, "book", book, NULL));
     g_return_val_if_fail (ret, NULL);
 
-    xaccInitAccount (ret, book);
 
     /* Do not Begin/CommitEdit() here; give the caller 
      * a chance to fix things up, and let them do it.
      * Also let caller issue the generate_event (EVENT_CREATE) */
-    ret->type = from->type;
+    ret->priv->type = from->priv->type;
 
-    ret->accountName = CACHE_INSERT(from->accountName);
-    ret->accountCode = CACHE_INSERT(from->accountCode);
-    ret->description = CACHE_INSERT(from->description);
+    ret->priv->accountName = CACHE_INSERT(from->priv->accountName);
+    ret->priv->accountCode = CACHE_INSERT(from->priv->accountCode);
+    ret->priv->description = CACHE_INSERT(from->priv->description);
 
-    kvp_frame_delete(ret->inst.kvp_data);
-    ret->inst.kvp_data = kvp_frame_copy(from->inst.kvp_data);
+    qof_instance_delete_kvp_data (QOF_INSTANCE (ret));
+    qof_instance_set_kvp_data (QOF_INSTANCE (ret), qof_instance_get_kvp_data (QOF_INSTANCE (from)));
 
     /* The new book should contain a commodity that matches
      * the one in the old book. Find it, use it. */
-    ret->commodity = gnc_commodity_obtain_twin (from->commodity, book);
+    ret->priv->commodity = gnc_commodity_obtain_twin (from->priv->commodity, book);
 
-    ret->commodity_scu = from->commodity_scu;
-    ret->non_standard_scu = from->non_standard_scu;
+    ret->priv->commodity_scu = from->priv->commodity_scu;
+    ret->priv->non_standard_scu = from->priv->non_standard_scu;
 
     LEAVE (" ");
     return ret;
@@ -450,7 +468,7 @@
 xaccCloneAccount (const GncAccount *from, QofBook *book)
 {
     GncAccount *ret = xaccCloneAccountCommon(from, book);
-    qof_instance_gemini (&ret->inst, (QofInstance *) &from->inst);
+    qof_instance_gemini (QOF_INSTANCE (ret), (QofInstance *) from);
     g_assert (ret ==
               (GncAccount*) qof_instance_lookup_twin (QOF_INSTANCE(from), book));
     return ret;
@@ -460,14 +478,27 @@
 xaccCloneAccountSimple (const GncAccount *from, QofBook *book)
 {
     GncAccount *ret = xaccCloneAccountCommon(from, book);    
-    qof_instance_set_dirty(&ret->inst);
+    qof_instance_set_dirty(QOF_INSTANCE (ret), TRUE);
     return ret;
 }
 
+
+AccountGroup* 
+gnc_account_get_children (GncAccount* acc)
+{
+  return acc->priv->children;
+}
+
+AccountGroup* 
+gnc_account_set_children (GncAccount* acc, AccountGroup *grp)
+{
+  acc->priv->children = grp;
+}
+
 /********************************************************************\
  * transactional routines
 \********************************************************************/
-/*TODO: Move this code */
+
 static void
 destroy_pending_splits_for_account(QofEntity *ent, gpointer acc)
 {
@@ -484,10 +515,30 @@
 gnc_account_destroy (GncAccount *acc) 
 {
   qof_instance_mark_free (QOF_INSTANCE (acc));
-  qof_instance_destroy (QOF_INSTANCE (acc));
-    qof_event_gen (&acc->inst.entity, QOF_EVENT_DESTROY, NULL);
+  qof_instance_destroy (QOF_INSTANCE (acc), NULL);
 }
 
+void
+xaccAccountDestroy (GncAccount *acc)
+{
+	gnc_account_destroy (acc);
+}
+
+gboolean 
+xaccAccountBeginEdit(GncAccount *acc)
+{
+	
+	return qof_instance_begin_edit(QOF_INSTANCE(acc), NULL);
+}
+
+gboolean
+xaccAccountCommitEdit (GncAccount *acc)
+{
+	
+	return qof_instance_commit_edit (QOF_INSTANCE (acc), NULL);
+}
+
+
 void 
 xaccAccountSetVersion (GncAccount *acc, gint32 vers)
 {
@@ -516,51 +567,51 @@
     return FALSE;
   }
 
-  if (aa->type != ab->type)
+  if (aa->priv->type != ab->priv->type)
   {
-    PWARN ("types differ: %d vs %d", aa->type, ab->type);
+    PWARN ("types differ: %d vs %d", aa->priv->type, ab->priv->type);
     return FALSE;
   }
 
-  if (safe_strcmp(aa->accountName, ab->accountName) != 0)
+  if (safe_strcmp(aa->priv->accountName, ab->priv->accountName) != 0)
   {
-    PWARN ("names differ: %s vs %s", aa->accountName, ab->accountName);
+    PWARN ("names differ: %s vs %s", aa->priv->accountName, ab->priv->accountName);
     return FALSE;
   }
 
-  if (safe_strcmp(aa->accountCode, ab->accountCode) != 0)
+  if (safe_strcmp(aa->priv->accountCode, ab->priv->accountCode) != 0)
   {
-    PWARN ("codes differ: %s vs %s", aa->accountCode, ab->accountCode);
+    PWARN ("codes differ: %s vs %s", aa->priv->accountCode, ab->priv->accountCode);
     return FALSE;
   }
 
-  if (safe_strcmp(aa->description, ab->description) != 0)
+  if (safe_strcmp(aa->priv->description, ab->priv->description) != 0)
   {
-    PWARN ("descriptions differ: %s vs %s", aa->description, ab->description);
+    PWARN ("descriptions differ: %s vs %s", aa->priv->description, ab->priv->description);
     return FALSE;
   }
 
-  if (!gnc_commodity_equal(aa->commodity, ab->commodity))
+  if (!gnc_commodity_equal(aa->priv->commodity, ab->priv->commodity))
   {
     PWARN ("commodities differ");
     return FALSE;
   }
 
   if(check_guids) {
-    if(!guid_equal(&aa->inst.entity.guid, &ab->inst.entity.guid))
+    if(!guid_equal(qof_instance_get_guid (QOF_INSTANCE (aa)), qof_instance_get_guid (QOF_INSTANCE (ab))))
     {
       PWARN ("GUIDs differ");
       return FALSE;
     }
   }
 
-  if (kvp_frame_compare(aa->inst.kvp_data, ab->inst.kvp_data) != 0)
+  if (kvp_frame_compare(qof_instance_get_kvp_data (QOF_INSTANCE (aa)), qof_instance_get_kvp_data (QOF_INSTANCE (ab))) != 0)
   {
     char *frame_a;
     char *frame_b;
 
-    frame_a = kvp_frame_to_string (aa->inst.kvp_data);
-    frame_b = kvp_frame_to_string (ab->inst.kvp_data);
+    frame_a = kvp_frame_to_string (qof_instance_get_kvp_data (QOF_INSTANCE (aa)));
+    frame_b = kvp_frame_to_string (qof_instance_get_kvp_data (QOF_INSTANCE (ab)));
 
     PWARN ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
 
@@ -570,13 +621,13 @@
     return FALSE;
   }
 
-  if (!gnc_numeric_equal (aa->starting_balance, ab->starting_balance))
+  if (!gnc_numeric_equal (aa->priv->starting_balance, ab->priv->starting_balance))
   {
     char *str_a;
     char *str_b;
 
-    str_a = gnc_numeric_to_string (aa->starting_balance);
-    str_b = gnc_numeric_to_string (ab->starting_balance);
+    str_a = gnc_numeric_to_string (aa->priv->starting_balance);
+    str_b = gnc_numeric_to_string (ab->priv->starting_balance);
 
     PWARN ("starting balances differ: %s vs %s", str_a, str_b);
 
@@ -586,14 +637,14 @@
     return FALSE;
   }
 
-  if (!gnc_numeric_equal (aa->starting_cleared_balance,
-                          ab->starting_cleared_balance))
+  if (!gnc_numeric_equal (aa->priv->starting_cleared_balance,
+                          ab->priv->starting_cleared_balance))
   {
     char *str_a;
     char *str_b;
 
-    str_a = gnc_numeric_to_string (aa->starting_cleared_balance);
-    str_b = gnc_numeric_to_string (ab->starting_cleared_balance);
+    str_a = gnc_numeric_to_string (aa->priv->starting_cleared_balance);
+    str_b = gnc_numeric_to_string (ab->priv->starting_cleared_balance);
 
     PWARN ("starting cleared balances differ: %s vs %s", str_a, str_b);
 
@@ -603,14 +654,14 @@
     return FALSE;
   }
 
-  if (!gnc_numeric_equal (aa->starting_reconciled_balance,
-                          ab->starting_reconciled_balance))
+  if (!gnc_numeric_equal (aa->priv->starting_reconciled_balance,
+                          ab->priv->starting_reconciled_balance))
   {
     char *str_a;
     char *str_b;
 
-    str_a = gnc_numeric_to_string (aa->starting_reconciled_balance);
-    str_b = gnc_numeric_to_string (ab->starting_reconciled_balance);
+    str_a = gnc_numeric_to_string (aa->priv->starting_reconciled_balance);
+    str_b = gnc_numeric_to_string (ab->priv->starting_reconciled_balance);
 
     PWARN ("starting reconciled balances differ: %s vs %s", str_a, str_b);
 
@@ -620,13 +671,13 @@
     return FALSE;
   }
 
-  if (!gnc_numeric_equal (aa->balance, ab->balance))
+  if (!gnc_numeric_equal (aa->priv->balance, ab->priv->balance))
   {
     char *str_a;
     char *str_b;
 
-    str_a = gnc_numeric_to_string (aa->balance);
-    str_b = gnc_numeric_to_string (ab->balance);
+    str_a = gnc_numeric_to_string (aa->priv->balance);
+    str_b = gnc_numeric_to_string (ab->priv->balance);
 
     PWARN ("balances differ: %s vs %s", str_a, str_b);
 
@@ -636,13 +687,13 @@
     return FALSE;
   }
 
-  if (!gnc_numeric_equal (aa->cleared_balance, ab->cleared_balance))
+  if (!gnc_numeric_equal (aa->priv->cleared_balance, ab->priv->cleared_balance))
   {
     char *str_a;
     char *str_b;
 
-    str_a = gnc_numeric_to_string (aa->cleared_balance);
-    str_b = gnc_numeric_to_string (ab->cleared_balance);
+    str_a = gnc_numeric_to_string (aa->priv->cleared_balance);
+    str_b = gnc_numeric_to_string (ab->priv->cleared_balance);
 
     PWARN ("cleared balances differ: %s vs %s", str_a, str_b);
 
@@ -652,13 +703,13 @@
     return FALSE;
   }
 
-  if (!gnc_numeric_equal (aa->reconciled_balance, ab->reconciled_balance))
+  if (!gnc_numeric_equal (aa->priv->reconciled_balance, ab->priv->reconciled_balance))
   {
     char *str_a;
     char *str_b;
 
-    str_a = gnc_numeric_to_string (aa->reconciled_balance);
-    str_b = gnc_numeric_to_string (ab->reconciled_balance);
+    str_a = gnc_numeric_to_string (aa->priv->reconciled_balance);
+    str_b = gnc_numeric_to_string (ab->priv->reconciled_balance);
 
     PWARN ("reconciled balances differ: %s vs %s", str_a, str_b);
 
@@ -671,8 +722,8 @@
   /* no parent; always compare downwards. */
 
   {
-    GList *la = aa->splits;
-    GList *lb = ab->splits;
+    GList *la = aa->priv->splits;
+    GList *lb = ab->priv->splits;
 
     if ((la && !lb) || (!la && lb))
     {
@@ -706,7 +757,7 @@
     }
   }
 
-  if (!xaccGroupEqual(aa->children, ab->children, check_guids))
+  if (!xaccGroupEqual(aa->priv->children, ab->priv->children, check_guids))
   {
     PWARN ("children differ");
     return FALSE;
@@ -720,14 +771,14 @@
 void
 xaccAccountSortSplits (GncAccount *acc, gboolean force)
 {
-  if (!acc || !acc->priv->sort_dirty || (!force && qof_instance_get_edit_level (QOF_INSTANCE (acc) > 0)) return;
+  if (!acc || !acc->priv->sort_dirty || (!force && qof_instance_get_edit_level (QOF_INSTANCE (acc)) > 0)) return;
 
   acc->priv->splits = g_list_sort(acc->priv->splits, (GCompareFunc)xaccSplitDateOrder);
   acc->priv->sort_dirty = FALSE;
   acc->priv->balance_dirty = TRUE;
 }
 
-/* TODO: Call this function as callback when  an event commit is emitted */
+/* was: xaccAccountBringUpdaToDate */
 static void
 gnc_account_bring_uptodate (GncAccount *acc) 
 {
@@ -886,16 +937,16 @@
 xaccAccountMoveAllSplits (GncAccount *accfrom, GncAccount *accto)
 {
   /* Handle special cases. */
-  if (!accfrom || !accto || !accfrom->splits || accfrom == accto) return;
+  if (!accfrom || !accto || !accfrom->priv->splits || accfrom == accto) return;
 
   /* check for book mix-up */
-  g_return_if_fail (accfrom->inst.book == accto->inst.book);
+  g_return_if_fail (qof_instance_get_book (QOF_INSTANCE (accfrom)) == qof_instance_get_book (QOF_INSTANCE (accto)));
   ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
 
   xaccAccountBeginEdit(accfrom);
   xaccAccountBeginEdit(accto);
   /* Begin editing both accounts and all transactions in accfrom. */
-  g_list_foreach(accfrom->splits, (GFunc)xaccPreSplitMove, NULL);
+  g_list_foreach(accfrom->priv->splits, (GFunc)xaccPreSplitMove, NULL);
 
   /* Concatenate accfrom's lists of splits and lots to accto's lists. */
   //accto->splits = g_list_concat(accto->splits, accfrom->splits);
@@ -912,11 +963,11 @@
    * Convert each split's amount to accto's commodity.
    * Commit to editing each transaction.
    */
-  g_list_foreach(accfrom->splits, (GFunc)xaccPostSplitMove, (gpointer)accto);
+  g_list_foreach(accfrom->priv->splits, (GFunc)xaccPostSplitMove, (gpointer)accto);
 
   /* Finally empty accfrom. */
-  g_assert(accfrom->splits == NULL);
-  g_assert(accfrom->lots == NULL);
+  g_assert(accfrom->priv->splits == NULL);
+  g_assert(accfrom->priv->lots == NULL);
   xaccAccountCommitEdit(accfrom);
   xaccAccountCommitEdit(accto);
 
@@ -1054,8 +1105,8 @@
   if ( !(*aa) && !(*ab) ) return 0;
 
   /* sort on accountCode strings */
-  da = (*aa)->accountCode;
-  db = (*ab)->accountCode;
+  da = (*aa)->priv->accountCode;
+  db = (*ab)->priv->accountCode;
 
   /* If accountCodes are both base 36 integers do an integer sort */
   la = strtoul (da, &endptr, 36);
@@ -1082,22 +1133,22 @@
   }
 
   /* otherwise, sort on account type */
-  ta = (*aa)->type;
-  tb = (*ab)->type;
+  ta = (*aa)->priv->type;
+  tb = (*ab)->priv->type;
   ta = revorder[ta];
   tb = revorder[tb];
   if (ta < tb) return -1;
   if (ta > tb) return +1;
 
   /* otherwise, sort on accountName strings */
-  da = (*aa)->accountName;
-  db = (*ab)->accountName;
+  da = (*aa)->priv->accountName;
+  db = (*ab)->priv->accountName;
   result = safe_utf8_collate(da, db);
   if (result)
     return result;
 
   /* guarantee a stable sort */
-  return guid_compare (&((*aa)->inst.entity.guid), &((*ab)->inst.entity.guid));
+  return guid_compare (qof_instance_get_guid (QOF_INSTANCE(aa)), qof_instance_get_guid (QOF_INSTANCE(ab)));
 }
 
 /********************************************************************\
@@ -1135,7 +1186,7 @@
 void 
 xaccAccountSetCode (GncAccount *acc, const char *str) 
 {
-   if (!acc || !str || str == acc->accountCode) return;
+   if (!acc || !str || str == acc->priv->accountCode) return;
 
    qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
    
@@ -1151,7 +1202,7 @@
 void
 xaccAccountSetDescription (GncAccount *acc, const char *str) 
 {
-   if (!acc || !str || str == acc->description) return;
+   if (!acc || !str || str == acc->priv->description) return;
 
    qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
    
@@ -1202,7 +1253,7 @@
 xaccAccountSetCommodity (GncAccount * acc, gnc_commodity * com) 
 {
   GList *lp;
-  if (!acc || !com || com == acc->commodity) return;
+  if (!acc || !com || com == acc->priv->commodity) return;
 
   qof_instance_begin_edit (QOF_INSTANCE (acc), NULL);
 
@@ -1248,8 +1299,8 @@
 
   xaccAccountBeginEdit(acc);
   acc->priv->commodity_scu = scu;
-  if (scu != gnc_commodity_get_fraction(acc->commodity))
-      acc->non_standard_scu = TRUE;
+  if (scu != gnc_commodity_get_fraction(acc->priv->commodity))
+      acc->priv->non_standard_scu = TRUE;
   mark_account(acc);
   xaccAccountCommitEdit(acc);
 }
@@ -1257,7 +1308,7 @@
 int
 xaccAccountGetCommoditySCUi (const GncAccount * acc)
 {
-  return acc ? acc->commodity_scu : 0;
+  return acc ? acc->priv->commodity_scu : 0;
 }
 
 int
@@ -1265,18 +1316,18 @@
 {
   if (!acc) return 0;
 
-  if (acc->non_standard_scu || !acc->commodity)
-    return acc->commodity_scu;
-  return gnc_commodity_get_fraction(acc->commodity);
+  if (acc->priv->non_standard_scu || !acc->priv->commodity)
+    return acc->priv->commodity_scu;
+  return gnc_commodity_get_fraction(acc->priv->commodity);
 }
 
 void
 xaccAccountSetNonStdSCU (GncAccount *acc, gboolean flag)
 {
-  if (!acc || acc->non_standard_scu == flag) return;
+  if (!acc || acc->priv->non_standard_scu == flag) return;
 
   xaccAccountBeginEdit(acc);
-  acc->non_standard_scu = flag;
+  acc->priv->non_standard_scu = flag;
   mark_account (acc);
   xaccAccountCommitEdit(acc);
 }
@@ -1284,7 +1335,7 @@
 gboolean
 xaccAccountGetNonStdSCU (const GncAccount * acc)
 {
-  return acc ? acc->non_standard_scu : 0;
+  return acc ? acc->priv->non_standard_scu : 0;
 }
 
 /********************************************************************\
@@ -1301,7 +1352,7 @@
 
   xaccAccountBeginEdit(acc);
   string = gnc_commodity_get_unique_name (currency);
-  kvp_frame_set_slot_nc(acc->inst.kvp_data, "old-currency",
+  kvp_frame_set_slot_nc(qof_instance_get_slots (QOF_INSTANCE (acc)), "old-currency",
                         kvp_value_new_string(string));
   mark_account (acc);
   xaccAccountCommitEdit(acc);
@@ -1309,7 +1360,7 @@
   commodity = DxaccAccountGetCurrency (acc);
   if (!commodity)
   {
-    gnc_commodity_table_insert (gnc_commodity_table_get_table (acc->inst.book), currency);
+    gnc_commodity_table_insert (gnc_commodity_table_get_table (qof_instance_get_book (QOF_INSTANCE (acc))), currency);
   }
 }
 
@@ -1319,37 +1370,37 @@
 AccountGroup *
 xaccAccountGetChildren (const GncAccount *acc)
 {
-   return acc ? acc->children : NULL;
+   return acc ? acc->priv->children : NULL;
 }
 
 AccountGroup *
 xaccAccountGetParent (const GncAccount *acc)
 {
-   return acc ? acc->parent : NULL;
+   return acc ? acc->priv->parent : NULL;
 }
 
 GncAccount *
 xaccAccountGetParentAccount (const GncAccount * acc)
 {
-  return acc ? xaccGroupGetParentAccount(acc->parent) : NULL;
+  return acc ? xaccGroupGetParentAccount(acc->priv->parent) : NULL;
 }
 
 GList *
 xaccAccountGetDescendants (const GncAccount *acc)
 {
-   return acc ? xaccGroupGetSubAccounts(acc->children) : NULL;
+   return acc ? xaccGroupGetSubAccounts(acc->priv->children) : NULL;
 }
 
 GNCAccountType
 xaccAccountGetType (const GncAccount *acc)
 {
-   return acc ? acc->type : ACCT_TYPE_NONE;
+   return acc ? acc->priv->type : ACCT_TYPE_NONE;
 }
 
 static const char*
 qofAccountGetTypeString (const GncAccount *acc)
 {
-   return acc ? xaccAccountTypeEnumAsString(acc->type) : NULL;
+   return acc ? xaccAccountTypeEnumAsString(acc->priv->type) : NULL;
 }
 
 static void
@@ -1361,7 +1412,7 @@
 const char *
 xaccAccountGetName (const GncAccount *acc)
 {
-   return acc ? acc->accountName : NULL;
+   return acc ? acc->priv->accountName : NULL;
 }
 
 char *
@@ -1385,7 +1436,7 @@
   names = g_malloc((level+1) * sizeof(gchar *));
   names[level] = NULL;
   for (a = account; a; a = xaccAccountGetParentAccount(a)) {
-    names[--level] = a->accountName;
+    names[--level] = a->priv->accountName;
   }
 
   /* Build it */
@@ -1398,19 +1449,19 @@
 const char *
 xaccAccountGetCode (const GncAccount *acc)
 {
-   return acc ? acc->accountCode : NULL;
+   return acc ? acc->priv->accountCode : NULL;
 }
 
 const char * 
 xaccAccountGetDescription (const GncAccount *acc)
 {
-   return acc ? acc->description : NULL;
+   return acc ? acc->priv->description : NULL;
 }
 
 const char * 
 xaccAccountGetNotes (const GncAccount *acc) 
 {
-   return acc ? kvp_frame_get_string(acc->inst.kvp_data, "notes") : NULL;
+   return acc ? kvp_frame_get_string(qof_instance_get_slots (QOF_INSTANCE (acc)), "notes") : NULL;
 }
 
 gnc_commodity * 
@@ -1422,13 +1473,13 @@
 
   if (!acc) return NULL;
 
-  v = kvp_frame_get_slot(acc->inst.kvp_data, "old-currency");
+  v = kvp_frame_get_slot(qof_instance_get_slots (QOF_INSTANCE (acc)), "old-currency");
   if (!v) return NULL;
 
   s = kvp_value_get_string (v);
   if (!s) return NULL;
 
-  table = gnc_commodity_table_get_table (acc->inst.book);
+  table = gnc_commodity_table_get_table (qof_instance_get_book (QOF_INSTANCE (acc)));
 
   return gnc_commodity_table_lookup_unique (table, s);
 }
@@ -1436,25 +1487,25 @@
 gnc_commodity * 
 xaccAccountGetCommodity (const GncAccount *acc)
 {
-  return acc ? acc->commodity : NULL;
+  return acc ? acc->priv->commodity : NULL;
 }
 
 gnc_numeric
 xaccAccountGetBalance (const GncAccount *acc) 
 {
-  return acc ? acc->balance : gnc_numeric_zero();
+  return acc ? acc->priv->balance : gnc_numeric_zero();
 }
 
 gnc_numeric
 xaccAccountGetClearedBalance (const GncAccount *acc)
 {
-  return acc ? acc->cleared_balance : gnc_numeric_zero();
+  return acc ? acc->priv->cleared_balance : gnc_numeric_zero();
 }
 
 gnc_numeric
 xaccAccountGetReconciledBalance (const GncAccount *acc)
 {
-  return acc ? acc->reconciled_balance : gnc_numeric_zero();
+  return acc ? acc->priv->reconciled_balance : gnc_numeric_zero();
 }
 
 gnc_numeric
@@ -1468,7 +1519,7 @@
   if (!acc) return gnc_numeric_zero ();
 
   today = gnc_timet_get_today_end();
-  for (node = g_list_last (acc->splits); node; node = node->prev)
+  for (node = g_list_last (acc->priv->splits); node; node = node->prev)
   {
     Split *split = node->data;
 
@@ -1510,7 +1561,7 @@
   xaccAccountSortSplits (acc, TRUE); /* just in case, normally a noop */
   xaccAccountRecomputeBalance (acc); /* just in case, normally a noop */
 
-  balance = acc->balance;
+  balance = acc->priv->balance;
 
   /* Since transaction post times are stored as a Timespec,
    * convert date into a Timespec as well rather than converting
@@ -1527,7 +1578,7 @@
   ts.tv_sec = date;
   ts.tv_nsec = 0;
 
-  lp = acc->splits;
+  lp = acc->priv->splits;
   while( lp && !found )
   {
     xaccTransGetDatePostedTS( xaccSplitGetParent( (Split *)lp->data ),
@@ -1575,7 +1626,7 @@
   g_return_val_if_fail(acc, gnc_numeric_zero());
 
   today = gnc_timet_get_today_end();
-  for (node = g_list_last (acc->splits); node; node = node->prev)
+  for (node = g_list_last (acc->priv->splits); node; node = node->prev)
   {
     Split *split = node->data;
 
@@ -1664,7 +1715,7 @@
   if (!acc || !fn || !report_currency) return gnc_numeric_zero ();
   balance = fn(acc);
   balance = xaccAccountConvertBalanceToCurrency(acc, balance,
-                                                acc->commodity,
+                                                acc->priv->commodity,
                                                 report_currency);
   return balance;
 }
@@ -1676,7 +1727,7 @@
 {
     g_return_val_if_fail(acc && fn && report_commodity, gnc_numeric_zero());
     return xaccAccountConvertBalanceToCurrency(
-        acc, fn(acc, date), acc->commodity, report_commodity);
+        acc, fn(acc, date), acc->priv->commodity, report_commodity);
 }
 
 /*
@@ -1758,7 +1809,7 @@
   if (include_children) {
     CurrencyBalance cb = { report_commodity, balance, fn, NULL, 0 };
 
-    xaccGroupForEachAccount (acc->children, xaccAccountBalanceHelper,
+    xaccGroupForEachAccount (acc->priv->children, xaccAccountBalanceHelper,
                              &cb, TRUE);
     balance = cb.balance;
   }
@@ -1785,7 +1836,7 @@
   if (include_children) {
     CurrencyBalance cb = { report_commodity, balance, NULL, fn, date };
 
-    xaccGroupForEachAccount (acc->children,
+    xaccGroupForEachAccount (acc->priv->children,
                              xaccAccountBalanceAsOfDateHelper, &cb, TRUE);
     balance = cb.balance;
   }
@@ -1875,13 +1926,13 @@
 SplitList *
 xaccAccountGetSplitList (const GncAccount *acc) 
 {
-  return acc ? acc->splits : NULL;
+  return acc ? acc->priv->splits : NULL;
 }
 
 LotList *
 xaccAccountGetLotList (const GncAccount *acc) 
 {
-  return acc ? acc->lots : NULL;
+  return acc ? acc->priv->lots : NULL;
 }
 
 LotList *
@@ -1926,7 +1977,7 @@
 
   if (!acc || !proc) return NULL;
   
-  for (node = acc->lots; node; node = node->next)
+  for (node = acc->priv->lots; node; node = node->next)
       if ((result = proc((GNCLot *)node->data, data))) 
           break;
   
@@ -1940,7 +1991,7 @@
 gboolean
 xaccAccountGetTaxRelated (const GncAccount *acc)
 {
-  return acc ? kvp_frame_get_gint64(acc->inst.kvp_data, "tax-related") : FALSE;
+  return acc ? kvp_frame_get_gint64(qof_instance_get_slots (QOF_INSTANCE (acc)), "tax-related") : FALSE;
 }
 
 void
@@ -1957,7 +2008,7 @@
     new_value = NULL;
 
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_slot_nc(acc->inst.kvp_data, "tax-related", new_value);
+  kvp_frame_set_slot_nc(qof_instance_get_slots (QOF_INSTANCE (acc)), "tax-related", new_value);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
 }
@@ -1965,7 +2016,7 @@
 const char *
 xaccAccountGetTaxUSCode (const GncAccount *acc)
 {
-  return acc ? kvp_frame_get_string(acc->inst.kvp_data, "tax-US/code") : NULL;
+  return acc ? kvp_frame_get_string(qof_instance_get_slots (QOF_INSTANCE (acc)), "tax-US/code") : NULL;
 }
 
 void
@@ -1974,7 +2025,7 @@
   if (!acc) return;
 
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_string (acc->inst.kvp_data, "/tax-US/code", code);
+  kvp_frame_set_string (qof_instance_get_slots (QOF_INSTANCE (acc)), "/tax-US/code", code);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
 }
@@ -1982,7 +2033,7 @@
 const char *
 xaccAccountGetTaxUSPayerNameSource (const GncAccount *acc)
 {
-  return acc ? kvp_frame_get_string(acc->inst.kvp_data, 
+  return acc ? kvp_frame_get_string(qof_instance_get_slots (QOF_INSTANCE (acc)), 
                                     "tax-US/payer-name-source") : NULL;
 }
 
@@ -1992,7 +2043,7 @@
   if (!acc) return;
 
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_string (acc->inst.kvp_data, 
+  kvp_frame_set_string (qof_instance_get_slots (QOF_INSTANCE (acc)), 
                         "/tax-US/payer-name-source", source);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
@@ -2007,7 +2058,7 @@
   const char *str;
   if (!acc) return FALSE;
   
-  str = kvp_frame_get_string(acc->inst.kvp_data, "placeholder");
+  str = kvp_frame_get_string(qof_instance_get_slots (QOF_INSTANCE (acc)), "placeholder");
   return (str && !strcmp(str, "true"));
 }
 
@@ -2017,7 +2068,7 @@
   if (!acc) return;
   
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_string (acc->inst.kvp_data, 
+  kvp_frame_set_string (qof_instance_get_slots (QOF_INSTANCE (acc)), 
                         "placeholder", val ? "true" : NULL);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
@@ -2032,7 +2083,7 @@
   if (!acc) return PLACEHOLDER_NONE;
   if (xaccAccountGetPlaceholder(acc)) return PLACEHOLDER_THIS;
 
-  descendants = xaccGroupGetSubAccounts(acc->children);
+  descendants = xaccGroupGetSubAccounts(acc->priv->children);
   for (node = descendants; node; node = node->next) 
       if (xaccAccountGetPlaceholder((GncAccount *) node->data)) {
           ret = PLACEHOLDER_CHILD;
@@ -2052,7 +2103,7 @@
   const char *str;
   if (!acc) return FALSE;
   
-  str = kvp_frame_get_string(acc->inst.kvp_data, "hidden");
+  str = kvp_frame_get_string(qof_instance_get_slots (QOF_INSTANCE (acc)), "hidden");
   return (str && !strcmp(str, "true"));
 }
 
@@ -2062,7 +2113,7 @@
   if (!acc) return;
   
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_string (acc->inst.kvp_data, "hidden",
+  kvp_frame_set_string (qof_instance_get_slots (QOF_INSTANCE (acc)), "hidden",
 			val ? "true" : NULL);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
@@ -2299,8 +2350,8 @@
 {
     if (!acc) return FALSE;
 
-    return (acc->type == ACCT_TYPE_STOCK || acc->type == ACCT_TYPE_MUTUAL || 
-            acc->type == ACCT_TYPE_CURRENCY);
+    return (acc->priv->type == ACCT_TYPE_STOCK || acc->priv->type == ACCT_TYPE_MUTUAL || 
+            acc->priv->type == ACCT_TYPE_CURRENCY);
 }
 
 /********************************************************************\
@@ -2313,7 +2364,7 @@
 
   if (!acc) return FALSE;
 
-  v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/last-date");
+  v = kvp_frame_get_value(qof_instance_get_slots (QOF_INSTANCE (acc)), "reconcile-info/last-date");
   
   if (!v || kvp_value_get_type(v) != KVP_TYPE_GINT64)
       return FALSE;
@@ -2333,7 +2384,7 @@
   if (!acc) return;
 
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_gint64 (acc->inst.kvp_data, 
+  kvp_frame_set_gint64 (qof_instance_get_slots (QOF_INSTANCE (acc)), 
                         "/reconcile-info/last-date", last_date);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
@@ -2350,9 +2401,9 @@
 
   if (!acc) return FALSE;
 
-  v1 = kvp_frame_get_value(acc->inst.kvp_data, 
+  v1 = kvp_frame_get_value(qof_instance_get_slots (QOF_INSTANCE (acc)), 
                            "reconcile-info/last-interval/months");
-  v2 = kvp_frame_get_value(acc->inst.kvp_data, 
+  v2 = kvp_frame_get_value(qof_instance_get_slots (QOF_INSTANCE (acc)), 
                            "reconcile-info/last-interval/days");
   if (!v1 || (kvp_value_get_type (v1) != KVP_TYPE_GINT64) ||
       !v2 || (kvp_value_get_type (v2) != KVP_TYPE_GINT64))
@@ -2376,7 +2427,7 @@
 
   xaccAccountBeginEdit (acc);
 
-  frame = kvp_frame_get_frame_slash (acc->inst.kvp_data, 
+  frame = kvp_frame_get_frame_slash (qof_instance_get_slots (QOF_INSTANCE (acc)), 
          "/reconcile-info/last-interval");
   g_assert(frame);
 
@@ -2397,7 +2448,7 @@
 
   if (!acc) return FALSE;
 
-  v = kvp_frame_get_value(acc->inst.kvp_data, "reconcile-info/postpone/date");
+  v = kvp_frame_get_value(qof_instance_get_slots (QOF_INSTANCE (acc)), "reconcile-info/postpone/date");
   if (!v || kvp_value_get_type (v) != KVP_TYPE_GINT64)
       return FALSE;
 
@@ -2418,7 +2469,7 @@
   xaccAccountBeginEdit (acc);
 
   /* XXX this should be using timespecs, not gints !! */
-  kvp_frame_set_gint64 (acc->inst.kvp_data,
+  kvp_frame_set_gint64 (qof_instance_get_slots (QOF_INSTANCE (acc)),
             "reconcile-info/postpone/date", postpone_date);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
@@ -2435,7 +2486,7 @@
 
   if (!acc) return FALSE;
 
-  v = kvp_frame_get_value(acc->inst.kvp_data, 
+  v = kvp_frame_get_value(qof_instance_get_slots (QOF_INSTANCE (acc)), 
                           "reconcile-info/postpone/balance");
   if (!v || kvp_value_get_type (v) != KVP_TYPE_NUMERIC)
       return FALSE;
@@ -2455,7 +2506,7 @@
   if (!acc) return;
 
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_gnc_numeric (acc->inst.kvp_data,
+  kvp_frame_set_gnc_numeric (qof_instance_get_slots (QOF_INSTANCE (acc)),
            "/reconcile-info/postpone/balance", balance);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
@@ -2471,7 +2522,7 @@
   if (!acc) return;
 
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_value (acc->inst.kvp_data, "reconcile-info/postpone", NULL);
+  kvp_frame_set_value (qof_instance_get_slots (QOF_INSTANCE (acc)), "reconcile-info/postpone", NULL);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
 }
@@ -2489,7 +2540,7 @@
   const char *str = NULL;
   if (!acc) return default_value;
 
-  str = kvp_frame_get_string(acc->inst.kvp_data, 
+  str = kvp_frame_get_string(qof_instance_get_slots (QOF_INSTANCE (acc)), 
                              "reconcile-info/auto-interest-transfer");
   return str ? !strcmp(str, "true") : default_value;
 }
@@ -2504,7 +2555,7 @@
 
   xaccAccountBeginEdit (acc);
   /* FIXME: need KVP_TYPE_BOOLEAN for this someday */
-  kvp_frame_set_string (acc->inst.kvp_data,
+  kvp_frame_set_string (qof_instance_get_slots (QOF_INSTANCE (acc)),
                         "/reconcile-info/auto-interest-transfer",
                         (option ? "true" : "false"));
   mark_account (acc);
@@ -2517,7 +2568,7 @@
 const char *
 xaccAccountGetLastNum (const GncAccount *acc)
 {
-  return acc ? kvp_frame_get_string(acc->inst.kvp_data, "last-num") : NULL;
+  return acc ? kvp_frame_get_string(qof_instance_get_slots (QOF_INSTANCE (acc)), "last-num") : NULL;
 }
 
 /********************************************************************\
@@ -2529,7 +2580,7 @@
   if (!acc) return;
 
   xaccAccountBeginEdit (acc);
-  kvp_frame_set_string(acc->inst.kvp_data, "last-num", num);
+  kvp_frame_set_string(qof_instance_get_slots (QOF_INSTANCE (acc)), "last-num", num);
   mark_account (acc);
   xaccAccountCommitEdit (acc);
 }
@@ -2544,13 +2595,13 @@
 
   xaccAccountBeginEdit(acc);
   if (xaccAccountIsPriced(acc)) {
-      kvp_frame_set_slot_nc(acc->inst.kvp_data,
+      kvp_frame_set_slot_nc(qof_instance_get_slots (QOF_INSTANCE (acc)),
                             "old-price-source",
                             src ? kvp_value_new_string(src) : NULL);
       mark_account (acc);
   }
   
-  qof_instance_set_dirty(&acc->inst);
+  qof_instance_set_dirty(QOF_INSTANCE (acc), TRUE);
   xaccAccountCommitEdit(acc);
 }
 
@@ -2563,7 +2614,7 @@
   if(!acc) return NULL;
 
   if (xaccAccountIsPriced(acc)) {
-      KvpValue *value = kvp_frame_get_slot(acc->inst.kvp_data, 
+      KvpValue *value = kvp_frame_get_slot(qof_instance_get_slots (QOF_INSTANCE (acc)), 
                                            "old-price-source");
       if (value) return (kvp_value_get_string(value));
   }
@@ -2580,12 +2631,12 @@
 
   xaccAccountBeginEdit(acc);
   if (xaccAccountIsPriced(acc)) {
-      kvp_frame_set_slot_nc(acc->inst.kvp_data,
+      kvp_frame_set_slot_nc(qof_instance_get_slots (QOF_INSTANCE (acc)),
                             "old-quote-tz",
                             tz ? kvp_value_new_string(tz) : NULL);
       mark_account (acc);
   }
-  qof_instance_set_dirty(&acc->inst);
+  qof_instance_set_dirty(QOF_INSTANCE (acc), TRUE);
   xaccAccountCommitEdit(acc);
 }
 
@@ -2598,7 +2649,7 @@
   if (!acc) return NULL;
 
   if (xaccAccountIsPriced(acc)) {
-      KvpValue *value = kvp_frame_get_slot(acc->inst.kvp_data, "old-quote-tz");
+      KvpValue *value = kvp_frame_get_slot(qof_instance_get_slots (QOF_INSTANCE (acc)), "old-quote-tz");
       if(value) return (kvp_value_get_string(value));
   }
   return NULL;
@@ -2615,7 +2666,7 @@
   xaccAccountBeginEdit (acc);
   
   /* XXX FIXME: someday this should use KVP_TYPE_BOOLEAN */
-  kvp_frame_set_gint64 (acc->inst.kvp_data, 
+  kvp_frame_set_gint64 (qof_instance_get_slots (QOF_INSTANCE (acc)), 
                         "/reconcile-info/include-children", status);
   mark_account(acc);
   xaccAccountCommitEdit (acc);
@@ -2631,7 +2682,7 @@
    * is found then we can assume not to include the children, that being
    * the default behaviour 
    */
-  return acc ? kvp_frame_get_gint64(acc->inst.kvp_data, 
+  return acc ? kvp_frame_get_gint64(qof_instance_get_slots (QOF_INSTANCE (acc)), 
                                     "reconcile-info/include-children") : FALSE;
 }
 
@@ -2671,7 +2722,7 @@
   /* Why is this loop iterated backwards ?? Presumably because the split
    * list is in date order, and the most recent matches should be 
    * returned!?  */
-  for (slp = g_list_last (acc->splits); slp; slp = slp->prev) {
+  for (slp = g_list_last (acc->priv->splits); slp; slp = slp->prev) {
     Split *lsplit = slp->data;
     Transaction *ltrans = xaccSplitGetParent(lsplit);
 
@@ -2699,18 +2750,20 @@
  * seems to belong somewhere else.] This routine is used for
  * auto-filling in registers with a default leading account. The
  * dest_trans is a transaction used for currency checking. */
-Transaction *
-xaccAccountFindTransByDesc(const GncAccount *acc, const char *description)
+GncTransaction *
+xaccAccountFindTransByDesc(const GncAccount *acc, const gchar *description)
 {
   Transaction *trans;
 
   /* Get the transation matching the description. */
   finder_help_function(acc, description, NULL, &trans);
-  return trans;
+  return (GncTransaction*) trans;
 }
 
 /* ================================================================ */
 /* QofObject function implementation and registration */
+/*
+BROKEN CODE
 
 static QofObject account_object_def = {
   interface_version:     QOF_OBJECT_VERSION,
@@ -2726,6 +2779,8 @@
   version_cmp:           (int (*)(gpointer,gpointer)) qof_instance_version_cmp,
 };
 
+
+
 gboolean xaccAccountRegister (void)
 {
   static QofParam params[] = {
@@ -2779,5 +2834,5 @@
 
   return qof_object_register (&account_object_def);
 }
-
+*/
 /* ======================= END OF FILE =========================== */

Modified: gnucash/branches/gobject-engine-dev/src/engine/Account.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Account.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/Account.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -48,48 +48,19 @@
 #include "qof.h"
 #include "gnc-engine.h"
 
-/* GObject declarations */
 
-#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))
-
-
-typedef struct _GncAccountClass GncAccountClass;
-typedef struct _GncAccount GncAccount;
-typedef struct _GncAccountPrivate GncAccountPrivate;
-
-typedef GncAccount GncAccount; //  Backward compatibility
-
-struct _GncAccount {
-	QofInstance inst;
-	GncAccountPrivate *priv;
-};
-
-struct _GncAccountClass {
-	QofInstanceClass parent_class;
-	/* virtual table */
-
-	/* Add Signal Functions Here */
-};
-
-GType   gnc_account_get_type ();
-
 /*************************************************************/
 
 typedef gnc_numeric (*xaccGetBalanceFn)( const Account *account );
 
 typedef gnc_numeric (*xaccGetBalanceInCurrencyFn) (
-    const GncAccount *account, const gnc_commodity *report_commodity,
+    const GncAccount *account, const GncCommodity *report_commodity,
     gboolean include_children);
 
 typedef gnc_numeric (*xaccGetBalanceAsOfDateFn) (
     GncAccount *account, time_t date);
 
-/** The account types are used to determine how the transaction data
+/** The account types are used to determine how the GncTransaction data
  * in the account is displayed.   These values can be safely changed
  * from one release to the next.  Note that if values are added,
  * the file IO translation routines need to be updated. Note 
@@ -172,7 +143,8 @@
 /** Constructor */
 GncAccount * gnc_account_new (QofBook *book);
 
-#define xaccMallocAccount(book) gnc_account_new(book)
+/* Deprecated */
+GncAccount *xaccMallocAccount (QofBook *book);
 
 /** The xaccCloneAccount() does the same as xaccCloneAccountSimple(), 
  *    except that it also also places a pair of GUID-pointers
@@ -185,7 +157,7 @@
 /** The xaccCloneAccountSimple() routine makes a simple copy of the
  *  indicated account, placing it in the indicated book.  It copies
  *  the account type, name, description, and the kvp values;
- *  it does not copy splits/transactions.  The book should have 
+ *  it does not copy splits/GncTransactions.  The book should have 
  *  a commodity table in it that has commodities with the same
  *  unique name as the ones being copied in the account (the 
  *  commodities in the clone will be those from the book).
@@ -195,18 +167,24 @@
 GncAccount * xaccCloneAccountSimple (const GncAccount *from, QofBook *book);
 
 /** The xaccAccountBeginEdit() subroutine is the first phase of
- *    a two-phase-commit wrapper for account updates. */ 
-#define xaccAccountBeginEdit(account) qof_instance_begin_edit(QOF_INSTANCE(account))
+ *    a two-phase-commit wrapper for account updates. 
+ *		A wrapper of  qof_instance_begin_edit
+ */ 
+ 
+gboolean xaccAccountBeginEdit(GncAccount *acc);
 
 /** ThexaccAccountCommitEdit() subroutine is the second phase of
- *    a two-phase-commit wrapper for account updates. */ 
-#define xaccAccountCommitEdit(account) qof_instance_commit_edit(QOF_INSTANCE(account))
+ *    a two-phase-commit wrapper for account updates. 
+ *		A wrapper of  qof_instance_commit_edit
+ */ 
+gboolean xaccAccountCommitEdit (GncAccount *acc);
 
 /** The xaccAccountDestroy() routine can be used to get rid of an
  *    account.  The account should have been opened for editing 
  *    (by calling xaccAccountBeginEdit()) before calling this routine.*/
-void gnc_account_destroy (GncAccount *account);
-#define xaccAccountDestroy(account) gnc_account_destroy(account)
+void gnc_account_destroy (GncAccount *acc);
+/* A wraper for gnc_account_destroy */
+void xaccAccountDestroy(GncAccount *acc);
 
 /** Compare two accounts for equality - this is a deep compare. */
 gboolean xaccAccountEqual(const GncAccount *a, const GncAccount* b, 
@@ -315,19 +293,19 @@
 
 /** Returns a per-account flag: Prior to reconciling an account which
     charges or pays interest, this flag tells whether to prompt the
-    user to enter a transaction for the interest charge or
+    user to enter a GncTransaction for the interest charge or
     payment. This per-account flag overrides the global preference. */
 gboolean xaccAccountGetAutoInterestXfer (const GncAccount *account, 
                                          gboolean default_value);
 /** Sets a per-account flag: Prior to reconciling an account which
     charges or pays interest, this flag tells whether to prompt the
-    user to enter a transaction for the interest charge or
+    user to enter a GncTransaction for the interest charge or
     payment. This per-account flag overrides the global preference. */
 void xaccAccountSetAutoInterestXfer (GncAccount *account, gboolean value);
 /** @} */
 
 /** @name Account Commodity setters/getters
-
+#include "Transaction.h"
  *   Accounts are used to store an amount of 'something', that 'something'
  *   is called the 'commodity'.  An account can only hold one kind of
  *   commodity.  The following are used to get and set the commodity,
@@ -336,10 +314,10 @@
  * Note that when we say that a 'split' holds an 'amount', that amount
  *   is denominated in the account commodity.  Do not confuse 'amount'
  *   and 'value'.  The 'value' of a split is the value of the amount
- *   expressed in the currency of the transaction.  Thus, for example,
+ *   expressed in the currency of the GncTransaction.  Thus, for example,
  *   the 'amount' may be 12 apples, where the account commodity is
  *   'apples'.  The value of these 12 apples may be 12 dollars, where 
- *   the transaction currency is 'dollars'.
+ *   the GncTransaction currency is 'dollars'.
  *
  * The SCU is the 'Smallest Commodity Unit', signifying the smallest
  *   non-zero amount that can be stored in the account.  It is 
@@ -358,13 +336,13 @@
 */
 
 /** Set the account's commodity */
-void xaccAccountSetCommodity (GncAccount *account, gnc_commodity *comm);
+void xaccAccountSetCommodity (GncAccount *account, GncCommodity *comm);
 
 /** @deprecated do not use */
 #define DxaccAccountSetSecurity xaccAccountSetCommodity
 
 /** Get the account's commodity  */
-gnc_commodity * xaccAccountGetCommodity (const GncAccount *account);
+GncCommodity * xaccAccountGetCommodity (const GncAccount *account);
 
 /** @deprecated do not use */
 #define DxaccAccountGetSecurity xaccAccountGetCommodity
@@ -404,10 +382,10 @@
     splits */
 gnc_numeric xaccAccountGetBalance (const GncAccount *account);
 /** Get the current balance of the account, only including cleared
-    transactions */
+    GncTransactions */
 gnc_numeric xaccAccountGetClearedBalance (const GncAccount *account);
 /** Get the current balance of the account, only including reconciled
-    transactions */
+    GncTransactions */
 gnc_numeric xaccAccountGetReconciledBalance (const GncAccount *account);
 gnc_numeric xaccAccountGetPresentBalance (const GncAccount *account);
 gnc_numeric xaccAccountGetProjectedMinimumBalance (const GncAccount *account);
@@ -427,35 +405,35 @@
 gnc_numeric xaccAccountConvertBalanceToCurrency(
     const GncAccount *account, /* for book */
     gnc_numeric balance,
-    const gnc_commodity *balance_currency,
-    const gnc_commodity *new_currency);
+    const GncCommodity *balance_currency,
+    const GncCommodity *new_currency);
 gnc_numeric xaccAccountConvertBalanceToCurrencyAsOfDate(
     const GncAccount *account, /* for book */
-    gnc_numeric balance, gnc_commodity *balance_currency,
-    gnc_commodity *new_currency, time_t date);
+    gnc_numeric balance, GncCommodity *balance_currency,
+    GncCommodity *new_currency, time_t date);
 
 /* These functions get some type of balance in the desired commodity.
    'report_commodity' may be NULL to use the account's commodity. */
 gnc_numeric xaccAccountGetBalanceInCurrency (
-    const GncAccount *account, const gnc_commodity *report_commodity,
+    const GncAccount *account, const GncCommodity *report_commodity,
     gboolean include_children);
 gnc_numeric xaccAccountGetClearedBalanceInCurrency (
-    const GncAccount *account, const gnc_commodity *report_commodity, 
+    const GncAccount *account, const GncCommodity *report_commodity, 
     gboolean include_children);
 gnc_numeric xaccAccountGetReconciledBalanceInCurrency (
-    const GncAccount *account, const gnc_commodity *report_commodity,
+    const GncAccount *account, const GncCommodity *report_commodity,
     gboolean include_children);
 gnc_numeric xaccAccountGetPresentBalanceInCurrency (
-    const GncAccount *account, const gnc_commodity *report_commodity,
+    const GncAccount *account, const GncCommodity *report_commodity,
     gboolean include_children);
 gnc_numeric xaccAccountGetProjectedMinimumBalanceInCurrency (
-    const GncAccount *account, const gnc_commodity *report_commodity,
+    const GncAccount *account, const GncCommodity *report_commodity,
     gboolean include_children);
 
 /* This function gets the balance as of the given date in the desired
    commodity. */
 gnc_numeric xaccAccountGetBalanceAsOfDateInCurrency(
-    GncAccount *account, time_t date, gnc_commodity *report_commodity,
+    GncAccount *account, time_t date, GncCommodity *report_commodity,
     gboolean include_children);
 
 gnc_numeric xaccAccountGetBalanceChangeForPeriod (
@@ -571,7 +549,7 @@
 
 /* ------------------ */
 
-/** @name GncAccount split/transaction list management 
+/** @name GncAccount split/GncTransaction list management 
 @{
 */
 /** The xaccAccountInsertSplit() method will insert the indicated
@@ -593,37 +571,37 @@
  *  in accfrom to accto. */
 void xaccAccountMoveAllSplits (GncAccount *accfrom, GncAccount *accto);
 
-/** The xaccAccountForEachTransaction() routine will traverse all of
-   the transactions in the given 'account' and call the callback
-   function 'proc' on each transaction.  Processing will continue
+/** The xaccAccountForEachGncTransaction() routine will traverse all of
+   the GncTransactions in the given 'account' and call the callback
+   function 'proc' on each GncTransaction.  Processing will continue
    if-and-only-if 'proc' returns 0. The user data pointer
    'data' will be passed on to the callback function 'proc'.
 
-   This function does not descend recursively to traverse transactions
+   This function does not descend recursively to traverse GncTransactions
    in child accounts.
 
-   'proc' will be called exactly once for each transaction that is
+   'proc' will be called exactly once for each GncTransaction that is
    pointed to by at least one split in the given account.
 
    The result of this function will be 0 if-and-only-if
-   every relevant transaction was traversed exactly once. 
+   every relevant GncTransaction was traversed exactly once. 
    Else the return value is the last non-zero value returned by proc.
 
-   Note that the traversal occurs only over the transactions that 
+   Note that the traversal occurs only over the GncTransactions that 
    are locally cached in the local gnucash engine.  If the gnucash 
    engine is attached to a remote database, the database may contain
-   (many) transactions that are not mirrored in the local cache.
+   (many) GncTransactions that are not mirrored in the local cache.
    This routine will not cause an SQL database query to be performed;
-   it will not traverse transactions present only in the remote
+   it will not traverse GncTransactions present only in the remote
    database.
 */
 gint xaccAccountForEachTransaction(const GncAccount *account,
                                    TransactionCallback proc,
                                    void *data);
 
-/** Returns a pointer to the transaction, not a copy. */
-Transaction * xaccAccountFindTransByDesc(const GncAccount *account, 
-                                         const char *description);
+/** Returns a pointer to the GncTransaction, not a copy. */
+GncTransaction* xaccAccountFindTransByDesc(const GncAccount *account, 
+                                         const gchar *description);
 
 /** Returns a pointer to the split, not a copy. */
 Split * xaccAccountFindSplitByDesc(const GncAccount *account, 
@@ -641,8 +619,8 @@
  *    belong to this account.  If the lot is already in another account,
  *    the lot, and all of the splits in it, will be moved from that
  *    account to this account. */
-void xaccAccountInsertLot (GncAccount *, GNCLot *);
-void xaccAccountRemoveLot (GncAccount *, GNCLot *);
+void xaccAccountInsertLot (GncAccount *, GncLot *);
+void xaccAccountRemoveLot (GncAccount *, GncLot *);
 
 /** The xaccAccountGetLotList() routine returns a pointer to the GList of
  *    the lots in this account.  
@@ -661,7 +639,7 @@
  */
 gpointer xaccAccountForEachLot(
     const GncAccount *acc,
-    gpointer (*proc)(GNCLot *lot, gpointer user_data), gpointer user_data);
+    gpointer (*proc)(GncLot *lot, gpointer user_data), gpointer user_data);
 
 
 /** Find a list of open lots that match the match_func.  Sort according
@@ -670,7 +648,7 @@
  * The caller must free to returned list.
  */
 LotList * xaccAccountFindOpenLots (const GncAccount *acc,
-				   gboolean (*match_func)(GNCLot *lot,
+				   gboolean (*match_func)(GncLot *lot,
 							  gpointer user_data),
 				   gpointer user_data, GCompareFunc sort_func);
 
@@ -834,13 +812,13 @@
  * account: the 'commodity'. Use xaccAccountGetCommodity() to fetch
  * it.
  *
- * These two funcs take control of their gnc_commodity args. Don't free */
-void DxaccAccountSetCurrency (GncAccount *account, gnc_commodity *currency);
+ * These two funcs take control of their GncCommodity args. Don't free */
+void DxaccAccountSetCurrency (GncAccount *account, GncCommodity *currency);
 
 /** @deprecated The current API associates only one thing with an
  * account: the 'commodity'. Use xaccAccountGetCommodity() to fetch
  * it. */
-gnc_commodity * DxaccAccountGetCurrency (const GncAccount *account);
+GncCommodity * DxaccAccountGetCurrency (const GncAccount *account);
 
 /** Set the timezone to be used when interpreting the results from a
  *  given Finance::Quote backend.  Unfortunately, the upstream sources
@@ -857,6 +835,13 @@
  *  @deprecated Price quote information is now stored on the
  *  commodity, not the account. */
 const char * dxaccAccountGetQuoteTZ (const GncAccount *account);
+
+AccountGroup* gnc_account_get_children (GncAccount* acc);
+void           gnc_account_set_children (GncAccount* acc, AccountGroup *grp);
+
+AccountGroup* gnc_account_get_parent (GncAccount* acc);
+void           gnc_account_set_parent (GncAccount* acc, AccountGroup *grp);
+
 /** @} */
 
 

Modified: gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -80,6 +80,7 @@
 #include "glib-compat.h"
 #include <string.h>
 #include <time.h>
+#include "gnc-engine.h"
 
 #ifdef HAVE_LANGINFO_D_FMT
 #include <langinfo.h>
@@ -91,10 +92,13 @@
 
 /* GObject */
 
-static void gnc_freq_spec_class_init(FreqSpecClass *klass);
-static void gnc_freq_spec_init(FreqSpec *sp);
+static void gnc_freq_spec_class_init(GncFreqSpecClass *klass);
+static void gnc_freq_spec_init(FreqSpec *fs);
 static void gnc_freq_spec_finalize(GObject *object);
+static void gnc_freq_spec_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec);
+static void gnc_freq_spec_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 
+
 struct _FreqSpecPrivate {
 	/* Private Members */
 };
@@ -104,6 +108,7 @@
 
 enum _FreqSpecSignalType {
 	/* Signals */
+	FIRST_SIGNAL,
 	LAST_SIGNAL
 };
 
@@ -121,13 +126,13 @@
 static GObjectClass *parent_class = NULL;
 
 GType
-gnc_freq_spec_get_type()
+gnc_freq_spec_get_type(void)
 {
 	static GType type = 0;
 
 	if(type == 0) {
 		static const GTypeInfo our_info = {
-			sizeof (FreqSpecClass),
+			sizeof (GncFreqSpecClass),
 			NULL,
 			NULL,
 			(GClassInitFunc)gnc_freq_spec_class_init,
@@ -138,7 +143,7 @@
 			(GInstanceInitFunc)gnc_freq_spec_init,
 		};
 
-		type = g_type_register_static(QOF_TYPE_ENTITY, 
+		type = g_type_register_static(QOF_TYPE_INSTANCE, 
 			"FreqSpec", &our_info, 0);
 	}
 
@@ -146,7 +151,7 @@
 }
 
 static void
-gnc_freq_spec_class_init(QofInstanceClass *klass)
+gnc_freq_spec_class_init(GncFreqSpecClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
@@ -162,9 +167,12 @@
 }
 
 static void
-gnc_freq_spec_init(FrecSpec *obj)
+gnc_freq_spec_init(FreqSpec *fs)
 {
 	/* Initialize private members, etc. */
+	fs->type = INVALID;
+  fs->uift = UIFREQ_ONCE;
+  memset( &(fs->s), 0, sizeof(fs->s) );
 }
 
 static void
@@ -188,7 +196,7 @@
 	switch (param_id) {		
 		default:
    			/* We don't have any other property... */
-    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,param_id,pspec);
     	break;
 	}
 }
@@ -290,17 +298,7 @@
 static void
 xaccFreqSpecInit( FreqSpec *fs, QofBook *book )
 {
-   QofCollection *col;
-   g_return_if_fail( fs );
-   g_return_if_fail (book);
-
-   col = qof_book_get_collection (book, QOF_ID_FREQSPEC);
-   qof_entity_init (QOF_ENTITY (fs), QOF_ID_FREQSPEC, col);
-
-   fs->type = INVALID;
-   fs->uift = UIFREQ_ONCE;
-
-   memset( &(fs->s), 0, sizeof(fs->s) );
+   
 }
 
 FreqSpec*
@@ -311,9 +309,9 @@
    g_return_val_if_fail (book, NULL);
 
    fs = GNC_FREQ_SPEC (g_object_new (GNC_TYPE_FREQ_SPEC, NULL));
-   xaccFreqSpecInit( fs, book );
-   qof_event_gen( QOF_ENTITY (fs), QOF_EVENT_CREATE , NULL);
-   g_signal_emit_by_name ( QOF_ENTITY (fs), "created::detail");
+   
+   qof_event_gen( QOF_INSTANCE (fs), QOF_EVENT_CREATE , NULL);
+   g_signal_emit_by_name ( QOF_INSTANCE (fs), "created::detail");
     
    return fs;
 }
@@ -345,10 +343,10 @@
 xaccFreqSpecFree( FreqSpec *fs )
 {
    if ( fs == NULL ) return;
-   qof_event_gen( &fs->entity, QOF_EVENT_DESTROY , NULL);
+   qof_event_gen( QOF_INSTANCE (fs), QOF_EVENT_DESTROY , NULL);
    xaccFreqSpecCleanUp( fs );
 
-   qof_entity_release (&fs->entity);
+   qof_entity_release (fs);
    // g_free( fs ); the qof_entity_realise function call g_object_unref
 }
 
@@ -1439,6 +1437,7 @@
 	qofFreqSpecCalculate(fs, value);
 }
 
+/*BROKEN CODE
 static QofObject FreqSpecDesc = 
 {
 	interface_version : QOF_OBJECT_VERSION,
@@ -1469,3 +1468,4 @@
 	qof_class_register(QOF_ID_FREQSPEC, (QofSortFunc)gnc_freq_spec_compare, params);
 	return qof_object_register(&FreqSpecDesc);
 }
+*/

Modified: gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -117,13 +117,21 @@
  * Forward declaration of FreqSpec type for storing
  * date repetition information. This is an opaque type.
  */
+typedef struct _GncFreqSpecClass GncFreqSpecClass;
 
 struct gncp_freq_spec;
 typedef struct gncp_freq_spec FreqSpec;
 
+struct _GncFreqSpecClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+
+	/* Add Signal Functions Here */
+};
+
 /** PROTOTYPES ******************************************************/
 
-GType   gnc_freq_spec_get_type ();
+GType   gnc_freq_spec_get_type (void);
 
 /**
  * Allocates memory for a FreqSpec and initializes it.
@@ -281,7 +289,7 @@
 In keeping with the rest of QOF, dates are handled as Timespec.
 @{
 */
-#define QOF_ID_FREQSPEC       "FreqSpec"
+#define QOF_ID_FREQSPEC       GNC_TYPE_FREQ_SPEC
 #define FS_UI_TYPE            "fs-frequency"
 #define FS_REPEAT             "fs-repeat"
 #define FS_BASE_DATE          "fs-initial-date"

Modified: gnucash/branches/gobject-engine-dev/src/engine/FreqSpecP.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/FreqSpecP.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/FreqSpecP.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -37,7 +37,7 @@
 
 struct gncp_freq_spec 
 {
-        QofEntity       entity;
+        QofInstance     inst;
         FreqType        type;
         UIFreqType      uift;
         union u {

Modified: gnucash/branches/gobject-engine-dev/src/engine/Group.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Group.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/Group.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -36,6 +36,144 @@
 
 static QofLogModule log_module = GNC_MOD_ENGINE;
 
+/* GObject declarations */
+
+static void gnc_account_group_class_init(GncAccountGroupClass *klass);
+static void gnc_account_group_init(AccountGroup *grp);
+static void gnc_account_group_finalize(GObject *object);
+static void gnc_account_group_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec);
+static void gnc_account_group_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+
+struct _GncAccountGroupPrivate
+{
+
+};
+
+typedef struct _GncAccountGroupSignal GncAccountGroupSignal;
+typedef enum _GncAccountGroupSignalType GncAccountGroupSignalType;
+
+enum _GncAccountGroupSignalType {
+	/* Signals */
+	FIRST_SIGNAL,
+	LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+        PROP_0
+};
+
+struct _GncAccountGroupSignal {
+	AccountGroup *object;
+};
+
+static guint gnc_account_group_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_account_group_get_type(void)
+{
+	static GType type = 0;
+
+	if(type == 0) {
+		static const GTypeInfo our_info = {
+			sizeof (GncAccountGroupClass),
+			NULL,
+			NULL,
+			(GClassInitFunc)gnc_account_group_class_init,
+			NULL,
+			NULL,
+			sizeof (AccountGroup),
+			0,
+			(GInstanceInitFunc)gnc_account_group_init,
+		};
+
+		type = g_type_register_static(QOF_TYPE_INSTANCE, 
+			"AccountGroup", &our_info, 0);
+	}
+
+	return type;
+}
+
+static void
+gnc_account_group_class_init(GncAccountGroupClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+	parent_class = g_type_class_peek_parent(klass);
+	object_class->finalize = gnc_account_group_finalize;
+	object_class->set_property = gnc_account_group_set_property;
+    object_class->get_property = gnc_account_group_get_property;
+
+	/* Install properties */
+	
+	/* Create signals here:*/
+	
+	
+}
+
+static void
+gnc_account_group_init(AccountGroup *grp)
+{
+	/* Initialize private members, etc. */
+	grp->saved       = 1;
+
+  grp->parent      = NULL;
+  grp->accounts    = NULL;
+
+/*  qof_instance_get_book (QOF_INSTANCE (grp))        = book; This isn't needed */
+  grp->editlevel   = 0;
+}
+
+static void
+gnc_account_group_finalize(GObject *object)
+{
+	
+	/* Free private members, etc. */
+	
+	G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_account_group_set_property (GObject *object,
+				  guint param_id,
+				  const GValue *value,
+				  GParamSpec *pspec)
+{
+	AccountGroup *obj;
+	
+	obj = GNC_ACCOUNT_GROUP (object);
+	
+	switch (param_id) {		
+		
+		default:
+   			/* We don't have any other property... */
+    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,param_id,pspec);
+    	break;
+	}
+}
+
+static void
+gnc_account_group_get_property (GObject      *object,
+                        guint         property_id,
+                        GValue       *value,
+                        GParamSpec   *pspec)
+{
+  AccountGroup *obj;
+  
+  obj = GNC_ACCOUNT_GROUP(object);
+
+  switch (property_id) {
+  
+  default:
+    /* We don't have any other property... */
+    G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+    break;
+  }
+}
+
+
 /********************************************************************\
  * Because I can't use C++ for this project, doesn't mean that I    *
  * can't pretend to!  These functions perform actions on the        *
@@ -49,13 +187,7 @@
 static void
 xaccInitializeAccountGroup (AccountGroup *grp, QofBook *book)
 {
-  grp->saved       = 1;
-
-  grp->parent      = NULL;
-  grp->accounts    = NULL;
-
-  grp->book        = book;
-  grp->editlevel   = 0;
+  
 }
 
 /********************************************************************\
@@ -67,10 +199,9 @@
   AccountGroup *grp;
   g_return_val_if_fail (book, NULL);
 
-  grp = g_new (AccountGroup, 1);
-  xaccInitializeAccountGroup (grp, book);
+  grp = GNC_ACCOUNT_GROUP (g_object_new (GNC_TYPE_ACCOUNT_GROUP, "book", book));
 
-  return grp;
+  return (AccountGroup*) grp;
 }
 
 /********************************************************************\
@@ -80,7 +211,7 @@
 xaccCollGetAccountGroup (const QofCollection *col)
 {
   if (!col) return NULL;
-  return qof_collection_get_data (col);
+  return GNC_ACCOUNT_GROUP (qof_collection_get_data (col));
 }
 
 void
@@ -113,7 +244,7 @@
   QofCollection *col;
   if (!book) return;
 
-  if (grp && grp->book != book)
+  if (grp && qof_instance_get_book (QOF_INSTANCE (grp)) != book)
   {
      PERR ("cannot mix and match books freely!");
      return;
@@ -161,8 +292,8 @@
       char sa[GUID_ENCODING_LENGTH + 1];
       char sb[GUID_ENCODING_LENGTH + 1];
 
-      guid_to_string_buff (xaccAccountGetGUID (aa), sa);
-      guid_to_string_buff (xaccAccountGetGUID (ab), sb);
+      guid_to_string_buff (qof_instance_get_guid (QOF_INSTANCE (aa)), sa);
+      guid_to_string_buff (qof_instance_get_guid (QOF_INSTANCE (ab)), sb);
 
       PWARN ("accounts %s and %s differ", sa, sb);
 
@@ -198,7 +329,7 @@
     Account *account = node->data;
 
     xaccAccountBeginEdit (account);
-    xaccAccountGroupBeginEdit (account->children);
+    xaccAccountGroupBeginEdit (gnc_account_get_children (account));
   }
 }
 
@@ -216,7 +347,7 @@
   {
     Account *account = node->data;
 
-    xaccAccountGroupCommitEdit (account->children);
+    xaccAccountGroupCommitEdit (gnc_account_get_children (account));
     xaccAccountCommitEdit (account);
   }
   grp->editlevel--;
@@ -235,8 +366,8 @@
   for (node = grp->accounts; node; node = node->next)
   {
     Account *account = node->data;
-    account->inst.do_free = TRUE;
-    xaccGroupMarkDoFree (account->children); 
+    qof_instace_do_free ((const QofInstance*) QOF_INSTANCE (account));
+    xaccGroupMarkDoFree (gnc_account_get_children (account)); 
   }
 }
 
@@ -254,12 +385,13 @@
 xaccGroupGetBook (const AccountGroup *group)
 {
   if (!group) return NULL;
-  return group->book;
+  return qof_instance_get_book (QOF_INSTANCE (group));
 }
 
 /********************************************************************\
 \********************************************************************/
 
+
 void
 xaccFreeAccountGroup (AccountGroup *grp)
 {
@@ -287,24 +419,24 @@
       /* FIXME: this and the same code below is kind of hacky.
        *        actually, all this code seems to assume that
        *        the account edit levels are all 1. */
-      if (account->inst.editlevel == 0)
+      if (qof_instance_get_edit_level (QOF_INSTANCE (account)) == 0)
         xaccAccountBeginEdit (account);
 
       xaccAccountDestroy (account);
     }
     account = grp->accounts->data;
-    if (account->inst.editlevel == 0) 
+    if (qof_instance_get_edit_level (QOF_INSTANCE (account)) == 0) 
       xaccAccountBeginEdit (account);
     xaccAccountDestroy (account);
 
     if (!root_grp) return;
   }
 
-  if (grp->parent) grp->parent->children = NULL;
+  if (grp->parent) gnc_account_set_children (grp->parent, NULL);
 
   grp->parent   = NULL;
 
-  g_free (grp);
+  qof_instance_release ();
 }
 
 /********************************************************************\
@@ -323,7 +455,7 @@
   {
     Account *account = node->data;
 
-    xaccGroupMarkSaved (account->children); 
+    xaccGroupMarkSaved (gnc_account_get_children (account)); 
   }
 }
 
@@ -354,7 +486,7 @@
   {
     Account *account = node->data;
 
-    if (xaccGroupNotSaved (account->children))
+    if (xaccGroupNotSaved (gnc_account_get_children (account)))
       return TRUE;
   }
 
@@ -379,7 +511,7 @@
   {
     Account *account = node->data;
 
-    num_acc += xaccGroupGetNumSubAccounts (account->children);
+    num_acc += xaccGroupGetNumSubAccounts (gnc_account_get_children (account));
   }
 
   return num_acc;
@@ -402,7 +534,7 @@
 
     *accounts_p = g_list_prepend (*accounts_p, account);
 
-    xaccPrependAccounts (account->children, accounts_p);
+    xaccPrependAccounts (gnc_account_get_children (account), accounts_p);
   }
 }
 
@@ -445,7 +577,7 @@
 
     *accounts_p = g_list_prepend (*accounts_p, account);
 
-    xaccPrependAccountsSorted (account->children, accounts_p);
+    xaccPrependAccountsSorted (gnc_account_get_children (account), accounts_p);
   }
   g_list_free(tmp_list);
 }
@@ -540,7 +672,7 @@
     Account *account = node->data;
     Account *acc;
 
-    acc = xaccGetAccountFromName (account->children, name);
+    acc = xaccGetAccountFromName (gnc_account_get_children (account), name);
     if (acc)
       return acc;
   }
@@ -588,13 +720,13 @@
 	}
 
 	/* No children?  We're done. */
-	if (!account->children) {
+	if (!gnc_account_get_children (account)) {
 	  found = NULL;
 	  goto done;
 	}
 
 	/* There's stuff left to search for.  Search recursively. */
-	found = xaccGetAccountFromFullNameHelper(account->children, &names[1]);
+	found = xaccGetAccountFromFullNameHelper(gnc_account_get_children (account), &names[1]);
 	if (found != NULL) {
 	  goto done;
 	}
@@ -792,7 +924,7 @@
 void
 xaccGroupInsertAccount (AccountGroup *grp, Account *acc)
 {
-  if (!grp || !grp->book) return;
+  if (!grp || !qof_instance_get_book (QOF_INSTANCE (grp))) return;
   if (!acc) return;
 
   ENTER("group %p, account %p named %s", grp, acc, xaccAccountGetName(acc));
@@ -809,7 +941,7 @@
       xaccGroupRemoveAccount (acc->parent, acc);
 
       /* switch over between books, if needed */
-      if (grp->book != acc->inst.book)
+      if (qof_instance_get_book (QOF_INSTANCE (grp)) != acc->inst.book)
       {
          QofCollection *col;
 // xxxxxxxxxxxxxxxxxxxxxxx
@@ -827,7 +959,7 @@
          PWARN ("reparenting accounts across books is not correctly supported\n");
 
          qof_event_gen (&acc->inst.entity, QOF_EVENT_DESTROY, NULL);
-         col = qof_book_get_collection (grp->book, GNC_ID_ACCOUNT);
+         col = qof_book_get_collection (qof_instance_get_book (QOF_INSTANCE (grp)), GNC_ID_ACCOUNT);
          qof_collection_insert_entity (col, &acc->inst.entity);
          qof_event_gen (&acc->inst.entity, QOF_EVENT_CREATE, NULL);
       }
@@ -1052,7 +1184,7 @@
   {
     Account *account = node->data;
 
-    depth = xaccGroupGetDepth (account->children);
+    depth = xaccGroupGetDepth (gnc_account_get_children (account));
 
     if (depth > maxdepth)
       maxdepth = depth;
@@ -1122,7 +1254,7 @@
     GList *lp;
 
     /* recursively do sub-accounts */
-    xaccGroupBeginStagedTransactionTraversals (account->children);
+    xaccGroupBeginStagedTransactionTraversals (gnc_account_get_children (account));
 
     for (lp = account->splits; lp; lp = lp->next)
     {
@@ -1179,7 +1311,7 @@
     int retval;
 
     /* recursively do sub-accounts */
-    retval = xaccGroupStagedTransactionTraversal (account->children, stage,
+    retval = xaccGroupStagedTransactionTraversal (gnc_account_get_children (account), stage,
                                                   callback, cb_data);
     if (retval) return retval;
 
@@ -1251,7 +1383,7 @@
       return(result);
 
     if(deeply)
-        result = xaccGroupForEachAccount (account->children,
+        result = xaccGroupForEachAccount (gnc_account_get_children (account),
                                           thunk, data, TRUE);
 
     if (result)
@@ -1261,14 +1393,25 @@
   return(NULL);
 }
 
+gboolean 
+gnc_account_group_is_saved (AccountGroup *g)
+{
+  return g->saved;
+};
+void      
+gnc_account_group_set_saved (AccountGroup *g)
+{
+  g->saved = TRUE;
+}
+
 /* ============================================================== */
 
 QofBackend *
 xaccGroupGetBackend (const AccountGroup *grp)
 {
   grp = xaccGroupGetRoot (grp);
-  if (!grp || !grp->book) return NULL;
-  return qof_book_get_backend(grp->book);
+  if (!grp || !qof_instance_get_book (QOF_INSTANCE (grp))) return NULL;
+  return qof_book_get_backend(qof_instance_get_book (QOF_INSTANCE (grp)));
 }
 
 /* ============================================================== */
@@ -1297,6 +1440,8 @@
 {
   xaccGroupMarkSaved(xaccCollGetAccountGroup(col));
 }
+/*
+BROKEN CODE
 
 static QofObject group_object_def = 
 {
@@ -1318,5 +1463,5 @@
 {
   return qof_object_register (&group_object_def);
 }
-
+*/
 /* ========================= END OF FILE ======================== */

Modified: gnucash/branches/gobject-engine-dev/src/engine/Group.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Group.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/Group.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -39,6 +39,8 @@
 #include "qof.h"
 #include "Account.h"
 
+
+
 /* PROTOTYPES ******************************************************/
 /** @name Constructors, Destructors 
  @{
@@ -432,6 +434,10 @@
 
 int xaccGroupForEachTransaction(AccountGroup *g, 
                                 TransactionCallback proc, void *data);
+                                
+                                
+gboolean gnc_account_group_is_saved (AccountGroup *g);
+void      gnc_account_group_set_saved (AccountGroup *g);
 
 /** @} */
 #endif /* XACC_ACCOUNT_GROUP_H */

Modified: gnucash/branches/gobject-engine-dev/src/engine/GroupP.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/GroupP.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/GroupP.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -40,16 +40,17 @@
 #include "Transaction.h"
 
 /** STRUCTS *********************************************************/
-struct account_group_s
+struct _GncAccountGroup
 {
+  QofInstance inst;
   /* The flags: */
-  unsigned int saved : 1;
+  gboolean saved : TRUE;
 
   Account *parent;         /* back-pointer to parent */
 
   AccountList *accounts;   /* list of account pointers */
 
-  QofBook *book;           /* The book which this group belongs to */
+/*  QofBook *book; */           /* The book which this group belongs to NOT NEEDED becouse this is a QofInstance object*/
 
   /* keep track of nesting level of begin/end edit calls */
   gint32 editlevel;

Modified: gnucash/branches/gobject-engine-dev/src/engine/SX-book.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/SX-book.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/SX-book.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -48,6 +48,136 @@
 
 static QofLogModule log_module = GNC_MOD_SX;
 
+/* GObject declarations */
+
+static void gnc_schedule_actions_class_init(GncScheduleActionsClass *klass);
+static void gnc_schedule_actions_init(GncScheduleActions *sp);
+static void gnc_schedule_actions_finalize(GObject *object);
+
+struct _GncScheduleActionsPrivate
+{
+
+};
+
+typedef struct _GncScheduleActionsSignal GncScheduleActionsSignal;
+typedef enum _GncScheduleActionsSignalType GncScheduleActionsSignalType;
+
+enum _GncScheduleActionsSignalType {
+	/* Signals */
+	LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+        PROP_0
+};
+
+struct _GncScheduleActionsSignal {
+	GncScheduleActions *object;
+};
+
+static guint gnc_schedule_actions_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_schedule_actions_get_type()
+{
+	static GType type = 0;
+
+	if(type == 0) {
+		static const GTypeInfo our_info = {
+			sizeof (GncScheduleActionsClass),
+			NULL,
+			NULL,
+			(GClassInitFunc)gnc_schedule_actions_class_init,
+			NULL,
+			NULL,
+			sizeof (GncScheduleActions),
+			0,
+			(GInstanceInitFunc)gnc_schedule_actions_init,
+		};
+
+		type = g_type_register_static(QOF_TYPE_ENTITY, 
+			"GncScheduleActions", &our_info, 0);
+	}
+
+	return type;
+}
+
+static void
+gnc_schedule_actions_class_init(GncScheduleActionsClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+	parent_class = g_type_class_peek_parent(klass);
+	object_class->finalize = gnc_schedule_actions_finalize;
+	object_class->set_property = gnc_schedule_actions_set_property;
+    object_class->get_property = gnc_schedule_actions_get_property;
+
+	/* Install properties */
+	
+	/* Create signals here:*/
+	
+				      
+}
+
+static void
+gnc_schedule_actions_init(GncScheduleActions *obj)
+{
+	/* Initialize private members, etc. */
+	
+}
+
+static void
+gnc_schedule_actions_finalize(GObject *object)
+{
+	
+	/* Free private members, etc. */
+	
+	
+	G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_schedule_actions_set_property (GObject *object,
+				  guint param_id,
+				  const GValue *value,
+				  GParamSpec *pspec)
+{
+	GncScheduleActions *obj;
+	
+	obj = GNC_SCHEDULE_ACTIONS (object);
+	
+	switch (param_id) {		
+		
+		default:
+   			/* We don't have any other property... */
+    		G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+    	break;
+	}
+}
+
+static void
+gnc_schedule_actions_get_property (GObject      *object,
+                        guint         property_id,
+                        GValue       *value,
+                        GParamSpec   *pspec)
+{
+  GncScheduleActions *obj;
+  
+  obj = GNC_SCHEDULE_ACTIONS(object);
+
+  switch (property_id) {
+  
+  default:
+    /* We don't have any other property... */
+    G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+    break;
+  }
+}
+
+
 /* XXX this whole file is crufty, it doesn't really use entities
  * in the most efficient/best way */
 
@@ -166,7 +296,7 @@
   if (g_list_find(sxes->sx_list, sx) != NULL)
     return;
   sxes->sx_list = g_list_append(sxes->sx_list, sx);
-  qof_event_gen(&sxes->inst.entity, GNC_EVENT_ITEM_ADDED, (gpointer)sx);
+  qof_event_gen(QOF_INSTANCE (sxes), GNC_EVENT_ITEM_ADDED, (gpointer)sx);
 }
 
 void
@@ -177,7 +307,7 @@
   if (to_remove == NULL)
     return;
   sxes->sx_list = g_list_delete_link(sxes->sx_list, to_remove);
-  qof_event_gen(&sxes->inst.entity, GNC_EVENT_ITEM_REMOVED, (gpointer)sx);
+  qof_event_gen(QOF_INSTANCE (sxes), GNC_EVENT_ITEM_REMOVED, (gpointer)sx);
 }
 
 /* ====================================================================== */
@@ -197,8 +327,7 @@
      SchedXactions *sxes;
 
      col = qof_book_get_collection(book, GNC_ID_SCHEDXACTION);
-     sxes = g_new (SchedXactions, 1);
-     qof_instance_init(&sxes->inst, GNC_ID_SXES, book);
+     sxes = g_object_new (GNC_TYPE_SCHEDULE_ACTIONS, "book", book);
      sxes->sx_list = NULL;
      sxes->sx_notsaved = TRUE;
      qof_collection_set_data(col, sxes);

Modified: gnucash/branches/gobject-engine-dev/src/engine/SX-book.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/SX-book.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/SX-book.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -43,17 +43,40 @@
 #include "SchedXaction.h"
 #include "qof.h"
 
-typedef struct xaccSchedXactionsDef SchedXactions;
+/* GObject declarations */
 
-struct xaccSchedXactionsDef {
-  QofInstance inst;
+#define GNC_TYPE_SCHEDULE_ACTIONS            (gnc_schedule_actions_get_type ())
+#define GNC_SCHEDULE_ACTIONS(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDULE_ACTIONS, GncScheduleActions))
+#define GNC_SCHEDULE_ACTIONS_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDULE_ACTIONS, GncScheduleActionsClass))
+#define GNC_IS_SCHEDULE_ACTIONS(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDULE_ACTIONS))
+#define GNC_IS_SCHEDULE_ACTIONS_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDULE_ACTIONS))
+#define GNC_SCHEDULE_ACTIONS_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDULE_ACTIONS, GncScheduleActionsClass))
+
+
+typedef struct _GncScheduleActionsClass GncScheduleActionsClass;
+typedef struct _GncScheduleActionsPrivate GncScheduleActionsPrivate;
+typedef struct _GncScheduleActions GncScheduleActions;
+typedef struct GncScheduleActions SchedXactions ; /* Backward compatibility*/
+
+struct _GncScheduleActions {
+	QofInstance inst;
   GList* sx_list;
   gboolean sx_notsaved;
 };
 
-#define GNC_IS_SXES(obj)  (QOF_CHECK_TYPE((obj), GNC_ID_SXES))
-#define GNC_SXES(obj)     (QOF_CHECK_CAST((obj), GNC_ID_SXES, SchedXactions))
+struct _GncScheduleActionsClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+	 
+	/* Add Signal Functions Here */
+};
 
+GType   gnc_schedule_actions_get_type ();
+
+
+#define GNC_IS_SXES(obj)  GNC_IS_SCHEDULE_ACTIONS(o)
+#define GNC_SXES(obj)     GNC_SCHEDULE_ACTIONS(o)
+
 SchedXactions* gnc_book_get_schedxactions(QofBook* book);
 
 void gnc_sxes_add_sx(SchedXactions* sxes, SchedXaction* sx);

Modified: gnucash/branches/gobject-engine-dev/src/engine/Split.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Split.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/Split.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -39,31 +39,9 @@
 
 #include "gnc-commodity.h"
 #include "gnc-engine.h"
+#include "Account.h"
+#include "Transaction.h"
 
-/* GObject declarations */
-
-#define GNC_TYPE_SPLIT            (gnc_split_get_type ())
-#define GNC_SPLIT(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SPLIT, GncSplit))
-#define GNC_SPLIT_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SPLIT, GncSplitClass))
-#define GNC_IS_SPLIT(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SPLIT))
-#define GNC_IS_SPLIT_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SPLIT))
-#define GNC_SPLIT_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SPLIT, GncSplitClass))
-
-
-typedef struct _GncSplitClass GncSplitClass;
-typedef struct _GncSplit GncSplit;
-typedef struct GncSplit Split; /*  Dummy type for backward compatilibity */
-
-struct _GncSplitClass {
-	QofInstanceClass parent_class;
-	/* virtual table */
-
-	/* Add Signal Functions Here */
-};
-
-GType   gnc_split_get_type ();
-
-
 /** @name Split Reconciled field values
 
     If you change these
@@ -83,7 +61,7 @@
  * in particular we want to convert the Split to be in to_commodity.
  * Returns the amount.
  */
-gnc_numeric xaccSplitConvertAmount (const Split *split, Account * account);
+gnc_numeric xaccSplitConvertAmount (const Split *split, GncAccount * account);
 
 /*-----------------------------------------------------------------------
  * Splits
@@ -127,8 +105,8 @@
 
 /** Returns the account of this split, which was set through
  * xaccAccountInsertSplit(). */
-Account *     xaccSplitGetAccount (const Split *split);
-void xaccSplitSetAccount (Split *s, Account *acc);
+GncAccount *     xaccSplitGetAccount (const Split *split);
+void xaccSplitSetAccount (Split *s, GncAccount *acc);
 
 /** Returns the parent transaction of the split. */
 Transaction * xaccSplitGetParent (const Split *split);

Modified: gnucash/branches/gobject-engine-dev/src/engine/SplitP.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/SplitP.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/SplitP.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -74,7 +74,7 @@
 
   Account *acc;              /* back-pointer to debited/credited account  */
   Account *orig_acc;
-  GNCLot *lot;               /* back-pointer to debited/credited lot */
+  GncLot *lot;               /* back-pointer to debited/credited lot */
 
   Transaction *parent;       /* parent of split                           */
   Transaction *orig_parent;

Modified: gnucash/branches/gobject-engine-dev/src/engine/Transaction.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Transaction.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/Transaction.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -50,6 +50,13 @@
 
 #include "qofbackend-p.h"
 
+static gulong begin_commit_event_handler = 0;
+static gulong begin_edit_event_handler = 0;
+
+static void gnc_transaction_on_begin_commit_edit (GncTransaction *trans);
+static void gnc_transaction_on_begin_edit (GncAccount *acc)
+
+
 /* GObject declarations */
 
 static void gnc_transaction_class_init(GncTransactionClass *klass);
@@ -126,6 +133,31 @@
 gnc_transaction_init(GncTransaction *obj)
 {
 	/* Initialize private members, etc. */
+	ENTER ("trans=%p", trans);
+  /* Fill in some sane defaults */
+  trans->num         = CACHE_INSERT("");
+  trans->description = CACHE_INSERT("");
+
+  trans->common_currency = NULL;
+  trans->splits = NULL;
+
+  trans->date_entered.tv_sec  = 0;
+  trans->date_entered.tv_nsec = 0;
+
+  trans->date_posted.tv_sec  = 0;
+  trans->date_posted.tv_nsec = 0;
+
+  trans->version = 0;
+  trans->version_check = 0;
+  trans->marker = 0;
+  trans->orig = NULL;
+
+  trans->idata = 0;
+  
+  begin_commit_event_handler = g_signal_connect (obj, "commit:beginning", G_CALLBACK (gnc_transaction_on_begin_commit), obj, NULL);
+  begin_edit_event_handler = g_signal_connect (obj, "begin-edit", G_CALLBACK (gnc_transaction_on_begin_edit), obj, NULL);
+  
+  LEAVE (" ");
 }
 
 static void
@@ -133,7 +165,47 @@
 {
 	
 	/* Free private members, etc. */
+	GList *node;
+
+  ENTER ("(addr=%p)", trans);
+  if (((char *) 1) == trans->num)
+  {
+    PERR ("double-free %p", trans);
+    LEAVE (" ");
+    return;
+  }
+
+  /* free up the destination splits */
+  for (node = trans->splits; node; node = node->next)
+    xaccFreeSplit (node->data);
+  g_list_free (trans->splits);
+  trans->splits = NULL;
+
+  /* free up transaction strings */
+  CACHE_REMOVE(trans->num);
+  CACHE_REMOVE(trans->description);
+
+  /* Just in case someone looks up freed memory ... */
+  trans->num         = (char *) 1;
+  trans->description = NULL;
+
+  trans->date_entered.tv_sec = 0;
+  trans->date_entered.tv_nsec = 0;
+  trans->date_posted.tv_sec = 0;
+  trans->date_posted.tv_nsec = 0;
+  trans->version = 0;
+
+  if (trans->orig)
+  {
+    xaccFreeTransaction (trans->orig);
+    trans->orig = NULL;
+  }
+
+  LEAVE ("(addr=%p)", trans);
 	
+	g_signal_handler_disconnect (object, begin_commit_event_handler);
+	g_signal_handler_disconnect (object, begin_edit_event_handler);
+	
 	G_OBJECT_CLASS(parent_class)->finalize(object);
 }
 
@@ -362,28 +434,7 @@
 static void
 xaccInitTransaction (Transaction * trans, QofBook *book)
 {
-  ENTER ("trans=%p", trans);
-  /* Fill in some sane defaults */
-  trans->num         = CACHE_INSERT("");
-  trans->description = CACHE_INSERT("");
-
-  trans->common_currency = NULL;
-  trans->splits = NULL;
-
-  trans->date_entered.tv_sec  = 0;
-  trans->date_entered.tv_nsec = 0;
-
-  trans->date_posted.tv_sec  = 0;
-  trans->date_posted.tv_nsec = 0;
-
-  trans->version = 0;
-  trans->version_check = 0;
-  trans->marker = 0;
-  trans->orig = NULL;
-
-  trans->idata = 0;
-  qof_instance_init (QOF_INSTANCE (trans), GNC_ID_TRANS, book);
-  LEAVE (" ");
+  
 }
 
 /********************************************************************\
@@ -396,8 +447,8 @@
 
   g_return_val_if_fail (book, NULL);
 
-  trans = g_object_new (GNC_TYPE_TRANSACTION, NULL);
-  xaccInitTransaction (trans, book);
+  trans = GNC_TRANSACTION (g_object_new (GNC_TYPE_TRANSACTION, NULL));
+  
   qof_event_gen (QOF_ENTITY (trans), QOF_EVENT_CREATE, NULL);
 
   return trans;
@@ -477,7 +528,8 @@
 {
   Transaction *trans;
   GList *node;
-
+  
+  /* This will create a Transaction object  with a guid set to NULL */
   trans = g_object_new (GNC_TYPE_TRANSACTION, NULL);
 
   trans->num         = CACHE_INSERT (t->num);
@@ -496,18 +548,8 @@
 
   trans->common_currency = t->common_currency;
 
-  /* Trash the guid and entity table. We don't want to mistake 
-   * the cloned transaction as something official.  If we ever 
-   * use this transaction, we'll have to fix this up.
-   */
-   /* FIXME: Entity & Instance initialization must be in object's constructor*/
-  trans->inst.entity.e_type = NULL;
-  trans->inst.entity.guid = *guid_null();
-  trans->inst.entity.collection = NULL;
-  trans->inst.book = t->inst.book;
-  trans->inst.editlevel = 0;
-  trans->inst.do_free = FALSE;
-  trans->inst.kvp_data = kvp_frame_copy (t->inst.kvp_data);
+  qof_instance_set_kvp_data (QOF_INSTANCE (trans), qof_instance_get_kvp_data (QOF_INSTANCE (trans)));
+  
 
   return trans;
 }
@@ -524,7 +566,7 @@
   GList *node;
 
   qof_event_suspend();
-  trans = g_object_new (GNC_TYPE_TRANSACTION, NULL);
+  trans = g_object_new (GNC_TYPE_TRANSACTION, "book", qof_instance_get_book (QOF_INSTANCE (t)));
 
   trans->date_entered    = t->date_entered;
   trans->date_posted     = t->date_posted;
@@ -537,10 +579,10 @@
   trans->orig            = NULL;
   trans->idata           = 0;
 
-  qof_instance_init (QOF_INSTANCE(trans), GNC_ID_TRANS, t->inst.book);
   qof_instance_set_kvp_data (QOF_INSTANCE (trans), qof_instance_get_kvp_data (t));
 
-  xaccTransBeginEdit(trans);
+  qof_instance_begin_edit (QOF_INSTANCE (trans));
+  
   for (node = t->splits; node; node = node->next)
   {
     split = xaccSplitClone(node->data);
@@ -548,6 +590,8 @@
     trans->splits = g_list_append (trans->splits, split);
   }
   qof_instance_set_dirty(QOF_INSTANCE(trans));
+  
+  qof_instance_commi_edit (QOF_INSTANCE (trans));
   xaccTransCommitEdit(trans);
   qof_event_resume();
 
@@ -561,47 +605,7 @@
 static void
 xaccFreeTransaction (Transaction *trans)
 {
-  GList *node;
-
-  if (!trans) return;
-
-  ENTER ("(addr=%p)", trans);
-  if (((char *) 1) == trans->num)
-  {
-    PERR ("double-free %p", trans);
-    LEAVE (" ");
-    return;
-  }
-
-  /* free up the destination splits */
-  for (node = trans->splits; node; node = node->next)
-    xaccFreeSplit (node->data);
-  g_list_free (trans->splits);
-  trans->splits = NULL;
-
-  /* free up transaction strings */
-  CACHE_REMOVE(trans->num);
-  CACHE_REMOVE(trans->description);
-
-  /* Just in case someone looks up freed memory ... */
-  trans->num         = (char *) 1;
-  trans->description = NULL;
-
-  trans->date_entered.tv_sec = 0;
-  trans->date_entered.tv_nsec = 0;
-  trans->date_posted.tv_sec = 0;
-  trans->date_posted.tv_nsec = 0;
-  trans->version = 0;
-
-  if (trans->orig)
-  {
-    xaccFreeTransaction (trans->orig);
-    trans->orig = NULL;
-  }
-
-  qof_instance_release (QOF_INSTANCE (trans));
-
-  LEAVE ("(addr=%p)", trans);
+  g_object_unref (G_OBJECT (trans));
 }
 
 /********************************************************************
@@ -767,10 +771,9 @@
 Transaction *
 xaccTransLookup (const GUID *guid, QofBook *book)
 {
-  QofCollection *col;
-  if (!guid || !book) return NULL;
-  col = qof_book_get_collection (book, GNC_ID_TRANS);
-  return (Transaction *) qof_collection_lookup_entity (col, guid);
+  g_return_if_fail (!guid || QOF_IS_BOOK (book));
+  
+  return GNC_TRANSACTION (qof_book_get_object (book, GNC_TYPE_TRANSACTION, guid));
 }
 
 /********************************************************************\
@@ -945,13 +948,16 @@
 void
 xaccTransBeginEdit (Transaction *trans)
 {
-   if (!trans) return;
-   if (!qof_begin_edit(QOF_INSTANCE (trans))) return;
+   return qof_instance_begin_edit (QOF_INSTANCE (trans));   
+}
 
-   if (qof_book_shutting_down(qof_instance_get_book (QOF_INSTANCE (trans)))) return;
+static void
+gnc_transaction_on_begin_edit (GncAccount *acc, gpointer user_data) 
+{
+  g_return_if_fail (GNC_IS_TRANSACTION (acc));
 
-   xaccOpenLog ();
-   xaccTransWriteLog (trans, 'B');
+  xaccOpenLog ();
+  xaccTransWriteLog (trans, 'B');
 
    /* Make a clone of the transaction; we will use this 
     * in case we need to roll-back the edit. */
@@ -964,13 +970,14 @@
 void
 xaccTransDestroy (Transaction *trans)
 {
-  if (!trans) return;
-
+  g_return_if_fail (GNC_IS_TRANSACTION (trans));
+ 
   if (!xaccTransGetReadOnly (trans) || 
       qof_book_shutting_down(qof_instance_get_book (QOF_INSTANCE (trans)))) {
       xaccTransBeginEdit(trans);
       qof_instance_mark_free (QOF_INSTANCE (trans));
       xaccTransCommitEdit(trans);
+      g_object_unref (G_OBJECT (trans));
   }
 }
 
@@ -1111,23 +1118,13 @@
     qof_event_gen (QOF_ENTITY (trans), QOF_EVENT_MODIFY, NULL);
 }
 
-void
-xaccTransCommitEdit (Transaction *trans)
+/* Callback for the "commited" event */
+static void
+gnc_transaction_on_begin_commit (GncTransaction *trans, gpointer user_data)
 {
-   if (!trans) return;
-
-   if (!qof_commit_edit (QOF_INSTANCE(trans))) return;
-
-   /* We increment this for the duration of the call
-    * so other functions don't result in a recursive
-    * call to xaccTransCommitEdit. */
-   editlevel = qof_instance_get_edit_level (QOF_INSTANCE (trans));
-   editlevel++;
-   qof_instance_set_edit_level (QOF_INSTANCE (trans), editlevel);
-   
-   if (was_trans_emptied(trans)) qof_instance_mark_free (QOF_INSTANCE (trans), TRUE);
-
-   /* Before commiting the transaction, we're gonna enforce certain
+	 if (was_trans_emptied(trans)) qof_instance_mark_free (QOF_INSTANCE (trans), TRUE);
+	 
+	 /* Before commiting the transaction, we're gonna enforce certain
     * constraints.  In particular, we want to enforce the cap-gains
     * and the balanced lot constraints.  These constraints might 
     * change the number of splits in this transaction, and the 
@@ -1167,14 +1164,17 @@
       trans->date_entered.tv_nsec = 1000 * tv.tv_usec;
    }
 
-   qof_commit_edit_part2(QOF_INSTANCE(trans),
-                         (void (*) (QofInstance *, QofBackendError))
-                         trans_on_error,
-                         (void (*) (QofInstance *)) trans_cleanup_commit,
-                         (void (*) (QofInstance *)) do_destroy);
-   LEAVE ("(trans=%p)", trans);
 }
 
+void
+xaccTransCommitEdit (Transaction *trans)
+{
+   g_return_if_fail (GNC_IS_TRANSACTION (trans));
+   
+   qof_instance_commit_edit (QOF_INSTANCE (trans));
+   
+}
+
 #define SWAP(a, b) do { gpointer tmp = (a); (a) = (b); (b) = tmp; } while (0);
 
 /* Ughhh. The Rollback function is terribly complex, and, what's worse,

Modified: gnucash/branches/gobject-engine-dev/src/engine/Transaction.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Transaction.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/Transaction.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -20,37 +20,37 @@
 /** @addtogroup Engine
     @{ */
 /** @addtogroup Transaction Financial Transactions
-    A good overview of transactions, splits and accounts can be 
+    A good overview of transactions, splits and GncAccounts can be 
     found in the texinfo documentation, together with an overview of
     how to use this API.
 
 Splits, or "Ledger Entries" are the fundamental
-accounting units. Each Split consists of an amount (number of dollar
+GncAccounting units. Each Split consists of an amount (number of dollar
 bills, number of shares, etc.), the value of that amount expressed in
 a (possibly) different currency than the amount, a Memo, a pointer to
-the parent Transaction, a pointer to the debited Account, a reconciled
+the parent Transaction, a pointer to the debited GncAccount, a reconciled
 flag and timestamp, an "Action" field, and a key-value frame which can
 store arbitrary data.
                                                                               
-Transactions embody the notion of "double entry" accounting. 
+Transactions embody the notion of "double entry" GncAccounting. 
 A Transaction consists of a date, a description, an ID number, 
 a list of one or more Splits, and a key-value frame.  The transaction
 also specifies the currency with which all of the splits will be valued.
 When double-entry rules are enforced, the sum total value of the splits 
 are zero.  If there are only two splits, then the value of one must be 
-positive, the other negative: this denotes that one account is debited, 
+positive, the other negative: this denotes that one GncAccount is debited, 
 and another is credited by an equal amount.  By forcing the value of the
 splits to always 'add up' to zero, we can guarantee that the balances
-of the accounts are always correctly balanced.
+of the GncAccounts are always correctly balanced.
 
-The engine does not enforce double-entry accounting, but provides an API
+The engine does not enforce double-entry GncAccounting, but provides an API
 to enable user-code to find unbalanced transactions and 'repair' them so
 that they are in balance. 
 
 Note the sum of the values of Splits in a Transaction is always computed
 with respect to a currency; thus splits can be balanced even when they
 are in different currencies, as long as they share a common currency.
-This feature allows currency-trading accounts to be established.
+This feature allows currency-trading GncAccounts to be established.
                                                                               
 Every Split must point to its parent Transaction, and that Transaction
 must in turn include that Split in the Transaction's list of Splits. A
@@ -59,22 +59,22 @@
 this relationship as long as they stick to using the API and never
 access internal structures directly.
 
-Splits are grouped into Accounts which are also known
-as "Ledgers" in accounting practice. Each Account consists of a list of
-Splits that debit that Account. To ensure consistency, if a Split points
-to an Account, then the Account must point to the Split, and vice-versa.
-A Split can belong to at most one Account. Besides merely containing a
-list of Splits, the Account structure also gives the Account a name, a
+Splits are grouped into GncAccounts which are also known
+as "Ledgers" in GncAccounting practice. Each GncAccount consists of a list of
+Splits that debit that GncAccount. To ensure consistency, if a Split points
+to an GncAccount, then the GncAccount must point to the Split, and vice-versa.
+A Split can belong to at most one GncAccount. Besides merely containing a
+list of Splits, the GncAccount structure also gives the GncAccount a name, a
 code number, description and notes fields, a key-value frame, a pointer
-to the commodity that is used for all splits in this account. The
+to the commodity that is used for all splits in this GncAccount. The
 commodity can be the name of anything traded and tradable: a stock 
 (e.g. "IBM", "McDonald's"), a currency (e.g. "USD", "GBP"), or anything
 added to the commodity table.  
 
-Accounts can be arranged in a hierarchical tree. The nodes of the tree
-are called "Account Groups". By accounting
-convention, the value of an Account is equal to the value of all of its
-Splits plus the value of all of its sub-Accounts.
+GncAccounts can be arranged in a hierarchical tree. The nodes of the tree
+are called "GncAccount Groups". By GncAccounting
+convention, the value of an GncAccount is equal to the value of all of its
+Splits plus the value of all of its sub-GncAccounts.
 
     @{ */
 /** @file Transaction.h 
@@ -91,30 +91,9 @@
 #include "gnc-commodity.h"
 #include "gnc-engine.h"
 #include "Split.h"
+#include "Account.h"
 
-/* GObject declarations */
 
-#define GNC_TYPE_TRANSACTION            (qof_book_get_type ())
-#define GNC_TRANSACTION(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TRANSACTION, GncTransaction))
-#define GNC_TRANSACTION_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TRANSACTION, GncTransactionClass))
-#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, GncTransactionClass))
-
-
-typedef struct _GncTransactionClass GncTransactionClass;
-typedef struct _GncTransaction GncTransaction;
-typedef struct GncTransaction Transaction; /*  Dummy type for backward compatilibity */
-
-struct _GncTransactionClass {
-	QofInstanceClass parent_class;
-	/* virtual table */
-
-	/* Add Signal Functions Here */
-};
-
-GType   gnc_transaction_get_type ();
-
 /** @name Transaction Type field values
 @{
 */
@@ -137,7 +116,7 @@
 
 /**
  The xaccTransDestroy() method will remove all 
- of the splits from each of their accounts, free the memory
+ of the splits from each of their GncAccounts, free the memory
  associated with them.  This routine must be followed by either
  an xaccTransCommitEdit(), in which case the transaction 
  memory will be freed, or by xaccTransRollbackEdit(), in which 
@@ -166,7 +145,7 @@
  *
  * @param check_balances If TRUE, when checking splits also compare
  * balances between the two splits.  Balances are recalculated
- * whenever a split is added or removed from an account, so YMMV on
+ * whenever a split is added or removed from an GncAccount, so YMMV on
  * whether this should be set.
  *
  * @param assume_ordered If TRUE, assume that the splits in each
@@ -215,7 +194,7 @@
 #define xaccTransLookupDirect(g,b) xaccTransLookup(&(g),b)
 
 Split * xaccTransFindSplitByAccount(const Transaction *trans, 
-                                    const Account *acc);
+                                    const GncAccount *acc);
 
 /** The xaccTransScrubGains() routine performs a number of cleanup
  *  functions on the indicated transaction, with the end-goal of
@@ -224,7 +203,7 @@
  *  assignments of all the splits are good, and that the lots 
  *  balance appropriately.
  */
-void xaccTransScrubGains (Transaction *trans, Account *gain_acc);
+void xaccTransScrubGains (Transaction *trans, GncAccount *gain_acc);
 
 
 /** \warning XXX FIXME 
@@ -315,15 +294,15 @@
 /** FIXME: document me */
 gboolean      xaccTransHasReconciledSplits (const Transaction *trans);
 /** FIXME: document me */
-gboolean      xaccTransHasReconciledSplitsByAccount (const Transaction *trans,
-						     const Account *account);
+gboolean      xaccTransHasReconciledSplitsByGncAccount (const Transaction *trans,
+						     const GncAccount *GncAccount);
 
 /** FIXME: document me */
 gboolean      xaccTransHasSplitsInState (const Transaction *trans, const char state);
 /** FIXME: document me */
-gboolean      xaccTransHasSplitsInStateByAccount (const Transaction *trans,
+gboolean      xaccTransHasSplitsInStateByGncAccount (const Transaction *trans,
 						  const char state,
-						  const Account *account);
+						  const GncAccount *GncAccount);
 
 
 /** Returns the valuation commodity of this transaction.
@@ -348,32 +327,32 @@
  * method. */
 gnc_numeric xaccTransGetImbalance (const Transaction * trans);
 
-/** The xaccTransGetAccountValue() method returns the total value applied
- *  to a particular account.  In some cases there may be multiple Splits
- *  in a single Transaction applied to one account (in particular when
+/** The xaccTransGetGncAccountValue() method returns the total value applied
+ *  to a particular GncAccount.  In some cases there may be multiple Splits
+ *  in a single Transaction applied to one GncAccount (in particular when
  *  trying to balance Lots) -- this function is just a convienience to
  *  view everything at once.
  */
-gnc_numeric xaccTransGetAccountValue (const Transaction *trans, 
-				      const Account *account);
+gnc_numeric xaccTransGetGncAccountValue (const Transaction *trans, 
+				      const GncAccount *GncAccount);
 
-/** Same as xaccTransGetAccountValue, but uses the Account's commodity. */
-gnc_numeric xaccTransGetAccountAmount (const Transaction *trans,
-                                       const Account *account);
+/** Same as xaccTransGetGncAccountValue, but uses the GncAccount's commodity. */
+gnc_numeric xaccTransGetGncAccountAmount (const Transaction *trans,
+                                       const GncAccount *GncAccount);
 
-/* Compute the conversion rate for the transaction to this account.
+/* Compute the conversion rate for the transaction to this GncAccount.
  * Any "split value" (which is in the transaction currency),
  * multiplied by this conversion rate, will give you the value you
- * should display for this account.
+ * should display for this GncAccount.
  *
  * If 'acc' is NULL, return unity.
  */
-gnc_numeric xaccTransGetAccountConvRate(Transaction *txn, Account *acc);
+gnc_numeric xaccTransGetGncAccountConvRate(Transaction *txn, GncAccount *acc);
 
-/** Get the account balance for the specified account after the last
+/** Get the GncAccount balance for the specified GncAccount after the last
     split in the specified transaction. */
-gnc_numeric xaccTransGetAccountBalance (const Transaction *trans,
-                                        const Account *account);
+gnc_numeric xaccTransGetGncAccountBalance (const Transaction *trans,
+                                        const GncAccount *GncAccount);
 
 /**
  * The xaccTransOrder(ta,tb) method is useful for sorting.
@@ -471,13 +450,13 @@
 \********************************************************************/
 
 
-/** The xaccGetAccountByName() is a convenience routine that 
- *  is essentially identical to xaccGetPeerAccountFromName(),
+/** The xaccGetGncAccountByName() is a convenience routine that 
+ *  is essentially identical to xaccGetPeerGncAccountFromName(),
  *  except that it accepts the handy transaction as root.*/
-Account * xaccGetAccountByName (const Transaction *trans, const char *name);
-/** The xaccGetAccountByFullName routine is similar to xaccGetAccountByName, but uses
+GncAccount * xaccGetGncAccountByName (const Transaction *trans, const char *name);
+/** The xaccGetGncAccountByFullName routine is similar to xaccGetGncAccountByName, but uses
  *  full names using the given separator.*/
-Account * xaccGetAccountByFullName (const Transaction *trans,
+GncAccount * xaccGetGncAccountByFullName (const Transaction *trans,
                                     const char *name);
 
 
@@ -508,7 +487,7 @@
 /** xaccTransReverse creates a Transaction that reverses the given
  *  tranaction by inverting all the numerical values in the given
  *  transaction.  This function cancels out the effect of an earlier
- *  transaction.  This will be needed by write only accounts as a way
+ *  transaction.  This will be needed by write only GncAccounts as a way
  *  to void a previous transaction (since you can't alter the existing
  *  transaction).
  *

Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -49,64 +49,6 @@
 #include <glib.h>
 #include "gnc-engine.h"
 
-/* GObject declarations for GncCommodity */
-
-#define GNC_TYPE_COMMODITY            (gnc_commodity_type ())
-#define GNC_COMMODITY(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_COMMODITY, GncCommodity))
-#define GNC_COMMODITY_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_COMMODITY, GncCommodityClass))
-#define GNC_IS_COMMODITY(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_COMMODITY))
-#define GNC_IS_COMMODITY_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_COMMODITY))
-#define GNC_COMMODITY_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_COMMODITY, GncCommodityClass))
-
-
-typedef struct _GncCommodityClass GncCommodityClass;
-typedef struct _GncCommodity GncCommodity;
-typedef struct _GncCommodityPrivate GncCommodityPrivate;
-typedef struct GncCommodityNamespace gnc_commodity; /*  Dummy type for backward compatilibity */
-
-struct _GncCommodity {
-    QofInstance instance;
-    GncCommodityPrivate *priv;
-};
-
-struct _GncCommodityClass {
-	QofInstanceClass parent_class;
-	/* virtual table */
-
-	/* Add Signal Functions Here */
-};
-
-GType   gnc_commodity_get_type ();
-
-/* GObject declarations */
-
-#define GNC_TYPE_COMMODITY_NAMESPACE            (gnc_commodity_namespace_get_type ())
-#define GNC_COMMODITY_NAMESPACE(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_COMMODITY_NAMESPACE, GncCommodityNamespace))
-#define GNC_COMMODITY_NAMESPACE_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_COMMODITY_NAMESPACE, GncCommodityNamespaceClass))
-#define GNC_IS_COMMODITY_NAMESPACE(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_COMMODITY_NAMESPACE))
-#define GNC_IS_COMMODITY_NAMESPACE_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_COMMODITY_NAMESPACE))
-#define GNC_COMMODITY_NAMESPACE_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_COMMODITY_NAMESPACE, GncCommodityNamespaceClass))
-
-
-typedef struct _GncCommodityNamespaceClass GncCommodityNamespaceClass;
-typedef struct _GncCommodityNamespace GncCommodityNamespace;
-typedef struct _GncCommodityNamespacePrivate GncCommodityPrivate;
-typedef struct GncCommodityNamespace gnc_commodity_namespace; /*  Dummy type for backward compatilibity */
-
-struct _GncCommodityNamespace {
-    QofInstance instance;
-    GncCommodityNamespacePrivate *priv;
-};
-
-struct _GncCommodityNamespaceClass {
-	QofInstanceClass parent_class;
-	/* virtual table */
-
-	/* Add Signal Functions Here */
-};
-
-GType   gnc_commodity_namespace_get_type ();
-
 /******************************************************/
 
 #define GNC_COMMODITY_TABLE "gnc_commodity_table"
@@ -322,7 +264,7 @@
  *
  *  @return A pointer to the new commodity.
  */
-gnc_commodity * gnc_commodity_new(QofBook *book,
+GncCommodity * gnc_commodity_new(QofBook *book,
 				  const char * fullname, 
                                   const char * namespace,
                                   const char * mnemonic,
@@ -334,13 +276,13 @@
  *  commodity is referenced anywhere.
  *  @param cm The commodity to destroy.
  */
-void  gnc_commodity_destroy(gnc_commodity * cm);
+void  gnc_commodity_destroy(GncCommodity * cm);
 
 /** Copy src into dest */
-void  gnc_commodity_copy(gnc_commodity * dest, gnc_commodity *src);
+void  gnc_commodity_copy(GncCommodity * dest, GncCommodity *src);
 
 /** allocate and copy */
-gnc_commodity * gnc_commodity_clone(gnc_commodity *src);
+GncCommodity * gnc_commodity_clone(GncCommodity *src);
 /** @} */
 
 
@@ -358,7 +300,7 @@
  *  @return A pointer to the mnemonic for this commodity.  This string
  *  is owned by the engine and should not be freed by the caller.
  */
-const char * gnc_commodity_get_mnemonic(const gnc_commodity * cm);
+const char * gnc_commodity_get_mnemonic(const GncCommodity * cm);
 
 /** Retrieve the namespace for the specified commodity.  This will be
  *  a pointer to a null terminated string of the form "AMEX",
@@ -369,7 +311,7 @@
  *  @return A pointer to the namespace for this commodity.  This string
  *  is owned by the engine and should not be freed by the caller.
  */
-const char * gnc_commodity_get_namespace(const gnc_commodity * cm);
+const char * gnc_commodity_get_namespace(const GncCommodity * cm);
 
 /** Retrieve the namespace for the specified commodity.  This will be
  *  a pointer to a null terminated string of the form "AMEX",
@@ -383,7 +325,7 @@
  *  @return A pointer to the namespace for this commodity.  This string
  *  is owned by the engine and should not be freed by the caller.
  */
-const char * gnc_commodity_get_namespace_compat(const gnc_commodity * cm);
+const char * gnc_commodity_get_namespace_compat(const GncCommodity * cm);
 
 /** Retrieve the namespace data strucure for the specified commodity.
  *  This will be a pointer to another data structure.
@@ -393,7 +335,7 @@
  *  @return A pointer to the namespace data structure for this
  *  commodity.
  */
-gnc_commodity_namespace *gnc_commodity_get_namespace_ds(const gnc_commodity * cm);
+gnc_commodity_namespace *gnc_commodity_get_namespace_ds(const GncCommodity * cm);
 
 /** Retrieve the full name for the specified commodity.  This will be
  *  a pointer to a null terminated string of the form "Acme Systems,
@@ -404,7 +346,7 @@
  *  @return A pointer to the full name for this commodity.  This string
  *  is owned by the engine and should not be freed by the caller.
  */
-const char * gnc_commodity_get_fullname(const gnc_commodity * cm);
+const char * gnc_commodity_get_fullname(const GncCommodity * cm);
 
 /** Retrieve the 'print' name for the specified commodity.  This will
  *  be a pointer to a null terminated string of the form "Acme
@@ -416,7 +358,7 @@
  *  string is owned by the engine and should not be freed by the
  *  caller.
  */
-const char * gnc_commodity_get_printname(const gnc_commodity * cm);
+const char * gnc_commodity_get_printname(const GncCommodity * cm);
 
 /** Retrieve the 'exchange code' for the specified commodity.  This
  *  will be a pointer to a null terminated string of the form
@@ -433,7 +375,7 @@
  *  string is owned by the engine and should not be freed by the
  *  caller.
  */
-const char * gnc_commodity_get_cusip(const gnc_commodity * cm);
+const char * gnc_commodity_get_cusip(const GncCommodity * cm);
 
 /** Retrieve the 'unique' name for the specified commodity.  This will
  *  be a pointer to a null terminated string of the form "AMEX::ACME",
@@ -446,7 +388,7 @@
  *  string is owned by the engine and should not be freed by the
  *  caller.
  */
-const char * gnc_commodity_get_unique_name(const gnc_commodity * cm);
+const char * gnc_commodity_get_unique_name(const GncCommodity * cm);
 
 /** Retrieve the fraction for the specified commodity.  This will be
  *  an integer value specifying the number of fractional units that
@@ -458,7 +400,7 @@
  *  @return The number of fractional units that one of these
  *  commodities can be divided into.
  */
-int     gnc_commodity_get_fraction(const gnc_commodity * cm);
+int     gnc_commodity_get_fraction(const GncCommodity * cm);
 
 /** Retrieve the 'mark' field for the specified commodity.
  *
@@ -468,7 +410,7 @@
  *
  *  @return The value of the mark field.
  */
-gint16  gnc_commodity_get_mark(const gnc_commodity * cm);
+gint16  gnc_commodity_get_mark(const GncCommodity * cm);
 
 /** Retrieve the automatic price quote flag for the specified
  *  commodity.  This flag indicates whether stock quotes should be
@@ -479,7 +421,7 @@
  *  @return TRUE if quotes should be pulled for this commodity, FALSE
  *  otherwise.
  */
-gboolean    gnc_commodity_get_quote_flag(const gnc_commodity *cm);
+gboolean    gnc_commodity_get_quote_flag(const GncCommodity *cm);
 
 /** Retrieve the automatic price quote source for the specified
  *  commodity.  This will be a pointer to a null terminated string of
@@ -489,8 +431,8 @@
  *
  *  @return A pointer to the price quote source for this commodity.
  */
-gnc_quote_source* gnc_commodity_get_quote_source(const gnc_commodity *cm);
-gnc_quote_source* gnc_commodity_get_default_quote_source(const gnc_commodity *cm);
+gnc_quote_source* gnc_commodity_get_quote_source(const GncCommodity *cm);
+gnc_quote_source* gnc_commodity_get_default_quote_source(const GncCommodity *cm);
 
 /** Retrieve the automatic price quote timezone for the specified
  *  commodity.  This will be a pointer to a null terminated string of
@@ -502,7 +444,7 @@
  *  This string is owned by the engine and should not be freed by the
  *  caller.
  */
-const char* gnc_commodity_get_quote_tz(const gnc_commodity *cm);
+const char* gnc_commodity_get_quote_tz(const GncCommodity *cm);
 /** @} */
 
 
@@ -521,7 +463,7 @@
  *  This string belongs to the caller and will be duplicated by the
  *  engine.
  */
-void  gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic);
+void  gnc_commodity_set_mnemonic(GncCommodity * cm, const char * mnemonic);
 
 /** Set the namespace for the specified commodity.  This should be a
  *  pointer to a null terminated string of the form "AMEX", "NASDAQ",
@@ -533,7 +475,7 @@
  *  This string belongs to the caller and will be duplicated by the
  *  engine.
  */
-void  gnc_commodity_set_namespace(gnc_commodity * cm, const char * namespace);
+void  gnc_commodity_set_namespace(GncCommodity * cm, const char * namespace);
 
 /** Set the full name for the specified commodity.  This should be
  *  a pointer to a null terminated string of the form "Acme Systems,
@@ -545,7 +487,7 @@
  *  This string belongs to the caller and will be duplicated by the
  *  engine.
  */
-void  gnc_commodity_set_fullname(gnc_commodity * cm, const char * fullname);
+void  gnc_commodity_set_fullname(GncCommodity * cm, const char * fullname);
 
 /** Set the 'exchange code' for the specified commodity.  This should
  *  be a pointer to a null terminated string of the form "AXQ14728",
@@ -561,7 +503,7 @@
  *  data for this commodity.  This string belongs to the caller and
  *  will be duplicated by the engine.
  */
-void  gnc_commodity_set_cusip(gnc_commodity * cm, const char * cusip);
+void  gnc_commodity_set_cusip(GncCommodity * cm, const char * cusip);
 
 /** Set the fraction for the specified commodity.  This should be
  *  an integer value specifying the number of fractional units that
@@ -573,7 +515,7 @@
  *  @param smallest_fraction The number of fractional units that one of
  *  these commodities can be divided into.
  */
-void  gnc_commodity_set_fraction(gnc_commodity * cm, int smallest_fraction);
+void  gnc_commodity_set_fraction(GncCommodity * cm, int smallest_fraction);
 
 /** Set the automatic price quote flag for the specified commodity.
  *  This flag indicates whether stock quotes should be retrieved for
@@ -584,7 +526,7 @@
  *  @param flag TRUE if quotes should be pulled for this commodity, FALSE
  *  otherwise.
  */
-void  gnc_commodity_set_quote_flag(gnc_commodity *cm, const gboolean flag);
+void  gnc_commodity_set_quote_flag(GncCommodity *cm, const gboolean flag);
 
 /** Set the automatic price quote source for the specified commodity.
  *  This should be a pointer to a null terminated string of the form
@@ -595,7 +537,7 @@
  *
  *  @param src A pointer to the price quote source for this commodity.
  */
-void  gnc_commodity_set_quote_source(gnc_commodity *cm, gnc_quote_source *src);
+void  gnc_commodity_set_quote_source(GncCommodity *cm, gnc_quote_source *src);
 
 /** Set the automatic price quote timezone for the specified
  *  commodity.  This should be a pointer to a null terminated string
@@ -608,7 +550,7 @@
  *  This string belongs to the caller and will be duplicated by the
  *  engine.
  */
-void  gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz);
+void  gnc_commodity_set_quote_tz(GncCommodity *cm, const char *tz);
 /** @} */
 
 
@@ -623,13 +565,13 @@
  *  exchanges, may have different fullnames, and may have different
  *  fractions.
  */
-gboolean gnc_commodity_equiv(const gnc_commodity * a, const gnc_commodity * b);
+gboolean gnc_commodity_equiv(const GncCommodity * a, const GncCommodity * b);
 
 /** This routine returns TRUE if the two commodities are equal.
  *  Commodities are equal if they have the same namespace, mnemonic,
  *  fullname, exchange private code and fraction.
  */
-gboolean gnc_commodity_equal(const gnc_commodity * a, const gnc_commodity * b);
+gboolean gnc_commodity_equal(const GncCommodity * a, const GncCommodity * b);
 /** @} */
 
 
@@ -650,7 +592,7 @@
  *  @param cm The commodity to check.
  *
  *  @return TRUE if the commodity represents a currency, FALSE otherwise. */
-gboolean gnc_commodity_is_iso(const gnc_commodity * cm);
+gboolean gnc_commodity_is_iso(const GncCommodity * cm);
 
 /** Checks to see if the specified commodity is an ISO 4217 recognized
  * currency or a legacy currency.
@@ -658,7 +600,7 @@
  *  @param cm The commodity to check.
  *
  *  @return TRUE if the commodity represents a currency, FALSE otherwise. */
-gboolean gnc_commodity_is_currency(const gnc_commodity *cm);
+gboolean gnc_commodity_is_currency(const GncCommodity *cm);
 
 /** @} */
 
@@ -687,17 +629,17 @@
 /** @name Commodity Table Lookup functions
 @{
 */
-gnc_commodity * gnc_commodity_table_lookup(const gnc_commodity_table * table, 
+GncCommodity * gnc_commodity_table_lookup(const gnc_commodity_table * table, 
                                            const char * namespace, 
                                            const char * mnemonic);
-gnc_commodity *
+GncCommodity *
 gnc_commodity_table_lookup_unique(const gnc_commodity_table *table,
                                   const char * unique_name);
-gnc_commodity * gnc_commodity_table_find_full(const gnc_commodity_table * t,
+GncCommodity * gnc_commodity_table_find_full(const gnc_commodity_table * t,
                                               const char * namespace,
                                               const char * fullname);
 
-gnc_commodity * gnc_commodity_find_commodity_by_guid(const GUID *guid, QofBook *book);
+GncCommodity * gnc_commodity_find_commodity_by_guid(const GUID *guid, QofBook *book);
 gnc_commodity_namespace * gnc_commodity_find_namespace_by_guid(const GUID *guid, QofBook *book);
 
 /** @} */
@@ -721,8 +663,8 @@
  *  @note The commodity pointer passed to this function should not be
  *  used after its return, as it may have been destroyed.  Use the
  *  return value which is guaranteed to be valid. */
-gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table,
-                                           gnc_commodity * comm);
+GncCommodity * gnc_commodity_table_insert(gnc_commodity_table * table,
+                                           GncCommodity * comm);
 
 /** Remove a commodity from the commodity table. If the commodity to
  *  remove doesn't exist, nothing happens.
@@ -731,7 +673,7 @@
  *
  *  @param comm A pointer to the commodity to remove. */
 void gnc_commodity_table_remove(gnc_commodity_table * table,
-				gnc_commodity * comm);
+				GncCommodity * comm);
 
 /** Add all the standard namespaces and currencies to the commodity
  *  table.  This routine creates the namespaces for the NYSE, NASDAQ,
@@ -897,7 +839,7 @@
  *  @param user_data A pointer that is passed into the function
  *  unchanged by the table walk routine. */
 gboolean gnc_commodity_table_foreach_commodity(const gnc_commodity_table * table,
-                                       gboolean (*f)(gnc_commodity *cm,
+                                       gboolean (*f)(GncCommodity *cm,
                                                      gpointer user_data),
                                        gpointer user_data);
 /** @} */
@@ -916,7 +858,7 @@
  *
  *  @param mark The new value of the mark field.
  */
-void  gnc_commodity_set_mark(gnc_commodity * cm, gint16 mark);
+void  gnc_commodity_set_mark(GncCommodity * cm, gint16 mark);
 
 /** You proably shouldn't be using gnc_commodity_table_new() directly,
  * its for internal use only. You should probably be using
@@ -930,7 +872,7 @@
  *   the indicated book.  This routine is primarily useful for setting
  *   up clones of things across multiple books.
  */
-gnc_commodity * gnc_commodity_obtain_twin (gnc_commodity *from, QofBook *book);
+GncCommodity * gnc_commodity_obtain_twin (GncCommodity *from, QofBook *book);
 
 /** You should probably not be using gnc_commodity_table_register()
  * It is an internal routine for registering the gncObject for the
@@ -938,8 +880,8 @@
  */
 gboolean gnc_commodity_table_register (void);
 
-void gnc_commodity_begin_edit (gnc_commodity *cm);
-void gnc_commodity_commit_edit (gnc_commodity *cm);
+void gnc_commodity_begin_edit (GncCommodity *cm);
+void gnc_commodity_commit_edit (GncCommodity *cm);
 		  
 /** @} */
 

Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-engine.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-engine.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-engine.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -87,23 +87,23 @@
 #define GNC_ID_SESSION        QOF_ID_SESSION
 #define GNC_ID_NULL           QOF_ID_NULL
 
-#define GNC_ID_ACCOUNT        "Account"
-#define GNC_ID_COMMODITY      "Commodity"
-#define GNC_ID_COMMODITY_NAMESPACE "CommodityNamespace"
-#define GNC_ID_COMMODITY_TABLE "CommodityTable"
-#define GNC_ID_FREQSPEC       "FreqSpec"
-#define GNC_ID_GROUP          "AccountGroup"
-#define GNC_ID_LOT            "Lot"
-#define GNC_ID_PERIOD         "Period"
-#define GNC_ID_PRICE          "Price"
-#define GNC_ID_PRICEDB        "PriceDB"
-#define GNC_ID_SPLIT          "Split"
-#define GNC_ID_BUDGET         "Budget"
-#define GNC_ID_SCHEDXACTION   "SchedXaction"
-#define GNC_ID_SXES           "SchedXactions"
-#define GNC_ID_SXTG           "SXTGroup"
-#define GNC_ID_SXTT           "SXTTrans"
-#define GNC_ID_TRANS          "Trans"
+#define GNC_ID_ACCOUNT        GNC_TYPE_ACCOUNT
+#define GNC_ID_COMMODITY      GNC_TYPE_COMMODITY
+#define GNC_ID_COMMODITY_NAMESPACE GNC_TYPE_COMMODITY_NAMESPACE
+#define GNC_ID_COMMODITY_TABLE GNC_TYPE_COMMODITY_TABLE
+#define GNC_ID_FREQSPEC       GNC_TYPE_FREQ_SPEC 
+#define GNC_ID_GROUP          GNC_TYPE_ACCOUNT_GROUP
+#define GNC_ID_LOT            GNC_TYPE_LOT
+#define GNC_ID_PERIOD         "Period" /* Broken QofIdType: actually comented out */
+#define GNC_ID_PRICE          GNC_TYPE_PRICE
+#define GNC_ID_PRICEDB        GNC_TYPE_PRICE_DB
+#define GNC_ID_SPLIT          GNC_TYPE_SPLIT
+#define GNC_ID_BUDGET         GNC_TYPE_BUDGET
+#define GNC_ID_SCHEDXACTION   GNC_TYPE_SCHEDULE_ACTION
+#define GNC_ID_SXES           GNC_TYPE_SCHEDULE_ACTIONS
+#define GNC_ID_SXTG           G_TYPE_CHAR /* FIXME: Use a diferent way to store hash for SchedXaction gruops */
+#define GNC_ID_SXTT           G_TYPE_NONE  /* FIXME: This type isn't used any plase or a kind of object */
+#define GNC_ID_TRANS          GNC_TYPE_TRANSACTION
 
 /* TYPES **********************************************************/
 
@@ -129,12 +129,67 @@
  * defined in the private header AccountP.h, but no one outside the
  * engine should include that file. Instead, access that data only
  * through the functions in Account.h .*/
-typedef struct account_s             Account;
+//typedef struct account_s             Account;
 
-/** @brief A group of accounts in Gnucash. 
+
+/* GObject declarations */
+
+#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))
+
+
+typedef struct _GncAccountClass GncAccountClass;
+typedef struct _GncAccount GncAccount;
+typedef struct _GncAccountPrivate GncAccountPrivate;
+
+#define Account GncAccount //  Backward compatibility
+
+struct _GncAccount {
+	QofInstance inst;
+	GncAccountPrivate *priv;
+};
+
+struct _GncAccountClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+
+	/* Add Signal Functions Here */
+};
+
+GType   gnc_account_get_type (void);
+
+/** @brief A group of accountsin Gnucash. 
 */
-typedef struct account_group_s       AccountGroup;
+//typedef struct account_group_s       AccountGroup;
+/* GObject declarations */
 
+#define GNC_TYPE_ACCOUNT_GROUP            (gnc_account_group_get_type ())
+#define GNC_ACCOUNT_GROUP(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ACCOUNT_GROUP, AccountGroup))
+#define GNC_ACCOUNT_GROUP_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ACCOUNT_GROUP, GncAccountGroupClass))
+#define GNC_IS_ACCOUNT_GROUP(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ACCOUNT_GROUP))
+#define GNC_IS_ACCOUNT_GROUP_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ACCOUNT_GROUP))
+#define GNC_ACCOUNT_GROUP_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ACCOUNT_GROUP, GncAccountGroupClass))
+
+
+typedef struct _GncAccountGroupClass GncAccountGroupClass;
+typedef struct _GncAccountGroupPrivate GncAccountGroupPrivate;
+typedef struct _GncAccountGroup AccountGroup;
+
+
+struct _GncAccountGroupClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+
+	/* Add Signal Functions Here */
+};
+
+GType   gnc_account_group_get_type (void);
+
+
 /** @brief Split in Gnucash. 
  * A "split" is more commonly refered to as a "entry" in a
  * "transaction". Each split belongs to one Account and one
@@ -145,8 +200,30 @@
  * in the private header TransactionP.h, but no one outside the engine
  * should include that file. Instead, access that data only through
  * the functions in Transaction.h .*/
-typedef struct split_s               Split;
+//typedef struct split_s               Split;
+/* GObject declarations */
 
+#define GNC_TYPE_SPLIT            (gnc_split_get_type ())
+#define GNC_SPLIT(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SPLIT, GncSplit))
+#define GNC_SPLIT_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SPLIT, GncSplitClass))
+#define GNC_IS_SPLIT(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SPLIT))
+#define GNC_IS_SPLIT_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SPLIT))
+#define GNC_SPLIT_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SPLIT, GncSplitClass))
+
+
+typedef struct _GncSplitClass GncSplitClass;
+typedef struct _GncSplit GncSplit;
+typedef GncSplit Split; /*  Dummy type for backward compatilibity */
+
+struct _GncSplitClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+
+	/* Add Signal Functions Here */
+};
+
+GType   gnc_split_get_type (void);
+
 /** @brief Transaction in Gnucash.  
  * A Transaction is a piece of business done; the transfer of money
  * from one account to one or more other accounts. Each Transaction is
@@ -156,8 +233,34 @@
  * defined in the private header TransactionP.h, but no one outside
  * the engine should include that file. Instead, access that data only
  * through the functions in Transaction.h .*/
-typedef struct transaction_s         Transaction;
+//typedef struct transaction_s         Transaction;
 
+/* GObject declarations */
+
+#define GNC_TYPE_TRANSACTION            (qof_book_get_type ())
+#define GNC_TRANSACTION(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TRANSACTION, GncTransaction))
+#define GNC_TRANSACTION_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TRANSACTION, GncTransactionClass))
+#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, GncTransactionClass))
+
+
+typedef struct _GncTransactionClass GncTransactionClass;
+typedef struct _GncTransaction GncTransaction;
+typedef struct _GncTransactionPrivate GncTransactionPrivate;
+typedef struct GncTransaction Transaction; /*  Dummy type for backward compatilibity */
+
+struct _GncTransactionClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+
+	/* Add Signal Functions Here */
+};
+
+
+GType   gnc_transaction_get_type (void);
+
+
 /** @brief An article that is bought and sold. 
  * A Commodity is the most general term of what an account keeps track
  * of. Usually this is a monetary currency, but it can also be a stock
@@ -172,11 +275,69 @@
  * This is the typename for a gnc_commodity. The actual structure is
  * defined in a private source file. For accessing that data, only use
  * the functions in gnc-commodity.h .*/
-typedef struct gnc_commodity_s       gnc_commodity;
+//typedef struct gnc_commodity_s       gnc_commodity;
+/* GObject declarations for GncCommodity */
 
+#define GNC_TYPE_COMMODITY            (gnc_commodity_type ())
+#define GNC_COMMODITY(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_COMMODITY, GncCommodity))
+#define GNC_COMMODITY_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_COMMODITY, GncCommodityClass))
+#define GNC_IS_COMMODITY(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_COMMODITY))
+#define GNC_IS_COMMODITY_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_COMMODITY))
+#define GNC_COMMODITY_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_COMMODITY, GncCommodityClass))
+
+
+typedef struct _GncCommodityClass GncCommodityClass;
+typedef struct _GncCommodity GncCommodity;
+typedef struct _GncCommodityPrivate GncCommodityPrivate;
+typedef GncCommodity gnc_commodity; /*  Dummy type for backward compatilibity */
+
+struct _GncCommodity {
+    QofInstance instance;
+    GncCommodityPrivate *priv;
+};
+
+struct _GncCommodityClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+
+	/* Add Signal Functions Here */
+};
+
+GType   gnc_commodity_get_type (void);
+
+
+
 /** @brief A gnc_commodity_namespace is an collection of commodities. */
-typedef struct gnc_commodity_namespace_s gnc_commodity_namespace;
+//typedef struct gnc_commodity_namespace_s gnc_commodity_namespace;
+/* GObject declarations */
 
+#define GNC_TYPE_COMMODITY_NAMESPACE            (gnc_commodity_namespace_get_type ())
+#define GNC_COMMODITY_NAMESPACE(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_COMMODITY_NAMESPACE, GncCommodityNamespace))
+#define GNC_COMMODITY_NAMESPACE_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_COMMODITY_NAMESPACE, GncCommodityNamespaceClass))
+#define GNC_IS_COMMODITY_NAMESPACE(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_COMMODITY_NAMESPACE))
+#define GNC_IS_COMMODITY_NAMESPACE_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_COMMODITY_NAMESPACE))
+#define GNC_COMMODITY_NAMESPACE_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_COMMODITY_NAMESPACE, GncCommodityNamespaceClass))
+
+
+typedef struct _GncCommodityNamespaceClass GncCommodityNamespaceClass;
+typedef struct _GncCommodityNamespace GncCommodityNamespace;
+typedef struct _GncCommodityNamespacePrivate GncCommodityNamespacePrivate;
+typedef struct GncCommodityNamespace gnc_commodity_namespace; /*  Dummy type for backward compatilibity */
+
+struct _GncCommodityNamespace {
+    QofInstance instance;
+    GncCommodityNamespacePrivate *priv;
+};
+
+struct _GncCommodityNamespaceClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+
+	/* Add Signal Functions Here */
+};
+
+GType   gnc_commodity_namespace_get_type (void);
+
 /** @brief A gnc_commodity_table is a database of commodity info. */
 typedef struct gnc_commodity_table_s gnc_commodity_table;
 
@@ -189,18 +350,40 @@
  *
  * See the file src/doc/lots.txt for implmentation overview.
  */
-typedef struct gnc_lot_struct        GNCLot;
+//typedef struct gnc_lot_struct        GNCLot;
+/* GObject declarations */
 
+#define GNC_TYPE_LOT            (gnc_lot_get_type ())
+#define GNC_LOT(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_LOT, GncLot))
+#define GNC_LOT_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_LOT, GncLotClass))
+#define GNC_IS_LOT(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_LOT))
+#define GNC_IS_LOT_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_LOT))
+#define GNC_LOT_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_LOT, GncLotClass))
+
+
+typedef struct _GncLotClass GncLotClass;
+typedef struct _GncLot GncLot;
+#define  GNCLot GncLot /* Dummy type for backward compatilibity */
+
+struct _GncLotClass {
+	QofInstanceClass parent_class;
+	/* virtual table */
+
+	/* Add Signal Functions Here */
+};
+
+GType   gnc_lot_get_type (void);
+
 /** @brief Price of commodity on a given date.
  * A GNCPrice encapsulates price information: the cost of a commodity
  * expressed as a currency, on a given date.  It also holds info about 
  * the provenance of the price: where it came from, its general validity.
  */
-typedef struct gnc_price_s           GNCPrice;
+//typedef struct gnc_price_s           GNCPrice;
 typedef struct gnc_quote_source_s    gnc_quote_source;
 
-#define GNC_IS_PRICE(obj)  (QOF_CHECK_TYPE((obj), GNC_ID_PRICE))
-#define GNC_PRICE(obj)     (QOF_CHECK_CAST((obj), GNC_ID_PRICE, GNCPrice))
+//#define GNC_IS_PRICE(obj)  (QOF_CHECK_TYPE((obj), GNC_ID_PRICE))
+//#define GNC_PRICE(obj)     (QOF_CHECK_CAST((obj), GNC_ID_PRICE, GNCPrice))
 
 /** GList of Account */
 typedef GList                  AccountList;

Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -63,31 +63,6 @@
 #include "qof.h"
 #include "gnc-lot-p.h"
 
-/* GObject declarations */
-
-#define GNC_TYPE_LOT            (gnc_lot_get_type ())
-#define GNC_LOT(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_LOT, GncLot))
-#define GNC_LOT_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_LOT, GncLotClass))
-#define QOF_IS_INSTANCE(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_LOT))
-#define QOF_IS_INSTANCE_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_LOT))
-#define GNC_LOT_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_LOT, GncLotClass))
-
-
-typedef struct _GncLotClass GncLotClass;
-typedef struct _GncLot GncLot;
-typedef struct GncLot GNCLot; /* Dummy type for backward compatilibity */
-
-struct _GncLotClass {
-	QofInstanceClass parent_class;
-	/* virtual table */
-
-	/* Add Signal Functions Here */
-};
-
-GType   gnc_lot_get_type ();
-
-
-
 GNCLot * gnc_lot_new (QofBook *);
 void gnc_lot_destroy (GNCLot *);
 
@@ -119,7 +94,7 @@
 
 /** The gnc_lot_get_account() routine returns the account with which 
  *    this lot is associated. */
-Account * gnc_lot_get_account (GNCLot *);
+GncAccount * gnc_lot_get_account (GNCLot *);
 
 /** The gnc_lot_get_balance() routine returns the balance of the lot. 
  *    The commodity in which this balance is expressed is the commodity 

Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -67,7 +67,7 @@
 static GObjectClass *parent_class = NULL;
 
 GType
-gnc_price_get_type()
+gnc_price_get_gtype()
 {
 	static GType type = 0;
 

Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.h	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.h	2007-03-08 13:23:14 UTC (rev 15690)
@@ -31,7 +31,7 @@
 /**************************** GncPrice Object ****************/
 /* GObject declarations */
 
-#define GNC_TYPE_PRICE            (gnc_price_get_type ())
+#define GNC_TYPE_PRICE            (gnc_price_get_gtype ())
 #define GNC_PRICE(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_PRICE, GncPrice))
 #define GNC_PRICE_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_PRICE, GncPriceClass))
 #define GNC_IS_PRICE(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_PRICE))
@@ -50,7 +50,7 @@
 	/* Add Signal Functions Here */
 };
 
-GType   gnc_price_get_type ();
+GType   gnc_price_get_gtype ();
 
 /** @addtogroup PriceDB
     @{ */

Modified: gnucash/branches/gobject-engine-dev/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/gnome-utils/gnc-main-window.c	2007-03-08 02:49:48 UTC (rev 15689)
+++ gnucash/branches/gobject-engine-dev/src/gnome-utils/gnc-main-window.c	2007-03-08 13:23:14 UTC (rev 15690)
@@ -1123,7 +1123,7 @@
 	g_return_if_fail(GNC_IS_MAIN_WINDOW(user_data));
 
 	/* soft failures */
-	if (!QOF_CHECK_TYPE(entity, QOF_ID_BOOK))
+	if (!QOF_IS_BOOK (entity))
 	  return;
 	if (event_type !=  QOF_EVENT_DESTROY)
 	  return;
@@ -1139,7 +1139,7 @@
 	for (item = priv->installed_pages; item; item = next) {
 	  next = g_list_next(item);
 	  page = GNC_PLUGIN_PAGE(item->data);
-	  if (gnc_plugin_page_has_book (page, (QofBook *)entity))
+	  if (gnc_plugin_page_has_book (page, QOF_BOOK (entity)))
               gnc_main_window_close_page (page);
 	}
 	LEAVE(" ");



More information about the gnucash-changes mailing list