r15781 - gnucash/branches/gobject-engine-dev-warlord - convert QofInstance to using GObject
Derek Atkins
warlord at cvs.gnucash.org
Tue Apr 3 09:51:36 EDT 2007
Author: warlord
Date: 2007-04-03 09:51:35 -0400 (Tue, 03 Apr 2007)
New Revision: 15781
Trac: http://svn.gnucash.org/trac/changeset/15781
Modified:
gnucash/branches/gobject-engine-dev-warlord/
gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qof-gobject.h
gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.c
gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.h
Log:
convert QofInstance to using GObject
note that this breaks the build of this branch, and that the
build will remain broken until each of the objects is converted
over to basic GObject support.
Property changes on: gnucash/branches/gobject-engine-dev-warlord
___________________________________________________________________
Name: svk:merge
- 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/swig-redo:802
3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:1037
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord:14369
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:14282
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk2:13366
+ 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/swig-redo:802
3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:1037
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord:14369
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord1:14377
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:14282
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk2:13366
Modified: gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qof-gobject.h
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qof-gobject.h 2007-04-03 11:42:09 UTC (rev 15780)
+++ gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qof-gobject.h 2007-04-03 13:51:35 UTC (rev 15781)
@@ -33,7 +33,8 @@
* for the QofInstance type you would need to define the following
* macros:
*
- * #define #define QOF_INSTANCE(o) \
+ * #define QOF_TYPE_INSTANCE (qof_instance_get_type ())
+ * #define QOF_INSTANCE(o) \
* (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_INSTANCE, QofInstance))
* #define QOF_INSTANCE_CLASS(k) \
* (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_INSTANCE, QofInstanceClass))
@@ -47,7 +48,7 @@
* @param type_name The function type_name for this type
*/
#define QOF_GOBJECT_DECL(type_name) \
- GType type_name##_get_type();
+ GType type_name##_get_type(void);
/**
* The following macros are for convenience in your QOF object
@@ -67,10 +68,11 @@
}
#define QOF_GOBJECT_FINALIZE(type_name) \
+ static void type_name##_finalize_real(GObject* object); \
static void type_name##_finalize(GObject *object) \
{ \
type_name##_finalize_real(object); \
- G_OBJECT_CLASS(type_name##parent_class)->finalize(object); \
+ G_OBJECT_CLASS(type_name##_parent_class)->finalize(object); \
}
#define QOF_GOBJECT_IMPL_WITH_CODE(type_name, TypeName, TYPE_PARENT, CODE) \
Modified: gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.c
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.c 2007-04-03 11:42:09 UTC (rev 15780)
+++ gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.c 2007-04-03 13:51:35 UTC (rev 15781)
@@ -39,24 +39,12 @@
/* ========================================================== */
-QofInstance*
-qof_instance_create (QofIdType type, QofBook *book)
-{
- QofInstance *inst;
+QOF_GOBJECT_IMPL(qof_instance, QofInstance, G_TYPE_OBJECT);
- inst = g_new0(QofInstance, 1);
- qof_instance_init(inst, type, book);
- return inst;
-}
-
-
-
-void
-qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
+static void
+qof_instance_init (QofInstance *inst)
{
- QofCollection *col;
-
- inst->book = book;
+ inst->book = NULL;
inst->kvp_data = kvp_frame_new();
inst->last_update.tv_sec = 0;
inst->last_update.tv_nsec = -1;
@@ -64,14 +52,25 @@
inst->do_free = FALSE;
inst->dirty = FALSE;
inst->infant = TRUE;
+}
+void
+qof_instance_init_data (QofInstance *inst, QofIdType type, QofBook *book)
+{
+ QofCollection *col;
+ g_return_if_fail(QOF_IS_INSTANCE(inst));
+ g_return_if_fail(!inst->book);
+
+ inst->book = book;
col = qof_book_get_collection (book, type);
qof_entity_init (inst, type, col);
}
-void
-qof_instance_release (QofInstance *inst)
+static void
+qof_instance_finalize_real (GObject *instp)
{
+ QofInstance* inst = QOF_INSTANCE(instp);
+
kvp_frame_delete (inst->kvp_data);
inst->kvp_data = NULL;
inst->editlevel = 0;
Modified: gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.h
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.h 2007-04-03 11:42:09 UTC (rev 15780)
+++ gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.h 2007-04-03 13:51:35 UTC (rev 15781)
@@ -36,17 +36,27 @@
#ifndef QOF_INSTANCE_H
#define QOF_INSTANCE_H
+typedef struct _QofInstanceClass QofInstanceClass;
+
+#include "qofid.h"
#include "guid.h"
#include "gnc-date.h"
#include "kvp_frame.h"
#include "qofbook.h"
-#include "qofid.h"
#include "qof-gobject.h"
/* --- type macros --- */
-/* cheesy, but will do for now, eventually should be more gtk-like, handle
- * thunks, etc. */
-#define QOF_INSTANCE(object) ((QofInstance *)(object))
+#define QOF_TYPE_INSTANCE (qof_instance_get_type ())
+#define QOF_INSTANCE(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_INSTANCE, QofInstance))
+#define QOF_INSTANCE_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_INSTANCE, QofInstanceClass))
+#define QOF_IS_INSTANCE(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_INSTANCE))
+#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))
struct QofInstance_s
{
@@ -95,15 +105,10 @@
};
/** Return the GType of a QofInstance */
-GType qof_instance_get_type();
+GType qof_instance_get_type(void);
-/** Initialise the memory associated with an instance */
-#if 1
-void qof_instance_init (QofInstance *, QofIdType, QofBook *);
-void qof_instance_release (QofInstance *);
-#else
+/** Initialise the settings associated with an instance */
void qof_instance_init_data (QofInstance *, QofIdType, QofBook *);
-#endif
/** Return the book pointer */
QofBook * qof_instance_get_book (const QofInstance *);
@@ -150,8 +155,6 @@
void qof_instance_mark_free(QofInstance *inst);
-QofInstance* qof_instance_create (QofIdType type, QofBook *book);
-
/** 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,
More information about the gnucash-changes
mailing list