r15522 - gnucash/branches/gobject-engine-dev - First QOF->GObject work. Now working on QofBook & QofBackend. Next auditing all the modified fiels and others becouse API changes and/or sync with the use of new GObject
Daniel Espinosa
esodan at cvs.gnucash.org
Thu Feb 8 00:50:09 EST 2007
Author: esodan
Date: 2007-02-08 00:49:51 -0500 (Thu, 08 Feb 2007)
New Revision: 15522
Trac: http://svn.gnucash.org/trac/changeset/15522
Modified:
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-p.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/qofid-p.h
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-p.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/src/business/business-core/gncAddress.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncAddress.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncBillTerm.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncBillTerm.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncCustomer.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncCustomer.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncEmployee.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncEmployee.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncEntry.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncEntry.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncInvoice.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncInvoice.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncJob.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncJob.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncOrder.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncOrder.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncTaxTable.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncTaxTable.h
gnucash/branches/gobject-engine-dev/src/business/business-core/gncVendor.c
gnucash/branches/gobject-engine-dev/src/business/business-core/gncVendor.h
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/AccountP.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/Makefile.am
gnucash/branches/gobject-engine-dev/src/engine/SchedXaction.c
gnucash/branches/gobject-engine-dev/src/engine/SchedXaction.h
gnucash/branches/gobject-engine-dev/src/engine/SchedXactionP.h
gnucash/branches/gobject-engine-dev/src/engine/Split.c
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/TransactionP.h
gnucash/branches/gobject-engine-dev/src/engine/gnc-budget.c
gnucash/branches/gobject-engine-dev/src/engine/gnc-budget.h
gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.c
gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.h
gnucash/branches/gobject-engine-dev/src/engine/gnc-lot-p.h
gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.c
gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.h
gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb-p.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/engine/test/test-book-merge.c
gnucash/branches/gobject-engine-dev/src/engine/test/test-recursive.c
Log:
First QOF->GObject work. Now working on QofBook & QofBackend. Next auditing all the modified fiels and others becouse API changes and/or sync with the use of new GObject
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -38,6 +38,36 @@
#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 *
\********************************************************************/
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbackend.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -216,6 +216,11 @@
gpointer value; /**< The value of the option. */
}QofBackendOption;
+/** Register and lookup backend-specific data for this particular object */
+gboolean qof_backend_register (GType type,
+ const char *backend_name,
+ gpointer be_data);
+
/** Initialise the backend_configuration */
void qof_backend_prepare_frame(QofBackend *be);
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook-p.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook-p.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -43,65 +43,6 @@
#include "qofid-p.h"
#include "qofinstance-p.h"
-/* Book structure */
-struct _QofBook
-{
- QofInstance inst; /* Unique guid for this book. */
-
- /* The time when the book was first dirtied. This is a secondary
- * indicator. It should only be used when inst.dirty is TRUE. */
- time_t dirty_time;
-
- /* This callback function is called any time the book dirty flag
- * changes state. Both clean->dirty and dirty->clean transitions
- * trigger a callback. */
- QofBookDirtyCB dirty_cb;
-
- /* This is the user supplied data that is returned in the dirty
- * callback function.*/
- gpointer dirty_data;
-
- /* The entity table associates the GUIDs of all the objects
- * belonging to this book, with their pointers to the respective
- * objects. This allows a lookup of objects based on thier guid.
- */
- GHashTable * hash_of_collections;
-
- /* In order to store arbitrary data, for extensibility, add a table
- * that will be used to hold arbitrary pointers.
- */
- GHashTable *data_tables;
-
- /* Hash table of destroy callbacks for the data table. */
- GHashTable *data_table_finalizers;
-
- /* state flag: 'y' means 'open for editing',
- * 'n' means 'book is closed'
- * xxxxx shouldn't this be replaced by the instance editlevel ???
- */
- char book_open;
-
- /* a flag denoting whether the book is closing down, used to
- * help the QOF objects shut down cleanly without maintaining
- * internal consistency.
- * XXX shouldn't this be replaced by instance->do_free ???
- */
- gboolean shutting_down;
-
- /* version number, used for tracking multiuser updates */
- gint32 version;
-
- /* To be technically correct, backends belong to sessions and
- * not books. So the pointer below "really shouldn't be here",
- * except that it provides a nice convenience, avoiding a lookup
- * from the session. Better solutions welcome ... */
- QofBackend *backend;
-
- /* -------------------------------------------------------------- */
- /* Backend private expansion data */
- guint32 idata; /* used by the sql backend for kvp management */
-};
-
/*
* qof_book_set_backend() is used by backends to
* initialize the pointers in the book structure to
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -44,49 +44,241 @@
#include "qofbackend-p.h"
#include "qofbook-p.h"
#include "qofid-p.h"
-#include "qofobject-p.h"
+//#include "qofobject-p.h"
static QofLogModule log_module = QOF_MOD_ENGINE;
-/* ====================================================================== */
-/* constructor / destructor */
+/* GObject declarations */
-static void coll_destroy(gpointer col)
+static void qof_book_class_init(QofBookClass *klass);
+static void qof_book_init(QofBook *sp);
+static void qof_book_finalize(GObject *object);
+
+/* Book structure */
+struct _QofBookPrivate
{
- qof_collection_destroy((QofCollection *) col);
+ /* The time when the book was first dirtied. This is a secondary
+ * indicator. It should only be used when inst.dirty is TRUE. */
+ time_t dirty_time;
+
+ /* This callback function is called any time the book dirty flag
+ * changes state. Both clean->dirty and dirty->clean transitions
+ * trigger a callback. */
+ QofBookDirtyCB dirty_cb;
+
+ /* This is the user supplied data that is returned in the dirty
+ * callback function.*/
+ gpointer dirty_data;
+
+ /* The entity table associates the GUIDs of all the objects
+ * belonging to this book, with their pointers to the respective
+ * objects. This allows a lookup of objects based on thier guid.
+ */
+ GHashTable * hash_of_collections;
+
+ /* In order to store arbitrary data, for extensibility, add a table
+ * that will be used to hold arbitrary pointers.
+ */
+ GHashTable *data_tables;
+
+ /* Hash table of destroy callbacks for the data table. */
+ GHashTable *data_table_finalizers;
+
+ /* state flag: 'y' means 'open for editing',
+ * 'n' means 'book is closed'
+ * xxxxx shouldn't this be replaced by the instance editlevel ???
+ */
+ char book_open;
+
+ /* a flag denoting whether the book is closing down, used to
+ * help the QOF objects shut down cleanly without maintaining
+ * internal consistency.
+ * XXX shouldn't this be replaced by instance->do_free ???
+ */
+ gboolean shutting_down;
+
+ /* version number, used for tracking multiuser updates */
+ gint32 version;
+
+ /* To be technically correct, backends belong to sessions and
+ * not books. So the pointer below "really shouldn't be here",
+ * except that it provides a nice convenience, avoiding a lookup
+ * from the session. Better solutions welcome ... */
+ QofBackend *backend;
+
+ /* -------------------------------------------------------------- */
+ /* Backend private expansion data */
+ guint32 idata; /* used by the sql backend for kvp management */
+};
+
+typedef struct _QofBookSignal QofBookSignal;
+typedef enum _QofBookSignalType QofBookSignalType;
+
+enum _QofBookSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _QofBookSignal {
+ QofBook *object;
+};
+
+static guint qof_book_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+qof_book_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (QofBookClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)qof_book_class_init,
+ NULL,
+ NULL,
+ sizeof (QofBook),
+ 0,
+ (GInstanceInitFunc)qof_book_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "QofBook", &our_info, 0);
+ }
+
+ return type;
}
static void
-qof_book_init (QofBook *book)
+qof_book_class_init(QofBookClass *klass)
{
- if (!book) return;
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = qof_book_finalize;
+ object_class->set_property = qof_book_set_property;
+ object_class->get_property = qof_book_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+qof_book_init(QofBook *obj)
+{
+ /* Initialize private members, etc. */
+
book->hash_of_collections = g_hash_table_new_full(
- g_str_hash, g_str_equal,
- (GDestroyNotify)qof_util_string_cache_remove, /* key_destroy_func */
+ g_int_hash, g_int_equal, NULL, /* key_destroy_func */
coll_destroy); /* value_destroy_func */
- qof_instance_init (&book->inst, QOF_ID_BOOK, book);
-
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->book_open = 'y';
book->version = 0;
book->idata = 0;
+
}
+static void
+qof_book_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ book->shutting_down = TRUE;
+ qof_event_force (&book->inst.entity, 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_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->hash_of_collections);
+ book->hash_of_collections = NULL;
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+qof_book_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ QofBook *obj;
+
+ obj = QOF_BOOK (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
+qof_book_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ QofBook *obj;
+
+ obj = QOF_BOOK(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+/* ====================================================================== */
+/* constructor / destructor */
+
+static void coll_destroy(gpointer col)
+{
+ qof_collection_destroy((QofCollection *) col);
+}
+
+static void
+qof_book_init (QofBook *book)
+{
+ }
+
QofBook *
qof_book_new (void)
{
QofBook *book;
ENTER (" ");
- book = g_new0(QofBook, 1);
- qof_book_init(book);
+ book = QOF_BOOK (g_object_new (QOF_TYPE_BOOK, NULL));
+
qof_object_book_begin (book);
qof_event_gen (&book->inst.entity, QOF_EVENT_CREATE, NULL);
+
+ g_signal_emit_by_name ( QOF_ENTITY (book), "created");
+
LEAVE ("book=%p", book);
return book;
}
@@ -104,31 +296,7 @@
void
qof_book_destroy (QofBook *book)
{
- if (!book) return;
- ENTER ("book=%p", book);
-
- book->shutting_down = TRUE;
- qof_event_force (&book->inst.entity, QOF_EVENT_DESTROY, NULL);
-
- /* 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);
-
- qof_object_book_end (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;
-
- qof_instance_release (&book->inst);
-
- g_hash_table_destroy (book->hash_of_collections);
- book->hash_of_collections = NULL;
-
- g_free (book);
- LEAVE ("book=%p", book);
+ g_object_unref (G_OBJECT (book));
}
/* ====================================================================== */
@@ -272,22 +440,54 @@
/* ====================================================================== */
QofCollection *
-qof_book_get_collection (const QofBook *book, QofIdType entity_type)
+qof_book_get_collection (const QofBook *book, GType type)
{
QofCollection *col;
- if (!book || !entity_type) return NULL;
+ g_return_val_if_fail (QOF_IS_BOOK (book) || G_TYPE_IS_OBJECT (type), NULL);
- col = g_hash_table_lookup (book->hash_of_collections, entity_type);
- if (!col) {
- col = qof_collection_new (entity_type);
- g_hash_table_insert(
- book->hash_of_collections,
- qof_util_string_cache_insert((gpointer) entity_type), col);
+ col = g_hash_table_lookup (book->hash_of_collections, type);
+
+ if (!QOF_IS_COLLECTION(col)) {
+ col = qof_collection_new (type);
+ g_hash_table_insert(book->hash_of_collections,
+ type, col);
}
return col;
}
+gboolean
+qof_book_remove_element (QofBook *book, QofInstance *inst)
+{
+ QofCollection *coll;
+
+ gboolean res;
+
+ g_return_val_if_fail (QOF_IS_BOOK (book) && QOF_IS_INSTANCE (inst), FALSE);
+
+ coll = qof_book_get_collection (book, G_OBJECT_TYPE (inst));
+
+ res = qof_collection_remove_element (coll, inst);
+
+ return res;
+
+}
+
+gboolean
+qof_book_insert_element (QofBook *book, QofInstance *inst)
+{
+ QofCollection *coll;
+ gboolean res;
+
+ g_return_val_if_fail (QOF_IS_BOOK (book) && QOF_IS_INSTANCE (inst));
+
+ coll = qof_book_get_collection (book, G_OBJECT_TYPE (inst));
+
+ res = qof_collection_add_element (coll, inst);
+
+ return res;
+}
+
struct _iterate {
QofCollectionForeachCB fn;
gpointer data;
@@ -308,7 +508,7 @@
{
struct _iterate iter;
- g_return_if_fail (book);
+ g_return_if_fail (QOF_IS_BOOK (book));
g_return_if_fail (cb);
iter.fn = cb;
@@ -317,6 +517,16 @@
g_hash_table_foreach (book->hash_of_collections, foreach_cb, &iter);
}
+void
+qof_book_foreach (const QofBook *book, GType type, QofInstanceForeachCB cb, gpointer user_data)
+{
+ QofCollection *col;
+
+ col = qof_book_get_collection (book, type);
+
+ qof_collection_foreach (col, cb, user_data);
+}
+
/* ====================================================================== */
void qof_book_mark_closed (QofBook *book)
@@ -325,33 +535,41 @@
book->book_open = 'n';
}
-gchar qof_book_get_open_marker(const QofBook *book)
+gchar qof_book_get_open_marker (const QofBook *book)
{
- if(!book) { return 'n'; }
- return book->book_open;
+ if(!QOF_IS_BOOK(book))
+ return 'n';
+ else
+ return book->book_open;
}
gint32 qof_book_get_version (const QofBook *book)
{
- if(!book) { return -1; }
- return book->version;
+ if(!QOF_IS_BOOK (book))
+ return -1;
+ else
+ return book->version;
}
guint32 qof_book_get_idata (const QofBook *book)
{
- if(!book) { return 0; }
- return book->idata;
+ if(!QOF_IS_BOOK (book))
+ return 0;
+ else
+ return book->idata;
}
void qof_book_set_version (QofBook *book, gint32 version)
{
- if(!book && version < 0) { return; }
+ g_return_if_fail (QOF_IS_BOOK (book) && version < 0);
+
book->version = version;
}
void qof_book_set_idata(QofBook *book, guint32 idata)
{
- if(!book && idata < 0) { return; }
+ g_return_if_fail (QOF_IS_BOOK (book) && idata < 0);
+
book->idata = idata;
}
@@ -363,7 +581,7 @@
KvpValue *value;
gint64 counter;
- if (!book) {
+ if (!QOF_IS_BOOK (book)) {
PWARN ("No book!!!");
return -1;
}
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofbook.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -43,31 +43,47 @@
#include "qofid.h"
#include "kvp_frame.h"
+/* GObject declarations */
+
+#define QOF_TYPE_BOOK (qof_book_get_type ())
+#define QOF_BOOK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook))
+#define QOF_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass))
+#define QOF_IS_BOOK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK))
+#define QOF_IS_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK))
+#define QOF_BOOK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass))
+
+
+typedef struct _QofBookClass QofBookClass;
+typedef struct _QofBookPrivate QofBookPrivate;
+typedef struct _QofBook QofBook;
+
+struct _QofBook {
+ QofInstance inst;
+ QofBookPrivate *priv;
+};
+
+struct _QofBookClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType qof_book_get_type ();
+
+
/** @brief Encapsulates all the information about a dataset
* manipulated by QOF. This is the top-most structure
* used for anchoring data.
*/
-/** Lookup an entity by guid, returning pointer to the entity */
-#define QOF_BOOK_LOOKUP_ENTITY(book,guid,e_type,c_type) ({ \
- QofEntity *val = NULL; \
- if (guid && book) { \
- QofCollection *col; \
- col = qof_book_get_collection (book, e_type); \
- val = qof_collection_lookup_entity (col, guid); \
- } \
- (c_type *) val; \
-})
-
-/** \brief QofBook reference */
-typedef struct _QofBook QofBook;
-
/** GList of QofBook */
typedef GList QofBookList;
typedef void (*QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data);
typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
+
/** Register the book object with the QOF object system. */
gboolean qof_book_register (void);
@@ -99,12 +115,14 @@
* a non-NULL value. (Unless the system malloc failed (out of
* memory) in which case what happens??).
*/
-QofCollection * qof_book_get_collection (const QofBook *, QofIdType);
+QofCollection * qof_book_get_collection (const QofBook *, GType);
/** 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 (const QofBook *book, GType type, QofInstanceForeachCB func, gpointer data);
+
/** 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
@@ -124,17 +142,16 @@
* of the book KVP are persistent (are saved and restored to file
* or database), whereas the data pointers exist only at runtime.
*/
-void qof_book_set_data (QofBook *book, const gchar *key, gpointer data);
+#define qof_book_set_data(book, key, data) g_object_set_data(G_OBJECT (book), key, data)
/** Same as qof_book_set_data(), except that the callback will be called
* when the book is destroyed. The argument to the callback will be
* the book followed by the data pointer.
*/
-void qof_book_set_data_fin (QofBook *book, const gchar *key, gpointer data,
- QofBookFinalCB);
+#define qof_book_set_data_fin(book, key, data, func) g_object_set_data_full(G_OBJECT (book), key, data, func)
/** Retrieves arbitrary pointers to structs stored by qof_book_set_data. */
-gpointer qof_book_get_data (const QofBook *book, const gchar *key);
+#define qof_book_get_data(book, key) g_object_get_data(G_OBJECT (book), key)
/** Is the book shutting down? */
gboolean qof_book_shutting_down (const QofBook *book);
@@ -190,8 +207,15 @@
*/
gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
+
+gboolean qof_book_remove_object (QofBook *book, QofInstance *inst);
+
+gboolean qof_book_insert_object (QofBook *book, QofInstance *inst);
+
+QofInstance qof_book_get_object (QofBook *book, GType type, GUID *guid);
+
/** deprecated */
-#define qof_book_get_guid(X) qof_entity_get_guid (QOF_ENTITY(X))
+#define qof_book_get_guid(X) qof_instance_get_guid (QOF_INSTANCE(X))
#endif /* QOF_BOOK_H */
/** @} */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid-p.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid-p.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -35,11 +35,8 @@
/* This file defines an engine-only API for using QOF entity
* identifiers. */
-/** 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 (QofEntity *ent, const GUID *guid);
+
/** Take entity, remove it from whatever collection its currently
* in, and place it in a new collection. To be used only for
* moving entity from one book to another.
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -33,251 +33,280 @@
static QofLogModule log_module = QOF_MOD_ENGINE;
static gboolean qof_alt_dirty_mode = FALSE;
-struct QofCollection_s
+/* GObject declarations */
+
+static void qof_collection_class_init(QofCollectionClass *klass);
+static void qof_collection_init(QofCollection *sp);
+static void qof_collection_finalize(GObject *object);
+
+struct _QofCollectionPrivate
{
- QofIdType e_type;
+ GType type;
gboolean is_dirty;
GHashTable * hash_of_entities;
- gpointer data; /* place where object class can hang arbitrary data */
};
-/* =============================================================== */
+typedef struct _QofCollectionSignal QofCollectionSignal;
+typedef enum _QofCollectionSignalType QofCollectionSignalType;
-gboolean
-qof_get_alt_dirty_mode (void)
-{
- return qof_alt_dirty_mode;
-}
+enum _QofCollectionSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
-void
-qof_set_alt_dirty_mode (gboolean enabled)
+/* properties */
+enum
{
- qof_alt_dirty_mode = enabled;
-}
+ PROP_0,
+ PROP_TYPE
+};
-/* =============================================================== */
+struct _QofCollectionSignal {
+ QofCollection *object;
+};
-static void qof_collection_remove_entity (QofEntity *ent);
+static guint qof_collection_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
-void
-qof_entity_init (QofEntity *ent, QofIdType type, QofCollection * tab)
+GType
+qof_collection_get_type()
{
- g_return_if_fail (NULL != tab);
-
- /* XXX We passed redundant info to this routine ... but I think that's
- * OK, it might eliminate programming errors. */
- if (safe_strcmp(tab->e_type, type))
- {
- PERR ("attempt to insert \"%s\" into \"%s\"", type, tab->e_type);
- return;
- }
- ent->e_type = CACHE_INSERT (type);
+ static GType type = 0;
- do
- {
- guid_new(&ent->guid);
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (QofCollectionClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)qof_collection_class_init,
+ NULL,
+ NULL,
+ sizeof (QofCollection),
+ 0,
+ (GInstanceInitFunc)qof_collection_init,
+ };
- if (NULL == qof_collection_lookup_entity (tab, &ent->guid)) break;
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "QofCollection", &our_info, 0);
+ }
- PWARN("duplicate id created, trying again");
- } while(1);
-
- ent->collection = tab;
+ return type;
+}
- qof_collection_insert_entity (tab, ent);
+static void
+qof_collection_class_init(QofCollectionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = qof_collection_finalize;
+ object_class->set_property = qof_collection_set_property;
+ object_class->get_property = qof_collection_get_property;
+
+ /* 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_READABLE | G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY)));
+ /* Create signals here:*/
+
}
-void
-qof_entity_release (QofEntity *ent)
+static void
+qof_collection_init(QofCollection *obj)
{
- if (!ent->collection) return;
- qof_collection_remove_entity (ent);
- CACHE_REMOVE (ent->e_type);
- ent->e_type = NULL;
+ /* Initialize private members, etc. */
+ col->priv = g_new0 (QofCollectionPrivate, 1);
+
+ col->priv->type = G_TYPE_INVALID;
+ col->priv->hash_of_entities = g_hash_table_new (id_hash, id_compare);
}
-
-/* This is a restricted function, should be used only during
- * read from file */
-void
-qof_entity_set_guid (QofEntity *ent, const GUID *guid)
+static void
+qof_collection_finalize(GObject *object)
{
- QofCollection *col;
- if (guid_equal (guid, &ent->guid)) return;
+
+ /* Free private members, etc. */
- col = ent->collection;
- qof_collection_remove_entity (ent);
- ent->guid = *guid;
- qof_collection_insert_entity (col, ent);
+ g_hash_table_destroy(col->hash_of_entities);
+ col->type = G_TYPE_INVALID;
+ col->hash_of_entities = NULL;
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
}
-const GUID *
-qof_entity_get_guid (const QofEntity *ent)
+static void
+qof_collection_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- if (!ent) return guid_null();
- return &ent->guid;
+ 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));
+ break;
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
}
-/* =============================================================== */
-
-static guint
-id_hash (gconstpointer key)
+static void
+qof_collection_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- const GUID *guid = key;
+ QofCollection *obj;
+
+ obj = QOF_COLLECTION(object);
- if (key == NULL)
- return 0;
-
- /* Compiler should optimize this all away! */
- if (sizeof(guint) <= 16)
- return *((guint *) guid->data);
- else
- {
- guint hash = 0;
- unsigned int i, j;
-
- for (i = 0, j = 0; i < sizeof(guint); i++, j++)
- {
- if (j == 16)
- j = 0;
-
- hash <<= 4;
- hash |= guid->data[j];
- }
-
- return hash;
+ switch (property_id) {
+ case PROP_TYPE:
+ g_value_set_int (value, obj->priv->type);
+ break;
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
}
}
-static gboolean
-id_compare(gconstpointer key_1, gconstpointer key_2)
-{
- return guid_equal (key_1, key_2);
-}
+static guint id_hash (gconstpointer key);
+static gboolean id_compare(gconstpointer key_1, gconstpointer key_2);
QofCollection *
-qof_collection_new (QofIdType type)
+qof_collection_new (GType type)
{
QofCollection *col;
- col = g_new0(QofCollection, 1);
- col->e_type = CACHE_INSERT (type);
- col->hash_of_entities = g_hash_table_new (id_hash, id_compare);
- col->data = NULL;
+
+ g_return_val_if_fail (G_TYPE_IS_OBJECT (type));
+
+ col = QOF_COLLECTION (g_object_new (QOF_TYPE_COLLECTION, "type", type));
+
return col;
}
void
qof_collection_destroy (QofCollection *col)
{
- CACHE_REMOVE (col->e_type);
- g_hash_table_destroy(col->hash_of_entities);
- col->e_type = NULL;
- col->hash_of_entities = NULL;
- col->data = NULL; /** XXX there should be a destroy notifier for this */
- g_free (col);
+ g_return_if_fail (QOF_IS_COLLECTION (col));
+
+ g_object_unref (col);
}
-/* =============================================================== */
-/* getters */
-
-QofIdType
-qof_collection_get_type (const QofCollection *col)
+const GType
+qof_collection_get_g_type (const QofInstance *entity)
{
- return col->e_type;
+ return collection->priv->type;
}
-/* =============================================================== */
-static void
-qof_collection_remove_entity (QofEntity *ent)
-{
- QofCollection *col;
- if (!ent) return;
- col = ent->collection;
- if (!col) return;
- g_hash_table_remove (col->hash_of_entities, &ent->guid);
- if (!qof_alt_dirty_mode)
- qof_collection_mark_dirty(col);
- ent->collection = NULL;
-}
-
void
-qof_collection_insert_entity (QofCollection *col, QofEntity *ent)
+qof_collection_remove_element (QofCollection *coll, QofInstance *inst)
{
- if (!col || !ent) return;
- if (guid_equal(&ent->guid, guid_null())) return;
- g_return_if_fail (col->e_type == ent->e_type);
- qof_collection_remove_entity (ent);
- g_hash_table_insert (col->hash_of_entities, &ent->guid, ent);
+ QofInstance *obj;
+
+ g_return_if_fail (QOF_IS_COLLECTION (coll) && QOF_IS_INSTANCE (inst));
+
+ obj = qof_collection_get_element (coll, qof_collection_get_guid (inst));
+
+ g_return_if_fail (QOF_IS_INSTANCE (col));
+
+ g_hash_table_remove (col->priv->hash_of_entities, qof_instance_get_guid (inst));
+
if (!qof_alt_dirty_mode)
- qof_collection_mark_dirty(col);
- ent->collection = col;
+ qof_collection_mark_dirty (col);
}
+
gboolean
-qof_collection_add_entity (QofCollection *coll, QofEntity *ent)
+qof_collection_add_element (QofCollection *coll, QofInstance *inst)
{
- QofEntity *e;
-
- e = NULL;
- if (!coll || !ent) { return FALSE; }
- if (guid_equal(&ent->guid, guid_null())) { return FALSE; }
- g_return_val_if_fail (coll->e_type == ent->e_type, FALSE);
- e = qof_collection_lookup_entity(coll, &ent->guid);
- if ( e != NULL ) { return FALSE; }
- g_hash_table_insert (coll->hash_of_entities, &ent->guid, ent);
+
+ g_return_val_if_fail ( coll != NULL &&
+ !guid_equal(qof_instance_get_guid (inst), guid_null()) &&
+ qof_collection_lookup_element (coll, qof_instance_get_guid (inst)) == NULL &&
+ QOF_IS_INSTANCE (inst),
+ FALSE);
+
+ g_hash_table_insert (coll->hash_of_entities, qof_instance_get_guid (inst), inst);
+
if (!qof_alt_dirty_mode)
qof_collection_mark_dirty(coll);
+
return TRUE;
}
static void
-collection_merge_cb (QofEntity *ent, gpointer data)
+collection_merge_cb (QofInstance *ent, gpointer data)
{
QofCollection *target;
target = (QofCollection*)data;
- qof_collection_add_entity(target, ent);
+
+ qof_collection_add_element (target, ent);
}
gboolean
qof_collection_merge (QofCollection *target, QofCollection *merge)
{
- if(!target || !merge) { return FALSE; }
- g_return_val_if_fail (target->e_type == merge->e_type, FALSE);
+ g_return_val_if_fail ( QOF_IS_COLLECTION (target) && QOF_IS_COLLECTION (merge), FALSE);
+
+ g_return_val_if_fail (target->priv->type == merge->priv->type, FALSE);
+
qof_collection_foreach(merge, collection_merge_cb, target);
+
return TRUE;
}
static void
-collection_compare_cb (QofEntity *ent, gpointer user_data)
+collection_compare_cb (QofInstance *inst, gpointer user_data)
{
QofCollection *target;
- QofEntity *e;
+ QofInstance *e;
gint value;
-
+
+ g_return_if_fail (QOF_IS_INSTANCE (inst) && QOF_IS_COLLECTION (QOF_COLLECTION (user_data)));
+
e = NULL;
- target = (QofCollection*)user_data;
- if (!target || !ent) { return; }
- value = *(gint*)qof_collection_get_data(target);
+
+ target = QOF_COLLECTION (user_data);
+
+ value = *(gint*) g_object_get_data (G_OBJECT (target), "value");
+
if (value != 0) { return; }
- if (guid_equal(&ent->guid, guid_null()))
+ if (guid_equal(qof_instance_get_guid (inst), guid_null()))
{
value = -1;
- qof_collection_set_data(target, &value);
+ g_object_set_data (G_OBJECT (target), "value", &value);
return;
}
- g_return_if_fail (target->e_type == ent->e_type);
- e = qof_collection_lookup_entity(target, &ent->guid);
+
+ g_return_if_fail (target->type == G_OBJECT_TYPE (inst));
+
+ e = qof_collection_lookup_element (target, qof_instance_get_guid (inst));
+
if ( e == NULL )
{
value = 1;
- qof_collection_set_data(target, &value);
+ g_object_set_data (G_OBJECT (target), "value", &value);
return;
}
- value = 0;
- qof_collection_set_data(target, &value);
+ else
+ {
+ value = 0;
+ g_object_set_data (G_OBJECT (target), "value", &value);
+ return;
+ }
}
gint
@@ -290,40 +319,49 @@
if (target == merge) { return 0; }
if (!target && merge) { return -1; }
if (target && !merge) { return 1; }
- if(target->e_type != merge->e_type) { return -1; }
- qof_collection_set_data(target, &value);
+ if(target->priv->type != merge->priv->type) { return -1; }
+
+ g_object_set_data (G_OBJECT (target), "value", &value);
+
qof_collection_foreach(merge, collection_compare_cb, target);
- value = *(gint*)qof_collection_get_data(target);
+
+ value = *(gint*) g_object_get_data(G_OBJECT (target), "value");
+
if(value == 0) {
- qof_collection_set_data(merge, &value);
+ g_object_set_data (G_OBJECT (merge), "value", &value);
qof_collection_foreach(target, collection_compare_cb, merge);
- value = *(gint*)qof_collection_get_data(merge);
+ value = *(gint*) g_object_get_data(G_OBJECT (merge), "value");
}
return value;
}
-QofEntity *
-qof_collection_lookup_entity (const QofCollection *col, const GUID * guid)
+QofInstance *
+qof_collection_lookup_element (const QofCollection *col, const GUID * guid)
{
- QofEntity *ent;
- g_return_val_if_fail (col, NULL);
+ QofInstance *inst;
+
+ g_return_val_if_fail (QOF_IS_COLLECTION(col) && !guid_equal (guid, guid_null()), NULL);
+
if (guid == NULL) return NULL;
- ent = g_hash_table_lookup (col->hash_of_entities, guid);
+
+ ent = g_hash_table_lookup (col->priv->hash_of_entities, guid);
+
return ent;
}
QofCollection *
-qof_collection_from_glist (QofIdType type, GList *glist)
+qof_collection_from_glist (QofBook *book, GType type, GList *glist)
{
QofCollection *coll;
- QofEntity *ent;
+ QofInstance *ent;
GList *list;
- coll = qof_collection_new(type);
+ coll = qof_collection_new (book, type);
+
for(list = glist; list != NULL; list = list->next)
{
- ent = (QofEntity*)list->data;
- if(FALSE == qof_collection_add_entity(coll, ent))
+ ent = (QofInstance*)list->data;
+ if(FALSE == qof_collection_add_element (coll, ent))
{
return NULL;
}
@@ -336,80 +374,121 @@
{
guint c;
- c = g_hash_table_size(col->hash_of_entities);
+ c = g_hash_table_size (col->priv->hash_of_entities);
return c;
}
/* =============================================================== */
+static guint
+id_hash (gconstpointer key)
+{
+ const GUID *guid = key;
+
+ if (key == NULL)
+ return 0;
+
+ /* Compiler should optimize this all away! */
+ if (sizeof(guint) <= 16)
+ return *((guint *) guid->data);
+ else
+ {
+ guint hash = 0;
+ unsigned int i, j;
+
+ for (i = 0, j = 0; i < sizeof(guint); i++, j++)
+ {
+ if (j == 16)
+ j = 0;
+
+ hash <<= 4;
+ hash |= guid->data[j];
+ }
+
+ return hash;
+ }
+}
+
+static gboolean
+id_compare(gconstpointer key_1, gconstpointer key_2)
+{
+ return guid_equal (key_1, key_2);
+}
+
+
+/* =============================================================== */
+
gboolean
qof_collection_is_dirty (const QofCollection *col)
{
- return col ? col->is_dirty : FALSE;
+ return col ? col->priv->is_dirty : FALSE;
}
void
qof_collection_mark_clean (QofCollection *col)
{
- if (col) { col->is_dirty = FALSE; }
+ if (col) { col->priv->is_dirty = FALSE; }
}
void
qof_collection_mark_dirty (QofCollection *col)
{
- if (col) { col->is_dirty = TRUE; }
+ if (col) {
+ col->priv->is_dirty = TRUE;
+ qof_collection_mark_dirty (col->priv->book);
+ }
}
void
qof_collection_print_dirty (const QofCollection *col, gpointer dummy)
{
- if (col->is_dirty)
- printf("%s collection is dirty.\n", col->e_type);
- qof_collection_foreach(col, (QofEntityForeachCB)qof_instance_print_dirty, NULL);
+ if (col->priv->is_dirty)
+ printf("%s collection is dirty.\n", col->priv->e_type);
+ qof_collection_foreach(col, (QofInstanceForeachCB)qof_instance_print_dirty, NULL);
}
/* =============================================================== */
-gpointer
-qof_collection_get_data (const QofCollection *col)
-{
- return col ? col->data : NULL;
-}
-
-void
-qof_collection_set_data (QofCollection *col, gpointer user_data)
-{
- if (col) { col->data = user_data; }
-}
-
-/* =============================================================== */
-
struct _iterate {
- QofEntityForeachCB fcn;
+ QofInstanceForeachCB fcn;
gpointer data;
};
static void foreach_cb (gpointer key, gpointer item, gpointer arg)
{
struct _iterate *iter = arg;
- QofEntity *ent = item;
+ QofInstance *ent = item;
iter->fcn (ent, iter->data);
}
void
-qof_collection_foreach (const QofCollection *col, QofEntityForeachCB cb_func,
+qof_collection_foreach (const QofCollection *col, QofInstanceForeachCB cb_func,
gpointer user_data)
{
struct _iterate iter;
- g_return_if_fail (col);
+ g_return_if_fail (QOF_IS_COLLECTION (col));
g_return_if_fail (cb_func);
iter.fcn = cb_func;
iter.data = user_data;
- g_hash_table_foreach (col->hash_of_entities, foreach_cb, &iter);
+ g_hash_table_foreach (col->priv->hash_of_entities, foreach_cb, &iter);
}
/* =============================================================== */
+
+gboolean
+qof_get_alt_dirty_mode (void)
+{
+ return qof_alt_dirty_mode;
+}
+
+void
+qof_set_alt_dirty_mode (gboolean enabled)
+{
+ qof_alt_dirty_mode = enabled;
+}
+
+/* =============================================================== */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofid.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -71,120 +71,53 @@
@brief QOF entity type identification system
@author Copyright (C) 2000 Dave Peticolas <peticola at cs.ucdavis.edu>
@author Copyright (C) 2003 Linas Vepstas <linas at linas.org>
+ @author Copyright (C) 2007 Daniel Espinosa <esodan at gmail.com>
*/
#include <string.h>
+#include <glib-object.h>
#include "guid.h"
-/** QofIdType declaration */
-typedef const gchar * QofIdType;
-/** QofIdTypeConst declaration */
-typedef const gchar * QofIdTypeConst;
-/** QofLogModule declaration */
-typedef const gchar* QofLogModule;
-#define QOF_ID_NONE NULL
-#define QOF_ID_NULL "null"
+/******************* QofCollection ****************/
-#define QOF_ID_BOOK "Book"
-#define QOF_ID_SESSION "Session"
-/** simple,cheesy cast but holds water for now */
-#define QOF_ENTITY(object) ((QofEntity *)(object))
+/** QofLogModule declaration */
+typedef const gchar* QofLogModule;
-/** Inline string comparision; compiler will optimize away most of this */
-#define QSTRCMP(da,db) ({ \
- gint val = 0; \
- if ((da) && (db)) { \
- if ((da) != (db)) { \
- val = strcmp ((da), (db)); \
- } \
- } else \
- if ((!(da)) && (db)) { \
- val = -1; \
- } else \
- if ((da) && (!(db))) { \
- val = 1; \
- } \
- val; /* block assumes value of last statement */ \
-})
+/* GObject declarations */
-/** return TRUE if object is of the given type */
-#define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
- (0 == QSTRCMP((type),(((QofEntity *)(obj))->e_type))))
+#define QOF_TYPE_COLLECTION (qof_collection_get_type ())
+#define QOF_COLLECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_COLLECTION, QofCollection))
+#define QOF_COLLECTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_COLLECTION, QofCollectionClass))
+#define QOF_IS_COLLECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_COLLECTION))
+#define QOF_IS_COLLECTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_COLLECTION))
+#define QOF_COLLECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_COLLECTION, QofCollectionClass))
-/** cast object to the indicated type,
-print error message if its bad */
-#define QOF_CHECK_CAST(obj,e_type,c_type) ( \
- QOF_CHECK_TYPE((obj),(e_type)) ? \
- (c_type *) (obj) : \
- (c_type *) ({ \
- g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
- "Error: Bad QofEntity at %s:%d", __FILE__, __LINE__); \
- (obj); \
- }))
+typedef struct _QofCollectionClass QofCollectionClass;
+typedef struct _QofCollectionPrivate QofCollectionPrivate;
+typedef struct _QofCollection QofCollection;
-/** QofEntity declaration */
-typedef struct QofEntity_s QofEntity;
-/** QofCollection declaration
-
- at param e_type QofIdType
- at param is_dirty gboolean
- at param hash_of_entities GHashTable
- at param data gpointer, place where object class can hang arbitrary data
-
-*/
-typedef struct QofCollection_s QofCollection;
-
-/** QofEntity structure
-
- at param e_type Entity type
- at param guid GUID for the entity
- at param collection Entity collection
-*/
-
-struct QofEntity_s
+struct _QofCollection
{
- QofIdType e_type;
- GUID guid;
- QofCollection * collection;
+ /* GObject Parent */
+ GObject parent;
+ QofCollectionPrivate *priv;
};
-/** @name QOF Entity Initialization & Shutdown
- @{ */
-/** Initialise the memory associated with an entity */
-void qof_entity_init (QofEntity *, QofIdType, QofCollection *);
-
-/** Release the data associated with this entity. Dont actually free
- * the memory associated with the instance. */
-void qof_entity_release (QofEntity *);
-/** @} */
-/** Is QOF operating in "alternate" dirty mode. In normal mode,
- * whenever an instance is dirtied, the collection (and therefore the
- * book) is immediately marked as dirty. In alternate mode, the
- * collection is only marked dirty when a dirty instance is
- * committed. If a dirty instance is freed instead of committed, the
- * dirty state of collection (and therefore the book) is never
- * changed. */
-gboolean qof_get_alt_dirty_mode (void);
+struct _QofCollectionClass {
+ GObjectClass parent_class;
+ /* virtual table */
-/** Set QOF into "alternate" dirty mode. In normal mode, whenever an
- * instance is dirtied, the collection (and therefore the book) is
- * immediately marked as dirty. In alternate mode, the collection is
- * only marked dirty when a dirty instance is committed. If a dirty
- * instance is freed instead of committed, the dirty state of
- * collection (and therefore the book) is never changed. */
-void qof_set_alt_dirty_mode (gboolean enabled);
+ /* Add Signal Functions Here */
+};
-/** Return the GUID of this entity */
-const GUID * qof_entity_get_guid (const QofEntity *);
-/** @name Collections of Entities
- @{ */
+GType qof_entity_get_type ();
/** create a new collection of entities of type */
-QofCollection * qof_collection_new (QofIdType type);
+QofCollection * qof_collection_new (GType type);
/** return the number of entities in the collection. */
guint qof_collection_count (const QofCollection *col);
@@ -193,14 +126,11 @@
void qof_collection_destroy (QofCollection *col);
/** return the type that the collection stores */
-QofIdType qof_collection_get_type (const QofCollection *);
+GType qof_collection_get_g_type (const QofCollection *);
/** Find the entity going only from its guid */
-QofEntity * qof_collection_lookup_entity (const QofCollection *, const GUID *);
+QofInstance * qof_collection_lookup_element (const QofCollection *, const GUID *);
-/** Callback type for qof_entity_foreach */
-typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
-
/** Call the callback for each entity in the collection. */
void qof_collection_foreach (const QofCollection *, QofEntityForeachCB,
gpointer user_data);
@@ -238,8 +168,11 @@
*/
gboolean
-qof_collection_add_entity (QofCollection *coll, QofEntity *ent);
+qof_collection_add_element (QofCollection *coll, QofInstance *inst);
+gboolean
+qof_collection_remove_element (QofCollection *coll, QofInstance *ent);
+
/** \brief Merge two QOF_TYPE_COLLECT of the same type.
\note \b NOT the same as the main collections in the book.
@@ -280,6 +213,26 @@
QofCollection*
qof_collection_from_glist (QofIdType type, GList *glist);
+/******************************************************/
+
+/** Is QOF operating in "alternate" dirty mode. In normal mode,
+ * whenever an instance is dirtied, the collection (and therefore the
+ * book) is immediately marked as dirty. In alternate mode, the
+ * collection is only marked dirty when a dirty instance is
+ * committed. If a dirty instance is freed instead of committed, the
+ * dirty state of collection (and therefore the book) is never
+ * changed. */
+gboolean qof_get_alt_dirty_mode (void);
+
+/** Set QOF into "alternate" dirty mode. In normal mode, whenever an
+ * instance is dirtied, the collection (and therefore the book) is
+ * immediately marked as dirty. In alternate mode, the collection is
+ * only marked dirty when a dirty instance is committed. If a dirty
+ * instance is freed instead of committed, the dirty state of
+ * collection (and therefore the book) is never changed. */
+void qof_set_alt_dirty_mode (gboolean enabled);
+
+
/** @} */
/** @} */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance-p.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance-p.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -37,43 +37,8 @@
* eventually, it may hold more fields, such as refrence counting...
*
*/
-struct QofInstance_s
-{
- /* Globally unique id identifying this instance */
- QofEntity entity;
- /* The entity_table in which this instance is stored */
- QofBook * book;
- /* kvp_data is a key-value pair database for storing arbirtary
- * information associated with this instance.
- * See src/engine/kvp_doc.txt for a list and description of the
- * important keys. */
- KvpFrame *kvp_data;
-
- /* Timestamp used to track the last modification to this
- * instance. Typically used to compare two versions of the
- * same object, to see which is newer. When used with the
- * SQL backend, this field is reserved for SQL use, to compare
- * the version in local memory to the remote, server version.
- */
- Timespec last_update;
-
- /* Keep track of nesting level of begin/end edit calls */
- int editlevel;
-
- /* In process of being destroyed */
- gboolean do_free;
-
- /* dirty/clean flag. If dirty, then this instance has been modified,
- * but has not yet been written out to storage (file/database)
- */
- gboolean dirty;
-
- /* True iff this instance has never been committed. */
- gboolean infant;
-};
-
/* reset the dirty flag */
void qof_instance_mark_clean (QofInstance *);
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -37,66 +37,301 @@
static QofLogModule log_module = QOF_MOD_ENGINE;
+/* GObject declarations */
+
+static void qof_instance_class_init(QofInstanceClass *klass);
+static void qof_instance_init(QofInstance *sp);
+static void qof_instance_finalize(GObject *object);
+
+struct _QofInstancePrivate
+{
+
+ /* The entity_table in which this instance is stored */
+ QofBook * book;
+
+ /* kvp_data is a key-value pair database for storing arbirtary
+ * information associated with this instance.
+ * See src/engine/kvp_doc.txt for a list and description of the
+ * important keys. */
+ KvpFrame *kvp_data;
+
+ /* Timestamp used to track the last modification to this
+ * instance. Typically used to compare two versions of the
+ * same object, to see which is newer. When used with the
+ * SQL backend, this field is reserved for SQL use, to compare
+ * the version in local memory to the remote, server version.
+ */
+ Timespec last_update;
+
+ /* Keep track of nesting level of begin/end edit calls */
+ gint editlevel;
+
+ /* In process of being destroyed */
+ gboolean do_free;
+
+ /* dirty/clean flag. If dirty, then this instance has been modified,
+ * but has not yet been written out to storage (file/database)
+ */
+ gboolean dirty;
+
+ /* True iff this instance has never been committed. */
+ gboolean infant;
+
+ /* Unique identifier for this object */
+ GUID *guid;
+};
+
+typedef struct _QofInstanceSignal QofInstanceSignal;
+typedef enum _QofInstanceSignalType QofInstanceSignalType;
+
+enum _QofInstanceSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0,
+ PROP_BOOK
+};
+
+struct _QofInstanceSignal {
+ QofInstance *object;
+};
+
+static guint qof_instance_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+qof_instance_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (QofInstanceClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)qof_instance_class_init,
+ NULL,
+ NULL,
+ sizeof (QofInstance),
+ 0,
+ (GInstanceInitFunc)qof_instance_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_ENTITY,
+ "QofInstance", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+qof_instance_class_init(QofInstanceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = qof_instance_finalize;
+ object_class->set_property = qof_instance_set_property;
+ object_class->get_property = qof_instance_get_property;
+
+ /* Install properties */
+ g_object_class_install_property (object_class, PROP_BOOK,
+ g_param_spec_object ("book", _("Book"), NULL,
+ QOF_TYPE_BOOK,
+ (G_PARAM_READABLE | G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY)));
+
+ /* Create signals here:*/
+
+}
+
+static void
+qof_instance_init(QofInstance *obj)
+{
+ /* Initialize private members, etc. */
+ inst->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;
+}
+
+static void
+qof_instance_finalize(GObject *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));
+
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+qof_instance_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ QofInstance *obj;
+
+ obj = QOF_INSTANCE (object);
+
+ switch (param_id) {
+ case PROP_BOOK:
+ obj->priv->book = qof_instance_set_book (obj, 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);
+ break;
+ }
+}
+
+static void
+qof_instance_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ QofInstance *obj;
+
+ obj = QOF_INSTANCE(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARNinst->priv = g_new0 (QofInstancePrivate, 1);
+ break;
+ }
+}
+
+
+
+
/* ========================================================== */
+void
+qof_instance_set_book (QofInstance *instance, 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_INSTANCE (qof_book_get_element (inst->book, G_OBJECT_TYPE (instance), ent->priv->guid)))
+ {
+ qof_collection_remove_element (qof_book_get_collection (ent->priv->book,
+ G_OBJECT_TYPE (instance)),
+ instance);
+ }
+ inst->priv->book = book;
+ }
+ else
+ {
+ inst->priv->book = book;
+ }
+
+ if (inst->priv->guid == NULL )
+ {
+ GUID *guid;
+
+ guid = NULL;
+
+ do
+ {
+ guid_new (guid);
+
+ if (NULL == qof_book_get_element (instance->priv->book, G_OBJECT_TYPE (instance), guid)) break;
+
+ PWARN("duplicate id created, trying again");
+ } while(1);
+
+ inst->priv->guid = guid;
+ }
+
+ qof_book_insert_element (instance->priv->book, instance);
+}
+
+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)
+{
+ if (guid_equal (guid, inst->priv->guid)) return;
+
+ qof_book_remove_element (inst->priv->book, inst);
+ inst->priv->guid = guid;
+ qof_book_insert_element (inst->priv->book, inst);
+}
+
+
QofInstance*
qof_instance_create (QofIdType type, QofBook *book)
{
QofInstance *inst;
- inst = g_new0(QofInstance, 1);
- qof_instance_init(inst, type, book);
+ inst = QOF_INSTANCE (g_object_new (QOF_TYPE_INSTANCE, "book", book, NULL));
+
return inst;
}
+
void
qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
{
- QofCollection *col;
-
- inst->book = book;
- inst->kvp_data = kvp_frame_new();
- inst->last_update.tv_sec = 0;
- inst->last_update.tv_nsec = -1;
- inst->editlevel = 0;
- inst->do_free = FALSE;
- inst->dirty = FALSE;
- inst->infant = TRUE;
-
- col = qof_book_get_collection (book, type);
- qof_entity_init (&inst->entity, type, col);
+
}
void
qof_instance_release (QofInstance *inst)
{
- kvp_frame_delete (inst->kvp_data);
- inst->kvp_data = NULL;
- inst->editlevel = 0;
- inst->do_free = FALSE;
- inst->dirty = FALSE;
- qof_entity_release (&inst->entity);
+
}
const GUID *
qof_instance_get_guid (const QofInstance *inst)
{
- if (!inst) return NULL;
- return &inst->entity.guid;
+ g_return_value_if_fail (QOF_IS_INSTANCE(inst), NULL);
+
+ return inst->priv->guid;
}
QofBook *
qof_instance_get_book (const QofInstance *inst)
{
if (!inst) return NULL;
- return inst->book;
+ return inst->priv->book;
}
KvpFrame*
qof_instance_get_slots (const QofInstance *inst)
{
if (!inst) return NULL;
- return inst->kvp_data;
+ return inst->priv->kvp_data;
}
Timespec
@@ -107,7 +342,7 @@
Timespec ts = {0,-1};
return ts;
}
- return inst->last_update;
+ return inst->priv->last_update;
}
int
@@ -128,9 +363,9 @@
{
QofInstance *inst = QOF_INSTANCE(entity);
- if (inst->dirty)
- printf("%s instance %s is dirty.\n", inst->entity.e_type,
- guid_to_string(&inst->entity.guid));
+ 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)))));
}
gboolean
@@ -140,42 +375,45 @@
if (!inst) { return FALSE; }
if (qof_get_alt_dirty_mode())
- return inst->dirty;
- coll = inst->entity.collection;
- if(qof_collection_is_dirty(coll)) { return inst->dirty; }
- inst->dirty = FALSE;
+ return inst->priv->dirty;
+ coll = qof_entity_get_collection (QOF_ENTITY (inst));
+ if(qof_collection_is_dirty(coll)) { return inst->priv->dirty; }
+ inst->priv->dirty = FALSE;
return FALSE;
}
void
-qof_instance_set_dirty(QofInstance* inst)
+qof_instance_set_dirty(QofInstance* inst, gboolean value)
{
QofCollection *coll;
- inst->dirty = TRUE;
- if (!qof_get_alt_dirty_mode()) {
- coll = inst->entity.collection;
- qof_collection_mark_dirty(coll);
+ if (value) {
+ inst->priv->dirty = TRUE;
+ if (!qof_get_alt_dirty_mode()) {
+ coll = qof_entity_get_collection (QOF_ENTITY (inst));
+ qof_collection_mark_dirty(coll);
+ }
}
+ inst->priv->dirty = FALSE;
}
gboolean
qof_instance_check_edit(const QofInstance *inst)
{
- if(inst->editlevel > 0) { return TRUE; }
+ if(inst->priv->editlevel > 0) { return TRUE; }
return FALSE;
}
gboolean
qof_instance_do_free(const QofInstance *inst)
{
- return inst->do_free;
+ return inst->priv->do_free;
}
void
qof_instance_mark_free(QofInstance *inst)
{
- inst->do_free = TRUE;
+ inst->priv->do_free = TRUE;
}
/* ========================================================== */
@@ -185,27 +423,27 @@
qof_instance_mark_clean (QofInstance *inst)
{
if(!inst) return;
- inst->dirty = FALSE;
+ inst->priv->dirty = FALSE;
}
void
qof_instance_set_slots (QofInstance *inst, KvpFrame *frm)
{
if (!inst) return;
- if (inst->kvp_data && (inst->kvp_data != frm))
+ if (inst->priv->kvp_data && (inst->priv->kvp_data != frm))
{
- kvp_frame_delete(inst->kvp_data);
+ kvp_frame_delete(inst->priv->kvp_data);
}
- inst->dirty = TRUE;
- inst->kvp_data = frm;
+ inst->priv->dirty = TRUE;
+ inst->priv->kvp_data = frm;
}
void
qof_instance_set_last_update (QofInstance *inst, Timespec ts)
{
if (!inst) return;
- inst->last_update = ts;
+ inst->priv->last_update = ts;
}
/* ========================================================== */
@@ -256,4 +494,29 @@
return twin;
}
+/* Gets the KvpFrame kvp data value stored in the instance */
+
+KvpFrame*
+qof_instance_get_kvp_data (const QofInstance *instance)
+{
+ return instance->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);
+}
+
+/* Gets the Instance's Edit Level*/
+gint qof_instance_get_edit_level (const QofInstance *instance)
+{
+ return instance->editlevel;
+}
+
+void qof_instance_set_edit_level (QofInstance *instance, gint editlevel)
+{
+ instance->editlevel = editlevel;
+}
/* ========================== END OF FILE ======================= */
Modified: gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h
===================================================================
--- gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/lib/libqof/qof/qofinstance.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -42,26 +42,48 @@
#include "qofbook.h"
#include "qofid.h"
-/* --- type macros --- */
-/* cheesy, but will do for now, eventually should be more gtk-like, handle
- * thunks, etc. */
-#define QOF_INSTANCE(object) ((QofInstance *)(object))
+/* GObject declarations */
-typedef struct QofInstance_s QofInstance;
+#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))
-/** Initialise the memory associated with an instance */
-void qof_instance_init (QofInstance *, QofIdType, QofBook *);
-/** release the data associated with this instance. Dont actually free
- * the memory associated with the instance. */
-void qof_instance_release (QofInstance *inst);
+typedef struct _QofInstanceClass QofInstanceClass;
+typedef struct _QofInstancePrivate QofInstancePrivate;
+typedef struct _QofInstance QofInstance;
+struct _QofInstance {
+ GObject object;
+ QofInstancePrivate *priv;
+};
+
+struct _QofInstanceClass {
+ GObjectClass parent_class;
+ /* virtual table */
+ void (*foreach) (const QofCollection *, QofEntityForeachCB, gpointer);
+ const char * (*printable) (gpointer instance);
+ /* Add Signal Functions Here */
+};
+
+GType qof_instance_get_type ();
+
/** Return the book pointer */
QofBook * qof_instance_get_book (const QofInstance *);
+QofCollection* qof_instance_get_collection (QofInstance *entity);
+
/** Return the GUID of this instance */
const GUID * qof_instance_get_guid (const QofInstance *);
+/** 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);
+
/** Return the pointer to the kvp_data */
KvpFrame* qof_instance_get_slots (const QofInstance *);
@@ -90,7 +112,7 @@
Sets this instance AND the collection as dirty.
*/
-void qof_instance_set_dirty(QofInstance* inst);
+void qof_instance_set_dirty(QofInstance* inst, gboolean value);
gboolean qof_instance_check_edit(const QofInstance *inst);
@@ -127,6 +149,24 @@
*/
QofInstance * qof_instance_lookup_twin (const QofInstance *src, QofBook *book);
+KvpFrame* qof_instance_get_kvp_data (const QofInstance *instance);
+void qof_instance_set_kvp_data (QofInstance *instance, KvpFrame *data);
+
+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)
+
+/** Callback type for qof_instance_foreach */
+typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
+
+#define qof_object_foreach (type, book, cb, data) qof_book_foreach_collection (book, type, cb, data)
+
+
+const char * (*printable) (gpointer instance);
+int (*version_cmp) (gpointer instance_left, gpointer instance_right);
+
+
/* @} */
/* @} */
#endif /* QOF_INSTANCE_H */
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncAddress.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncAddress.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncAddress.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -33,10 +33,14 @@
#include "gncAddressP.h"
#include "gncCustomerP.h"
-struct _gncAddress
+/* GObject declarations */
+
+static void gnc_address_class_init(GncAddressClass *klass);
+static void gnc_address_init(GncAddress *sp);
+static void gnc_address_finalize(GObject *object);
+
+struct _GncAddressPrivate
{
- QofInstance inst;
-
QofBook * book;
QofEntity * parent;
gboolean dirty;
@@ -50,6 +54,119 @@
char * email;
};
+typedef struct _GncAddressSignal GncAddressSignal;
+typedef enum _GncAddressSignalType GncAddressSignalType;
+
+enum _GncAddressSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncAddressSignal {
+ GncAddress *object;
+};
+
+static guint gnc_address_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_address_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncAddressClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_address_class_init,
+ NULL,
+ NULL,
+ sizeof (GncAddress),
+ 0,
+ (GInstanceInitFunc)gnc_address_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncAddress", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_address_class_init(GncAddressClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_address_finalize;
+ object_class->set_property = gnc_address_set_property;
+ object_class->get_property = gnc_address_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_address_init(GncAddress *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_address_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_address_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncAddress *obj;
+
+ obj = GNC_ADDRESS (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_address_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncAddress *obj;
+
+ obj = GNC_ADDRESS (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
static QofLogModule log_module = GNC_MOD_BUSINESS;
#define _GNC_MOD_NAME GNC_ADDRESS_MODULE_NAME
@@ -71,20 +188,22 @@
if (!book) return NULL;
- addr = g_new0 (GncAddress, 1);
- qof_instance_init(&addr->inst, GNC_ID_ADDRESS, book);
- addr->book = book;
- addr->dirty = FALSE;
- addr->parent = prnt;
+ addr = GNC_ADDRESS (g_object_new (GNC_TYPE_ADDRESS, NULL));
+ addr->priv = g_new0 (GncAddressPrivate, 1);
+
+ qof_instance_init(QOF_INSTANCE (addr), GNC_ID_ADDRESS, book);
+ addr->priv->book = book;
+ addr->priv->dirty = FALSE;
+ addr->priv->parent = prnt;
- addr->name = CACHE_INSERT ("");
- addr->addr1 = CACHE_INSERT ("");
- addr->addr2 = CACHE_INSERT ("");
- addr->addr3 = CACHE_INSERT ("");
- addr->addr4 = CACHE_INSERT ("");
- addr->phone = CACHE_INSERT ("");
- addr->fax = CACHE_INSERT ("");
- addr->email = CACHE_INSERT ("");
+ addr->priv->name = CACHE_INSERT ("");
+ addr->priv->addr1 = CACHE_INSERT ("");
+ addr->priv->addr2 = CACHE_INSERT ("");
+ addr->priv->addr3 = CACHE_INSERT ("");
+ addr->priv->addr4 = CACHE_INSERT ("");
+ addr->priv->phone = CACHE_INSERT ("");
+ addr->priv->fax = CACHE_INSERT ("");
+ addr->priv->email = CACHE_INSERT ("");
return addr;
}
@@ -100,7 +219,7 @@
qofAddressSetOwner(GncAddress *addr, QofEntity *ent)
{
if(!addr || !ent) { return; }
- if(addr->parent == NULL) { addr->parent = ent; }
+ if(addr->priv->parent == NULL) { addr->priv->parent = ent; }
}
static QofEntity*
@@ -108,7 +227,7 @@
{
if(!addr) { return NULL; }
- return addr->parent;
+ return addr->priv->parent;
}
GncAddress *
@@ -119,18 +238,18 @@
if (!book) return NULL;
addr = g_new0 (GncAddress, 1);
- addr->book = book;
- addr->dirty = TRUE;
- addr->parent = new_parent;
+ addr->priv->book = book;
+ addr->priv->dirty = TRUE;
+ addr->priv->parent = new_parent;
- addr->name = CACHE_INSERT (from->name);
- addr->addr1 = CACHE_INSERT (from->addr1);
- addr->addr2 = CACHE_INSERT (from->addr2);
- addr->addr3 = CACHE_INSERT (from->addr3);
- addr->addr4 = CACHE_INSERT (from->addr4);
- addr->phone = CACHE_INSERT (from->phone);
- addr->fax = CACHE_INSERT (from->fax);
- addr->email = CACHE_INSERT (from->email);
+ addr->priv->name = CACHE_INSERT (from->name);
+ addr->priv->addr1 = CACHE_INSERT (from->addr1);
+ addr->priv->addr2 = CACHE_INSERT (from->addr2);
+ addr->priv->addr3 = CACHE_INSERT (from->addr3);
+ addr->priv->addr4 = CACHE_INSERT (from->addr4);
+ addr->priv->phone = CACHE_INSERT (from->phone);
+ addr->priv->fax = CACHE_INSERT (from->fax);
+ addr->priv->email = CACHE_INSERT (from->email);
return addr;
}
@@ -139,7 +258,7 @@
gncAddressDestroy (GncAddress *addr)
{
if (!addr) return;
- addr->inst.do_free = TRUE;
+ qof_instance_mark_free (QOF_INSTANCE (addr));
gncAddressCommitEdit (addr);
}
@@ -148,19 +267,18 @@
{
if (!addr) return;
- qof_event_gen (&addr->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (addr), QOF_EVENT_DESTROY, NULL);
- CACHE_REMOVE (addr->name);
- CACHE_REMOVE (addr->addr1);
- CACHE_REMOVE (addr->addr2);
- CACHE_REMOVE (addr->addr3);
- CACHE_REMOVE (addr->addr4);
- CACHE_REMOVE (addr->phone);
- CACHE_REMOVE (addr->fax);
- CACHE_REMOVE (addr->email);
+ CACHE_REMOVE (addr->priv->name);
+ CACHE_REMOVE (addr->priv->addr1);
+ CACHE_REMOVE (addr->priv->addr2);
+ CACHE_REMOVE (addr->priv->addr3);
+ CACHE_REMOVE (addr->priv->addr4);
+ CACHE_REMOVE (addr->priv->phone);
+ CACHE_REMOVE (addr->priv->fax);
+ CACHE_REMOVE (addr->priv->email);
- qof_instance_release (&addr->inst);
- g_free (addr);
+ qof_instance_release (QOF_INSTANCE (addr));
}
@@ -181,7 +299,7 @@
{
if (!addr) return;
if (!name) return;
- SET_STR(addr, addr->name, name);
+ SET_STR(addr, addr->priv->name, name);
mark_address (addr);
gncAddressCommitEdit (addr);
}
@@ -190,7 +308,7 @@
{
if (!addr) return;
if (!addr1) return;
- SET_STR(addr, addr->addr1, addr1);
+ SET_STR(addr, addr->priv->addr1, addr1);
mark_address (addr);
gncAddressCommitEdit (addr);
}
@@ -199,7 +317,7 @@
{
if (!addr) return;
if (!addr2) return;
- SET_STR(addr, addr->addr2, addr2);
+ SET_STR(addr, addr->priv->addr2, addr2);
mark_address (addr);
gncAddressCommitEdit (addr);
}
@@ -208,7 +326,7 @@
{
if (!addr) return;
if (!addr3) return;
- SET_STR(addr, addr->addr3, addr3);
+ SET_STR(addr, addr->priv->addr3, addr3);
mark_address (addr);
gncAddressCommitEdit (addr);
}
@@ -217,7 +335,7 @@
{
if (!addr) return;
if (!addr4) return;
- SET_STR(addr, addr->addr4, addr4);
+ SET_STR(addr, addr->priv->addr4, addr4);
mark_address (addr);
gncAddressCommitEdit (addr);
}
@@ -226,7 +344,7 @@
{
if (!addr) return;
if (!phone) return;
- SET_STR(addr, addr->phone, phone);
+ SET_STR(addr, addr->priv->phone, phone);
mark_address (addr);
gncAddressCommitEdit (addr);
}
@@ -235,7 +353,7 @@
{
if (!addr) return;
if (!fax) return;
- SET_STR(addr, addr->fax, fax);
+ SET_STR(addr, addr->priv->fax, fax);
mark_address (addr);
gncAddressCommitEdit (addr);
}
@@ -244,14 +362,14 @@
{
if (!addr) return;
if (!email) return;
- SET_STR(addr, addr->email, email);
+ SET_STR(addr, addr->priv->email, email);
mark_address (addr);
gncAddressCommitEdit (addr);
}
void gncAddressBeginEdit (GncAddress *addr)
{
- qof_begin_edit (&addr->inst);
+ qof_begin_edit (QOF_INSTANCE (addr));
}
static void gncAddressOnError (QofInstance *inst, QofBackendError errcode)
@@ -270,7 +388,7 @@
void gncAddressCommitEdit (GncAddress *addr)
{
if (!qof_commit_edit (QOF_INSTANCE(addr))) return;
- qof_commit_edit_part2 (&addr->inst, gncAddressOnError,
+ qof_commit_edit_part2 (QOF_INSTANCE (addr), gncAddressOnError,
gncAddressOnDone, address_free);
}
@@ -280,61 +398,61 @@
const char * gncAddressGetName (const GncAddress *addr)
{
if (!addr) return NULL;
- return addr->name;
+ return addr->priv->name;
}
const char * gncAddressGetAddr1 (const GncAddress *addr)
{
if (!addr) return NULL;
- return addr->addr1;
+ return addr->priv->addr1;
}
const char * gncAddressGetAddr2 (const GncAddress *addr)
{
if (!addr) return NULL;
- return addr->addr2;
+ return addr->priv->addr2;
}
const char * gncAddressGetAddr3 (const GncAddress *addr)
{
if (!addr) return NULL;
- return addr->addr3;
+ return addr->priv->addr3;
}
const char * gncAddressGetAddr4 (const GncAddress *addr)
{
if (!addr) return NULL;
- return addr->addr4;
+ return addr->priv->addr4;
}
const char * gncAddressGetPhone (const GncAddress *addr)
{
if (!addr) return NULL;
- return addr->phone;
+ return addr->priv->phone;
}
const char * gncAddressGetFax (const GncAddress *addr)
{
if (!addr) return NULL;
- return addr->fax;
+ return addr->priv->fax;
}
const char * gncAddressGetEmail (const GncAddress *addr)
{
if (!addr) return NULL;
- return addr->email;
+ return addr->priv->email;
}
gboolean gncAddressIsDirty (const GncAddress *addr)
{
if (!addr) return FALSE;
- return addr->dirty;
+ return addr->priv->dirty;
}
void gncAddressClearDirty (GncAddress *addr)
{
if (!addr) return;
- addr->dirty = FALSE;
+ qof_instance_set_dirty (QOF_INSTANCE (addr), FALSE);
}
int gncAddressCompare (const GncAddress *a, const GncAddress *b)
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncAddress.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncAddress.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncAddress.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -76,8 +76,36 @@
@param char* fax number
@param char* email address
*/
-typedef struct _gncAddress GncAddress;
+/* GObject declarations */
+
+#define GNC_TYPE_ADDRESS (qof_book_get_type ())
+#define GNC_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ADDRESS, GncAddress))
+#define GNC_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ADDRESS, GncAddressClass))
+#define GNC_IS_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ADDRESS))
+#define GNC_IS_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ADDRESS))
+#define GNC_ADDRESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ADDRESS, GncAddressClass))
+
+
+typedef struct _GncAddressClass GncAddressClass;
+typedef struct _GncAddressPrivate GncAddressPrivate;
+typedef struct _GncAddress GncAddress;
+
+struct _GncAdress {
+ QofInstance inst;
+ GncAddressPrivate *priv;
+};
+
+struct _GncAddressClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType qof_book_get_type ();
+
+
/** @name Create/Destroy functions
@{ */
GncAddress *gncAddressCreate (QofBook *book, QofEntity *parent);
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncBillTerm.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncBillTerm.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncBillTerm.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -33,10 +33,14 @@
#include "gnc-engine.h"
#include "gncBillTermP.h"
-struct _gncBillTerm
+/* GObject declarations */
+
+static void gnc_bill_term_class_init(GncBillTermClass *klass);
+static void gnc_bill_term_init(GncBillTerm *sp);
+static void gnc_bill_term_finalize(GObject *object);
+
+struct _GncBillTermPrivate
{
- QofInstance inst;
-
/* 'visible' data fields directly manipulated by user */
char * name;
char * desc;
@@ -56,6 +60,120 @@
GList * children; /* list of children for disconnection */
};
+typedef struct _GncBillTermSignal GncBillTermSignal;
+typedef enum _GncBillTermSignalType GncBillTermSignalType;
+
+enum _GncBillTermSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncBillTermSignal {
+ GncBillTerm *object;
+};
+
+static guint gnc_bill_term_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_bill_term_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncBillTermClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_bill_term_class_init,
+ NULL,
+ NULL,
+ sizeof (GncBillTerm),
+ 0,
+ (GInstanceInitFunc)gnc_bill_term_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncBillTerm", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_bill_term_class_init (GncBillTermClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_bill_term_finalize;
+ object_class->set_property = gnc_bill_term_set_property;
+ object_class->get_property = gnc_bill_term_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_bill_term_init (GncBillTerm *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_bill_term_finalize (GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_bill_term_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncBillTerm *obj;
+
+ obj = GNC_BILL_TERM (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_bill_term_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncBillTerm *obj;
+
+ obj = GNC_BILL_TERM (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+/*********************************************************************************************/
+
struct _book_info
{
GList * terms; /* visible terms */
@@ -84,8 +202,8 @@
static inline void
mark_term (GncBillTerm *term)
{
- qof_instance_set_dirty(&term->inst);
- qof_event_gen (&term->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(GNC_INSTANCE (term));
+ qof_event_gen (GNC_ENTITY (term), QOF_EVENT_MODIFY, NULL);
}
static inline void maybe_resort_list (GncBillTerm *term)
@@ -93,14 +211,14 @@
struct _book_info *bi;
if (term->parent || term->invisible) return;
- bi = qof_book_get_data (term->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book (QOF_INSTANCE (term)), _GNC_MOD_NAME);
bi->terms = g_list_sort (bi->terms, (GCompareFunc)gncBillTermCompare);
}
static inline void addObj (GncBillTerm *term)
{
struct _book_info *bi;
- bi = qof_book_get_data (term->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book (QOF_INSTANCE (term)), _GNC_MOD_NAME);
bi->terms = g_list_insert_sorted (bi->terms, term,
(GCompareFunc)gncBillTermCompare);
}
@@ -108,7 +226,7 @@
static inline void remObj (GncBillTerm *term)
{
struct _book_info *bi;
- bi = qof_book_get_data (term->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book (QOF_INSTANCE (term)), _GNC_MOD_NAME);
bi->terms = g_list_remove (bi->terms, term);
}
@@ -134,13 +252,16 @@
GncBillTerm *term;
if (!book) return NULL;
- term = g_new0 (GncBillTerm, 1);
- qof_instance_init(&term->inst, _GNC_MOD_NAME, book);
+ term = GNC_BILL_TERM (g_object_new (GNC_TYPE_BILL_TERM, NULL));
+ term->priv = g_new0 (GncBillTermPrivate, 1);
+
+ qof_instance_init(GNC_INSTANCE (term), _GNC_MOD_NAME, book);
+
term->name = CACHE_INSERT ("");
term->desc = CACHE_INSERT ("");
term->discount = gnc_numeric_zero ();
addObj (term);
- qof_event_gen (&term->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (GNC_ENTITY (term), QOF_EVENT_CREATE, NULL);
return term;
}
@@ -148,9 +269,9 @@
{
if (!term) return;
DEBUG("destroying bill term %s (%p)",
- guid_to_string(qof_instance_get_guid(&term->inst)), term);
- term->inst.do_free = TRUE;
- qof_instance_set_dirty (&term->inst);
+ guid_to_string(qof_instance_get_guid(GNC_INSTANCE (term))), term);
+ qof_instance_mark_free (QOF_INSTANCE (term));
+ qof_instance_set_dirty (GNC_INSTANCE (term));
gncBillTermCommitEdit (term);
}
@@ -161,12 +282,12 @@
if (!term) return;
- qof_event_gen (&term->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (GNC_ENTITY (term), QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (term->name);
CACHE_REMOVE (term->desc);
remObj (term);
- if (!term->inst.do_free)
+ if (!qof_instance_do_free (QOF_INSTANCE (term)))
PERR("free a billterm without do_free set!");
/* disconnect from parent */
@@ -180,8 +301,7 @@
}
g_list_free(term->children);
- qof_instance_release(&term->inst);
- g_free (term);
+ qof_instance_release(GNC_INSTANCE (term));
}
GncBillTerm *
@@ -193,8 +313,8 @@
if (!book || !from) return NULL;
term = g_new0 (GncBillTerm, 1);
- qof_instance_init(&term->inst, _GNC_MOD_NAME, book);
- qof_instance_gemini (&term->inst, &from->inst);
+ qof_instance_init(GNC_INSTANCE (term), _GNC_MOD_NAME, book);
+ qof_instance_gemini (GNC_INSTANCE (term), &from->inst);
term->name = CACHE_INSERT (from->name);
term->desc = CACHE_INSERT (from->desc);
@@ -228,7 +348,7 @@
}
addObj (term);
- qof_event_gen (&term->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (GNC_ENTITY (term), QOF_EVENT_CREATE, NULL);
return term;
}
@@ -398,7 +518,7 @@
void gncBillTermBeginEdit (GncBillTerm *term)
{
- QOF_BEGIN_EDIT (&term->inst);
+ QOF_BEGIN_EDIT (GNC_INSTANCE (term));
}
static void gncBillTermOnError (QofInstance *inst, QofBackendError errcode)
@@ -417,7 +537,7 @@
void gncBillTermCommitEdit (GncBillTerm *term)
{
if (!qof_commit_edit (QOF_INSTANCE(term))) return;
- qof_commit_edit_part2 (&term->inst, gncBillTermOnError,
+ qof_commit_edit_part2 (GNC_INSTANCE (term), gncBillTermOnError,
on_done, bill_free);
}
@@ -501,7 +621,7 @@
GncBillTerm *t;
if (!term) return NULL;
- t = gncBillTermCreate (term->inst.book);
+ t = gncBillTermCreate (qof_instance_get_book (QOF_INSTANCE (term)));
gncBillTermBeginEdit(t);
@@ -569,7 +689,7 @@
gboolean gncBillTermIsDirty (GncBillTerm *term)
{
if (!term) return FALSE;
- return term->inst.dirty;
+ return qof_instance_set_dirty (QOF_INSTANCE (term));
}
/********************************************************/
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncBillTerm.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncBillTerm.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncBillTerm.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -37,9 +37,36 @@
#ifdef GNUCASH_MAJOR_VERSION
#include "gncBusiness.h"
#endif
+
+/* GObject declarations */
+
+#define GNC_TYPE_BILL_TERM (qof_book_get_type ())
+#define GNC_BILL_TERM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BILL_TERM, GncBillTerm))
+#define GNC_BILL_TERM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BILL_TERM, GncBillTermClass))
+#define GNC_IS_BILL_TERM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BILL_TERM))
+#define GNC_IS_BILL_TERM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BILL_TERM))
+#define GNC_BILL_TERM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BILL_TERM, GncBillTermClass))
+
+
+typedef struct _GncBillTermClass GncBillTermClass;
+typedef struct _GncBillTermPrivate GncBillTermPrivate;
+typedef struct _GncBillTerm GncBillTerm;
+
+struct _GncBillTerm {
+ QofInstance inst;
+ GncBillTermPrivate *priv;
+}
+
+struct _GncBillTermClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_bill_term_get_type ();
+
#define GNC_ID_BILLTERM "gncBillTerm"
-#define GNC_IS_BILLTERM(obj) (QOF_CHECK_TYPE((obj), GNC_ID_BILLTERM))
-#define GNC_BILLTERM(obj) (QOF_CHECK_CAST((obj), GNC_ID_BILLTERM, GncBillTerm))
/** @name BillTerm parameter names
@{ */
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncCustomer.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncCustomer.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncCustomer.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -45,7 +45,17 @@
#include "gncJobP.h"
#include "gncTaxTableP.h"
-struct _gncCustomer
+/* GObject declarations */
+
+static void gnc_customer_class_init(GncCustomerClass *klass);
+static void gnc_customer_init(GncCustomer *sp);
+static void gnc_customer_finalize(GObject *object);
+
+
+typedef struct _GncCustomerSignal GncCustomerSignal;
+typedef enum _GncCustomerSignalType GncCustomerSignalType;
+
+struct _GncCustomerPrivate
{
QofInstance inst;
@@ -68,6 +78,139 @@
GncAddress * shipaddr;
};
+enum _GncCustomerSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncCustomerSignal {
+ GncCustomer *object;
+};
+
+static guint gnc_customer_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_customer_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncCustomerClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_customer_class_init,
+ NULL,
+ NULL,
+ sizeof (GncCustomer),
+ 0,
+ (GInstanceInitFunc)gnc_customer_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncCustomer", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_customer_class_init(GncCustomerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_customer_finalize;
+ object_class->set_property = gnc_customer_set_property;
+ object_class->get_property = gnc_customer_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_customer_init(GncCustomer *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_customer_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_customer_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncCustomer *obj;
+
+ obj = GNC_CUSTOMER (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_customer_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncCustomer *obj;
+
+ obj = GNC_CUSTOMER (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+struct _GncCustomerPrivate
+{
+ QofInstance inst;
+
+ /* The following fields are identical to 'vendor' */
+ char * id;
+ char * name;
+ char * notes;
+ GncBillTerm * terms;
+ GncAddress * addr;
+ gnc_commodity * currency;
+ GncTaxTable* taxtable;
+ gboolean taxtable_override;
+ GncTaxIncluded taxincluded;
+ gboolean active;
+ GList * jobs;
+
+ /* The following fields are unique to 'customer' */
+ gnc_numeric credit;
+ gnc_numeric discount;
+ GncAddress * shipaddr;
+};
+
static QofLogModule log_module = GNC_MOD_BUSINESS;
#define _GNC_MOD_NAME GNC_ID_CUSTOMER
@@ -92,21 +235,21 @@
if (!book) return NULL;
cust = g_new0 (GncCustomer, 1);
- qof_instance_init (&cust->inst, _GNC_MOD_NAME, book);
+ qof_instance_init (QOF_INSTANCE (cust), _GNC_MOD_NAME, book);
- cust->id = CACHE_INSERT ("");
- cust->name = CACHE_INSERT ("");
- cust->notes = CACHE_INSERT ("");
- cust->addr = gncAddressCreate (book, &cust->inst.entity);
- cust->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
- cust->active = TRUE;
- cust->jobs = NULL;
+ cust->priv->id = CACHE_INSERT ("");
+ cust->priv->name = CACHE_INSERT ("");
+ cust->priv->notes = CACHE_INSERT ("");
+ cust->priv->addr = gncAddressCreate (book, QOF_ENTITY (cust));
+ cust->priv->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
+ cust->priv->active = TRUE;
+ cust->priv->jobs = NULL;
- cust->discount = gnc_numeric_zero();
- cust->credit = gnc_numeric_zero();
- cust->shipaddr = gncAddressCreate (book, &cust->inst.entity);
+ cust->priv->discount = gnc_numeric_zero();
+ cust->priv->credit = gnc_numeric_zero();
+ cust->priv->shipaddr = gncAddressCreate (book, QOF_ENTITY (cust));
- qof_event_gen (&cust->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (cust), QOF_EVENT_CREATE, NULL);
return cust;
}
@@ -120,37 +263,37 @@
cust = g_new0 (GncCustomer, 1);
- qof_instance_init (&cust->inst, _GNC_MOD_NAME, book);
- qof_instance_gemini (&cust->inst, &from->inst);
+ qof_instance_init (QOF_INSTANCE (cust), _GNC_MOD_NAME, book);
+ qof_instance_gemini (QOF_INSTANCE (cust), &from->inst);
- cust->id = CACHE_INSERT (from->id);
- cust->name = CACHE_INSERT (from->name);
- cust->notes = CACHE_INSERT (from->notes);
- cust->discount = from->discount;
- cust->credit = from->credit;
- cust->taxincluded = from->taxincluded;
- cust->active = from->active;
- cust->taxtable_override = from->taxtable_override;
+ cust->priv->id = CACHE_INSERT (from->id);
+ cust->priv->name = CACHE_INSERT (from->name);
+ cust->priv->notes = CACHE_INSERT (from->notes);
+ cust->priv->discount = from->discount;
+ cust->priv->credit = from->credit;
+ cust->priv->taxincluded = from->taxincluded;
+ cust->priv->active = from->active;
+ cust->priv->taxtable_override = from->taxtable_override;
- cust->addr = gncCloneAddress (from->addr, &cust->inst.entity, book);
- cust->shipaddr = gncCloneAddress (from->shipaddr, &cust->inst.entity, book);
+ cust->priv->addr = gncCloneAddress (from->addr, QOF_ENTITY (cust), book);
+ cust->priv->shipaddr = gncCloneAddress (from->shipaddr, QOF_ENTITY (cust), book);
/* Find the matching currency in the new book, assumes
* currency has already been copied into new book. */
- cust->currency = gnc_commodity_obtain_twin (from->currency, book);
+ cust->priv->currency = gnc_commodity_obtain_twin (from->currency, book);
/* Find the matching bill term, tax table in the new book */
- cust->terms = gncBillTermObtainTwin(from->terms, book);
- cust->taxtable = gncTaxTableObtainTwin (from->taxtable, book);
+ cust->priv->terms = gncBillTermObtainTwin(from->terms, book);
+ cust->priv->taxtable = gncTaxTableObtainTwin (from->taxtable, book);
- for (node=g_list_last(cust->jobs); node; node=node->next)
+ for (node=g_list_last(cust->priv->jobs); node; node=node->next)
{
GncJob *job = node->data;
job = gncJobObtainTwin (job, book);
- cust->jobs = g_list_prepend(cust->jobs, job);
+ cust->priv->jobs = g_list_prepend(cust->priv->jobs, job);
}
- qof_event_gen (&cust->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (cust), QOF_EVENT_CREATE, NULL);
return cust;
}
@@ -158,8 +301,8 @@
void gncCustomerDestroy (GncCustomer *cust)
{
if (!cust) return;
- cust->inst.do_free = TRUE;
- qof_instance_set_dirty (&cust->inst);
+ cust->priv->inst.do_free = TRUE;
+ qof_instance_set_dirty (QOF_INSTANCE (cust));
gncCustomerCommitEdit (cust);
}
@@ -167,22 +310,22 @@
{
if (!cust) return;
- qof_event_gen (&cust->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (cust), QOF_EVENT_DESTROY, NULL);
- CACHE_REMOVE (cust->id);
- CACHE_REMOVE (cust->name);
- CACHE_REMOVE (cust->notes);
- gncAddressDestroy (cust->addr);
- gncAddressDestroy (cust->shipaddr);
- g_list_free (cust->jobs);
+ CACHE_REMOVE (cust->priv->id);
+ CACHE_REMOVE (cust->priv->name);
+ CACHE_REMOVE (cust->priv->notes);
+ gncAddressDestroy (cust->priv->addr);
+ gncAddressDestroy (cust->priv->shipaddr);
+ g_list_free (cust->priv->jobs);
- if (cust->terms)
- gncBillTermDecRef (cust->terms);
- if (cust->taxtable) {
- gncTaxTableDecRef (cust->taxtable);
+ if (cust->priv->terms)
+ gncBillTermDecRef (cust->priv->terms);
+ if (cust->priv->taxtable) {
+ gncTaxTableDecRef (cust->priv->taxtable);
}
- qof_instance_release (&cust->inst);
+ qof_instance_release (QOF_INSTANCE (cust));
g_free (cust);
}
@@ -217,7 +360,7 @@
{
if (!cust) return;
if (!id) return;
- SET_STR(cust, cust->id, id);
+ SET_STR(cust, cust->priv->id, id);
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -226,7 +369,7 @@
{
if (!cust) return;
if (!name) return;
- SET_STR(cust, cust->name, name);
+ SET_STR(cust, cust->priv->name, name);
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -235,7 +378,7 @@
{
if (!cust) return;
if (!notes) return;
- SET_STR(cust, cust->notes, notes);
+ SET_STR(cust, cust->priv->notes, notes);
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -243,14 +386,14 @@
void gncCustomerSetTerms (GncCustomer *cust, GncBillTerm *terms)
{
if (!cust) return;
- if (cust->terms == terms) return;
+ if (cust->priv->terms == terms) return;
gncCustomerBeginEdit (cust);
- if (cust->terms)
- gncBillTermDecRef (cust->terms);
- cust->terms = terms;
- if (cust->terms)
- gncBillTermIncRef (cust->terms);
+ if (cust->priv->terms)
+ gncBillTermDecRef (cust->priv->terms);
+ cust->priv->terms = terms;
+ if (cust->priv->terms)
+ gncBillTermIncRef (cust->priv->terms);
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -258,9 +401,9 @@
void gncCustomerSetTaxIncluded (GncCustomer *cust, GncTaxIncluded taxincl)
{
if (!cust) return;
- if (taxincl == cust->taxincluded) return;
+ if (taxincl == cust->priv->taxincluded) return;
gncCustomerBeginEdit (cust);
- cust->taxincluded = taxincl;
+ cust->priv->taxincluded = taxincl;
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -268,9 +411,9 @@
void gncCustomerSetActive (GncCustomer *cust, gboolean active)
{
if (!cust) return;
- if (active == cust->active) return;
+ if (active == cust->priv->active) return;
gncCustomerBeginEdit (cust);
- cust->active = active;
+ cust->priv->active = active;
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -278,9 +421,9 @@
void gncCustomerSetDiscount (GncCustomer *cust, gnc_numeric discount)
{
if (!cust) return;
- if (gnc_numeric_equal (discount, cust->discount)) return;
+ if (gnc_numeric_equal (discount, cust->priv->discount)) return;
gncCustomerBeginEdit (cust);
- cust->discount = discount;
+ cust->priv->discount = discount;
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -288,9 +431,9 @@
void gncCustomerSetCredit (GncCustomer *cust, gnc_numeric credit)
{
if (!cust) return;
- if (gnc_numeric_equal (credit, cust->credit)) return;
+ if (gnc_numeric_equal (credit, cust->priv->credit)) return;
gncCustomerBeginEdit (cust);
- cust->credit = credit;
+ cust->priv->credit = credit;
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -298,9 +441,9 @@
void gncCustomerSetCurrency (GncCustomer *cust, gnc_commodity *currency)
{
if (!cust || !currency) return;
- if (cust->currency && gnc_commodity_equal (cust->currency, currency)) return;
+ if (cust->priv->currency && gnc_commodity_equal (cust->priv->currency, currency)) return;
gncCustomerBeginEdit (cust);
- cust->currency = currency;
+ cust->priv->currency = currency;
mark_customer (cust);
gncCustomerCommitEdit (cust);
}
@@ -336,11 +479,11 @@
if (!cust) return;
if (!job) return;
- if (g_list_index(cust->jobs, job) == -1)
- cust->jobs = g_list_insert_sorted (cust->jobs, job,
+ if (g_list_index(cust->priv->jobs, job) == -1)
+ cust->priv->jobs = g_list_insert_sorted (cust->priv->jobs, job,
(GCompareFunc)gncJobCompare);
- qof_event_gen (&cust->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen (QOF_ENTITY (cust), QOF_EVENT_MODIFY, NULL);
}
void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
@@ -350,19 +493,19 @@
if (!cust) return;
if (!job) return;
- node = g_list_find (cust->jobs, job);
+ node = g_list_find (cust->priv->jobs, job);
if (!node) {
/* PERR ("split not in account"); */
} else {
- cust->jobs = g_list_remove_link (cust->jobs, node);
+ cust->priv->jobs = g_list_remove_link (cust->priv->jobs, node);
g_list_free_1 (node);
}
- qof_event_gen (&cust->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen (QOF_ENTITY (cust), QOF_EVENT_MODIFY, NULL);
}
void gncCustomerBeginEdit (GncCustomer *cust)
{
- qof_begin_edit (&cust->inst);
+ qof_begin_edit (QOF_INSTANCE (cust));
}
static void gncCustomerOnError (QofInstance *inst, QofBackendError errcode)
@@ -373,8 +516,8 @@
static void gncCustomerOnDone (QofInstance *inst)
{
GncCustomer *cust = (GncCustomer *) inst;
- gncAddressClearDirty (cust->addr);
- gncAddressClearDirty (cust->shipaddr);
+ gncAddressClearDirty (cust->priv->addr);
+ gncAddressClearDirty (cust->priv->shipaddr);
}
static void cust_free (QofInstance *inst)
@@ -386,7 +529,7 @@
void gncCustomerCommitEdit (GncCustomer *cust)
{
if (!qof_commit_edit (QOF_INSTANCE(cust))) return;
- qof_commit_edit_part2 (&cust->inst, gncCustomerOnError,
+ qof_commit_edit_part2 (QOF_INSTANCE (cust), gncCustomerOnError,
gncCustomerOnDone, cust_free);
}
@@ -396,19 +539,19 @@
const char * gncCustomerGetID (GncCustomer *cust)
{
if (!cust) return NULL;
- return cust->id;
+ return cust->priv->id;
}
const char * gncCustomerGetName (GncCustomer *cust)
{
if (!cust) return NULL;
- return cust->name;
+ return cust->priv->name;
}
GncAddress * gncCustomerGetAddr (GncCustomer *cust)
{
if (!cust) return NULL;
- return cust->addr;
+ return cust->priv->addr;
}
static void
@@ -418,10 +561,10 @@
if(!cust || !addr_ent) { return; }
addr = (GncAddress*)addr_ent;
- if(addr == cust->addr) { return; }
- if(cust->addr != NULL) { gncAddressDestroy(cust->addr); }
+ if(addr == cust->priv->addr) { return; }
+ if(cust->priv->addr != NULL) { gncAddressDestroy(cust->priv->addr); }
gncCustomerBeginEdit(cust);
- cust->addr = addr;
+ cust->priv->addr = addr;
gncCustomerCommitEdit(cust);
}
@@ -432,59 +575,59 @@
if(!cust || !ship_addr_ent) { return; }
ship_addr = (GncAddress*)ship_addr_ent;
- if(ship_addr == cust->shipaddr) { return; }
- if(cust->shipaddr != NULL) { gncAddressDestroy(cust->shipaddr); }
+ if(ship_addr == cust->priv->shipaddr) { return; }
+ if(cust->priv->shipaddr != NULL) { gncAddressDestroy(cust->priv->shipaddr); }
gncCustomerBeginEdit(cust);
- cust->shipaddr = ship_addr;
+ cust->priv->shipaddr = ship_addr;
gncCustomerCommitEdit(cust);
}
GncAddress * gncCustomerGetShipAddr (GncCustomer *cust)
{
if (!cust) return NULL;
- return cust->shipaddr;
+ return cust->priv->shipaddr;
}
const char * gncCustomerGetNotes (GncCustomer *cust)
{
if (!cust) return NULL;
- return cust->notes;
+ return cust->priv->notes;
}
GncBillTerm * gncCustomerGetTerms (GncCustomer *cust)
{
if (!cust) return NULL;
- return cust->terms;
+ return cust->priv->terms;
}
GncTaxIncluded gncCustomerGetTaxIncluded (GncCustomer *cust)
{
if (!cust) return GNC_TAXINCLUDED_USEGLOBAL;
- return cust->taxincluded;
+ return cust->priv->taxincluded;
}
gnc_commodity * gncCustomerGetCurrency (GncCustomer *cust)
{
if (!cust) return NULL;
- return cust->currency;
+ return cust->priv->currency;
}
gboolean gncCustomerGetActive (GncCustomer *cust)
{
if (!cust) return FALSE;
- return cust->active;
+ return cust->priv->active;
}
gnc_numeric gncCustomerGetDiscount (GncCustomer *cust)
{
if (!cust) return gnc_numeric_zero();
- return cust->discount;
+ return cust->priv->discount;
}
gnc_numeric gncCustomerGetCredit (GncCustomer *cust)
{
if (!cust) return gnc_numeric_zero();
- return cust->credit;
+ return cust->priv->credit;
}
gboolean gncCustomerGetTaxTableOverride (GncCustomer *customer)
@@ -504,10 +647,10 @@
if (!cust) return NULL;
if (show_all) {
- return (g_list_copy (cust->jobs));
+ return (g_list_copy (cust->priv->jobs));
} else {
GList *list = NULL, *iterator;
- for (iterator = cust->jobs; iterator; iterator=iterator->next) {
+ for (iterator = cust->priv->jobs; iterator; iterator=iterator->next) {
GncJob *j = iterator->data;
if (gncJobGetActive (j))
list = g_list_append (list, j);
@@ -519,9 +662,9 @@
gboolean gncCustomerIsDirty (GncCustomer *cust)
{
if (!cust) return FALSE;
- return (qof_instance_is_dirty(&cust->inst) ||
- gncAddressIsDirty (cust->addr) ||
- gncAddressIsDirty (cust->shipaddr));
+ return (qof_instance_is_dirty(QOF_INSTANCE (cust)) ||
+ gncAddressIsDirty (cust->priv->addr) ||
+ gncAddressIsDirty (cust->priv->shipaddr));
}
/* Other functions */
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncCustomer.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncCustomer.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncCustomer.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -54,16 +54,42 @@
@param GncAddress * shipaddr;
*/
-typedef struct _gncCustomer GncCustomer;
#include "gncAddress.h"
#include "gncBillTerm.h"
#include "gncTaxTable.h"
#include "gncJob.h"
+/* GObject declarations */
+
+#define GNC_TYPE_CUSTOMER (gnc_customer_get_type ())
+#define GNC_CUSTOMER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_CUSTOMER, GncCustomer))
+#define GNC_CUSTOMER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_CUSTOMER, GncCustomerClass))
+#define GNC_IS_CUSTOMER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_CUSTOMER))
+#define GNC_IS_CUSTOMER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_CUSTOMER))
+#define GNC_CUSTOMER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_CUSTOMER, GncCustomerClass))
+
+
+typedef struct _GncCustomerClass GncCustomerClass;
+typedef struct _GncCustomerPrivate GncCustomerPrivate;
+typedef struct _GncCustomer GncCustomer;
+
+typedef struct _GncCustomer {
+ QofInstance inst;
+ GncCustomerPrivate *priv;
+};
+
+struct _GncCustomerClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_customer_get_type ();
+
+
#define GNC_ID_CUSTOMER "gncCustomer"
-#define GNC_IS_CUSTOMER(obj) (QOF_CHECK_TYPE((obj), GNC_ID_CUSTOMER))
-#define GNC_CUSTOMER(obj) (QOF_CHECK_CAST((obj), GNC_ID_CUSTOMER, GncCustomer))
/** @name Create/Destroy Functions
@{ */
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncEmployee.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncEmployee.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncEmployee.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -37,9 +37,15 @@
#include "gncEmployee.h"
#include "gncEmployeeP.h"
-struct _gncEmployee
+/* GObject declarations */
+
+static void gnc_employee_class_init(GncEmployeeClass *klass);
+static void gnc_employee_init(GncEmployee *sp);
+static void gnc_employee_finalize(GObject *object);
+
+
+struct _GncEmployeePrivate
{
- QofInstance inst;
char * id;
char * username;
GncAddress * addr;
@@ -54,6 +60,121 @@
Account * ccard_acc;
};
+
+typedef struct _GncEmployeeSignal GncEmployeeSignal;
+typedef enum _GncEmployeeSignalType GncEmployeeSignalType;
+
+enum _GncEmployeeSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncEmployeeSignal {
+ GncEmployee *object;
+};
+
+static guint gnc_employee_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_employee_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncEmployeeClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_employee_class_init,
+ NULL,
+ NULL,
+ sizeof (GncEmployee),
+ 0,
+ (GInstanceInitFunc)gnc_employee_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncEmployee", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_employee_class_init(GncEmployeeClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_employee_finalize;
+ object_class->set_property = gnc_employee_set_property;
+ object_class->get_property = gnc_employee_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_employee_init(GncEmployee *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_employee_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_employee_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncEmployee *obj;
+
+ obj = GNC_EMPLOYEE (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_employee_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncEmployee *obj;
+
+ obj = GNC_EMPLOYEE (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+/************************************************/
+
static QofLogModule log_module = GNC_MOD_BUSINESS;
#define _GNC_MOD_NAME GNC_ID_EMPLOYEE
@@ -61,8 +182,8 @@
G_INLINE_FUNC void mark_employee (GncEmployee *employee);
void mark_employee (GncEmployee *employee)
{
- qof_instance_set_dirty(&employee->inst);
- qof_event_gen (&employee->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(QOF_INSTANCE (employee));
+ qof_event_gen (QOF_ENTITY (employee), QOF_EVENT_MODIFY, NULL);
}
/* ============================================================== */
@@ -74,19 +195,21 @@
if (!book) return NULL;
- employee = g_new0 (GncEmployee, 1);
- qof_instance_init (&employee->inst, _GNC_MOD_NAME, book);
+ employee = GNC_EMPLOYEE (g_object_new (GNC_TYPE_EMPLOYEE, NULL));
+ employee->priv = g_new0 (GncEmployeePrivate, 1);
- employee->id = CACHE_INSERT ("");
- employee->username = CACHE_INSERT ("");
- employee->language = CACHE_INSERT ("");
- employee->acl = CACHE_INSERT ("");
- employee->addr = gncAddressCreate (book, &employee->inst.entity);
- employee->workday = gnc_numeric_zero();
- employee->rate = gnc_numeric_zero();
- employee->active = TRUE;
+ qof_instance_init (QOF_INSTANCE (employee) , _GNC_MOD_NAME, book);
- qof_event_gen (&employee->inst.entity, QOF_EVENT_CREATE, NULL);
+ employee->priv->id = CACHE_INSERT ("");
+ employee->priv->username = CACHE_INSERT ("");
+ employee->priv->language = CACHE_INSERT ("");
+ employee->priv->acl = CACHE_INSERT ("");
+ employee->priv->addr = gncAddressCreate (book, QOF_ENTITY (employee));
+ employee->priv->workday = gnc_numeric_zero();
+ employee->priv->rate = gnc_numeric_zero();
+ employee->priv->active = TRUE;
+
+ qof_event_gen (QOF_ENTITY (employee), QOF_EVENT_CREATE, NULL);
return employee;
}
@@ -94,7 +217,7 @@
void gncEmployeeDestroy (GncEmployee *employee)
{
if (!employee) return;
- employee->inst.do_free = TRUE;
+ qof_instance_mark_free (QOF_INSTANCE (employee));
gncEmployeeCommitEdit(employee);
}
@@ -102,16 +225,15 @@
{
if (!employee) return;
- qof_event_gen (&employee->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (employee), QOF_EVENT_DESTROY, NULL);
- CACHE_REMOVE (employee->id);
- CACHE_REMOVE (employee->username);
- CACHE_REMOVE (employee->language);
- CACHE_REMOVE (employee->acl);
- gncAddressDestroy (employee->addr);
+ CACHE_REMOVE (employee->priv->id);
+ CACHE_REMOVE (employee->priv->username);
+ CACHE_REMOVE (employee->priv->language);
+ CACHE_REMOVE (employee->priv->acl);
+ gncAddressDestroy (employee->priv->addr);
- qof_instance_release (&employee->inst);
- g_free (employee);
+ qof_instance_release (QOF_INSTANCE (employee));
}
GncEmployee *
@@ -121,22 +243,22 @@
if (!book || !from) return NULL;
employee = g_new0 (GncEmployee, 1);
- qof_instance_init(&employee->inst, _GNC_MOD_NAME, book);
- qof_instance_gemini (&employee->inst, &from->inst);
+ qof_instance_init(QOF_INSTANCE (employee), _GNC_MOD_NAME, book);
+ qof_instance_gemini (QOF_INSTANCE (employee), &from->inst);
- employee->id = CACHE_INSERT (from->id);
- employee->username = CACHE_INSERT (from->username);
- employee->language = CACHE_INSERT (from->language);
- employee->acl = CACHE_INSERT (from->acl);
- employee->addr = gncCloneAddress (from->addr, &employee->inst.entity, book);
- employee->workday = from->workday;
- employee->rate = from->rate;
- employee->active = from->active;
- employee->currency = gnc_commodity_obtain_twin(from->currency, book);
- employee->ccard_acc =
+ employee->priv->id = CACHE_INSERT (from->id);
+ employee->priv->username = CACHE_INSERT (from->username);
+ employee->priv->language = CACHE_INSERT (from->language);
+ employee->priv->acl = CACHE_INSERT (from->acl);
+ employee->priv->addr = gncCloneAddress (from->addr, QOF_ENTITY (employee), book);
+ employee->priv->workday = from->workday;
+ employee->priv->rate = from->rate;
+ employee->priv->active = from->active;
+ employee->priv->currency = gnc_commodity_obtain_twin(from->currency, book);
+ employee->priv->ccard_acc =
GNC_ACCOUNT(qof_instance_lookup_twin(QOF_INSTANCE(from->ccard_acc), book));
- qof_event_gen (&employee->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (employee), QOF_EVENT_CREATE, NULL);
return employee;
}
@@ -173,7 +295,7 @@
{
if (!employee) return;
if (!id) return;
- SET_STR(employee, employee->id, id);
+ SET_STR(employee, employee->priv->id, id);
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -182,7 +304,7 @@
{
if (!employee) return;
if (!username) return;
- SET_STR(employee, employee->username, username);
+ SET_STR(employee, employee->priv->username, username);
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -191,7 +313,7 @@
{
if (!employee) return;
if (!language) return;
- SET_STR(employee, employee->language, language);
+ SET_STR(employee, employee->priv->language, language);
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -200,7 +322,7 @@
{
if (!employee) return;
if (!acl) return;
- SET_STR(employee, employee->acl, acl);
+ SET_STR(employee, employee->priv->acl, acl);
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -208,9 +330,9 @@
void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday)
{
if (!employee) return;
- if (gnc_numeric_equal (workday, employee->workday)) return;
+ if (gnc_numeric_equal (workday, employee->priv->workday)) return;
gncEmployeeBeginEdit (employee);
- employee->workday = workday;
+ employee->priv->workday = workday;
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -218,9 +340,9 @@
void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate)
{
if (!employee) return;
- if (gnc_numeric_equal (rate, employee->rate)) return;
+ if (gnc_numeric_equal (rate, employee->priv->rate)) return;
gncEmployeeBeginEdit (employee);
- employee->rate = rate;
+ employee->priv->rate = rate;
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -228,11 +350,11 @@
void gncEmployeeSetCurrency (GncEmployee *employee, gnc_commodity *currency)
{
if (!employee || !currency) return;
- if (employee->currency &&
- gnc_commodity_equal (employee->currency, currency))
+ if (employee->priv->currency &&
+ gnc_commodity_equal (employee->priv->currency, currency))
return;
gncEmployeeBeginEdit (employee);
- employee->currency = currency;
+ employee->priv->currency = currency;
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -240,9 +362,9 @@
void gncEmployeeSetActive (GncEmployee *employee, gboolean active)
{
if (!employee) return;
- if (active == employee->active) return;
+ if (active == employee->priv->active) return;
gncEmployeeBeginEdit (employee);
- employee->active = active;
+ employee->priv->active = active;
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -250,9 +372,9 @@
void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc)
{
if (!employee) return;
- if (ccard_acc == employee->ccard_acc) return;
+ if (ccard_acc == employee->priv->ccard_acc) return;
gncEmployeeBeginEdit (employee);
- employee->ccard_acc = ccard_acc;
+ employee->priv->ccard_acc = ccard_acc;
mark_employee (employee);
gncEmployeeCommitEdit (employee);
}
@@ -264,10 +386,10 @@
if(!employee || !addr_ent) { return; }
addr = (GncAddress*)addr_ent;
- if(addr == employee->addr) { return; }
- if(employee->addr != NULL) { gncAddressDestroy(employee->addr); }
+ if(addr == employee->priv->addr) { return; }
+ if(employee->priv->addr != NULL) { gncAddressDestroy(employee->priv->addr); }
gncEmployeeBeginEdit(employee);
- employee->addr = addr;
+ employee->priv->addr = addr;
gncEmployeeCommitEdit(employee);
}
@@ -276,72 +398,72 @@
const char * gncEmployeeGetID (GncEmployee *employee)
{
if (!employee) return NULL;
- return employee->id;
+ return employee->priv->id;
}
const char * gncEmployeeGetUsername (GncEmployee *employee)
{
if (!employee) return NULL;
- return employee->username;
+ return employee->priv->username;
}
GncAddress * gncEmployeeGetAddr (GncEmployee *employee)
{
if (!employee) return NULL;
- return employee->addr;
+ return employee->priv->addr;
}
const char * gncEmployeeGetLanguage (GncEmployee *employee)
{
if (!employee) return NULL;
- return employee->language;
+ return employee->priv->language;
}
const char * gncEmployeeGetAcl (GncEmployee *employee)
{
if (!employee) return NULL;
- return employee->acl;
+ return employee->priv->acl;
}
gnc_numeric gncEmployeeGetWorkday (GncEmployee *employee)
{
if (!employee) return gnc_numeric_zero();
- return employee->workday;
+ return employee->priv->workday;
}
gnc_numeric gncEmployeeGetRate (GncEmployee *employee)
{
if (!employee) return gnc_numeric_zero();
- return employee->rate;
+ return employee->priv->rate;
}
gnc_commodity * gncEmployeeGetCurrency (GncEmployee *employee)
{
if (!employee) return NULL;
- return employee->currency;
+ return employee->priv->currency;
}
gboolean gncEmployeeGetActive (GncEmployee *employee)
{
if (!employee) return FALSE;
- return employee->active;
+ return employee->priv->active;
}
Account * gncEmployeeGetCCard (GncEmployee *employee)
{
if (!employee) return NULL;
- return employee->ccard_acc;
+ return employee->priv->ccard_acc;
}
gboolean gncEmployeeIsDirty (GncEmployee *employee)
{
if (!employee) return FALSE;
- return (employee->inst.dirty || gncAddressIsDirty (employee->addr));
+ return (qof_instance_is_dirty (QOF_INSTANCE (employee) || gncAddressIsDirty (employee->priv->addr));
}
void gncEmployeeBeginEdit (GncEmployee *employee)
{
- QOF_BEGIN_EDIT (&employee->inst);
+ QOF_BEGIN_EDIT (QOF_INSTANCE (employee));
}
static void gncEmployeeOnError (QofInstance *employee, QofBackendError errcode)
@@ -352,7 +474,7 @@
static void gncEmployeeOnDone (QofInstance *inst)
{
GncEmployee *employee = (GncEmployee *) inst;
- gncAddressClearDirty (employee->addr);
+ gncAddressClearDirty (employee->priv->addr);
}
static void emp_free (QofInstance *inst)
@@ -365,7 +487,7 @@
void gncEmployeeCommitEdit (GncEmployee *employee)
{
if (!qof_commit_edit (QOF_INSTANCE(employee))) return;
- qof_commit_edit_part2 (&employee->inst, gncEmployeeOnError,
+ qof_commit_edit_part2 (QOF_INSTANCE (employee), gncEmployeeOnError,
gncEmployeeOnDone, emp_free);
}
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncEmployee.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncEmployee.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncEmployee.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -31,18 +31,44 @@
#ifndef GNC_EMPLOYEE_H_
#define GNC_EMPLOYEE_H_
-typedef struct _gncEmployee GncEmployee;
+
#include "gncAddress.h"
#include "Account.h"
+/* GObject declarations */
+
+#define GNC_TYPE_EMPLOYEE (gnc_employee_get_type ())
+#define GNC_EMPLOYEE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_EMPLOYEE, GncEmployee))
+#define GNC_EMPLOYEE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_EMPLOYEE, GncEmployeeClass))
+#define GNC_IS_EMPLOYEE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_EMPLOYEE))
+#define GNC_IS_EMPLOYEE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_EMPLOYEE))
+#define GNC_EMPLOYEE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_EMPLOYEE, GncEmployeeClass))
+
+
+typedef struct _GncEmployeeClass GncEmployeeClass
+typedef struct _GncEmployeePrivate GncEmployeePrivate;
+typedef struct _GncEmployee GncEmployee;
+
+struct _GncEmployee {
+ QofInstance inst;
+ GncEmployeePrivate *priv;
+};
+
+struct _GncEmployeeClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_employee_get_type ();
+
#define GNC_ID_EMPLOYEE "gncEmployee"
-#define GNC_IS_EMPLOYEE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_EMPLOYEE))
-#define GNC_EMPLOYEE(obj) (QOF_CHECK_CAST((obj), GNC_ID_EMPLOYEE, GncEmployee))
/** @name Create/Destroy Functions
@{ */
-GncEmployee *gncEmployeeCreate (QofBook *book);
+GncEmployee *gncEmployeeCreate (GncEmployee *book);
void gncEmployeeDestroy (GncEmployee *employee);
void gncEmployeeBeginEdit (GncEmployee *employee);
void gncEmployeeCommitEdit (GncEmployee *employee);
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncEntry.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncEntry.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncEntry.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -36,10 +36,14 @@
#include "gncInvoice.h"
#include "gncOrder.h"
-struct _gncEntry
+/* GObject declarations */
+
+static void gnc_entry_class_init(GncEntryClass *klass);
+static void gnc_entry_init(GncEntry *sp);
+static void gnc_entry_finalize(GObject *object);
+
+struct _GncEntryPrivate
{
- QofInstance inst;
-
Timespec date;
Timespec date_entered;
char * desc;
@@ -96,6 +100,120 @@
Timespec b_taxtable_modtime;
};
+typedef struct _GncEntrySignal GncEntrySignal;
+typedef enum _GncEntrySignalType GncEntrySignalType;
+
+enum _GncEntrySignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncEntrySignal {
+ GncEntry *object;
+};
+
+static guint gnc_entry_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_entry_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncEntryClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_entry_class_init,
+ NULL,
+ NULL,
+ sizeof (GncEntry),
+ 0,
+ (GInstanceInitFunc)gnc_entry_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncEntry", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_entry_class_init(GncEntryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_entry_finalize;
+ object_class->set_property = gnc_entry_set_property;
+ object_class->get_property = gnc_entry_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_entry_init(GncEntry *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_entry_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_entry_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncEntry *obj;
+
+ obj = GNC_ENTRY (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_entry_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncEntry *obj;
+
+ obj = GNC_ENTRY (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+
static QofLogModule log_module = GNC_MOD_BUSINESS;
/* You must edit the functions in this block in tandem. KEEP THEM IN
@@ -168,8 +286,8 @@
G_INLINE_FUNC void mark_entry (GncEntry *entry);
void mark_entry (GncEntry *entry)
{
- qof_instance_set_dirty(&entry->inst);
- qof_event_gen (&entry->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(GNC_INSTANCE (entry));
+ qof_event_gen (GNC_ENTITY (entry), QOF_EVENT_MODIFY, NULL);
}
/* ================================================================ */
@@ -182,36 +300,37 @@
if (!book) return NULL;
- entry = g_new0 (GncEntry, 1);
- qof_instance_init (&entry->inst, _GNC_MOD_NAME, book);
+ entry = GNC_TYPE_ENTRY (g_object_new (GNC_TYPE_ENTRY, NULL));
+ qof_instance_init (GNC_INSTANCE (entry), _GNC_MOD_NAME, book);
+
+ entry->priv = g_new0 (GncEntry, 1);
+ entry->priv->desc = CACHE_INSERT ("");
+ entry->priv->action = CACHE_INSERT ("");
+ entry->priv->notes = CACHE_INSERT ("");
+ entry->priv->quantity = zero;
- entry->desc = CACHE_INSERT ("");
- entry->action = CACHE_INSERT ("");
- entry->notes = CACHE_INSERT ("");
- entry->quantity = zero;
+ entry->priv->i_price = zero;
+ entry->priv->i_taxable = TRUE;
+ entry->priv->i_discount = zero;
+ entry->priv->i_disc_type = GNC_AMT_TYPE_PERCENT;
+ entry->priv->i_disc_how = GNC_DISC_PRETAX;
- entry->i_price = zero;
- entry->i_taxable = TRUE;
- entry->i_discount = zero;
- entry->i_disc_type = GNC_AMT_TYPE_PERCENT;
- entry->i_disc_how = GNC_DISC_PRETAX;
+ entry->priv->b_price = zero;
+ entry->priv->b_taxable = TRUE;
+ entry->priv->billto.type = GNC_OWNER_CUSTOMER;
+ entry->priv->b_payment = GNC_PAYMENT_CASH;
- entry->b_price = zero;
- entry->b_taxable = TRUE;
- entry->billto.type = GNC_OWNER_CUSTOMER;
- entry->b_payment = GNC_PAYMENT_CASH;
+ entry->priv->values_dirty = TRUE;
- entry->values_dirty = TRUE;
+ qof_event_gen (GNC_ENTITY (entry), QOF_EVENT_CREATE, NULL);
- qof_event_gen (&entry->inst.entity, QOF_EVENT_CREATE, NULL);
-
return entry;
}
void gncEntryDestroy (GncEntry *entry)
{
if (!entry) return;
- entry->inst.do_free = TRUE;
+ entry->priv->inst.do_free = TRUE;
gncEntryCommitEdit(entry);
}
@@ -219,22 +338,21 @@
{
if (!entry) return;
- qof_event_gen (&entry->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (GNC_ENTITY (entry), QOF_EVENT_DESTROY, NULL);
- CACHE_REMOVE (entry->desc);
- CACHE_REMOVE (entry->action);
- CACHE_REMOVE (entry->notes);
- if (entry->i_tax_values)
- gncAccountValueDestroy (entry->i_tax_values);
- if (entry->b_tax_values)
- gncAccountValueDestroy (entry->b_tax_values);
- if (entry->i_tax_table)
- gncTaxTableDecRef (entry->i_tax_table);
- if (entry->b_tax_table)
- gncTaxTableDecRef (entry->b_tax_table);
+ CACHE_REMOVE (entry->priv->desc);
+ CACHE_REMOVE (entry->priv->action);
+ CACHE_REMOVE (entry->priv->notes);
+ if (entry->priv->i_tax_values)
+ gncAccountValueDestroy (entry->priv->i_tax_values);
+ if (entry->priv->b_tax_values)
+ gncAccountValueDestroy (entry->priv->b_tax_values);
+ if (entry->priv->i_tax_table)
+ gncTaxTableDecRef (entry->priv->i_tax_table);
+ if (entry->priv->b_tax_table)
+ gncTaxTableDecRef (entry->priv->b_tax_table);
- qof_instance_release (&entry->inst);
- g_free (entry);
+ qof_instance_release (GNC_INSTANCE (entry));
}
GncEntry *
@@ -269,29 +387,29 @@
Timespec zero_time = { 0, 0 };
if (!entry) return;
- if (timespec_equal (&entry->date, &date)) return;
- if (timespec_equal (&entry->date, &zero_time))
+ if (timespec_equal (&entry->priv->date, &date)) return;
+ if (timespec_equal (&entry->priv->date, &zero_time))
first_date = TRUE;
gncEntryBeginEdit (entry);
- entry->date = date;
+ entry->priv->date = date;
mark_entry (entry);
gncEntryCommitEdit (entry);
/* Don't re-sort the first time we set the date on this entry */
if (!first_date) {
- if (entry->invoice)
- gncInvoiceSortEntries(entry->invoice);
- if (entry->bill)
- gncInvoiceSortEntries(entry->bill);
+ if (entry->priv->invoice)
+ gncInvoiceSortEntries(entry->priv->invoice);
+ if (entry->priv->bill)
+ gncInvoiceSortEntries(entry->priv->bill);
}
}
void gncEntrySetDateEntered (GncEntry *entry, Timespec date)
{
if (!entry) return;
- if (timespec_equal (&entry->date_entered, &date)) return;
+ if (timespec_equal (&entry->priv->date_entered, &date)) return;
gncEntryBeginEdit (entry);
- entry->date_entered = date;
+ entry->priv->date_entered = date;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -299,7 +417,7 @@
void gncEntrySetDescription (GncEntry *entry, const char *desc)
{
if (!entry || !desc) return;
- SET_STR (entry, entry->desc, desc);
+ SET_STR (entry, entry->priv->desc, desc);
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -307,7 +425,7 @@
void gncEntrySetAction (GncEntry *entry, const char *action)
{
if (!entry || !action) return;
- SET_STR (entry,entry->action, action);
+ SET_STR (entry,entry->priv->action, action);
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -315,7 +433,7 @@
void gncEntrySetNotes (GncEntry *entry, const char *notes)
{
if (!entry || !notes) return;
- SET_STR (entry, entry->notes, notes);
+ SET_STR (entry, entry->priv->notes, notes);
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -323,10 +441,10 @@
void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity)
{
if (!entry) return;
- if (gnc_numeric_eq (entry->quantity, quantity)) return;
+ if (gnc_numeric_eq (entry->priv->quantity, quantity)) return;
gncEntryBeginEdit (entry);
- entry->quantity = quantity;
- entry->values_dirty = TRUE;
+ entry->priv->quantity = quantity;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -336,9 +454,9 @@
void gncEntrySetInvAccount (GncEntry *entry, Account *acc)
{
if (!entry) return;
- if (entry->i_account == acc) return;
+ if (entry->priv->i_account == acc) return;
gncEntryBeginEdit (entry);
- entry->i_account = acc;
+ entry->priv->i_account = acc;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -346,10 +464,10 @@
void gncEntrySetInvPrice (GncEntry *entry, gnc_numeric price)
{
if (!entry) return;
- if (gnc_numeric_eq (entry->i_price, price)) return;
+ if (gnc_numeric_eq (entry->priv->i_price, price)) return;
gncEntryBeginEdit (entry);
- entry->i_price = price;
- entry->values_dirty = TRUE;
+ entry->priv->i_price = price;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -357,10 +475,10 @@
void gncEntrySetInvTaxable (GncEntry *entry, gboolean taxable)
{
if (!entry) return;
- if (entry->i_taxable == taxable) return;
+ if (entry->priv->i_taxable == taxable) return;
gncEntryBeginEdit (entry);
- entry->i_taxable = taxable;
- entry->values_dirty = TRUE;
+ entry->priv->i_taxable = taxable;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -368,10 +486,10 @@
void gncEntrySetInvTaxIncluded (GncEntry *entry, gboolean taxincluded)
{
if (!entry) return;
- if (entry->i_taxincluded == taxincluded) return;
+ if (entry->priv->i_taxincluded == taxincluded) return;
gncEntryBeginEdit (entry);
- entry->i_taxincluded = taxincluded;
- entry->values_dirty = TRUE;
+ entry->priv->i_taxincluded = taxincluded;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -379,14 +497,14 @@
void gncEntrySetInvTaxTable (GncEntry *entry, GncTaxTable *table)
{
if (!entry) return;
- if (entry->i_tax_table == table) return;
+ if (entry->priv->i_tax_table == table) return;
gncEntryBeginEdit (entry);
- if (entry->i_tax_table)
- gncTaxTableDecRef (entry->i_tax_table);
+ if (entry->priv->i_tax_table)
+ gncTaxTableDecRef (entry->priv->i_tax_table);
if (table)
gncTaxTableIncRef (table);
- entry->i_tax_table = table;
- entry->values_dirty = TRUE;
+ entry->priv->i_tax_table = table;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -394,10 +512,10 @@
void gncEntrySetInvDiscount (GncEntry *entry, gnc_numeric discount)
{
if (!entry) return;
- if (gnc_numeric_eq (entry->i_discount, discount)) return;
+ if (gnc_numeric_eq (entry->priv->i_discount, discount)) return;
gncEntryBeginEdit (entry);
- entry->i_discount = discount;
- entry->values_dirty = TRUE;
+ entry->priv->i_discount = discount;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -405,11 +523,11 @@
void gncEntrySetInvDiscountType (GncEntry *entry, GncAmountType type)
{
if (!entry) return;
- if (entry->i_disc_type == type) return;
+ if (entry->priv->i_disc_type == type) return;
gncEntryBeginEdit (entry);
- entry->i_disc_type = type;
- entry->values_dirty = TRUE;
+ entry->priv->i_disc_type = type;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -417,11 +535,11 @@
void gncEntrySetInvDiscountHow (GncEntry *entry, GncDiscountHow how)
{
if (!entry) return;
- if (entry->i_disc_how == how) return;
+ if (entry->priv->i_disc_how == how) return;
gncEntryBeginEdit (entry);
- entry->i_disc_how = how;
- entry->values_dirty = TRUE;
+ entry->priv->i_disc_how = how;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -432,10 +550,10 @@
if (!entry) return;
gncAmountStringToType(type_string, &type);
- if (entry->i_disc_type == type) return;
+ if (entry->priv->i_disc_type == type) return;
gncEntryBeginEdit (entry);
- entry->i_disc_type = type;
- entry->values_dirty = TRUE;
+ entry->priv->i_disc_type = type;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
@@ -448,9 +566,9 @@
if (!entry) return;
gncEntryBeginEdit (entry);
gncEntryDiscountStringToHow(type, &how);
- if (entry->i_disc_how == how) return;
- entry->i_disc_how = how;
- entry->values_dirty = TRUE;
+ if (entry->priv->i_disc_how == how) return;
+ entry->priv->i_disc_how = how;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -460,9 +578,9 @@
void gncEntrySetBillAccount (GncEntry *entry, Account *acc)
{
if (!entry) return;
- if (entry->b_account == acc) return;
+ if (entry->priv->b_account == acc) return;
gncEntryBeginEdit (entry);
- entry->b_account = acc;
+ entry->priv->b_account = acc;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -470,10 +588,10 @@
void gncEntrySetBillPrice (GncEntry *entry, gnc_numeric price)
{
if (!entry) return;
- if (gnc_numeric_eq (entry->b_price, price)) return;
+ if (gnc_numeric_eq (entry->priv->b_price, price)) return;
gncEntryBeginEdit (entry);
- entry->b_price = price;
- entry->values_dirty = TRUE;
+ entry->priv->b_price = price;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -481,10 +599,10 @@
void gncEntrySetBillTaxable (GncEntry *entry, gboolean taxable)
{
if (!entry) return;
- if (entry->b_taxable == taxable) return;
+ if (entry->priv->b_taxable == taxable) return;
gncEntryBeginEdit (entry);
- entry->b_taxable = taxable;
- entry->values_dirty = TRUE;
+ entry->priv->b_taxable = taxable;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -492,10 +610,10 @@
void gncEntrySetBillTaxIncluded (GncEntry *entry, gboolean taxincluded)
{
if (!entry) return;
- if (entry->b_taxincluded == taxincluded) return;
+ if (entry->priv->b_taxincluded == taxincluded) return;
gncEntryBeginEdit (entry);
- entry->b_taxincluded = taxincluded;
- entry->values_dirty = TRUE;
+ entry->priv->b_taxincluded = taxincluded;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -503,14 +621,14 @@
void gncEntrySetBillTaxTable (GncEntry *entry, GncTaxTable *table)
{
if (!entry) return;
- if (entry->b_tax_table == table) return;
+ if (entry->priv->b_tax_table == table) return;
gncEntryBeginEdit (entry);
- if (entry->b_tax_table)
- gncTaxTableDecRef (entry->b_tax_table);
+ if (entry->priv->b_tax_table)
+ gncTaxTableDecRef (entry->priv->b_tax_table);
if (table)
gncTaxTableIncRef (table);
- entry->b_tax_table = table;
- entry->values_dirty = TRUE;
+ entry->priv->b_tax_table = table;
+ entry->priv->values_dirty = TRUE;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -518,10 +636,10 @@
void gncEntrySetBillable (GncEntry *entry, gboolean billable)
{
if (!entry) return;
- if (entry->billable == billable) return;
+ if (entry->priv->billable == billable) return;
gncEntryBeginEdit (entry);
- entry->billable = billable;
+ entry->priv->billable = billable;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -529,10 +647,10 @@
void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto)
{
if (!entry || !billto) return;
- if (gncOwnerEqual (&entry->billto, billto)) return;
+ if (gncOwnerEqual (&entry->priv->billto, billto)) return;
gncEntryBeginEdit (entry);
- gncOwnerCopy (billto, &entry->billto);
+ gncOwnerCopy (billto, &entry->priv->billto);
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -540,9 +658,9 @@
void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type)
{
if (!entry) return;
- if (entry->b_payment == type) return;
+ if (entry->priv->b_payment == type) return;
gncEntryBeginEdit (entry);
- entry->b_payment = type;
+ entry->priv->b_payment = type;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -551,9 +669,9 @@
void gncEntrySetOrder (GncEntry *entry, GncOrder *order)
{
if (!entry) return;
- if (entry->order == order) return;
+ if (entry->priv->order == order) return;
gncEntryBeginEdit (entry);
- entry->order = order;
+ entry->priv->order = order;
mark_entry (entry);
gncEntryCommitEdit (entry);
@@ -568,9 +686,9 @@
void gncEntrySetInvoice (GncEntry *entry, GncInvoice *invoice)
{
if (!entry) return;
- if (entry->invoice == invoice) return;
+ if (entry->priv->invoice == invoice) return;
gncEntryBeginEdit (entry);
- entry->invoice = invoice;
+ entry->priv->invoice = invoice;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -579,9 +697,9 @@
void gncEntrySetBill (GncEntry *entry, GncInvoice *bill)
{
if (!entry) return;
- if (entry->bill == bill) return;
+ if (entry->priv->bill == bill) return;
gncEntryBeginEdit (entry);
- entry->bill = bill;
+ entry->priv->bill = bill;
mark_entry (entry);
gncEntryCommitEdit (entry);
}
@@ -640,38 +758,38 @@
{
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
if (!entry) return ts;
- return entry->date;
+ return entry->priv->date;
}
Timespec gncEntryGetDateEntered (GncEntry *entry)
{
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
if (!entry) return ts;
- return entry->date_entered;
+ return entry->priv->date_entered;
}
const char * gncEntryGetDescription (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->desc;
+ return entry->priv->desc;
}
const char * gncEntryGetAction (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->action;
+ return entry->priv->action;
}
const char * gncEntryGetNotes (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->notes;
+ return entry->priv->notes;
}
gnc_numeric gncEntryGetQuantity (GncEntry *entry)
{
if (!entry) return gnc_numeric_zero();
- return entry->quantity;
+ return entry->priv->quantity;
}
/* Customer Invoice */
@@ -679,31 +797,31 @@
Account * gncEntryGetInvAccount (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->i_account;
+ return entry->priv->i_account;
}
gnc_numeric gncEntryGetInvPrice (GncEntry *entry)
{
if (!entry) return gnc_numeric_zero();
- return entry->i_price;
+ return entry->priv->i_price;
}
gnc_numeric gncEntryGetInvDiscount (GncEntry *entry)
{
if (!entry) return gnc_numeric_zero();
- return entry->i_discount;
+ return entry->priv->i_discount;
}
GncAmountType gncEntryGetInvDiscountType (GncEntry *entry)
{
if (!entry) return 0;
- return entry->i_disc_type;
+ return entry->priv->i_disc_type;
}
GncDiscountHow gncEntryGetInvDiscountHow (GncEntry *entry)
{
if (!entry) return 0;
- return entry->i_disc_how;
+ return entry->priv->i_disc_how;
}
char* qofEntryGetInvDiscType (GncEntry *entry)
@@ -711,7 +829,7 @@
char *type_string;
if (!entry) return 0;
- type_string = g_strdup(gncAmountTypeToString(entry->i_disc_type));
+ type_string = g_strdup(gncAmountTypeToString(entry->priv->i_disc_type));
return type_string;
}
@@ -720,26 +838,26 @@
char *type_string;
if (!entry) return 0;
- type_string = g_strdup(gncEntryDiscountHowToString(entry->i_disc_how));
+ type_string = g_strdup(gncEntryDiscountHowToString(entry->priv->i_disc_how));
return type_string;
}
gboolean gncEntryGetInvTaxable (GncEntry *entry)
{
if (!entry) return FALSE;
- return entry->i_taxable;
+ return entry->priv->i_taxable;
}
gboolean gncEntryGetInvTaxIncluded (GncEntry *entry)
{
if (!entry) return FALSE;
- return entry->i_taxincluded;
+ return entry->priv->i_taxincluded;
}
GncTaxTable * gncEntryGetInvTaxTable (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->i_tax_table;
+ return entry->priv->i_tax_table;
}
/* vendor bills */
@@ -747,67 +865,67 @@
Account * gncEntryGetBillAccount (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->b_account;
+ return entry->priv->b_account;
}
gnc_numeric gncEntryGetBillPrice (GncEntry *entry)
{
if (!entry) return gnc_numeric_zero();
- return entry->b_price;
+ return entry->priv->b_price;
}
gboolean gncEntryGetBillTaxable (GncEntry *entry)
{
if (!entry) return FALSE;
- return entry->b_taxable;
+ return entry->priv->b_taxable;
}
gboolean gncEntryGetBillTaxIncluded (GncEntry *entry)
{
if (!entry) return FALSE;
- return entry->b_taxincluded;
+ return entry->priv->b_taxincluded;
}
GncTaxTable * gncEntryGetBillTaxTable (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->b_tax_table;
+ return entry->priv->b_tax_table;
}
gboolean gncEntryGetBillable (GncEntry *entry)
{
if (!entry) return FALSE;
- return entry->billable;
+ return entry->priv->billable;
}
GncOwner * gncEntryGetBillTo (GncEntry *entry)
{
if (!entry) return NULL;
- return &entry->billto;
+ return &entry->priv->billto;
}
GncEntryPaymentType gncEntryGetBillPayment (GncEntry* entry)
{
if (!entry) return 0;
- return entry->b_payment;
+ return entry->priv->b_payment;
}
GncInvoice * gncEntryGetInvoice (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->invoice;
+ return entry->priv->invoice;
}
GncInvoice * gncEntryGetBill (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->bill;
+ return entry->priv->bill;
}
GncOrder * gncEntryGetOrder (GncEntry *entry)
{
if (!entry) return NULL;
- return entry->order;
+ return entry->priv->order;
}
/* ================================================================ */
@@ -1027,13 +1145,13 @@
gnc_commodity *c;
if (!entry)
return 0;
- if (entry->invoice) {
- c = gncInvoiceGetCurrency (entry->invoice);
+ if (entry->priv->invoice) {
+ c = gncInvoiceGetCurrency (entry->priv->invoice);
if (c)
return (gnc_commodity_get_fraction (c));
}
- if (entry->bill) {
- c = gncInvoiceGetCurrency (entry->bill);
+ if (entry->priv->bill) {
+ c = gncInvoiceGetCurrency (entry->priv->bill);
if (c)
return (gnc_commodity_get_fraction (c));
}
@@ -1046,69 +1164,69 @@
int denom;
/* See if either tax table changed since we last computed values */
- if (entry->i_tax_table) {
- Timespec modtime = gncTaxTableLastModified (entry->i_tax_table);
- if (timespec_cmp (&entry->i_taxtable_modtime, &modtime)) {
- entry->values_dirty = TRUE;
- entry->i_taxtable_modtime = modtime;
+ if (entry->priv->i_tax_table) {
+ Timespec modtime = gncTaxTableLastModified (entry->priv->i_tax_table);
+ if (timespec_cmp (&entry->priv->i_taxtable_modtime, &modtime)) {
+ entry->priv->values_dirty = TRUE;
+ entry->priv->i_taxtable_modtime = modtime;
}
}
- if (entry->b_tax_table) {
- Timespec modtime = gncTaxTableLastModified (entry->b_tax_table);
- if (timespec_cmp (&entry->b_taxtable_modtime, &modtime)) {
- entry->values_dirty = TRUE;
- entry->b_taxtable_modtime = modtime;
+ if (entry->priv->b_tax_table) {
+ Timespec modtime = gncTaxTableLastModified (entry->priv->b_tax_table);
+ if (timespec_cmp (&entry->priv->b_taxtable_modtime, &modtime)) {
+ entry->priv->values_dirty = TRUE;
+ entry->priv->b_taxtable_modtime = modtime;
}
}
- if (!entry->values_dirty)
+ if (!entry->priv->values_dirty)
return;
/* Clear the last-computed tax values */
- if (entry->i_tax_values) {
- gncAccountValueDestroy (entry->i_tax_values);
- entry->i_tax_values = NULL;
+ if (entry->priv->i_tax_values) {
+ gncAccountValueDestroy (entry->priv->i_tax_values);
+ entry->priv->i_tax_values = NULL;
}
- if (entry->b_tax_values) {
- gncAccountValueDestroy (entry->b_tax_values);
- entry->b_tax_values = NULL;
+ if (entry->priv->b_tax_values) {
+ gncAccountValueDestroy (entry->priv->b_tax_values);
+ entry->priv->b_tax_values = NULL;
}
/* Determine the commodity denominator */
denom = get_entry_commodity_denom (entry);
/* Compute the invoice values */
- gncEntryComputeValue (entry->quantity, entry->i_price,
- (entry->i_taxable ? entry->i_tax_table : NULL),
- entry->i_taxincluded,
- entry->i_discount, entry->i_disc_type,
- entry->i_disc_how,
+ gncEntryComputeValue (entry->priv->quantity, entry->priv->i_price,
+ (entry->priv->i_taxable ? entry->priv->i_tax_table : NULL),
+ entry->priv->i_taxincluded,
+ entry->priv->i_discount, entry->priv->i_disc_type,
+ entry->priv->i_disc_how,
denom,
- &(entry->i_value), &(entry->i_disc_value),
- &(entry->i_tax_values));
+ &(entry->priv->i_value), &(entry->priv->i_disc_value),
+ &(entry->priv->i_tax_values));
/* Compute the bill values */
- gncEntryComputeValue (entry->quantity, entry->b_price,
- (entry->b_taxable ? entry->b_tax_table : NULL),
- entry->b_taxincluded,
+ gncEntryComputeValue (entry->priv->quantity, entry->priv->b_price,
+ (entry->priv->b_taxable ? entry->priv->b_tax_table : NULL),
+ entry->priv->b_taxincluded,
gnc_numeric_zero(), GNC_AMT_TYPE_VALUE, GNC_DISC_PRETAX,
denom,
- &(entry->b_value), NULL, &(entry->b_tax_values));
+ &(entry->priv->b_value), NULL, &(entry->priv->b_tax_values));
- entry->i_value_rounded = gnc_numeric_convert (entry->i_value, denom,
+ entry->priv->i_value_rounded = gnc_numeric_convert (entry->priv->i_value, denom,
GNC_RND_ROUND);
- entry->i_disc_value_rounded = gnc_numeric_convert (entry->i_disc_value, denom,
+ entry->priv->i_disc_value_rounded = gnc_numeric_convert (entry->priv->i_disc_value, denom,
GNC_RND_ROUND);
- entry->i_tax_value = gncAccountValueTotal (entry->i_tax_values);
- entry->i_tax_value_rounded = gnc_numeric_convert (entry->i_tax_value, denom,
+ entry->priv->i_tax_value = gncAccountValueTotal (entry->priv->i_tax_values);
+ entry->priv->i_tax_value_rounded = gnc_numeric_convert (entry->priv->i_tax_value, denom,
GNC_RND_ROUND);
- entry->b_value_rounded = gnc_numeric_convert (entry->b_value, denom,
+ entry->priv->b_value_rounded = gnc_numeric_convert (entry->priv->b_value, denom,
GNC_RND_ROUND);
- entry->b_tax_value = gncAccountValueTotal (entry->b_tax_values);
- entry->b_tax_value_rounded = gnc_numeric_convert (entry->b_tax_value, denom,
+ entry->priv->b_tax_value = gncAccountValueTotal (entry->priv->b_tax_values);
+ entry->priv->b_tax_value_rounded = gnc_numeric_convert (entry->priv->b_tax_value, denom,
GNC_RND_ROUND);
- entry->values_dirty = FALSE;
+ entry->priv->values_dirty = FALSE;
}
void gncEntryGetValue (GncEntry *entry, gboolean is_inv, gnc_numeric *value,
@@ -1118,55 +1236,55 @@
if (!entry) return;
gncEntryRecomputeValues (entry);
if (value)
- *value = (is_inv ? entry->i_value : entry->b_value);
+ *value = (is_inv ? entry->priv->i_value : entry->priv->b_value);
if (discount_value)
- *discount_value = (is_inv ? entry->i_disc_value : gnc_numeric_zero());
+ *discount_value = (is_inv ? entry->priv->i_disc_value : gnc_numeric_zero());
if (tax_value)
- *tax_value = (is_inv ? entry->i_tax_value : entry->b_tax_value);
+ *tax_value = (is_inv ? entry->priv->i_tax_value : entry->priv->b_tax_value);
if (tax_values)
- *tax_values = (is_inv ? entry->i_tax_values : entry->b_tax_values);
+ *tax_values = (is_inv ? entry->priv->i_tax_values : entry->priv->b_tax_values);
}
gnc_numeric gncEntryReturnValue (GncEntry *entry, gboolean is_inv)
{
if (!entry) return gnc_numeric_zero();
gncEntryRecomputeValues (entry);
- return (is_inv ? entry->i_value_rounded : entry->b_value_rounded);
+ return (is_inv ? entry->priv->i_value_rounded : entry->priv->b_value_rounded);
}
gnc_numeric gncEntryReturnTaxValue (GncEntry *entry, gboolean is_inv)
{
if (!entry) return gnc_numeric_zero();
gncEntryRecomputeValues (entry);
- return (is_inv ? entry->i_tax_value_rounded : entry->b_tax_value_rounded);
+ return (is_inv ? entry->priv->i_tax_value_rounded : entry->priv->b_tax_value_rounded);
}
AccountValueList * gncEntryReturnTaxValues (GncEntry *entry, gboolean is_inv)
{
if (!entry) return NULL;
gncEntryRecomputeValues (entry);
- return (is_inv ? entry->i_tax_values : entry->b_tax_values);
+ return (is_inv ? entry->priv->i_tax_values : entry->priv->b_tax_values);
}
gnc_numeric gncEntryReturnDiscountValue (GncEntry *entry, gboolean is_inv)
{
if (!entry) return gnc_numeric_zero();
gncEntryRecomputeValues (entry);
- return (is_inv ? entry->i_disc_value_rounded : gnc_numeric_zero());
+ return (is_inv ? entry->priv->i_disc_value_rounded : gnc_numeric_zero());
}
/* XXXX this exsitnace of this routine is just wrong */
gboolean gncEntryIsOpen (GncEntry *entry)
{
if (!entry) return FALSE;
- return (entry->inst.editlevel > 0);
+ return (entry->priv->inst.editlevel > 0);
}
/* ================================================================ */
void gncEntryBeginEdit (GncEntry *entry)
{
- QOF_BEGIN_EDIT (&entry->inst);
+ QOF_BEGIN_EDIT (GNC_INSTANCE (entry));
}
static void gncEntryOnError (QofInstance *entry, QofBackendError errcode)
@@ -1185,7 +1303,7 @@
void gncEntryCommitEdit (GncEntry *entry)
{
if (!qof_commit_edit (QOF_INSTANCE(entry))) return;
- qof_commit_edit_part2 (&entry->inst, gncEntryOnError,
+ qof_commit_edit_part2 (GNC_INSTANCE (entry), gncEntryOnError,
gncEntryOnDone, entry_free);
}
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncEntry.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncEntry.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncEntry.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -31,8 +31,36 @@
#ifndef GNC_ENTRY_H_
#define GNC_ENTRY_H_
-typedef struct _gncEntry GncEntry;
+/* GObject declarations */
+#define GNC_TYPE_ENTRY (gnc_entry_get_type ())
+#define GNC_ENTRY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ENTRY, GncEntry))
+#define GNC_ENTRY_CLASS (k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ENTRY, GncEntryClass))
+#define GNC_IS_ENTRY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ENTRY))
+#define GNC_IS_ENTRY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ENTRY))
+#define GNC_ENTRY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ENTRY, GncEntryClass))
+
+
+typedef struct _GncEntryClass GncEntryClass;
+typedef struct _GncEntryPrivate GncEntryPrivate;
+typedef struct _GncEntry GncEntry;
+typedef struct GncEntry gncEntry; /* Dummy type for backward compatibility */
+
+typedef struct _GncEntry {
+ QofInstance inst;
+ GncEntryPrivate *priv;
+};
+
+struct _GncEntryClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_entry_get_type ();
+
+
typedef enum {
GNC_PAYMENT_CASH = 1,
GNC_PAYMENT_CARD
@@ -53,8 +81,6 @@
#include "gncOwner.h"
#define GNC_ID_ENTRY "gncEntry"
-#define GNC_IS_ENTRY(obj) (QOF_CHECK_TYPE((obj), GNC_ID_ENTRY))
-#define GNC_ENTRY(obj) (QOF_CHECK_CAST((obj), GNC_ID_ENTRY, GncEntry))
/** How to apply the discount and taxes. There are three distinct ways to
* apply them:
@@ -64,7 +90,7 @@
* SAMETIME pretax pretax
* POSTTAX pretax+tax pretax
*/
-
+term->inst
const char * gncEntryDiscountHowToString (GncDiscountHow how);
gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how);
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncInvoice.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncInvoice.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -42,10 +42,17 @@
#include "gncInvoiceP.h"
#include "gncOwnerP.h"
-struct _gncInvoice
-{
- QofInstance inst;
-
+/* GObject declarations */
+
+static void gnc_invoice_class_init(GncInvoiceClass *klass);
+static void gnc_invoice_init(GncInvoice *sp);
+static void gnc_invoice_finalize(GObject *object);
+
+typedef struct _GncInvoiceSignal GncInvoiceSignal;
+typedef enum _GncInvoiceSignalType GncInvoiceSignalType;
+
+struct _GncInvoicePrivate
+{
char *id;
char *notes;
gboolean active;
@@ -69,6 +76,115 @@
GNCLot *posted_lot;
};
+enum _GncInvoiceSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncInvoiceSignal {
+ GncInvoice *object;
+};
+
+static guint gnc_invoice_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_invoice_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncInvoiceClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_invoice_class_init,
+ NULL,
+ NULL,
+ sizeof (GncInvoice),
+ 0,
+ (GInstanceInitFunc)gnc_invoice_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncInvoice", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_invoice_class_init(GncInvoiceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_invoice_finalize;
+ object_class->set_property = gnc_invoice_set_property;
+ object_class->get_property = gnc_invoice_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_invoice_init(GncInvoice *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_invoice_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_invoice_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncInvoice *obj;
+
+ obj = GNC_INVOICE (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_invoice_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncInvoice *obj;
+
+ obj = GNC_INVOICE (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
static QofLogModule log_module = GNC_MOD_BUSINESS;
#define _GNC_MOD_NAME GNC_ID_INVOICE
@@ -90,8 +206,8 @@
static void
mark_invoice (GncInvoice *invoice)
{
- qof_instance_set_dirty(&invoice->inst);
- qof_event_gen (&invoice->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(QOF_INSTANCE (invoice));
+ qof_event_gen (QOF_ENTITY (invoice), QOF_EVENT_MODIFY, NULL);
}
QofBook * gncInvoiceGetBook(GncInvoice *x)
@@ -109,18 +225,18 @@
if (!book) return NULL;
invoice = g_new0 (GncInvoice, 1);
- qof_instance_init (&invoice->inst, _GNC_MOD_NAME, book);
+ qof_instance_init (QOF_INSTANCE (invoice), _GNC_MOD_NAME, book);
- invoice->id = CACHE_INSERT ("");
- invoice->notes = CACHE_INSERT ("");
- invoice->billing_id = CACHE_INSERT ("");
+ invoice->priv->id = CACHE_INSERT ("");
+ invoice->priv->notes = CACHE_INSERT ("");
+ invoice->priv->billing_id = CACHE_INSERT ("");
- invoice->billto.type = GNC_OWNER_CUSTOMER;
- invoice->active = TRUE;
+ invoice->priv->billto.type = GNC_OWNER_CUSTOMER;
+ invoice->priv->active = TRUE;
- invoice->to_charge_amount = gnc_numeric_zero();
+ invoice->priv->to_charge_amount = gnc_numeric_zero();
- qof_event_gen (&invoice->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (invoice), QOF_EVENT_CREATE, NULL);
return invoice;
}
@@ -128,7 +244,7 @@
void gncInvoiceDestroy (GncInvoice *invoice)
{
if (!invoice) return;
- invoice->inst.do_free = TRUE;
+ qof_instance_mark_free (QOF_INSTANCE (invoice));
gncInvoiceCommitEdit (invoice);
}
@@ -136,20 +252,20 @@
{
if (!invoice) return;
- qof_event_gen (&invoice->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (invoice), QOF_EVENT_DESTROY, NULL);
- CACHE_REMOVE (invoice->id);
- CACHE_REMOVE (invoice->notes);
- CACHE_REMOVE (invoice->billing_id);
- g_list_free (invoice->entries);
+ CACHE_REMOVE (invoice->priv->id);
+ CACHE_REMOVE (invoice->priv->notes);
+ CACHE_REMOVE (invoice->priv->billing_id);
+ g_list_free (invoice->priv->entries);
- if (invoice->printname) g_free (invoice->printname);
+ if (invoice->priv->printname) g_free (invoice->priv->printname);
- if (invoice->terms)
- gncBillTermDecRef (invoice->terms);
+ if (invoice->priv->terms)
+ gncBillTermDecRef (invoice->priv->terms);
- qof_instance_release (&invoice->inst);
- g_free (invoice);
+ qof_instance_release (QOF_INSTANCE (invoice));
+
}
GncInvoice *
@@ -160,38 +276,40 @@
if (!book) return NULL;
- invoice = g_new0 (GncInvoice, 1);
- qof_instance_init (&invoice->inst, _GNC_MOD_NAME, book);
+ invoice = GNC_INVOICE (g_object_new (GNC_TYPE_INVOICE, NULL));
+ invoice->priv = g_new0 (GncInvoicePrivate, 1);
+
+ qof_instance_init (QOF_INSTANCE (invoice), _GNC_MOD_NAME, book);
- invoice->id = CACHE_INSERT (from->id);
- invoice->notes = CACHE_INSERT (from->notes);
- invoice->billing_id = CACHE_INSERT (from->billing_id);
- invoice->active = from->active;
+ invoice->priv->id = CACHE_INSERT (from->id);
+ invoice->priv->notes = CACHE_INSERT (from->notes);
+ invoice->priv->billing_id = CACHE_INSERT (from->billing_id);
+ invoice->priv->active = from->active;
- invoice->billto = gncCloneOwner (&from->billto, book);
- invoice->owner = gncCloneOwner (&from->owner, book);
- invoice->job = (GncJob*)gncJobObtainTwin (from->job, book);
- invoice->terms = gncBillTermObtainTwin (from->terms, book);
- gncBillTermIncRef (invoice->terms);
+ invoice->priv->billto = gncCloneOwner (&from->billto, book);
+ invoice->priv->owner = gncCloneOwner (&from->owner, book);
+ invoice->priv->job = (GncJob*)gncJobObtainTwin (from->job, book);
+ invoice->priv->terms = gncBillTermObtainTwin (from->terms, book);
+ gncBillTermIncRef (invoice->priv->terms);
- invoice->to_charge_amount = from->to_charge_amount;
- invoice->printname = NULL; /* that's right, NULL. See below. */
- invoice->date_opened = from->date_opened;
- invoice->date_posted = from->date_posted;
+ invoice->priv->to_charge_amount = from->to_charge_amount;
+ invoice->priv->printname = NULL; /* that's right, NULL. See below. */
+ invoice->priv->date_opened = from->date_opened;
+ invoice->priv->date_posted = from->date_posted;
- invoice->currency = gnc_commodity_obtain_twin (from->currency, book);
+ invoice->priv->currency = gnc_commodity_obtain_twin (from->currency, book);
- invoice->entries = NULL;
+ invoice->priv->entries = NULL;
for (node = g_list_last(from->entries); node; node=node->next)
{
GncEntry *entry = node->data;
entry = gncEntryObtainTwin (entry, book);
- invoice->entries = g_list_prepend (invoice->entries, entry);
+ invoice->priv->entries = g_list_prepend (invoice->priv->entries, entry);
}
/* XXX should probably be obtain-twin not lookup-twin */
- invoice->posted_acc =
+ invoice->priv->posted_acc =
GNC_ACCOUNT(qof_instance_lookup_twin(QOF_INSTANCE(from->posted_acc), book));
#if 0
XXX not done */
@@ -199,7 +317,7 @@
GNCLot * posted_lot;
#endif
- qof_event_gen (&invoice->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (invoice), QOF_EVENT_CREATE, NULL);
return invoice;
}
@@ -225,7 +343,7 @@
void gncInvoiceSetID (GncInvoice *invoice, const char *id)
{
if (!invoice || !id) return;
- SET_STR (invoice, invoice->id, id);
+ SET_STR (invoice, invoice->priv->id, id);
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -233,9 +351,9 @@
void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner)
{
if (!invoice || !owner) return;
- if (gncOwnerEqual (&invoice->owner, owner)) return;
+ if (gncOwnerEqual (&invoice->priv->owner, owner)) return;
gncInvoiceBeginEdit (invoice);
- gncOwnerCopy (owner, &invoice->owner);
+ gncOwnerCopy (owner, &invoice->priv->owner);
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -245,7 +363,7 @@
{
if(!invoice || !ent) { return; }
gncInvoiceBeginEdit (invoice);
- qofOwnerSetEntity(&invoice->owner, ent);
+ qofOwnerSetEntity(&invoice->priv->owner, ent);
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -255,7 +373,7 @@
{
if(!invoice || !ent) { return; }
gncInvoiceBeginEdit (invoice);
- qofOwnerSetEntity(&invoice->billto, ent);
+ qofOwnerSetEntity(&invoice->priv->billto, ent);
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -263,9 +381,9 @@
void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date)
{
if (!invoice) return;
- if (timespec_equal (&invoice->date_opened, &date)) return;
+ if (timespec_equal (&invoice->priv->date_opened, &date)) return;
gncInvoiceBeginEdit (invoice);
- invoice->date_opened = date;
+ invoice->priv->date_opened = date;
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -273,9 +391,9 @@
void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date)
{
if (!invoice) return;
- if (timespec_equal (&invoice->date_posted, &date)) return;
+ if (timespec_equal (&invoice->priv->date_posted, &date)) return;
gncInvoiceBeginEdit (invoice);
- invoice->date_posted = date;
+ invoice->priv->date_posted = date;
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -283,13 +401,13 @@
void gncInvoiceSetTerms (GncInvoice *invoice, GncBillTerm *terms)
{
if (!invoice) return;
- if (invoice->terms == terms) return;
+ if (invoice->priv->terms == terms) return;
gncInvoiceBeginEdit (invoice);
- if (invoice->terms)
- gncBillTermDecRef (invoice->terms);
- invoice->terms = terms;
- if (invoice->terms)
- gncBillTermIncRef (invoice->terms);
+ if (invoice->priv->terms)
+ gncBillTermDecRef (invoice->priv->terms);
+ invoice->priv->terms = terms;
+ if (invoice->priv->terms)
+ gncBillTermIncRef (invoice->priv->terms);
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -297,7 +415,7 @@
void gncInvoiceSetBillingID (GncInvoice *invoice, const char *billing_id)
{
if (!invoice) return;
- SET_STR (invoice, invoice->billing_id, billing_id);
+ SET_STR (invoice, invoice->priv->billing_id, billing_id);
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -305,7 +423,7 @@
void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes)
{
if (!invoice || !notes) return;
- SET_STR (invoice, invoice->notes, notes);
+ SET_STR (invoice, invoice->priv->notes, notes);
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -313,9 +431,9 @@
void gncInvoiceSetActive (GncInvoice *invoice, gboolean active)
{
if (!invoice) return;
- if (invoice->active == active) return;
+ if (invoice->priv->active == active) return;
gncInvoiceBeginEdit (invoice);
- invoice->active = active;
+ invoice->priv->active = active;
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -323,11 +441,11 @@
void gncInvoiceSetCurrency (GncInvoice *invoice, gnc_commodity *currency)
{
if (!invoice || !currency) return;
- if (invoice->currency &&
- gnc_commodity_equal (invoice->currency, currency))
+ if (invoice->priv->currency &&
+ gnc_commodity_equal (invoice->priv->currency, currency))
return;
gncInvoiceBeginEdit (invoice);
- invoice->currency = currency;
+ invoice->priv->currency = currency;
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -335,10 +453,10 @@
void gncInvoiceSetBillTo (GncInvoice *invoice, GncOwner *billto)
{
if (!invoice || !billto) return;
- if (gncOwnerEqual (&invoice->billto, billto)) return;
+ if (gncOwnerEqual (&invoice->priv->billto, billto)) return;
gncInvoiceBeginEdit (invoice);
- gncOwnerCopy (billto, &invoice->billto);
+ gncOwnerCopy (billto, &invoice->priv->billto);
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -346,9 +464,9 @@
void gncInvoiceSetToChargeAmount (GncInvoice *invoice, gnc_numeric amount)
{
if (!invoice) return;
- if (gnc_numeric_equal (invoice->to_charge_amount, amount)) return;
+ if (gnc_numeric_equal (invoice->priv->to_charge_amount, amount)) return;
gncInvoiceBeginEdit (invoice);
- invoice->to_charge_amount = amount;
+ invoice->priv->to_charge_amount = amount;
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -356,10 +474,10 @@
void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn)
{
if (!invoice) return;
- g_return_if_fail (invoice->posted_txn == NULL);
+ g_return_if_fail (invoice->priv->posted_txn == NULL);
gncInvoiceBeginEdit (invoice);
- invoice->posted_txn = txn;
+ invoice->priv->posted_txn = txn;
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -367,10 +485,10 @@
void gncInvoiceSetPostedLot (GncInvoice *invoice, GNCLot *lot)
{
if (!invoice) return;
- g_return_if_fail (invoice->posted_lot == NULL);
+ g_return_if_fail (invoice->priv->posted_lot == NULL);
gncInvoiceBeginEdit (invoice);
- invoice->posted_lot = lot;
+ invoice->priv->posted_lot = lot;
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -378,10 +496,10 @@
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc)
{
if (!invoice) return;
- g_return_if_fail (invoice->posted_acc == NULL);
+ g_return_if_fail (invoice->priv->posted_acc == NULL);
gncInvoiceBeginEdit (invoice);
- invoice->posted_acc = acc;
+ invoice->priv->posted_acc = acc;
mark_invoice (invoice);
gncInvoiceCommitEdit (invoice);
}
@@ -397,7 +515,7 @@
if (old) gncInvoiceRemoveEntry (old, entry);
gncEntrySetInvoice (entry, invoice);
- invoice->entries = g_list_insert_sorted (invoice->entries, entry,
+ invoice->priv->entries = g_list_insert_sorted (invoice->priv->entries, entry,
(GCompareFunc)gncEntryCompare);
mark_invoice (invoice);
}
@@ -407,7 +525,7 @@
if (!invoice || !entry) return;
gncEntrySetInvoice (entry, NULL);
- invoice->entries = g_list_remove (invoice->entries, entry);
+ invoice->priv->entries = g_list_remove (invoice->priv->entries, entry);
mark_invoice (invoice);
}
@@ -439,7 +557,7 @@
void gncInvoiceSortEntries (GncInvoice *invoice)
{
if (!invoice) return;
- invoice->entries = g_list_sort(invoice->entries,
+ invoice->priv->entries = g_list_sort(invoice->priv->entries,
(GCompareFunc)gncEntryCompare);
mark_invoice(invoice);
}
@@ -450,41 +568,41 @@
const char * gncInvoiceGetID (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return invoice->id;
+ return invoice->priv->id;
}
GncOwner * gncInvoiceGetOwner (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return &invoice->owner;
+ return &invoice->priv->owner;
}
static QofEntity*
qofInvoiceGetOwner (GncInvoice *invoice)
{
if(!invoice) { return NULL; }
- return (QofEntity*)&invoice->owner;
+ return (QofEntity*)&invoice->priv->owner;
}
static QofEntity*
qofInvoiceGetBillTo (GncInvoice *invoice)
{
if(!invoice) { return NULL; }
- return (QofEntity*)&invoice->billto;
+ return (QofEntity*)&invoice->priv->billto;
}
Timespec gncInvoiceGetDateOpened (GncInvoice *invoice)
{
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
if (!invoice) return ts;
- return invoice->date_opened;
+ return invoice->priv->date_opened;
}
Timespec gncInvoiceGetDatePosted (GncInvoice *invoice)
{
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
if (!invoice) return ts;
- return invoice->date_posted;
+ return invoice->priv->date_posted;
}
Timespec gncInvoiceGetDateDue (GncInvoice *invoice)
@@ -500,19 +618,19 @@
GncBillTerm * gncInvoiceGetTerms (GncInvoice *invoice)
{
if (!invoice) return 0;
- return invoice->terms;
+ return invoice->priv->terms;
}
const char * gncInvoiceGetBillingID (GncInvoice *invoice)
{
if (!invoice) return 0;
- return invoice->billing_id;
+ return invoice->priv->billing_id;
}
const char * gncInvoiceGetNotes (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return invoice->notes;
+ return invoice->priv->notes;
}
static GncOwnerType gncInvoiceGetOwnerType (GncInvoice *invoice)
@@ -604,50 +722,50 @@
gnc_commodity * gncInvoiceGetCurrency (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return invoice->currency;
+ return invoice->priv->currency;
}
GncOwner * gncInvoiceGetBillTo (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return &invoice->billto;
+ return &invoice->priv->billto;
}
GNCLot * gncInvoiceGetPostedLot (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return invoice->posted_lot;
+ return invoice->priv->posted_lot;
}
Transaction * gncInvoiceGetPostedTxn (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return invoice->posted_txn;
+ return invoice->priv->posted_txn;
}
Account * gncInvoiceGetPostedAcc (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return invoice->posted_acc;
+ return invoice->priv->posted_acc;
}
gboolean gncInvoiceGetActive (GncInvoice *invoice)
{
if (!invoice) return FALSE;
- return invoice->active;
+ return invoice->priv->active;
}
gnc_numeric gncInvoiceGetToChargeAmount (GncInvoice *invoice)
{
if (!invoice) return gnc_numeric_zero();
- return invoice->to_charge_amount;
+ return invoice->priv->to_charge_amount;
}
EntryList * gncInvoiceGetEntries (GncInvoice *invoice)
{
if (!invoice) return NULL;
- return invoice->entries;
+ return invoice->priv->entries;
}
static QofCollection*
@@ -699,14 +817,14 @@
qofInvoiceGetJob (GncInvoice *invoice)
{
if(!invoice) { return NULL; }
- return invoice->job;
+ return invoice->priv->job;
}
static void
qofInvoiceSetJob (GncInvoice *invoice, GncJob *job)
{
if(!invoice) { return; }
- invoice->job = job;
+ invoice->priv->job = job;
}
static void
@@ -729,7 +847,7 @@
if (!invoice || !lot)
return;
- if (invoice->posted_lot) return; /* Cannot reset invoice's lot */
+ if (invoice->priv->posted_lot) return; /* Cannot reset invoice's lot */
kvp = gnc_lot_get_slots (lot);
value = kvp_value_new_guid (qof_instance_get_guid (QOF_INSTANCE(invoice)));
@@ -765,7 +883,7 @@
if (!invoice || !txn)
return;
- if (invoice->posted_txn) return; /* Cannot reset invoice's txn */
+ if (invoice->priv->posted_txn) return; /* Cannot reset invoice's txn */
xaccTransBeginEdit (txn);
kvp = xaccTransGetSlots (txn);
@@ -845,9 +963,9 @@
gncInvoiceBeginEdit (invoice);
/* Stabilize the Billing Terms of this invoice */
- if (invoice->terms)
+ if (invoice->priv->terms)
gncInvoiceSetTerms (invoice,
- gncBillTermReturnChild (invoice->terms, TRUE));
+ gncBillTermReturnChild (invoice->priv->terms, TRUE));
/* Figure out if we need to "reverse" the numbers. */
reverse = (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_CUSTOMER);
@@ -875,7 +993,7 @@
/* Create a new lot for this invoice, if we need to do so */
if (!lot)
- lot = gnc_lot_new (invoice->inst.book);
+ lot = gnc_lot_new (qof_instance_get_book (QOF_INSTANCE (invoice));
type = gncInvoiceGetType (invoice);
@@ -885,7 +1003,7 @@
g_free (lot_title);
/* Create a new transaction */
- txn = xaccMallocTransaction (invoice->inst.book);
+ txn = xaccMallocTransaction (qof_instance_get_book (QOF_INSTANCE (invoice));
xaccTransBeginEdit (txn);
name = gncOwnerGetName (gncOwnerGetEndOwner (gncInvoiceGetOwner (invoice)));
@@ -893,7 +1011,7 @@
/* Set Transaction Description (Owner Name) , Num (invoice ID), Currency */
xaccTransSetDescription (txn, name ? name : "");
xaccTransSetNum (txn, gncInvoiceGetID (invoice));
- xaccTransSetCurrency (txn, invoice->currency);
+ xaccTransSetCurrency (txn, invoice->priv->currency);
/* Entered and Posted at date */
xaccTransSetDateEnteredSecs (txn, time(NULL));
@@ -943,7 +1061,7 @@
} else {
Split *split;
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (qof_instance_get_book (QOF_INSTANCE (invoice));
/* set action and memo? */
xaccSplitSetMemo (split, gncEntryGetDescription (entry));
@@ -959,7 +1077,7 @@
xaccTransAppendSplit (txn, split);
xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (value)
: value),
- invoice->currency);
+ invoice->priv->currency);
}
/* If there is a credit-card account, and this is a CCard
@@ -974,7 +1092,7 @@
if (ccard_acct && gncEntryGetBillPayment (entry) == GNC_PAYMENT_CARD) {
Split *split;
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (qof_instance_get_book (QOF_INSTANCE (invoice));
/* set action? */
xaccSplitSetMemo (split, gncEntryGetDescription (entry));
xaccSplitSetAction (split, type);
@@ -983,7 +1101,7 @@
xaccAccountCommitEdit (ccard_acct);
xaccTransAppendSplit (txn, split);
xaccSplitSetBaseValue (split, (reverse ? value : gnc_numeric_neg (value)),
- invoice->currency);
+ invoice->priv->currency);
} else
total = gnc_numeric_add (total, value, GNC_DENOM_AUTO, GNC_DENOM_LCD);
@@ -1008,7 +1126,7 @@
Split *split;
GncAccountValue *acc_val = iter->data;
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (qof_instance_get_book (QOF_INSTANCE (invoice));
/* set action and memo? */
xaccSplitSetMemo (split, memo);
@@ -1020,14 +1138,14 @@
xaccTransAppendSplit (txn, split);
xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (acc_val->value)
: acc_val->value),
- invoice->currency);
+ invoice->priv->currency);
}
/* If there is a ccard account, we may have an additional "to_card" payment.
* we should make that now..
*/
- if (ccard_acct && !gnc_numeric_zero_p (invoice->to_charge_amount)) {
- Split *split = xaccMallocSplit (invoice->inst.book);
+ if (ccard_acct && !gnc_numeric_zero_p (invoice->priv->to_charge_amount)) {
+ Split *split = xaccMallocSplit (qof_instance_get_book (QOF_INSTANCE (invoice));
/* Set memo. action? */
xaccSplitSetMemo (split, _("Extra to Charge Card"));
@@ -1037,17 +1155,17 @@
xaccAccountInsertSplit (ccard_acct, split);
xaccAccountCommitEdit (ccard_acct);
xaccTransAppendSplit (txn, split);
- xaccSplitSetBaseValue (split, (reverse ? invoice->to_charge_amount :
- gnc_numeric_neg(invoice->to_charge_amount)),
- invoice->currency);
+ xaccSplitSetBaseValue (split, (reverse ? invoice->priv->to_charge_amount :
+ gnc_numeric_neg(invoice->priv->to_charge_amount)),
+ invoice->priv->currency);
- total = gnc_numeric_sub (total, invoice->to_charge_amount,
+ total = gnc_numeric_sub (total, invoice->priv->to_charge_amount,
GNC_DENOM_AUTO, GNC_DENOM_LCD);
}
/* Now create the Posted split (which is negative -- it's a credit) */
{
- Split *split = xaccMallocSplit (invoice->inst.book);
+ Split *split = xaccMallocSplit (qof_instance_get_book (QOF_INSTANCE (invoice));
/* Set action/memo */
xaccSplitSetMemo (split, memo);
@@ -1058,7 +1176,7 @@
xaccAccountCommitEdit (acc);
xaccTransAppendSplit (txn, split);
xaccSplitSetBaseValue (split, (reverse ? total : gnc_numeric_neg (total)),
- invoice->currency);
+ invoice->priv->currency);
/* add this split to the lot */
gnc_lot_add_split (lot, split);
@@ -1090,8 +1208,8 @@
char *memo2 = _("Automatic Payment Forward");
char *action2 = _("Auto Split");
- t2 = xaccMallocTransaction (invoice->inst.book);
- lot2 = gnc_lot_new (invoice->inst.book);
+ t2 = xaccMallocTransaction (qof_instance_get_book (QOF_INSTANCE (invoice));
+ lot2 = gnc_lot_new (qof_instance_get_book (QOF_INSTANCE (invoice));
gncOwnerAttachToLot (gncOwnerGetEndOwner (gncInvoiceGetOwner (invoice)),
lot2);
@@ -1100,7 +1218,7 @@
/* Set Transaction Description (Owner Name), Currency */
xaccTransSetDescription (t2, name ? name : "");
- xaccTransSetCurrency (t2, invoice->currency);
+ xaccTransSetCurrency (t2, invoice->priv->currency);
/* Entered and Posted at date */
xaccTransSetDateEnteredSecs (t2, time(NULL));
@@ -1108,22 +1226,22 @@
xaccTransSetDatePostedTS (t2, post_date);
/* Balance out this lot */
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (qof_instance_get_book (QOF_INSTANCE (invoice));
xaccSplitSetMemo (split, memo2);
xaccSplitSetAction (split, action2);
xaccAccountInsertSplit (acc, split);
xaccTransAppendSplit (t2, split);
xaccSplitSetBaseValue (split, gnc_numeric_neg (total),
- invoice->currency);
+ invoice->priv->currency);
gnc_lot_add_split (lot, split);
/* And apply the pre-payment to a new lot */
- split = xaccMallocSplit (invoice->inst.book);
+ split = xaccMallocSplit (qof_instance_get_book (QOF_INSTANCE (invoice));
xaccSplitSetMemo (split, memo2);
xaccSplitSetAction (split, action2);
xaccAccountInsertSplit (acc, split);
xaccTransAppendSplit (t2, split);
- xaccSplitSetBaseValue (split, total, invoice->currency);
+ xaccSplitSetBaseValue (split, total, invoice->priv->currency);
gnc_lot_add_split (lot2, split);
xaccTransCommitEdit (t2);
@@ -1158,7 +1276,7 @@
/* Disconnect the lot from the invoice; re-attach to the invoice owner */
gncInvoiceDetachFromLot (lot);
- gncOwnerAttachToLot (&invoice->owner, lot);
+ gncOwnerAttachToLot (&invoice->priv->owner, lot);
/* If the lot has no splits, then destroy it */
if (!gnc_lot_count_splits (lot))
@@ -1167,10 +1285,10 @@
/* Clear out the invoice posted information */
gncInvoiceBeginEdit (invoice);
- invoice->posted_acc = NULL;
- invoice->posted_txn = NULL;
- invoice->posted_lot = NULL;
- invoice->date_posted.tv_sec = invoice->date_posted.tv_nsec = 0;
+ invoice->priv->posted_acc = NULL;
+ invoice->priv->posted_txn = NULL;
+ invoice->priv->posted_lot = NULL;
+ invoice->priv->date_posted.tv_sec = invoice->priv->date_posted.tv_nsec = 0;
/* if we've been asked to reset the tax tables, then do so */
if (reset_tax_tables) {
@@ -1385,7 +1503,7 @@
/* Now send an event for the invoice so it gets updated as paid */
this_invoice = gncInvoiceGetInvoiceFromLot(lot);
if (this_invoice)
- qof_event_gen (&this_invoice->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen (QOF_INSTANCE (&this_invoice), QOF_EVENT_MODIFY, NULL);
if (gnc_numeric_zero_p (amount))
break;
@@ -1428,21 +1546,21 @@
gboolean gncInvoiceIsPosted (GncInvoice *invoice)
{
if (!invoice) return FALSE;
- return gncInvoiceDateExists (&(invoice->date_posted));
+ return gncInvoiceDateExists (&(invoice->priv->date_posted));
}
gboolean gncInvoiceIsPaid (GncInvoice *invoice)
{
if (!invoice) return FALSE;
- if (!invoice->posted_lot) return FALSE;
- return gnc_lot_is_closed(invoice->posted_lot);
+ if (!invoice->priv->posted_lot) return FALSE;
+ return gnc_lot_is_closed(invoice->priv->posted_lot);
}
/* ================================================================== */
void gncInvoiceBeginEdit (GncInvoice *invoice)
{
- QOF_BEGIN_EDIT (&invoice->inst);
+ QOF_BEGIN_EDIT (QOF_INSTANCE (invoice));
}
static void gncInvoiceOnError (QofInstance *inst, QofBackendError errcode)
@@ -1461,7 +1579,7 @@
void gncInvoiceCommitEdit (GncInvoice *invoice)
{
if (!qof_commit_edit (QOF_INSTANCE(invoice))) return;
- qof_commit_edit_part2 (&invoice->inst, gncInvoiceOnError,
+ qof_commit_edit_part2 (QOF_INSTANCE (invoice), gncInvoiceOnError,
gncInvoiceOnDone, invoice_free);
}
@@ -1494,15 +1612,15 @@
g_return_val_if_fail (invoice, NULL);
- if (invoice->inst.dirty || invoice->printname == NULL) {
- if (invoice->printname) g_free (invoice->printname);
+ if (qof_instance_set_dirty (QOF_INSTANCE (invoice)) || invoice->priv->printname == NULL) {
+ if (invoice->priv->printname) g_free (invoice->priv->printname);
- invoice->printname =
- g_strdup_printf ("%s%s", invoice->id,
+ invoice->priv->printname =
+ g_strdup_printf ("%s%s", invoice->priv->id,
gncInvoiceIsPosted (invoice) ? _(" (posted)") : "");
}
- return invoice->printname;
+ return invoice->priv->printname;
}
static QofObject gncInvoiceDesc =
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncInvoice.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncInvoice.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncInvoice.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -36,18 +36,42 @@
#ifndef GNC_INVOICE_H_
#define GNC_INVOICE_H_
-struct _gncInvoice;
-typedef struct _gncInvoice GncInvoice;
-
#include "gncBillTerm.h"
#include "gncEntry.h"
#include "gncOwner.h"
#include "gnc-lot.h"
#include "qofbook.h"
+/* GObject declarations */
+
+#define GNC_TYPE_INVOICE (gnc_invoice_get_type ())
+#define GNC_INVOICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_INVOICE, GncInvoice))
+#define GNC_INVOICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_INVOICE, GncInvoiceClass))
+#define GNC_IS_INVOICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_INVOICE))
+#define GNC_IS_INVOICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_INVOICE))
+#define GNC_INVOICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_INVOICE, GncInvoiceClass))
+
+
+typedef struct _GncInvoiceClass GncInvoiceClass;
+typedef struct _GncInvoicePrivate GncInvoicePrivate;
+typedef struct _GncInvoice GncInvoice;
+
+struct _GncInvoice {
+ QofInstance inst;
+ GncInvoicePrivate *priv;
+}
+
+struct _GncInvoiceClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_invoice_get_type ();
+
+
#define GNC_ID_INVOICE "gncInvoice"
-#define GNC_IS_INVOICE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_INVOICE))
-#define GNC_INVOICE(obj) (QOF_CHECK_CAST((obj), GNC_ID_INVOICE, GncInvoice))
/** @name Create/Destroy Functions
@{ */
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncJob.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncJob.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncJob.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -36,28 +36,144 @@
#include "gncJobP.h"
#include "gncOwnerP.h"
-struct _gncJob
+static QofLogModule log_module = GNC_MOD_BUSINESS;
+
+#define _GNC_MOD_NAME GNC_ID_JOB
+
+/* GObject declarations */
+
+static void gnc_job_class_init(GncJobClass *klass);
+static void gnc_job_init(GncJob *sp);
+static void gnc_job_finalize(GObject *object);
+
+struct _GncJobPrivate
{
- QofInstance inst;
char * id;
char * name;
char * desc;
GncOwner owner;
gboolean active;
};
+typedef struct _GncJobSignal GncJobSignal;
+typedef enum _GncJobSignalType GncJobSignalType;
-static QofLogModule log_module = GNC_MOD_BUSINESS;
+enum _GncJobSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
-#define _GNC_MOD_NAME GNC_ID_JOB
+/* properties */
+enum
+{
+ PROP_0
+};
+struct _GncJobSignal {
+ GncJob *object;
+};
+
+static guint gnc_job_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_job_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncJobClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_job_class_init,
+ NULL,
+ NULL,
+ sizeof (GncJob),
+ 0,
+ (GInstanceInitFunc)gnc_job_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncJob", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_job_class_init(GncJobClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_job_finalize;
+ object_class->set_property = gnc_job_set_property;
+ object_class->get_property = gnc_job_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_job_init(GncJob *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_job_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_job_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncJob *obj;
+
+ obj = QOF_BOOK (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_job_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncJob *obj;
+
+ obj = QOF_BOOK(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
/* ================================================================== */
/* misc inline functions */
G_INLINE_FUNC void mark_job (GncJob *job);
void mark_job (GncJob *job)
{
- qof_instance_set_dirty(&job->inst);
- qof_event_gen (&job->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(QOF_INSTANCE (job));
+ qof_event_gen (QOF_ENTITY (job), QOF_EVENT_MODIFY, NULL);
}
/* ================================================================== */
@@ -69,16 +185,18 @@
if (!book) return NULL;
- job = g_new0 (GncJob, 1);
- qof_instance_init (&job->inst, _GNC_MOD_NAME, book);
+ job = GNC_JOB (g_object_new (GNC_TYPE_JOB, NULL));
+ job->priv = g_new0 (GncJobPrivate, 1);
+
+ qof_instance_init (QOF_INSTANCE (job), _GNC_MOD_NAME, book);
- job->id = CACHE_INSERT ("");
- job->name = CACHE_INSERT ("");
- job->desc = CACHE_INSERT ("");
- job->active = TRUE;
+ job->priv->id = CACHE_INSERT ("");
+ job->priv->name = CACHE_INSERT ("");
+ job->priv->desc = CACHE_INSERT ("");
+ job->priv->active = TRUE;
/* GncOwner not initialized */
- qof_event_gen (&job->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (job), QOF_EVENT_CREATE, NULL);
return job;
}
@@ -91,17 +209,17 @@
if (!book) return NULL;
job = g_new0 (GncJob, 1);
- qof_instance_init (&job->inst, _GNC_MOD_NAME, book);
- qof_instance_gemini (&job->inst, &from->inst);
+ qof_instance_init (QOF_INSTANCE (job), _GNC_MOD_NAME, book);
+ qof_instance_gemini (QOF_INSTANCE (job), &from->inst);
- job->id = CACHE_INSERT (from->id);
- job->name = CACHE_INSERT (from->name);
- job->desc = CACHE_INSERT (from->desc);
- job->active = from->active;
+ job->priv->id = CACHE_INSERT (from->id);
+ job->priv->name = CACHE_INSERT (from->name);
+ job->priv->desc = CACHE_INSERT (from->desc);
+ job->priv->active = from->active;
- job->owner = gncCloneOwner(&from->owner, book);
+ job->priv->owner = gncCloneOwner(&from->owner, book);
- qof_event_gen (&job->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (job), QOF_EVENT_CREATE, NULL);
return job;
}
@@ -109,7 +227,7 @@
void gncJobDestroy (GncJob *job)
{
if (!job) return;
- job->inst.do_free = TRUE;
+ job->priv->inst.do_free = TRUE;
gncJobCommitEdit (job);
}
@@ -117,25 +235,24 @@
{
if (!job) return;
- qof_event_gen (&job->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (job), QOF_EVENT_DESTROY, NULL);
- CACHE_REMOVE (job->id);
- CACHE_REMOVE (job->name);
- CACHE_REMOVE (job->desc);
+ CACHE_REMOVE (job->priv->id);
+ CACHE_REMOVE (job->priv->name);
+ CACHE_REMOVE (job->priv->desc);
- switch (gncOwnerGetType (&(job->owner))) {
+ switch (gncOwnerGetType (&(job->priv->owner))) {
case GNC_OWNER_CUSTOMER:
- gncCustomerRemoveJob (gncOwnerGetCustomer(&job->owner), job);
+ gncCustomerRemoveJob (gncOwnerGetCustomer(&job->priv->owner), job);
break;
case GNC_OWNER_VENDOR:
- gncVendorRemoveJob (gncOwnerGetVendor(&job->owner), job);
+ gncVendorRemoveJob (gncOwnerGetVendor(&job->priv->owner), job);
break;
default:
break;
}
- qof_instance_release (&job->inst);
- g_free (job);
+ qof_instance_release (QOF_INSTANCE (job));
}
GncJob *
@@ -169,7 +286,7 @@
{
if (!job) return;
if (!id) return;
- SET_STR(job, job->id, id);
+ SET_STR(job, job->priv->id, id);
mark_job (job);
gncJobCommitEdit (job);
}
@@ -178,7 +295,7 @@
{
if (!job) return;
if (!name) return;
- SET_STR(job, job->name, name);
+ SET_STR(job, job->priv->name, name);
mark_job (job);
gncJobCommitEdit (job);
}
@@ -187,7 +304,7 @@
{
if (!job) return;
if (!desc) return;
- SET_STR(job, job->desc, desc);
+ SET_STR(job, job->priv->desc, desc);
mark_job (job);
gncJobCommitEdit (job);
}
@@ -196,7 +313,7 @@
{
if (!job) return;
if (!owner) return;
- if (gncOwnerEqual (owner, &(job->owner))) return;
+ if (gncOwnerEqual (owner, &(job->priv->owner))) return;
switch (gncOwnerGetType (owner)) {
case GNC_OWNER_CUSTOMER:
@@ -209,25 +326,25 @@
gncJobBeginEdit (job);
- switch (gncOwnerGetType (&(job->owner))) {
+ switch (gncOwnerGetType (&(job->priv->owner))) {
case GNC_OWNER_CUSTOMER:
- gncCustomerRemoveJob (gncOwnerGetCustomer(&job->owner), job);
+ gncCustomerRemoveJob (gncOwnerGetCustomer(&job->priv->owner), job);
break;
case GNC_OWNER_VENDOR:
- gncVendorRemoveJob (gncOwnerGetVendor(&job->owner), job);
+ gncVendorRemoveJob (gncOwnerGetVendor(&job->priv->owner), job);
break;
default:
break;
}
- gncOwnerCopy (owner, &(job->owner));
+ gncOwnerCopy (owner, &(job->priv->owner));
- switch (gncOwnerGetType (&(job->owner))) {
+ switch (gncOwnerGetType (&(job->priv->owner))) {
case GNC_OWNER_CUSTOMER:
- gncCustomerAddJob (gncOwnerGetCustomer(&job->owner), job);
+ gncCustomerAddJob (gncOwnerGetCustomer(&job->priv->owner), job);
break;
case GNC_OWNER_VENDOR:
- gncVendorAddJob (gncOwnerGetVendor(&job->owner), job);
+ gncVendorAddJob (gncOwnerGetVendor(&job->priv->owner), job);
break;
default:
break;
@@ -240,9 +357,9 @@
void gncJobSetActive (GncJob *job, gboolean active)
{
if (!job) return;
- if (active == job->active) return;
+ if (active == job->priv->active) return;
gncJobBeginEdit (job);
- job->active = active;
+ job->priv->active = active;
mark_job (job);
gncJobCommitEdit (job);
}
@@ -251,15 +368,15 @@
qofJobSetOwner (GncJob *job, QofEntity *ent)
{
if(!job || !ent) { return; }
- qof_begin_edit(&job->inst);
- qofOwnerSetEntity(&job->owner, ent);
+ qof_begin_edit(QOF_INSTANCE (job));
+ qofOwnerSetEntity(&job->priv->owner, ent);
mark_job (job);
- qof_commit_edit(&job->inst);
+ qof_commit_edit(QOF_INSTANCE (job));
}
void gncJobBeginEdit (GncJob *job)
{
- QOF_BEGIN_EDIT (&job->inst);
+ QOF_BEGIN_EDIT (QOF_INSTANCE (job));
}
static void gncJobOnError (QofInstance *inst, QofBackendError errcode)
@@ -278,7 +395,7 @@
void gncJobCommitEdit (GncJob *job)
{
if (!qof_commit_edit (QOF_INSTANCE(job))) return;
- qof_commit_edit_part2 (&job->inst, gncJobOnError,
+ qof_commit_edit_part2 (QOF_INSTANCE (job), gncJobOnError,
gncJobOnDone, job_free);
}
@@ -288,38 +405,38 @@
const char * gncJobGetID (GncJob *job)
{
if (!job) return NULL;
- return job->id;
+ return job->priv->id;
}
const char * gncJobGetName (GncJob *job)
{
if (!job) return NULL;
- return job->name;
+ return job->priv->name;
}
const char * gncJobGetReference (GncJob *job)
{
if (!job) return NULL;
- return job->desc;
+ return job->priv->desc;
}
GncOwner * gncJobGetOwner (GncJob *job)
{
if (!job) return NULL;
- return &(job->owner);
+ return &(job->priv->owner);
}
gboolean gncJobGetActive (GncJob *job)
{
if (!job) return FALSE;
- return job->active;
+ return job->priv->active;
}
static QofEntity*
qofJobGetOwner (GncJob *job)
{
if(!job) { return NULL; }
- return (QofEntity*)qofOwnerGetOwner(&job->owner);
+ return (QofEntity*)qofOwnerGetOwner(&job->priv->owner);
}
/* Other functions */
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncJob.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncJob.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncJob.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -36,13 +36,40 @@
#include "gncAddress.h"
#include "gncOwner.h"
+/* GObject declarations */
+
+#define GNC_TYPE_JOB (gnc_job_get_type ())
+#define GNC_JOB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_JOB, GncJob))
+#define GNC_JOB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_JOB, GncJobClass))
+#define GNC_IS_JOB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_JOB))
+#define GNC_IS_JOB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_JOB))
+#define GNC_JOB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_JOB, GncJobClass))
+
+
+typedef struct _GncJobClass GncJobClass;
+typedef struct _GncJobPrivate GncJobPrivate;
+typedef struct _GncJob GncJob;
+
+struct _GncJob {
+ QofInstance inst;
+ GncJobPrivate *priv;
+};
+
+struct _GncJobClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_job_get_type ();
+
+
#define GNC_ID_JOB "gncJob"
-#define GNC_IS_JOB(obj) (QOF_CHECK_TYPE((obj), GNC_ID_JOB))
-#define GNC_JOB(obj) (QOF_CHECK_CAST((obj), GNC_ID_JOB, GncJob))
/* Create/Destroy Functions */
-GncJob *gncJobCreate (QofBook *book);
+GncJob *gncJobCreate (GncJob *book);
void gncJobDestroy (GncJob *job);
/** \name Set Functions
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncOrder.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncOrder.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncOrder.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -37,10 +37,14 @@
#include "gncOwner.h"
#include "gncOwnerP.h"
-struct _gncOrder
+/* GObject declarations */
+
+static void gnc_order_class_init(GncOrderClass *klass);
+static void gnc_order_init(GncOrder *sp);
+static void gnc_order_finalize(GObject *object);
+
+struct _GncOrderPrivate
{
- QofInstance inst;
-
char * id;
char * notes;
gboolean active;
@@ -53,6 +57,118 @@
Timespec closed;
};
+typedef struct _GncOrderSignal GncOrderSignal;
+typedef enum _GncOrderSignalType GncOrderSignalType;
+
+enum _GncOrderSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncOrderSignal {
+ GncOrder *object;
+};
+
+static guint gnc_order_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_order_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncOrderClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_order_class_init,
+ NULL,
+ NULL,
+ sizeof (GncOrder),
+ 0,
+ (GInstanceInitFunc)gnc_order_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncOrder", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_order_class_init(GncOrderClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_order_finalize;
+ object_class->set_property = gnc_order_set_property;
+ object_class->get_property = gnc_order_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_order_init(GncOrder *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_order_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_order_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncOrder *obj;
+
+ obj = GNC_ORDER (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_order_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncOrder *obj;
+
+ obj = GNC_ORDER (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
static QofLogModule log_module = GNC_MOD_BUSINESS;
#define _GNC_MOD_NAME GNC_ID_ORDER
@@ -70,8 +186,8 @@
G_INLINE_FUNC void mark_order (GncOrder *order);
void mark_order (GncOrder *order)
{
- qof_instance_set_dirty(&order->inst);
- qof_event_gen (&order->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(QOF_INSTANCE (order));
+ qof_event_gen (QOF_ENTITY (order), QOF_EVENT_MODIFY, NULL);
}
/* =============================================================== */
@@ -83,16 +199,18 @@
if (!book) return NULL;
- order = g_new0 (GncOrder, 1);
- qof_instance_init (&order->inst, _GNC_MOD_NAME, book);
+ order = GNC_ORDER (g_object_new (GNC_TYPE_ORDER, NULL));
+ order->priv = g_new0 (GncOrderPrivate, 1);
+
+ qof_instance_init (QOF_INSTANCE (order), _GNC_MOD_NAME, book);
- order->id = CACHE_INSERT ("");
- order->notes = CACHE_INSERT ("");
- order->reference = CACHE_INSERT ("");
+ order->priv->id = CACHE_INSERT ("");
+ order->priv->notes = CACHE_INSERT ("");
+ order->priv->reference = CACHE_INSERT ("");
- order->active = TRUE;
+ order->priv->active = TRUE;
- qof_event_gen (&order->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (order), QOF_EVENT_CREATE, NULL);
return order;
}
@@ -100,7 +218,7 @@
void gncOrderDestroy (GncOrder *order)
{
if (!order) return;
- order->inst.do_free = TRUE;
+ order->priv->inst.do_free = TRUE;
gncOrderCommitEdit (order);
}
@@ -108,17 +226,16 @@
{
if (!order) return;
- qof_event_gen (&order->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (order), QOF_EVENT_DESTROY, NULL);
- g_list_free (order->entries);
- CACHE_REMOVE (order->id);
- CACHE_REMOVE (order->notes);
- CACHE_REMOVE (order->reference);
+ g_list_free (order->priv->entries);
+ CACHE_REMOVE (order->priv->id);
+ CACHE_REMOVE (order->priv->notes);
+ CACHE_REMOVE (order->priv->reference);
- if (order->printname) g_free (order->printname);
+ if (order->priv->printname) g_free (order->priv->printname);
- qof_instance_release (&order->inst);
- g_free (order);
+ qof_instance_release (QOF_INSTANCE (order));
}
GncOrder *
@@ -128,31 +245,32 @@
GncOrder *order;
if (!book) return NULL;
+ order = GNC_ORDER (g_object_new (GNC_TYPE_ORDER, NULL))
+ order->priv = g_new0 (GncOrder, 1);
+
+ qof_instance_init (QOF_INSTANCE (order), _GNC_MOD_NAME, book);
+ qof_instance_gemini (QOF_INSTANCE (order), &from->inst);
- order = g_new0 (GncOrder, 1);
- qof_instance_init (&order->inst, _GNC_MOD_NAME, book);
- qof_instance_gemini (&order->inst, &from->inst);
+ order->priv->id = CACHE_INSERT (from->id);
+ order->priv->notes = CACHE_INSERT (from->notes);
+ order->priv->reference = CACHE_INSERT (from->reference);
- order->id = CACHE_INSERT (from->id);
- order->notes = CACHE_INSERT (from->notes);
- order->reference = CACHE_INSERT (from->reference);
+ order->priv->active = from->active;
+ order->priv->printname = NULL; /* yes, null, that's right */
+ order->priv->opened = from->opened;
+ order->priv->closed = from->closed;
- order->active = from->active;
- order->printname = NULL; /* yes, null, that's right */
- order->opened = from->opened;
- order->closed = from->closed;
+ order->priv->owner = gncCloneOwner (&from->owner, book);
- order->owner = gncCloneOwner (&from->owner, book);
-
- order->entries = NULL;
+ order->priv->entries = NULL;
for (node = g_list_last(from->entries); node; node=node->prev)
{
GncEntry *entry = node->data;
entry = gncEntryObtainTwin (entry, book);
- order->entries = g_list_prepend (order->entries, entry);
+ order->priv->entries = g_list_prepend (order->priv->entries, entry);
}
- qof_event_gen (&order->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (order), QOF_EVENT_CREATE, NULL);
return order;
}
@@ -178,7 +296,7 @@
void gncOrderSetID (GncOrder *order, const char *id)
{
if (!order || !id) return;
- SET_STR (order, order->id, id);
+ SET_STR (order, order->priv->id, id);
mark_order (order);
gncOrderCommitEdit (order);
}
@@ -186,10 +304,10 @@
void gncOrderSetOwner (GncOrder *order, GncOwner *owner)
{
if (!order || !owner) return;
- if (gncOwnerEqual (&order->owner, owner)) return;
+ if (gncOwnerEqual (&order->priv->owner, owner)) return;
gncOrderBeginEdit (order);
- gncOwnerCopy (owner, &order->owner);
+ gncOwnerCopy (owner, &order->priv->owner);
mark_order (order);
gncOrderCommitEdit (order);
}
@@ -197,9 +315,9 @@
void gncOrderSetDateOpened (GncOrder *order, Timespec date)
{
if (!order) return;
- if (timespec_equal (&order->opened, &date)) return;
+ if (timespec_equal (&order->priv->opened, &date)) return;
gncOrderBeginEdit (order);
- order->opened = date;
+ order->priv->opened = date;
mark_order (order);
gncOrderCommitEdit (order);
}
@@ -207,9 +325,9 @@
void gncOrderSetDateClosed (GncOrder *order, Timespec date)
{
if (!order) return;
- if (timespec_equal (&order->closed, &date)) return;
+ if (timespec_equal (&order->priv->closed, &date)) return;
gncOrderBeginEdit (order);
- order->closed = date;
+ order->priv->closed = date;
mark_order (order);
gncOrderCommitEdit (order);
}
@@ -217,7 +335,7 @@
void gncOrderSetNotes (GncOrder *order, const char *notes)
{
if (!order || !notes) return;
- SET_STR (order, order->notes, notes);
+ SET_STR (order, order->priv->notes, notes);
mark_order (order);
gncOrderCommitEdit (order);
}
@@ -225,7 +343,7 @@
void gncOrderSetReference (GncOrder *order, const char *reference)
{
if (!order || !reference) return;
- SET_STR (order, order->reference, reference);
+ SET_STR (order, order->priv->reference, reference);
mark_order (order);
gncOrderCommitEdit (order);
}
@@ -233,9 +351,9 @@
void gncOrderSetActive (GncOrder *order, gboolean active)
{
if (!order) return;
- if (order->active == active) return;
+ if (order->priv->active == active) return;
gncOrderBeginEdit (order);
- order->active = active;
+ order->priv->active = active;
mark_order (order);
gncOrderCommitEdit (order);
}
@@ -252,7 +370,7 @@
if (old == order) return; /* I already own it */
if (old) gncOrderRemoveEntry (old, entry);
- order->entries = g_list_insert_sorted (order->entries, entry,
+ order->priv->entries = g_list_insert_sorted (order->priv->entries, entry,
(GCompareFunc)gncEntryCompare);
/* This will send out an event -- make sure we're attached */
@@ -265,7 +383,7 @@
if (!order || !entry) return;
gncEntrySetOrder (entry, NULL);
- order->entries = g_list_remove (order->entries, entry);
+ order->priv->entries = g_list_remove (order->priv->entries, entry);
mark_order (order);
}
@@ -274,58 +392,58 @@
const char * gncOrderGetID (GncOrder *order)
{
if (!order) return NULL;
- return order->id;
+ return order->priv->id;
}
GncOwner * gncOrderGetOwner (GncOrder *order)
{
if (!order) return NULL;
- return &order->owner;
+ return &order->priv->owner;
}
Timespec gncOrderGetDateOpened (GncOrder *order)
{
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
if (!order) return ts;
- return order->opened;
+ return order->priv->opened;
}
Timespec gncOrderGetDateClosed (GncOrder *order)
{
Timespec ts; ts.tv_sec = 0; ts.tv_nsec = 0;
if (!order) return ts;
- return order->closed;
+ return order->priv->closed;
}
const char * gncOrderGetNotes (GncOrder *order)
{
if (!order) return NULL;
- return order->notes;
+ return order->priv->notes;
}
const char * gncOrderGetReference (GncOrder *order)
{
if (!order) return NULL;
- return order->reference;
+ return order->priv->reference;
}
gboolean gncOrderGetActive (GncOrder *order)
{
if (!order) return FALSE;
- return order->active;
+ return order->priv->active;
}
/* Get the list Entries */
GList * gncOrderGetEntries (GncOrder *order)
{
if (!order) return NULL;
- return order->entries;
+ return order->priv->entries;
}
gboolean gncOrderIsClosed (GncOrder *order)
{
if (!order) return FALSE;
- if (order->closed.tv_sec || order->closed.tv_nsec) return TRUE;
+ if (order->priv->closed.tv_sec || order->priv->closed.tv_nsec) return TRUE;
return FALSE;
}
@@ -333,7 +451,7 @@
void gncOrderBeginEdit (GncOrder *order)
{
- qof_begin_edit(&order->inst);
+ qof_begin_edit(QOF_INSTANCE (order));
}
static void gncOrderOnError (QofInstance *order, QofBackendError errcode)
@@ -352,7 +470,7 @@
void gncOrderCommitEdit (GncOrder *order)
{
if (!qof_commit_edit (QOF_INSTANCE(order))) return;
- qof_commit_edit_part2 (&order->inst, gncOrderOnError,
+ qof_commit_edit_part2 (QOF_INSTANCE (order), gncOrderOnError,
gncOrderOnDone, order_free);
}
@@ -386,15 +504,15 @@
g_return_val_if_fail (order, NULL);
- if (order->inst.dirty || order->printname == NULL) {
- if (order->printname) g_free (order->printname);
+ if (qof_instance_is_dirty (QOF_INSTANCE (order)) || order->priv->printname == NULL) {
+ if (order->priv->printname) g_free (order->priv->printname);
- order->printname =
- g_strdup_printf ("%s%s", order->id,
+ order->priv->printname =
+ g_strdup_printf ("%s%s", order->priv->id,
gncOrderIsClosed (order) ? _(" (closed)") : "");
}
- return order->printname;
+ return order->priv->printname;
}
static QofObject gncOrderDesc =
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncOrder.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncOrder.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncOrder.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -40,9 +40,30 @@
#include "gncOwner.h"
#include "qof.h"
+/* GObject declarations */
+
+#define GNC_TYPE_ORDER (gnc_order_get_type ())
+#define GNC_ORDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ORDER, GncOrder))
+#define GNC_ORDER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ORDER, GncOrderClass))
+#define GNC_IS_ORDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ORDER))
+#define GNC_IS_ORDER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ORDER))
+#define GNC_ORDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ORDER, GncOrderClass))
+
+
+typedef struct _GncOrderClass GncOrderClass;
+typedef struct _GncOrder GncOrder;
+
+struct _GncOrderClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_order_get_type ();
+
+
#define GNC_ID_ORDER "gncOrder"
-#define GNC_IS_ORDER(obj) (QOF_CHECK_TYPE((obj), GNC_ID_ORDER))
-#define GNC_ORDER(obj) (QOF_CHECK_CAST((obj), GNC_ID_ORDER, GncOrder))
/* Create/Destroy Functions */
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncTaxTable.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncTaxTable.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncTaxTable.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -32,9 +32,17 @@
#include "gncTaxTableP.h"
-struct _gncTaxTable
+
+/* GObject declarations */
+
+static void gnc_tax_table_class_init(GncTaxTableClass *klass);
+static void gnc_tax_table_init(GncTaxTable *sp);
+static void gnc_tax_table_finalize(GObject *object);
+
+
+
+struct _GncTaxTablePrivate
{
- QofInstance inst;
char * name;
GList * entries;
Timespec modtime; /* internal date of last modtime */
@@ -48,6 +56,118 @@
GList * children; /* list of children for disconnection */
};
+
+enum _GncTaxTableSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncTaxTableSignal {
+ GncTaxTable *object;
+};
+
+static guint gnc_tax_table_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_tax_table_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncTaxTableClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_tax_table_class_init,
+ NULL,
+ NULL,
+ sizeof (GncTaxTable),
+ 0,
+ (GInstanceInitFunc)gnc_tax_table_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncTaxTable", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_tax_table_class_init(GncTaxTableClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_tax_table_finalize;
+ object_class->set_property = gnc_tax_table_set_property;
+ object_class->get_property = gnc_tax_table_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_tax_table_init(GncTaxTable *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_tax_table_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_tax_table_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncTaxTable *obj;
+
+ obj = GNC_TAX_TABLE (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_tax_table_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncTaxTable *obj;
+
+ obj = GNC_TAX_TABLE (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+/*******************************************************************************/
+
struct _gncTaxTableEntry
{
GncTaxTable * table;
@@ -143,8 +263,8 @@
static inline void
mark_table (GncTaxTable *table)
{
- qof_instance_set_dirty(&table->inst);
- qof_event_gen (&table->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(QOF_INSTANCE (table));
+ qof_event_gen (GNC_ENTITY (table), QOF_EVENT_MODIFY, NULL);
}
static inline void
@@ -152,21 +272,21 @@
{
struct _book_info *bi;
- if (table->parent || table->invisible) return;
- bi = qof_book_get_data (table->inst.book, _GNC_MOD_NAME);
+ if (table->priv->parent || table->priv->invisible) return;
+ bi = qof_book_get_data (qof_instance_get_book (QOF_INSTANCE (table), _GNC_MOD_NAME);
bi->tables = g_list_sort (bi->tables, (GCompareFunc)gncTaxTableCompare);
}
static inline void
mod_table (GncTaxTable *table)
{
- timespecFromTime_t (&table->modtime, time(NULL));
+ timespecFromTime_t (&table->priv->modtime, time(NULL));
}
static inline void addObj (GncTaxTable *table)
{
struct _book_info *bi;
- bi = qof_book_get_data (table->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book (QOF_INSTANCE (table), _GNC_MOD_NAME);
bi->tables = g_list_insert_sorted (bi->tables, table,
(GCompareFunc)gncTaxTableCompare);
}
@@ -174,7 +294,7 @@
static inline void remObj (GncTaxTable *table)
{
struct _book_info *bi;
- bi = qof_book_get_data (table->inst.book, _GNC_MOD_NAME);
+ bi = qof_book_get_data (qof_instance_get_book (QOF_INSTANCE (table), _GNC_MOD_NAME);
bi->tables = g_list_remove (bi->tables, table);
}
@@ -183,9 +303,9 @@
{
g_return_if_fail(table);
g_return_if_fail(child);
- g_return_if_fail(table->inst.do_free == FALSE);
+ g_return_if_fail(qof_instance_do_free (QOF_INSTANCE(table)) == FALSE);
- table->children = g_list_prepend(table->children, child);
+ table->priv->children = g_list_prepend(table->priv->children, child);
}
static inline void
@@ -194,9 +314,9 @@
g_return_if_fail(table);
g_return_if_fail(child);
- if (table->inst.do_free) return;
+ if (qof_instance_do_free(QOF_INSTANCE (table))) return;
- table->children = g_list_remove(table->children, child);
+ table->priv->children = g_list_remove(table->priv->children, child);
}
/* =============================================================== */
@@ -208,11 +328,13 @@
GncTaxTable *table;
if (!book) return NULL;
- table = g_new0 (GncTaxTable, 1);
- qof_instance_init (&table->inst, _GNC_MOD_NAME, book);
- table->name = CACHE_INSERT ("");
+ table = GNC_TAX_TABLE (g_object_new (GNC_TYPE_TAX_TABLE, NULL));
+ table->priv = g_new0 (GncTaxTablePrivate, 1);
+
+ qof_instance_init (GNC_INSTANCE (table), _GNC_MOD_NAME, book);
+ table->priv->name = CACHE_INSERT ("");
addObj (table);
- qof_event_gen (&table->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (GNC_ENTITY (table), QOF_EVENT_CREATE, NULL);
return table;
}
@@ -225,46 +347,46 @@
if (!book) return NULL;
table = g_new0 (GncTaxTable, 1);
- qof_instance_init (&table->inst, _GNC_MOD_NAME, book);
- qof_instance_gemini (&table->inst, &from->inst);
+ qof_instance_init (GNC_INSTANCE (table), _GNC_MOD_NAME, book);
+ qof_instance_gemini (GNC_INSTANCE (table), &from->inst);
- table->name = CACHE_INSERT (from->name);
- table->modtime = from->modtime;
- table->invisible = from->invisible;
+ table->priv->name = CACHE_INSERT (from->name);
+ table->priv->modtime = from->modtime;
+ table->priv->invisible = from->invisible;
- table->refcount = 0;
+ table->priv->refcount = 0;
/* Make copies of parents and children. Note that this can be
* a recursive copy ... treat as doubly-linked list. */
if (from->child)
{
- table->child = gncTaxTableObtainTwin (from->child, book);
- table->child->parent = table;
+ table->priv->child = gncTaxTableObtainTwin (from->child, book);
+ table->priv->child->parent = table;
}
if (from->parent)
{
- table->parent = gncTaxTableObtainTwin (from->parent, book);
- table->parent->child = table;
+ table->priv->parent = gncTaxTableObtainTwin (from->parent, book);
+ table->priv->parent->child = table;
}
for (node=g_list_last(from->children); node; node=node->next)
{
GncTaxTable *tbl = node->data;
tbl = gncTaxTableObtainTwin (tbl, book);
tbl->parent = table;
- table->children = g_list_prepend(table->children, tbl);
+ table->priv->children = g_list_prepend(table->priv->children, tbl);
}
/* Copy tax entries, preserving the order in the list */
- table->entries = NULL;
+ table->priv->entries = NULL;
for (node=g_list_last(from->entries); node; node=node->prev)
{
GncTaxTableEntry *ent = node->data;
ent = CloneTaxEntry (ent, book);
- table->entries = g_list_prepend (table->entries, ent);
+ table->priv->entries = g_list_prepend (table->priv->entries, ent);
}
addObj (table);
- qof_event_gen (&table->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (GNC_ENTITY (table), QOF_EVENT_CREATE, NULL);
return table;
}
@@ -287,8 +409,8 @@
gncTaxTableDestroy (GncTaxTable *table)
{
if (!table) return;
- table->inst.do_free = TRUE;
- qof_instance_set_dirty (&table->inst);
+ qof_instance_mark_free (QOF_INSTANCE (table));
+ qof_instance_set_dirty (GNC_INSTANCE (table));
gncTaxTableCommitEdit (table);
}
@@ -300,31 +422,30 @@
if (!table) return;
- qof_event_gen (&table->inst.entity, QOF_EVENT_DESTROY, NULL);
- CACHE_REMOVE (table->name);
+ qof_event_gen (GNC_ENTITY (table), QOF_EVENT_DESTROY, NULL);
+ CACHE_REMOVE (table->priv->name);
remObj (table);
/* destroy the list of entries */
- for (list = table->entries; list; list=list->next)
+ for (list = table->priv->entries; list; list=list->next)
gncTaxTableEntryDestroy (list->data);
- g_list_free (table->entries);
+ g_list_free (table->priv->entries);
- if (!table->inst.do_free)
+ if (!qof_instance_do_free (QOF_INSTANCE (table)))
PERR("free a taxtable without do_free set!");
/* disconnect from parent */
- if (table->parent)
- gncTaxTableRemoveChild(table->parent, table);
+ if (table->priv->parent)
+ gncTaxTableRemoveChild(table->priv->parent, table);
/* disconnect from the children */
- for (list = table->children; list; list=list->next) {
+ for (list = table->priv->children; list; list=list->next) {
child = list->data;
gncTaxTableSetParent(child, NULL);
}
- g_list_free(table->children);
+ g_list_free(table->priv->children);
- qof_instance_release (&table->inst);
- g_free (table);
+ qof_instance_release (GNC_INSTANCE (table));
}
/* =============================================================== */
@@ -368,7 +489,7 @@
void gncTaxTableSetName (GncTaxTable *table, const char *name)
{
if (!table || !name) return;
- SET_STR (table, table->name, name);
+ SET_STR (table, table->priv->name, name);
mark_table (table);
maybe_resort_list (table);
gncTaxTableCommitEdit (table);
@@ -378,12 +499,12 @@
{
if (!table) return;
gncTaxTableBeginEdit (table);
- if (table->parent)
- gncTaxTableRemoveChild(table->parent, table);
- table->parent = parent;
+ if (table->priv->parent)
+ gncTaxTableRemoveChild(table->priv->parent, table);
+ table->priv->parent = parent;
if (parent)
gncTaxTableAddChild(parent, table);
- table->refcount = 0;
+ table->priv->refcount = 0;
gncTaxTableMakeInvisible (table);
gncTaxTableCommitEdit (table);
}
@@ -392,33 +513,33 @@
{
if (!table) return;
gncTaxTableBeginEdit (table);
- table->child = child;
+ table->priv->child = child;
gncTaxTableCommitEdit (table);
}
void gncTaxTableIncRef (GncTaxTable *table)
{
if (!table) return;
- if (table->parent || table->invisible) return; /* children dont need refcounts */
+ if (table->priv->parent || table->priv->invisible) return; /* children dont need refcounts */
gncTaxTableBeginEdit (table);
- table->refcount++;
+ table->priv->refcount++;
gncTaxTableCommitEdit (table);
}
void gncTaxTableDecRef (GncTaxTable *table)
{
if (!table) return;
- if (table->parent || table->invisible) return; /* children dont need refcounts */
+ if (table->priv->parent || table->priv->invisible) return; /* children dont need refcounts */
gncTaxTableBeginEdit (table);
- table->refcount--;
- g_return_if_fail (table->refcount >= 0);
+ table->priv->refcount--;
+ g_return_if_fail (table->priv->refcount >= 0);
gncTaxTableCommitEdit (table);
}
void gncTaxTableSetRefcount (GncTaxTable *table, gint64 refcount)
{
if (!table) return;
- table->refcount = refcount;
+ table->priv->refcount = refcount;
}
void gncTaxTableMakeInvisible (GncTaxTable *table)
@@ -426,8 +547,8 @@
struct _book_info *bi;
if (!table) return;
gncTaxTableBeginEdit (table);
- table->invisible = TRUE;
- bi = qof_book_get_data (table->inst.book, _GNC_MOD_NAME);
+ table->priv->invisible = TRUE;
+ bi = qof_book_get_data (qof_instance_get_book (QOF_INSTANCE (table), _GNC_MOD_NAME);
bi->tables = g_list_remove (bi->tables, table);
gncTaxTableCommitEdit (table);
}
@@ -475,7 +596,7 @@
gncTaxTableRemoveEntry (entry->table, entry);
entry->table = table;
- table->entries = g_list_insert_sorted (table->entries, entry,
+ table->priv->entries = g_list_insert_sorted (table->priv->entries, entry,
(GCompareFunc)gncTaxTableEntryCompare);
mark_table (table);
mod_table (table);
@@ -487,7 +608,7 @@
if (!table || !entry) return;
gncTaxTableBeginEdit (table);
entry->table = NULL;
- table->entries = g_list_remove (table->entries, entry);
+ table->priv->entries = g_list_remove (table->priv->entries, entry);
mark_table (table);
mod_table (table);
gncTaxTableCommitEdit (table);
@@ -497,7 +618,7 @@
{
if (!table) return;
gncTaxTableBeginEdit (table);
- table->child = NULL;
+ table->priv->child = NULL;
gncTaxTableCommitEdit (table);
}
@@ -505,7 +626,7 @@
void gncTaxTableBeginEdit (GncTaxTable *table)
{
- QOF_BEGIN_EDIT (&table->inst);
+ QOF_BEGIN_EDIT (GNC_INSTANCE (table));
}
static void gncTaxTableOnError (QofInstance *inst, QofBackendError errcode)
@@ -524,7 +645,7 @@
void gncTaxTableCommitEdit (GncTaxTable *table)
{
if (!qof_commit_edit (QOF_INSTANCE(table))) return;
- qof_commit_edit_part2 (&table->inst, gncTaxTableOnError,
+ qof_commit_edit_part2 (GNC_INSTANCE (table), gncTaxTableOnError,
gncTaxTableOnDone, table_free);
}
@@ -538,7 +659,7 @@
for ( ; list; list = list->next) {
GncTaxTable *table = list->data;
- if (!safe_strcmp (table->name, name))
+ if (!safe_strcmp (table->priv->name, name))
return list->data;
}
return NULL;
@@ -556,7 +677,7 @@
const char *gncTaxTableGetName (GncTaxTable *table)
{
if (!table) return NULL;
- return table->name;
+ return table->priv->name;
}
static GncTaxTableEntry *gncTaxTableEntryCopy (GncTaxTableEntry *entry)
@@ -578,9 +699,9 @@
GList *list;
if (!table) return NULL;
- t = gncTaxTableCreate (table->inst.book);
- gncTaxTableSetName (t, table->name);
- for (list = table->entries; list; list=list->next) {
+ t = gncTaxTableCreate (qof_instance_get_book (QOF_INSTANCE (table));
+ gncTaxTableSetName (t, table->priv->name);
+ for (list = table->priv->entries; list; list=list->next) {
GncTaxTableEntry *entry, *e;
entry = list->data;
e = gncTaxTableEntryCopy (entry);
@@ -594,8 +715,8 @@
GncTaxTable *child = NULL;
if (!table) return NULL;
- if (table->child) return table->child;
- if (table->parent || table->invisible) return table;
+ if (table->priv->child) return table->priv->child;
+ if (table->priv->parent || table->priv->invisible) return table;
if (make_new) {
child = gncTaxTableCopy (table);
gncTaxTableSetChild (table, child);
@@ -607,32 +728,32 @@
GncTaxTable *gncTaxTableGetParent (GncTaxTable *table)
{
if (!table) return NULL;
- return table->parent;
+ return table->priv->parent;
}
GList *gncTaxTableGetEntries (GncTaxTable *table)
{
if (!table) return NULL;
- return table->entries;
+ return table->priv->entries;
}
gint64 gncTaxTableGetRefcount (GncTaxTable *table)
{
if (!table) return 0;
- return table->refcount;
+ return table->priv->refcount;
}
Timespec gncTaxTableLastModified (GncTaxTable *table)
{
Timespec ts = { 0 , 0 };
if (!table) return ts;
- return table->modtime;
+ return table->priv->modtime;
}
gboolean gncTaxTableGetInvisible (GncTaxTable *table)
{
if (!table) return FALSE;
- return table->invisible;
+ return table->priv->invisible;
}
Account * gncTaxTableEntryGetAccount (GncTaxTableEntry *entry)
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncTaxTable.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncTaxTable.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncTaxTable.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -31,6 +31,35 @@
#ifndef GNC_TAXTABLE_H_
#define GNC_TAXTABLE_H_
+/* GObject declarations */
+
+#define GNC_TYPE_TAX_TABLE (gnc_tax_table_get_type ())
+#define GNC_TAX_TABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAX_TABLE, GncTaxTable))
+#define GNC_TAX_TABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAX_TABLE, GncTaxTableClass))
+#define GNC_IS_TAX_TABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAX_TABLE))
+#define GNC_IS_TAX_TABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAX_TABLE))
+#define GNC_TAX_TABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAX_TABLE, GncTaxTableClass))
+
+
+typedef struct _GncTaxTableClass GncTaxTableClass;
+typedef struct _GncTaxTablePrivate GncTaxTablePrivate;
+typedef struct _GncTaxTable GncTaxTable;
+
+struct _GncTaxTable {
+ QofInstance inst;
+ GncTablePrivate *priv;
+};
+
+struct _GncTaxTableClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_tax_table_get_type ();
+
+
/** @struct GncTaxTable
modtime is the internal date of the last modtime\n
@@ -70,8 +99,6 @@
#endif
#define GNC_ID_TAXTABLE "gncTaxTable"
-#define GNC_IS_TAXTABLE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_TAXTABLE))
-#define GNC_TAXTABLE(obj) (QOF_CHECK_CAST((obj), GNC_ID_TAXTABLE, GncTaxTable))
/**
* How to interpret the amount.
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncVendor.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncVendor.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncVendor.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -40,10 +40,18 @@
#include "gncVendor.h"
#include "gncVendorP.h"
-struct _gncVendor
+/* GObject declarations */
+
+static void gnc_vendor_class_init(GncVendorClass *klass);
+static void gnc_vendor_init(GncVendor *sp);
+static void gnc_vendor_finalize(GObject *object);
+
+
+typedef struct _GncVendorSignal GncVendorSignal;
+typedef enum _GncVendorSignalType GncVendorSignalType;
+
+struct _GncVendorPrivate
{
- QofInstance inst;
-
char * id;
char * name;
char * notes;
@@ -57,6 +65,117 @@
GList * jobs;
};
+
+enum _GncVendorSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncVendorSignal {
+ GncVendor *object;
+};
+
+static guint gnc_vendor_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_vendor_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncVendorClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_vendor_class_init,
+ NULL,
+ NULL,
+ sizeof (GncVendor),
+ 0,
+ (GInstanceInitFunc)gnc_vendor_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncVendor", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_vendor_class_init(GncVendorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_vendor_finalize;
+ object_class->set_property = gnc_vendor_set_property;
+ object_class->get_property = gnc_vendor_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_vendor_init(GncVendor *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_vendor_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_vendor_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncVendor *obj;
+
+ obj = QOF_BOOK (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_vendor_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncVendor *obj;
+
+ obj = QOF_BOOK(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+/*************************************************************************************/
+
static QofLogModule log_module = GNC_MOD_BUSINESS;
#define _GNC_MOD_NAME GNC_ID_VENDOR
@@ -67,8 +186,8 @@
G_INLINE_FUNC void mark_vendor (GncVendor *vendor);
void mark_vendor (GncVendor *vendor)
{
- qof_instance_set_dirty(&vendor->inst);
- qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(QOF_ENTITY (vendor));
+ qof_event_gen (QOF_ENTITY (vendor), QOF_EVENT_MODIFY, NULL);
}
/* ============================================================== */
@@ -81,17 +200,17 @@
if (!book) return NULL;
vendor = g_new0 (GncVendor, 1);
- qof_instance_init (&vendor->inst, _GNC_MOD_NAME, book);
+ qof_instance_init (QOF_ENTITY (vendor), _GNC_MOD_NAME, book);
- vendor->id = CACHE_INSERT ("");
- vendor->name = CACHE_INSERT ("");
- vendor->notes = CACHE_INSERT ("");
- vendor->addr = gncAddressCreate (book, &vendor->inst.entity);
- vendor->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
- vendor->active = TRUE;
- vendor->jobs = NULL;
+ vendor->priv->id = CACHE_INSERT ("");
+ vendor->priv->name = CACHE_INSERT ("");
+ vendor->priv->notes = CACHE_INSERT ("");
+ vendor->priv->addr = gncAddressCreate (book, QOF_ENTITY (vendor));
+ vendor->priv->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
+ vendor->priv->active = TRUE;
+ vendor->priv->jobs = NULL;
- qof_event_gen (&vendor->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (vendor), QOF_EVENT_CREATE, NULL);
return vendor;
}
@@ -99,7 +218,7 @@
void gncVendorDestroy (GncVendor *vendor)
{
if (!vendor) return;
- vendor->inst.do_free = TRUE;
+ qof_instance_mark_free (QOF_INSTANCE (vendor));
gncVendorCommitEdit (vendor);
}
@@ -107,21 +226,21 @@
{
if (!vendor) return;
- qof_event_gen (&vendor->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (vendor), QOF_EVENT_DESTROY, NULL);
- CACHE_REMOVE (vendor->id);
- CACHE_REMOVE (vendor->name);
- CACHE_REMOVE (vendor->notes);
- gncAddressDestroy (vendor->addr);
- g_list_free (vendor->jobs);
+ CACHE_REMOVE (vendor->priv->id);
+ CACHE_REMOVE (vendor->priv->name);
+ CACHE_REMOVE (vendor->priv->notes);
+ gncAddressDestroy (vendor->priv->addr);
+ g_list_free (vendor->priv->jobs);
- if (vendor->terms)
- gncBillTermDecRef (vendor->terms);
- if (vendor->taxtable)
- gncTaxTableDecRef (vendor->taxtable);
+ if (vendor->priv->terms)
+ gncBillTermDecRef (vendor->priv->terms);
+ if (vendor->priv->taxtable)
+ gncTaxTableDecRef (vendor->priv->taxtable);
- qof_instance_release (&vendor->inst);
- g_free (vendor);
+ qof_instance_release (QOF_ENTITY (vendor));
+
}
/** Create a copy of a vendor, placing the copy into a new book. */
@@ -132,36 +251,37 @@
GncVendor *vendor;
if (!book) return NULL;
-
- vendor = g_new0 (GncVendor, 1);
- qof_instance_init (&vendor->inst, _GNC_MOD_NAME, book);
- qof_instance_gemini (&vendor->inst, &from->inst);
+ vendor = GNC_VENDOR ( g_object_new (GNC_TYPE_VENDOR, NULL));
+ vendor->priv = g_new0 (GncVendorPrivate, 1);
- vendor->id = CACHE_INSERT (from->id);
- vendor->name = CACHE_INSERT (from->name);
- vendor->notes = CACHE_INSERT (from->notes);
- vendor->addr = gncCloneAddress (from->addr, &vendor->inst.entity, book);
- vendor->taxincluded = from->taxincluded;
- vendor->taxtable_override = from->taxtable_override;
- vendor->active = from->active;
+ qof_instance_init (QOF_ENTITY (vendor), _GNC_MOD_NAME, book);
+ qof_instance_gemini (QOF_ENTITY (vendor), &from->inst);
+
+ vendor->priv->id = CACHE_INSERT (from->id);
+ vendor->priv->name = CACHE_INSERT (from->name);
+ vendor->priv->notes = CACHE_INSERT (from->notes);
+ vendor->priv->addr = gncCloneAddress (from->addr, QOF_ENTITY (vendor), book);
+ vendor->priv->taxincluded = from->taxincluded;
+ vendor->priv->taxtable_override = from->taxtable_override;
+ vendor->priv->active = from->active;
- vendor->terms = gncBillTermObtainTwin (from->terms, book);
- gncBillTermIncRef (vendor->terms);
+ vendor->priv->terms = gncBillTermObtainTwin (from->terms, book);
+ gncBillTermIncRef (vendor->priv->terms);
- vendor->currency = gnc_commodity_obtain_twin (from->currency, book);
+ vendor->priv->currency = gnc_commodity_obtain_twin (from->currency, book);
- vendor->taxtable = gncTaxTableObtainTwin (from->taxtable, book);
- gncTaxTableIncRef (vendor->taxtable);
+ vendor->priv->taxtable = gncTaxTableObtainTwin (from->taxtable, book);
+ gncTaxTableIncRef (vendor->priv->taxtable);
- vendor->jobs = NULL;
+ vendor->priv->jobs = NULL;
for (node=g_list_last(from->jobs); node; node=node->prev)
{
GncJob *job = node->data;
job = gncJobObtainTwin (job, book);
- vendor->jobs = g_list_prepend(vendor->jobs, job);
+ vendor->priv->jobs = g_list_prepend(vendor->priv->jobs, job);
}
- qof_event_gen (&vendor->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (vendor), QOF_EVENT_CREATE, NULL);
return vendor;
}
@@ -198,7 +318,7 @@
{
if (!vendor) return;
if (!id) return;
- SET_STR(vendor, vendor->id, id);
+ SET_STR(vendor, vendor->priv->id, id);
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -207,7 +327,7 @@
{
if (!vendor) return;
if (!name) return;
- SET_STR(vendor, vendor->name, name);
+ SET_STR(vendor, vendor->priv->name, name);
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -216,7 +336,7 @@
{
if (!vendor) return;
if (!notes) return;
- SET_STR(vendor,vendor->notes, notes);
+ SET_STR(vendor,vendor->priv->notes, notes);
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -224,14 +344,14 @@
void gncVendorSetTerms (GncVendor *vendor, GncBillTerm *terms)
{
if (!vendor) return;
- if (vendor->terms == terms) return;
+ if (vendor->priv->terms == terms) return;
gncVendorBeginEdit (vendor);
- if (vendor->terms)
- gncBillTermDecRef (vendor->terms);
- vendor->terms = terms;
- if (vendor->terms)
- gncBillTermIncRef (vendor->terms);
+ if (vendor->priv->terms)
+ gncBillTermDecRef (vendor->priv->terms);
+ vendor->priv->terms = terms;
+ if (vendor->priv->terms)
+ gncBillTermIncRef (vendor->priv->terms);
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -239,9 +359,9 @@
void gncVendorSetTaxIncluded (GncVendor *vendor, GncTaxIncluded taxincl)
{
if (!vendor) return;
- if (taxincl == vendor->taxincluded) return;
+ if (taxincl == vendor->priv->taxincluded) return;
gncVendorBeginEdit (vendor);
- vendor->taxincluded = taxincl;
+ vendor->priv->taxincluded = taxincl;
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -249,11 +369,11 @@
void gncVendorSetCurrency (GncVendor *vendor, gnc_commodity *currency)
{
if (!vendor || !currency) return;
- if (vendor->currency &&
- gnc_commodity_equal (vendor->currency, currency))
+ if (vendor->priv->currency &&
+ gnc_commodity_equal (vendor->priv->currency, currency))
return;
gncVendorBeginEdit (vendor);
- vendor->currency = currency;
+ vendor->priv->currency = currency;
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -261,9 +381,9 @@
void gncVendorSetActive (GncVendor *vendor, gboolean active)
{
if (!vendor) return;
- if (active == vendor->active) return;
+ if (active == vendor->priv->active) return;
gncVendorBeginEdit (vendor);
- vendor->active = active;
+ vendor->priv->active = active;
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -271,9 +391,9 @@
void gncVendorSetTaxTableOverride (GncVendor *vendor, gboolean override)
{
if (!vendor) return;
- if (vendor->taxtable_override == override) return;
+ if (vendor->priv->taxtable_override == override) return;
gncVendorBeginEdit (vendor);
- vendor->taxtable_override = override;
+ vendor->priv->taxtable_override = override;
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -281,13 +401,13 @@
void gncVendorSetTaxTable (GncVendor *vendor, GncTaxTable *table)
{
if (!vendor) return;
- if (vendor->taxtable == table) return;
+ if (vendor->priv->taxtable == table) return;
gncVendorBeginEdit (vendor);
- if (vendor->taxtable)
- gncTaxTableDecRef (vendor->taxtable);
+ if (vendor->priv->taxtable)
+ gncTaxTableDecRef (vendor->priv->taxtable);
if (table)
gncTaxTableIncRef (table);
- vendor->taxtable = table;
+ vendor->priv->taxtable = table;
mark_vendor (vendor);
gncVendorCommitEdit (vendor);
}
@@ -299,10 +419,10 @@
if(!vendor || !addr_ent) { return; }
addr = (GncAddress*)addr_ent;
- if(addr == vendor->addr) { return; }
- if(vendor->addr != NULL) { gncAddressDestroy(vendor->addr); }
+ if(addr == vendor->priv->addr) { return; }
+ if(vendor->priv->addr != NULL) { gncAddressDestroy(vendor->priv->addr); }
gncVendorBeginEdit(vendor);
- vendor->addr = addr;
+ vendor->priv->addr = addr;
gncVendorCommitEdit(vendor);
}
@@ -313,7 +433,7 @@
if(!gncTaxIncludedStringToType(type_string, &inc)) { return; }
gncVendorBeginEdit(vendor);
- vendor->taxincluded = inc;
+ vendor->priv->taxincluded = inc;
gncVendorCommitEdit(vendor);
}
@@ -323,67 +443,67 @@
const char * gncVendorGetID (GncVendor *vendor)
{
if (!vendor) return NULL;
- return vendor->id;
+ return vendor->priv->id;
}
const char * gncVendorGetName (GncVendor *vendor)
{
if (!vendor) return NULL;
- return vendor->name;
+ return vendor->priv->name;
}
GncAddress * gncVendorGetAddr (GncVendor *vendor)
{
if (!vendor) return NULL;
- return vendor->addr;
+ return vendor->priv->addr;
}
const char * gncVendorGetNotes (GncVendor *vendor)
{
if (!vendor) return NULL;
- return vendor->notes;
+ return vendor->priv->notes;
}
GncBillTerm * gncVendorGetTerms (GncVendor *vendor)
{
if (!vendor) return 0;
- return vendor->terms;
+ return vendor->priv->terms;
}
GncTaxIncluded gncVendorGetTaxIncluded (GncVendor *vendor)
{
if (!vendor) return GNC_TAXINCLUDED_USEGLOBAL;
- return vendor->taxincluded;
+ return vendor->priv->taxincluded;
}
gnc_commodity * gncVendorGetCurrency (GncVendor *vendor)
{
if (!vendor) return NULL;
- return vendor->currency;
+ return vendor->priv->currency;
}
gboolean gncVendorGetActive (GncVendor *vendor)
{
if (!vendor) return FALSE;
- return vendor->active;
+ return vendor->priv->active;
}
gboolean gncVendorGetTaxTableOverride (GncVendor *vendor)
{
if (!vendor) return FALSE;
- return vendor->taxtable_override;
+ return vendor->priv->taxtable_override;
}
GncTaxTable* gncVendorGetTaxTable (GncVendor *vendor)
{
if (!vendor) return NULL;
- return vendor->taxtable;
+ return vendor->priv->taxtable;
}
static const char*
qofVendorGetTaxIncluded(GncVendor *vendor)
{
- return gncTaxIncludedTypeToString(vendor->taxincluded);
+ return gncTaxIncludedTypeToString(vendor->priv->taxincluded);
}
/* Note that JobList changes do not affect the "dirtiness" of the vendor */
@@ -392,11 +512,11 @@
if (!vendor) return;
if (!job) return;
- if (g_list_index(vendor->jobs, job) == -1)
- vendor->jobs = g_list_insert_sorted (vendor->jobs, job,
+ if (g_list_index(vendor->priv->jobs, job) == -1)
+ vendor->priv->jobs = g_list_insert_sorted (vendor->priv->jobs, job,
(GCompareFunc)gncJobCompare);
- qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen (QOF_ENTITY (vendor), QOF_EVENT_MODIFY, NULL);
}
void gncVendorRemoveJob (GncVendor *vendor, GncJob *job)
@@ -406,20 +526,20 @@
if (!vendor) return;
if (!job) return;
- node = g_list_find (vendor->jobs, job);
+ node = g_list_find (vendor->priv->jobs, job);
if (!node) {
/* PERR ("split not in account"); */
} else {
- vendor->jobs = g_list_remove_link (vendor->jobs, node);
+ vendor->priv->jobs = g_list_remove_link (vendor->priv->jobs, node);
g_list_free_1 (node);
}
- qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen (QOF_ENTITY (vendor), QOF_EVENT_MODIFY, NULL);
}
void gncVendorBeginEdit (GncVendor *vendor)
{
- QOF_BEGIN_EDIT (&vendor->inst);
+ QOF_BEGIN_EDIT (QOF_ENTITY (vendor));
}
static void gncVendorOnError (QofInstance *vendor, QofBackendError errcode)
@@ -430,7 +550,7 @@
static void gncVendorOnDone (QofInstance *inst)
{
GncVendor *vendor = (GncVendor *) inst;
- gncAddressClearDirty (vendor->addr);
+ gncAddressClearDirty (vendor->priv->addr);
}
static void vendor_free (QofInstance *inst)
@@ -442,7 +562,7 @@
void gncVendorCommitEdit (GncVendor *vendor)
{
if (!qof_commit_edit (QOF_INSTANCE(vendor))) return;
- qof_commit_edit_part2 (&vendor->inst, gncVendorOnError,
+ qof_commit_edit_part2 (QOF_ENTITY (vendor), gncVendorOnError,
gncVendorOnDone, vendor_free);
}
@@ -463,10 +583,10 @@
if (!vendor) return NULL;
if (show_all) {
- return (g_list_copy (vendor->jobs));
+ return (g_list_copy (vendor->priv->jobs));
} else {
GList *list = NULL, *iterator;
- for (iterator = vendor->jobs; iterator; iterator=iterator->next) {
+ for (iterator = vendor->priv->jobs; iterator; iterator=iterator->next) {
GncJob *j = iterator->data;
if (gncJobGetActive (j))
list = g_list_append (list, j);
@@ -478,7 +598,7 @@
gboolean gncVendorIsDirty (GncVendor *vendor)
{
if (!vendor) return FALSE;
- return (vendor->inst.dirty || gncAddressIsDirty (vendor->addr));
+ return (qof_instance_is_dirty (QOF_INSTANCE (vendor)) || gncAddressIsDirty (vendor->priv->addr));
}
/* ============================================================== */
Modified: gnucash/branches/gobject-engine-dev/src/business/business-core/gncVendor.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/business/business-core/gncVendor.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/business/business-core/gncVendor.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -39,9 +39,36 @@
#include "gncJob.h"
#define GNC_ID_VENDOR "gncVendor"
-#define GNC_IS_VENDOR(obj) (QOF_CHECK_TYPE((obj), GNC_ID_VENDOR))
-#define GNC_VENDOR(obj) (QOF_CHECK_CAST((obj), GNC_ID_VENDOR, GncVendor))
+/* GObject declarations */
+
+#define GNC_TYPE_VENDOR (gnc_vendor_get_type ())
+#define GNC_VENDOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_VENDOR, GncVendor))
+#define GNC_VENDOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_VENDOR, GncVendorClass))
+#define GNC_IS_VENDOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_VENDOR))
+#define GNC_IS_VENDOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_VENDOR))
+#define GNC_VENDOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_VENDOR, GncVendorClass))
+
+
+typedef struct _GncVendorClass GncVendorClass;
+typedef struct _GncVendorPrivate GncVendorPrivate;
+typedef struct _GncVendor GncVendor;
+
+struct _GncVendor {
+ QofInstance inst;
+ GncVendorPrivate *priv;
+}
+
+struct _GncVendorClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_vendor_get_type ();
+
+
/* Create/Destroy Functions */
GncVendor *gncVendorCreate (QofBook *book);
Modified: gnucash/branches/gobject-engine-dev/src/engine/Account.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Account.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/Account.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -42,6 +42,130 @@
static QofLogModule log_module = GNC_MOD_ACCOUNT;
+/* GObject declarations */
+
+static void gnc_account_class_init(AccountClass *klass);
+static void gnc_account_init(Account *sp);
+static void gnc_account_finalize(GObject *object);
+
+struct _AccountPrivate {
+ /* Private Members */
+};
+
+typedef struct _AccountSignal AccountSignal;
+typedef enum _AccountSignalType AccountSignalType;
+
+enum _AccountSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _AccountSignal {
+ Account *object;
+};
+
+static guint gnc_account_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_account_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (AccountClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_account_class_init,
+ NULL,
+ NULL,
+ sizeof (Account),
+ 0,
+ (GInstanceInitFunc)gnc_account_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncAccount", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_account_class_init(AccountClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_account_finalize;
+ object_class->set_property = gnc_account_set_property;
+ object_class->get_property = gnc_account_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_account_init(Account *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_account_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_account_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ Account *obj;
+
+ obj = GNC_ACCOUNT (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_account_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ Account *obj;
+
+ obj = GNC_ACCOUNT(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+/***************************************************************/
/* The Canonical Account Separator. Pre-Initialized. */
static gchar account_separator[8] = ".";
gunichar account_uc_separator = ':';
@@ -301,7 +425,7 @@
acc->sort_dirty = FALSE;
qof_instance_release (&acc->inst);
- g_free(acc);
+ //g_free(acc);
}
/********************************************************************\
Modified: gnucash/branches/gobject-engine-dev/src/engine/Account.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Account.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/Account.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -48,6 +48,30 @@
#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 _AccountClass AccountClass;
+typedef struct _Account Account;
+
+struct _AccountClass {
+ 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) (
@@ -57,9 +81,6 @@
typedef gnc_numeric (*xaccGetBalanceAsOfDateFn) (
Account *account, time_t date);
-#define GNC_IS_ACCOUNT(obj) (QOF_CHECK_TYPE((obj), GNC_ID_ACCOUNT))
-#define GNC_ACCOUNT(obj) (QOF_CHECK_CAST((obj), GNC_ID_ACCOUNT, Account))
-
/** The account types are used to determine how the transaction data
* in the account is displayed. These values can be safely changed
* from one release to the next. Note that if values are added,
Modified: gnucash/branches/gobject-engine-dev/src/engine/AccountP.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/AccountP.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/AccountP.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -53,7 +53,7 @@
*/
/** \struct Account */
-struct account_s
+struct _Account
{
QofInstance inst;
Modified: gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -88,6 +88,129 @@
#include "FreqSpecP.h"
static QofLogModule log_module = GNC_MOD_SX;
+
+/* GObject */
+
+static void gnc_freq_spec_class_init(FreqSpecClass *klass);
+static void gnc_freq_spec_init(FreqSpec *sp);
+static void gnc_freq_spec_finalize(GObject *object);
+
+struct _FreqSpecPrivate {
+ /* Private Members */
+};
+
+typedef struct _FreqSpecSignal FreqSpecSignal;
+typedef enum _FreqSpecSignalType FreqSpecSignalType;
+
+enum _FreqSpecSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _FreqSpecSignal {
+ FreqSpec *object;
+};
+
+static guint gnc_freq_spec_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_freq_spec_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (FreqSpecClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_freq_spec_class_init,
+ NULL,
+ NULL,
+ sizeof (FreqSpec),
+ 0,
+ (GInstanceInitFunc)gnc_freq_spec_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_ENTITY,
+ "FreqSpec", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_freq_spec_class_init(QofInstanceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_freq_spec_finalize;
+ object_class->set_property = gnc_freq_spec_set_property;
+ object_class->get_property = gnc_freq_spec_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_freq_spec_init(FrecSpec *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_freq_spec_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_freq_spec_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ FreqSpec *obj;
+
+ obj = GNC_FREQ_SPEC (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_freq_spec_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ FreqSpec *obj;
+
+ obj = GNC_FREQ_SPEC(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
/*
* FIXME: should be in a header file
*/
@@ -172,7 +295,7 @@
g_return_if_fail (book);
col = qof_book_get_collection (book, QOF_ID_FREQSPEC);
- qof_entity_init (&fs->entity, QOF_ID_FREQSPEC, col);
+ qof_entity_init (QOF_ENTITY (fs), QOF_ID_FREQSPEC, col);
fs->type = INVALID;
fs->uift = UIFREQ_ONCE;
@@ -187,9 +310,11 @@
g_return_val_if_fail (book, NULL);
- fs = g_new0(FreqSpec, 1);
+ fs = GNC_FREQ_SPEC (g_object_new (GNC_TYPE_FREQ_SPEC, NULL));
xaccFreqSpecInit( fs, book );
- qof_event_gen( &fs->entity, QOF_EVENT_CREATE , NULL);
+ qof_event_gen( QOF_ENTITY (fs), QOF_EVENT_CREATE , NULL);
+ g_signal_emit_by_name ( QOF_ENTITY (fs), "created::detail");
+
return fs;
}
@@ -224,7 +349,7 @@
xaccFreqSpecCleanUp( fs );
qof_entity_release (&fs->entity);
- g_free( fs );
+ // g_free( fs ); the qof_entity_realise function call g_object_unref
}
FreqType
Modified: gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/FreqSpec.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -63,6 +63,14 @@
#include <glib.h>
#include "qof.h"
+#define GNC_TYPE_FREQ_SPEC (gnc_freq_spec_get_type ())
+#define GNC_FREQ_SPEC(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_FREQ_SPEC, FreqSpec))
+#define GNC_FREQ_SPEC_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_FREQ_SPEC, ))
+#define GNC_IS_FREQ_SPEC(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_FREQ_SPEC))
+#define GNC_IS_FREQ_SPEC_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_FREQ_SPEC))
+#define GNC_FREQ_SPEC_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_FREQ_SPEC, FreqSpecClass))
+
+
#define ENUM_LIST_TYPE(_) \
_(INVALID,) \
_(ONCE,) \
@@ -115,6 +123,8 @@
/** PROTOTYPES ******************************************************/
+GType gnc_freq_spec_get_type ();
+
/**
* Allocates memory for a FreqSpec and initializes it.
**/
Modified: gnucash/branches/gobject-engine-dev/src/engine/Makefile.am
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Makefile.am 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/Makefile.am 2007-02-08 05:49:51 UTC (rev 15522)
@@ -1,4 +1,4 @@
-SUBDIRS = . test-core test
+SUBDIRS =
pkglib_LTLIBRARIES = libgncmod-engine.la
Modified: gnucash/branches/gobject-engine-dev/src/engine/SchedXaction.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/SchedXaction.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/SchedXaction.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -43,6 +43,129 @@
static QofLogModule log_module = GNC_MOD_SX;
+/* GObject declarations */
+
+static void gnc_schedule_action_class_init(GncScheduleActionClass *klass);
+static void gnc_schedule_action_init(GncScheduleAction *sp);
+static void gnc_schedule_action_finalize(GObject *object);
+
+struct _GncScheduleActionPrivate {
+ /* Private Members */
+};
+
+typedef struct _GncScheduleActionSignal GncScheduleActionSignal;
+typedef enum _GncScheduleActionSignalType GncScheduleActionSignalType;
+
+enum _GncScheduleActionSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncScheduleActionSignal {
+ GncScheduleAction *object;
+};
+
+static guint gnc_schedule_action_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_schedule_action_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncScheduleActionClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_schedule_action_class_init,
+ NULL,
+ NULL,
+ sizeof (GncScheduleAction),
+ 0,
+ (GInstanceInitFunc)gnc_schedule_action_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncScheduleAction", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_schedule_action_class_init(GncScheduleActionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_schedule_action_finalize;
+ object_class->set_property = gnc_schedule_action_set_property;
+ object_class->get_property = gnc_schedule_action_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_schedule_action_init(GncScheduleAction *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_schedule_action_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_schedule_action_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncScheduleAction *obj;
+
+ obj = GNC_SCHEDULE_ACTION (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_action_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncScheduleAction *obj;
+
+ obj = GNC_SCHEDULE_ACTION(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
/* Local Prototypes *****/
void sxprivtransactionListMapDelete( gpointer data, gpointer user_data );
@@ -72,7 +195,7 @@
sx->template_acct = xaccMallocAccount(book);
/* THREAD-UNSAFE */
xaccAccountSetName( sx->template_acct,
- guid_to_string( &sx->inst.entity.guid ));
+ guid_to_string( QOF_INSTANCE (sx).entity.guid ));
xaccAccountSetCommodity
(sx->template_acct,
gnc_commodity_new( book,
@@ -90,9 +213,9 @@
g_return_val_if_fail (book, NULL);
- sx = g_new0( SchedXaction, 1 );
+ sx = g_object_new (GNC_SCHEDULE_ACTION, NULL );
xaccSchedXactionInit( sx, book );
- qof_event_gen( &sx->inst.entity, QOF_EVENT_CREATE , NULL);
+ qof_event_gen( QOF_ENTITY (sx), QOF_EVENT_CREATE , NULL);
return sx;
}
@@ -146,7 +269,7 @@
if ( sx == NULL ) return;
xaccFreqSpecFree( sx->freq );
- qof_event_gen( &sx->inst.entity, QOF_EVENT_DESTROY , NULL);
+ qof_event_gen( QOF_ENTITY (sx), QOF_EVENT_DESTROY , NULL);
if ( sx->name )
g_free( sx->name );
@@ -175,8 +298,7 @@
sx->deferredList = NULL;
}
- qof_instance_release (&sx->inst);
- g_free( sx );
+ qof_instance_release (QOF_INSTANCE (sx));
}
/* ============================================================ */
@@ -184,7 +306,7 @@
void
gnc_sx_begin_edit (SchedXaction *sx)
{
- qof_begin_edit (&sx->inst);
+ qof_begin_edit (QOF_INSTANCE (sx));
}
static void commit_err (QofInstance *inst, QofBackendError errcode)
@@ -194,7 +316,7 @@
static void commit_done(QofInstance *inst)
{
- qof_event_gen (&inst->entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen (inst, QOF_EVENT_MODIFY, NULL);
}
static void noop(QofInstance *inst) {}
@@ -203,7 +325,8 @@
gnc_sx_commit_edit (SchedXaction *sx)
{
if (!qof_commit_edit (QOF_INSTANCE(sx))) return;
- qof_commit_edit_part2 (&sx->inst, commit_err, commit_done, noop);
+
+ qof_commit_edit_part2 (QOF_INSTANCE (sx), commit_err, commit_done, noop);
}
/* ============================================================ */
@@ -222,7 +345,7 @@
gnc_sx_begin_edit(sx);
xaccFreqSpecFree( sx->freq );
sx->freq = fs;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -242,7 +365,7 @@
sx->name = NULL;
}
sx->name = g_strdup( newName );
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -257,7 +380,7 @@
{
gnc_sx_begin_edit(sx);
sx->start_date = *newStart;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -289,7 +412,7 @@
gnc_sx_begin_edit(sx);
sx->end_date = *newEnd;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -304,7 +427,7 @@
{
gnc_sx_begin_edit(sx);
sx->last_date = *newLastOccur;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -325,7 +448,7 @@
{
gnc_sx_begin_edit(sx);
sx->num_occurances_remain = sx->num_occurances_total = newNum;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -348,7 +471,7 @@
{
gnc_sx_begin_edit(sx);
sx->num_occurances_remain = numRemain;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
}
@@ -371,7 +494,7 @@
gnc_sx_begin_edit(sx);
kvp_frame_set_slot( sx->inst.kvp_data, slot, value );
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -396,7 +519,7 @@
gnc_sx_begin_edit(sx);
sx->autoCreateOption = newAutoCreate;
sx->autoCreateNotify = newNotify;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
return;
}
@@ -412,7 +535,7 @@
{
gnc_sx_begin_edit(sx);
sx->advanceCreateDays = createDays;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -427,7 +550,7 @@
{
gnc_sx_begin_edit(sx);
sx->advanceRemindDays = reminderDays;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
@@ -712,7 +835,7 @@
sx->last_date = tsd->last_date;
sx->num_occurances_remain = tsd->num_occur_rem;
sx->instance_num = tsd->num_inst;
- qof_instance_set_dirty(&sx->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (sx));
gnc_sx_commit_edit(sx);
}
Modified: gnucash/branches/gobject-engine-dev/src/engine/SchedXaction.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/SchedXaction.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/SchedXaction.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -42,9 +42,31 @@
#include "FreqSpec.h"
#include "gnc-engine.h"
-#define GNC_IS_SX(obj) (QOF_CHECK_TYPE((obj), GNC_ID_SCHEDXACTION))
-#define GNC_SX(obj) (QOF_CHECK_CAST((obj), GNC_ID_SCHEDXACTION, SchedXaction))
+/* GObject declarations */
+#define GNC_TYPE_SCHEDULE_ACTION (qof_book_get_type ())
+#define GNC_SCHEDULE_ACTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDULE_ACTION, GncScheduleAction))
+#define GNC_SCHEDULE_ACTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDULE_ACTION, GncScheduleActionClass))
+#define GNC_IS_SCHEDULE_ACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDULE_ACTION))
+#define GNC_IS_SCHEDULE_ACTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDULE_ACTION))
+#define GNC_SCHEDULE_ACTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDULE_ACTION, GncScheduleActionClass))
+
+
+typedef struct _GncScheduleActionClass GncScheduleActionClass;
+typedef struct _GncScheduleAction GncScheduleAction;
+typedef struct GncScheduleAction ShedXaction; /* Dummy type for backward compatilibity */
+
+struct _GncScheduleActionClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_schedule_action_get_type ();
+
+/********************************************/
+
/**
* The SchedXaction data.
*/
Modified: gnucash/branches/gobject-engine-dev/src/engine/SchedXactionP.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/SchedXactionP.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/SchedXactionP.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -47,7 +47,7 @@
* We should be able to use the GeneralLedger [or, yet-another-subtype
* of the internal ledger] for this editing.
**/
-struct gncp_SchedXaction
+struct _GncScheduleAction
{
QofInstance inst;
gchar *name;
Modified: gnucash/branches/gobject-engine-dev/src/engine/Split.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Split.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/Split.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -48,6 +48,130 @@
#include "gnc-lot.h"
#include "gnc-event.h"
+/* GObject declarations */
+
+static void gnc_split_class_init(GncSplitClass *klass);
+static void gnc_split_init(GncSplit *sp);
+static void gnc_split_finalize(GObject *object);
+
+struct _GncSplitPrivate {
+ /* Private Members */
+};
+
+typedef struct _GncSplitSignal GncSplitSignal;
+typedef enum _GncSplitSignalType GncSplitSignalType;
+
+enum _GncSplitSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncSplitSignal {
+ GncSplit *object;
+};
+
+static guint gnc_split_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_split_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncSplitClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_split_class_init,
+ NULL,
+ NULL,
+ sizeof (GncSplit),
+ 0,
+ (GInstanceInitFunc)gnc_split_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncSplit", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_split_class_init(GncSplitClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_split_finalize;
+ object_class->set_property = gnc_split_set_property;
+ object_class->get_property = gnc_split_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_split_init(GncSplit *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_split_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_split_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncSplit *obj;
+
+ obj = GNC_SPLIT (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_split_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncSplit *obj;
+
+ obj = GNC_SPLIT (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+/********************************************************/
const char *void_former_amt_str = "void-former-amount";
const char *void_former_val_str = "void-former-value";
@@ -88,7 +212,7 @@
split->gains = GAINS_STATUS_UNKNOWN;
split->gains_split = NULL;
- qof_instance_init(&split->inst, GNC_ID_SPLIT, book);
+ qof_instance_init(QOF_INSTANCE (split), GNC_ID_SPLIT, book);
}
void
@@ -131,7 +255,7 @@
Split *split;
g_return_val_if_fail (book, NULL);
- split = g_new0 (Split, 1);
+ split = g_object_new (GNC_TYPE_SPLIT, NULL);
xaccInitSplit (split, book);
return split;
@@ -149,7 +273,7 @@
Split *
xaccDupeSplit (const Split *s)
{
- Split *split = g_new0 (Split, 1);
+ Split *split = g_object_new (GNC_TYPE_SPLIT, NULL);
/* Trash the entity table. We don't want to mistake the cloned
* splits as something official. If we ever use this split, we'll
@@ -188,7 +312,7 @@
Split *
xaccSplitClone (const Split *s)
{
- Split *split = g_new0 (Split, 1);
+ Split *split = g_object_new (GNC_TYPE_SPLIT, NULL);
split->parent = NULL;
split->memo = CACHE_INSERT(s->memo);
@@ -205,7 +329,7 @@
split->gains = GAINS_STATUS_UNKNOWN;
split->gains_split = NULL;
- qof_instance_init(&split->inst, GNC_ID_SPLIT, s->inst.book);
+ qof_instance_init(QOF_INSTANCE (split), GNC_ID_SPLIT, s->inst.book);
kvp_frame_delete(split->inst.kvp_data);
split->inst.kvp_data = kvp_frame_copy(s->inst.kvp_data);
@@ -275,8 +399,7 @@
// Is this right?
if (split->gains_split) split->gains_split->gains_split = NULL;
- qof_instance_release(&split->inst);
- g_free(split);
+ qof_instance_release(QOF_INSTANCE (split));
}
static void mark_acc(Account *acc)
Modified: gnucash/branches/gobject-engine-dev/src/engine/Split.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Split.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/Split.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -31,6 +31,7 @@
@author Copyright (C) 1997-2001 Linas Vepstas <linas at linas.org>
*/
+
#ifndef XACC_SPLIT_H
#define XACC_SPLIT_H
@@ -39,6 +40,30 @@
#include "gnc-commodity.h"
#include "gnc-engine.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
Modified: gnucash/branches/gobject-engine-dev/src/engine/SplitP.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/SplitP.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/SplitP.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -68,7 +68,7 @@
#define GAINS_STATUS_VDIRTY (GAINS_STATUS_VALU_DIRTY)
#define GAINS_STATUS_A_VDIRTY (GAINS_STATUS_AMNT_DIRTY|GAINS_STATUS_VALU_DIRTY|GAINS_STATUS_LOT_DIRTY)
-struct split_s
+struct _GncSplit
{
QofInstance inst;
Modified: gnucash/branches/gobject-engine-dev/src/engine/Transaction.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Transaction.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/Transaction.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -50,6 +50,129 @@
#include "qofbackend-p.h"
+/* GObject declarations */
+
+static void gnc_transaction_class_init(GncTransactionClass *klass);
+static void gnc_transaction_init(GncTransaction *sp);
+static void gnc_transaction_finalize(GObject *object);
+
+struct _GncTransactionPrivate {
+ /* Private Members */
+};
+
+typedef struct _GncTransactionSignal GncTransactionSignal;
+typedef enum _GncTransactionSignalType GncTransactionSignalType;
+
+enum _GncTransactionSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncTransactionSignal {
+ GncTransaction *object;
+};
+
+static guint gnc_transaction_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_transaction_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncTransactionClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_transaction_class_init,
+ NULL,
+ NULL,
+ sizeof (GncTransaction),
+ 0,
+ (GInstanceInitFunc)gnc_transaction_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncTransaction", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_transaction_class_init(GncTransactionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_transaction_finalize;
+ object_class->set_property = gnc_transaction_set_property;
+ object_class->get_property = gnc_transaction_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_transaction_init(GncTransaction *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_transaction_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_transaction_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncTransaction *obj;
+
+ obj = GNC_TRANSACTION (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_transaction_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncTransaction *obj;
+
+ obj = GNC_TRANSACTION(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
/* Notes about xaccTransBeginEdit(), xaccTransCommitEdit(), and
* xaccTransRollback():
*
@@ -179,7 +302,7 @@
void check_open (const Transaction *trans)
{
- if (trans && 0 >= trans->inst.editlevel)
+ if (trans && 0 >= qof_instance_get_edit_level (QOF_INSTANCE (trans)))
PERR ("transaction %p not open for editing", trans);
}
/********************************************************************\
@@ -259,7 +382,7 @@
trans->orig = NULL;
trans->idata = 0;
- qof_instance_init (&trans->inst, GNC_ID_TRANS, book);
+ qof_instance_init (QOF_INSTANCE (trans), GNC_ID_TRANS, book);
LEAVE (" ");
}
@@ -273,9 +396,9 @@
g_return_val_if_fail (book, NULL);
- trans = g_new(Transaction, 1);
+ trans = g_object_new (GNC_TYPE_TRANSACTION, NULL);
xaccInitTransaction (trans, book);
- qof_event_gen (&trans->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_event_gen (QOF_ENTITY (trans), QOF_EVENT_CREATE, NULL);
return trans;
}
@@ -355,7 +478,7 @@
Transaction *trans;
GList *node;
- trans = g_new0 (Transaction, 1);
+ trans = g_object_new (GNC_TYPE_TRANSACTION, NULL);
trans->num = CACHE_INSERT (t->num);
trans->description = CACHE_INSERT (t->description);
@@ -377,6 +500,7 @@
* 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;
@@ -400,7 +524,7 @@
GList *node;
qof_event_suspend();
- trans = g_new0 (Transaction, 1);
+ trans = g_object_new (GNC_TYPE_TRANSACTION, NULL);
trans->date_entered = t->date_entered;
trans->date_posted = t->date_posted;
@@ -413,9 +537,8 @@
trans->orig = NULL;
trans->idata = 0;
- qof_instance_init (&trans->inst, GNC_ID_TRANS, t->inst.book);
- kvp_frame_delete (trans->inst.kvp_data);
- trans->inst.kvp_data = kvp_frame_copy (t->inst.kvp_data);
+ 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);
for (node = t->splits; node; node = node->next)
@@ -476,8 +599,7 @@
trans->orig = NULL;
}
- qof_instance_release (&trans->inst);
- g_free(trans);
+ qof_instance_release (QOF_INSTANCE (trans));
LEAVE ("(addr=%p)", trans);
}
@@ -824,9 +946,9 @@
xaccTransBeginEdit (Transaction *trans)
{
if (!trans) return;
- if (!qof_begin_edit(&trans->inst)) return;
+ if (!qof_begin_edit(QOF_INSTANCE (trans))) return;
- if (qof_book_shutting_down(trans->inst.book)) return;
+ if (qof_book_shutting_down(qof_instance_get_book (QOF_INSTANCE (trans)))) return;
xaccOpenLog ();
xaccTransWriteLog (trans, 'B');
@@ -845,9 +967,9 @@
if (!trans) return;
if (!xaccTransGetReadOnly (trans) ||
- qof_book_shutting_down(trans->inst.book)) {
+ qof_book_shutting_down(qof_instance_get_book (QOF_INSTANCE (trans)))) {
xaccTransBeginEdit(trans);
- trans->inst.do_free = TRUE;
+ qof_instance_mark_free (QOF_INSTANCE (trans));
xaccTransCommitEdit(trans);
}
}
@@ -876,7 +998,7 @@
do_destroy (Transaction *trans)
{
SplitList *node;
- gboolean shutting_down = qof_book_shutting_down(trans->inst.book);
+ gboolean shutting_down = qof_book_shutting_down(qof_instance_get_book (QOF_INSTANCE (trans)));
/* If there are capital-gains transactions associated with this,
* they need to be destroyed too. */
@@ -886,7 +1008,7 @@
if (!shutting_down)
xaccTransWriteLog (trans, 'D');
- qof_event_gen (&trans->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (trans), QOF_EVENT_DESTROY, NULL);
/* We only own the splits that still think they belong to us. */
trans->splits = g_list_copy(trans->splits);
@@ -935,6 +1057,7 @@
static void trans_cleanup_commit(Transaction *trans)
{
GList *slist, *node;
+ gint editlevel;
/* ------------------------------------------------- */
/* Make sure all associated splits are in proper order
@@ -980,11 +1103,12 @@
xaccTransSortSplits(trans);
/* Put back to zero. */
- trans->inst.editlevel--;
- g_assert(trans->inst.editlevel == 0);
+ editlevel = qof_instance_get_edit_level (QOF_INSTANCE (trans));
+ editlevel--;
+ qof_instance_set_edit_level (QOF_INSTANCE (trans), editlevel);
gen_event_trans (trans); //TODO: could be conditional
- qof_event_gen (&trans->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen (QOF_ENTITY (trans), QOF_EVENT_MODIFY, NULL);
}
void
@@ -997,10 +1121,12 @@
/* We increment this for the duration of the call
* so other functions don't result in a recursive
* call to xaccTransCommitEdit. */
- trans->inst.editlevel++;
+ 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);
- if (was_trans_emptied(trans)) trans->inst.do_free = 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
@@ -1010,7 +1136,7 @@
* can cause pointers to splits and transactions to disapear out
* from under the holder.
*/
- if (!(trans->inst.do_free) && scrub_data &&
+ if (!qof_instance_do_free (QOF_INSTANCE (trans)) && scrub_data &&
!qof_book_shutting_down(xaccTransGetBook(trans))) {
/* If scrubbing gains recurses through here, don't call it again. */
scrub_data = 0;
@@ -1078,7 +1204,7 @@
trans->date_entered = orig->date_entered;
trans->date_posted = orig->date_posted;
SWAP(trans->common_currency, orig->common_currency);
- SWAP(trans->inst.kvp_data, orig->inst.kvp_data);
+ SWAP(qof_instance_get_kvp_data (QOF_INSTANCE (trans)), qof_instance_get_kvp_data (QOF_INSTANCE (orig)));
/* The splits at the front of trans->splits are exactly the same
splits as in the original, but some of them may have changed, so
@@ -1135,7 +1261,7 @@
/* Now that the engine copy is back to its original version,
* get the backend to fix it in the database */
- be = qof_book_get_backend (trans->inst.book);
+ be = qof_book_get_backend (qof_instance_get_book (QOF_INSTANCE (trans)));
/** \todo Fix transrollbackedit in QOF so that rollback
is exposed via the API. */
if (be && be->rollback)
Modified: gnucash/branches/gobject-engine-dev/src/engine/Transaction.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/Transaction.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/Transaction.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -92,10 +92,29 @@
#include "gnc-engine.h"
#include "Split.h"
-/* FIXME: These macros are not consistent with the type name */
-#define GNC_IS_TRANS(obj) (QOF_CHECK_TYPE((obj), GNC_ID_TRANS))
-#define GNC_TRANS(obj) (QOF_CHECK_CAST((obj), GNC_ID_TRANS, 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 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
@{
*/
Modified: gnucash/branches/gobject-engine-dev/src/engine/TransactionP.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/TransactionP.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/TransactionP.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -71,7 +71,7 @@
* A "split" is more commonly referred to as an "entry" in a "transaction".
*/
-struct transaction_s
+struct _GncTransaction
{
QofInstance inst; /* glbally unique id */
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-budget.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-budget.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-budget.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -40,15 +40,135 @@
static QofLogModule log_module = GNC_MOD_ENGINE;
-struct gnc_budget_private{
- QofInstance inst;
+/* GObject declarations */
+static void gnc_budget_class_init(GncBudgetClass *klass);
+static void gnc_budget_init(GncBudget *sp);
+static void gnc_budget_finalize(GObject *object);
+
+struct _GncBudgetPrivate {
gchar* name;
gchar* description;
Recurrence recurrence;
guint num_periods;
};
+
+typedef struct _GncBudgetSignal GncBudgetSignal;
+typedef enum _GncBudgetSignalType GncBudgetSignalType;
+
+enum _GncBudgetSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncBudgetSignal {
+ GncBudget *object;
+};
+
+static guint gnc_budget_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_budget_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncBudgetClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_budget_class_init,
+ NULL,
+ NULL,
+ sizeof (GncBudget),
+ 0,
+ (GInstanceInitFunc)gnc_budget_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncBudget", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_budget_class_init(GncBudgetClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_budget_finalize;
+ object_class->set_property = gnc_budget_set_property;
+ object_class->get_property = gnc_budget_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_budget_init(GncBudget *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_budget_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_budget_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncBudget *obj;
+
+ obj = QOF_INSTANCE (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_budget_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncBudget *obj;
+
+ obj = QOF_INSTANCE(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+/******************************************************************************/
+
static void commit_err (QofInstance *inst, QofBackendError errcode)
{
PERR ("Failed to commit: %d", errcode);
@@ -66,13 +186,13 @@
/* We first send the message that this object is about to be
* destroyed so that any GUI elements can remove it before it is
* actually gone. */
- qof_event_gen( &budget->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen( QOF_ENTITY (budget), QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE(budget->name);
CACHE_REMOVE(budget->description);
- qof_instance_release (&budget->inst);
- g_free(budget);
+ qof_instance_release (QOF_INSTANCE (budget));
+ //g_free(budget);
}
static void noop (QofInstance *inst) {}
@@ -99,19 +219,21 @@
g_return_val_if_fail(book, NULL);
ENTER(" ");
- budget = g_new0(GncBudget, 1);
- qof_instance_init (&budget->inst, GNC_ID_BUDGET, book);
+ budget = g_object_new (GNC_TYPE_BUDGET, NULL);
+
+ qof_instance_init (QOF_INSTANCE (budget), GNC_ID_BUDGET, book);
g_date_set_time_t(&date, time(NULL));
g_date_subtract_days(&date, g_date_get_day(&date)-1);
- recurrenceSet(&budget->recurrence, 1, PERIOD_MONTH, &date);
+ recurrenceSet(budget->priv->recurrence, 1, PERIOD_MONTH, &date);
gnc_budget_set_name(budget, _("Unnamed Budget"));
gnc_budget_set_description(budget, "");
gnc_budget_set_num_periods(budget, 12);
- qof_event_gen( &budget->inst.entity, QOF_EVENT_CREATE , NULL);
-
+ qof_event_gen( QOF_ENTITY (budget), QOF_EVENT_CREATE , NULL);
+
+ g_signal_emit_by_name ( QOF_ENTITY (budget), "created");
LEAVE(" ");
return budget;
}
@@ -121,7 +243,7 @@
{
g_return_if_fail(GNC_IS_BUDGET(budget));
gnc_budget_begin_edit(budget);
- qof_instance_set_dirty(&budget->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (budget));
budget->inst.do_free = TRUE;
gnc_budget_commit_edit(budget);
}
@@ -133,10 +255,10 @@
gnc_budget_begin_edit(budget);
CACHE_REPLACE(budget->name, name);
- qof_instance_set_dirty(&budget->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (budget));
gnc_budget_commit_edit(budget);
- qof_event_gen( &budget->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen( QOF_ENTITY (budget) , QOF_EVENT_MODIFY, NULL);
}
const gchar*
@@ -154,10 +276,10 @@
gnc_budget_begin_edit(budget);
CACHE_REPLACE(budget->description, description);
- qof_instance_set_dirty(&budget->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (budget));
gnc_budget_commit_edit(budget);
- qof_event_gen( &budget->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen( QOF_ENTITY (budget), QOF_EVENT_MODIFY, NULL);
}
const gchar*
@@ -173,17 +295,17 @@
g_return_if_fail(budget && r);
gnc_budget_begin_edit(budget);
budget->recurrence = *r;
- qof_instance_set_dirty(&budget->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (budget));
gnc_budget_commit_edit(budget);
- qof_event_gen(&budget->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen(QOF_ENTITY (budget), QOF_EVENT_MODIFY, NULL);
}
const Recurrence *
gnc_budget_get_recurrence(GncBudget *budget)
{
g_return_val_if_fail(budget, NULL);
- return (&budget->recurrence);
+ return (budget->priv->recurrence);
}
const GUID*
@@ -201,10 +323,10 @@
gnc_budget_begin_edit(budget);
budget->num_periods = num_periods;
- qof_instance_set_dirty(&budget->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (budget));
gnc_budget_commit_edit(budget);
- qof_event_gen( &budget->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen( QOF_ENTITY (budget), QOF_EVENT_MODIFY, NULL);
}
guint
@@ -235,10 +357,10 @@
g_sprintf(bufend, "/%d", period_num);
kvp_frame_set_value(frame, path, NULL);
- qof_instance_set_dirty(&budget->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (budget));
gnc_budget_commit_edit(budget);
- qof_event_gen( &budget->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen( QOF_ENTITY (entity), QOF_EVENT_MODIFY, NULL);
}
@@ -263,10 +385,10 @@
kvp_frame_set_value(frame, path, NULL);
else
kvp_frame_set_numeric(frame, path, val);
- qof_instance_set_dirty(&budget->inst);
+ qof_instance_set_dirty(QOF_INSTANCE (budget));
gnc_budget_commit_edit(budget);
- qof_event_gen( &budget->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_event_gen( QOF_ENTITY (budget), QOF_EVENT_MODIFY, NULL);
}
@@ -348,7 +470,7 @@
{
Timespec ts;
timespecFromTime_t(
- &ts, recurrenceGetPeriodTime(&budget->recurrence, period_num, FALSE));
+ &ts, recurrenceGetPeriodTime(budget->priv->recurrence, period_num, FALSE));
return ts;
}
@@ -358,7 +480,7 @@
{
// FIXME: maybe zero is not best error return val.
g_return_val_if_fail(GNC_IS_BUDGET(budget) && acc, gnc_numeric_zero());
- return recurrenceGetAccountPeriodValue(&budget->recurrence,
+ return recurrenceGetAccountPeriodValue(budget->priv->recurrence,
acc, period_num);
}
@@ -366,7 +488,7 @@
gnc_budget_get_book(GncBudget* budget)
{
g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL);
- return qof_instance_get_book(&budget->inst);
+ return qof_instance_get_book(QOF_INSTANCE (budget));
}
GncBudget*
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-budget.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-budget.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-budget.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -73,9 +73,35 @@
#include "Account.h"
#include "Recurrence.h"
-#define GNC_IS_BUDGET(obj) (QOF_CHECK_TYPE((obj), GNC_ID_BUDGET))
-#define GNC_BUDGET(obj) (QOF_CHECK_CAST((obj), GNC_ID_BUDGET, GncBudget))
+/* GObject declarations */
+#define GNC_TYPE_BUDGET (gnc_budget_get_type ())
+#define GNC_BUDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_BUDGET, GncBudget))
+#define GNC_BUDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_BUDGET, GncBudgetClass))
+#define GNC_IS_BUDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_BUDGET))
+#define GNC_IS_BUDGET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_BUDGET))
+#define GNC_BUDGET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_BUDGET, GncBudgetClass))
+
+
+typedef struct _GncBudgetClass GncBudgetClass;
+typedef struct _GncBudget GncBudget;
+typedef struct _GncBudgetPrivate GncBudgetPrivate;
+
+struct _GncBudget {
+ QofInstance inst;
+ GncBudgetPrivate *priv;
+};
+
+struct _GncBudgetClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_budget_get_type ();
+
+
#define GNC_BUDGET_MAX_NUM_PERIODS_DIGITS 3 // max num periods == 999
gboolean gnc_budget_register(void);
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -44,10 +44,14 @@
* of the smallest-transactional-units of the currency are there
* in a 'unitname' unit. */
-struct gnc_commodity_s
-{
- QofInstance inst;
+/* GObject declarations */
+static void gnc_commodity_class_init(GncCommodityClass *klass);
+static void gnc_commodity_init(GncCommodity *sp);
+static void gnc_commodity_finalize(GObject *object);
+
+struct _GncCommodityPrivate {
+
gnc_commodity_namespace *namespace;
char * fullname;
@@ -63,16 +67,246 @@
char * quote_tz;
};
-struct gnc_commodity_namespace_s
+typedef struct _GncCommoditySignal GncCommoditySignal;
+typedef enum _GncCommoditySignalType GncCommoditySignalType;
+
+enum _GncCommoditySignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
{
- QofInstance inst;
+ PROP_0
+};
+struct _GncCommoditySignal {
+ GncCommodity *object;
+};
+
+static guint gnc_commodity_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_commodity_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncCommodityClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_commodity_class_init,
+ NULL,
+ NULL,
+ sizeof (GncCommodity),
+ 0,
+ (GInstanceInitFunc)gnc_commodity_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncCommodity", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_commodity_class_init (GncCommodityClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_commodity_finalize;
+ object_class->set_property = gnc_commodity_set_property;
+ object_class->get_property = gnc_commodity_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_commodity_init (GncCommodity *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_commodity_finalize (GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_commodity_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncCommodity *obj;
+
+ obj = GNC_COMMODITY (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_commodity_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncCommodity *obj;
+
+ obj = GNC_COMMODITY(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+/* GncCommodityNamespace */
+/* GObject declarations */
+
+static void gnc_commodity_namespace_class_init (GncCommodityNamespaceClass *klass);
+static void gnc_commodity_namespace_init (GncCommodityNamespace *sp);
+static void gnc_commodity_namespace_finalize (GObject *object);
+
+struct _GncCommodityNamespacePrivate {
gchar * name;
gboolean iso4217;
GHashTable * cm_table;
GList * cm_list;
};
+typedef struct _GncCommodityNamespaceSignal GncCommodityNamespaceSignal;
+typedef enum _GncCommodityNamespaceSignalType GncCommodityNamespaceSignalType;
+
+enum _GncCommodityNamespaceSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncCommodityNamespaceSignal {
+ GncCommodityNamespace *object;
+};
+
+static guint gnc_commodity_namespace_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_commodity_namespace_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncCommodityNamespaceClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_commodity_namespace_class_init,
+ NULL,
+ NULL,
+ sizeof (GncCommodityNamespace),
+ 0,
+ (GInstanceInitFunc)gnc_commodity_namespace_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "GncCommodityNamespace", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_commodity_namespace_class_init(GncCommodityNamespaceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_commodity_namespace_finalize;
+ object_class->set_property = gnc_commodity_namespace_set_property;
+ object_class->get_property = gnc_commodity_namespace_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_commodity_namespace_init(GncCommodityNamespace *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_commodity_namespace_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_commodity_namespace_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncCommodityNamespace *obj;
+
+ obj = GNC_COMMODITY_NAMESPACE (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_commodity_namespace_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncCommodityNamespace *obj;
+
+ obj = GNC_COMMODITY_NAMESPACE (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+/************************************/
struct gnc_commodity_table_s
{
GHashTable * ns_table;
@@ -473,7 +707,7 @@
void
gnc_commodity_begin_edit (gnc_commodity *cm)
{
- qof_begin_edit(&cm->inst);
+ qof_begin_edit(QOF_INSTANCE (cm));
}
static void commit_err (QofInstance *inst, QofBackendError errcode)
@@ -487,7 +721,7 @@
gnc_commodity_commit_edit (gnc_commodity *cm)
{
if (!qof_commit_edit (QOF_INSTANCE(cm))) return;
- qof_commit_edit_part2 (&cm->inst, commit_err, noop, noop);
+ qof_commit_edit_part2 (QOF_INSTANCE (cm), commit_err, noop, noop);
}
/********************************************************************
@@ -497,8 +731,8 @@
static void
mark_commodity_dirty (gnc_commodity *cm)
{
- qof_instance_set_dirty(&cm->inst);
- qof_event_gen (&cm->inst.entity, QOF_EVENT_MODIFY, NULL);
+ qof_instance_set_dirty(QOF_INSTANCE (cm));
+ qof_event_gen (QOF_ENTITY (cm), QOF_EVENT_MODIFY, NULL);
}
static void
@@ -527,7 +761,7 @@
const char * namespace, const char * mnemonic,
const char * cusip, int fraction)
{
- gnc_commodity * retval = g_new0(gnc_commodity, 1);
+ gnc_commodity * retval = g_object_new (GNC_TYPE_COMMODITY, NULL);
gnc_commodity_table *table;
qof_instance_init (&retval->inst, GNC_ID_COMMODITY, book);
@@ -570,33 +804,33 @@
gnc_commodity_table *table;
if(!cm) return;
- book = qof_instance_get_book(&cm->inst);
+ book = qof_instance_get_book(QOF_INSTANCE (cm));
table = gnc_commodity_table_get_table(book);
gnc_commodity_table_remove(table, cm);
- qof_event_gen (&cm->inst.entity, QOF_EVENT_DESTROY, NULL);
+ qof_event_gen (QOF_ENTITY (cm), QOF_EVENT_DESTROY, NULL);
/* Set at creation */
CACHE_REMOVE (cm->fullname);
- CACHE_REMOVE (cm->cusip);
- CACHE_REMOVE (cm->mnemonic);
- CACHE_REMOVE (cm->quote_tz);
- cm->namespace = NULL;
+ CACHE_REMOVE (cm->priv->cusip);
+ CACHE_REMOVE (cm->priv->mnemonic);
+ CACHE_REMOVE (cm->priv->quote_tz);
+ cm->priv->namespace = NULL;
/* Set through accessor functions */
- cm->quote_source = NULL;
+ cm->priv->quote_source = NULL;
/* Automatically generated */
- g_free(cm->printname);
- cm->printname = NULL;
+ g_free(cm->priv->printname);
+ cm->priv->printname = NULL;
- g_free(cm->unique_name);
- cm->unique_name = NULL;
+ g_free(cm->priv->unique_name);
+ cm->priv->unique_name = NULL;
- cm->mark = 0;
+ cm->priv->mark = 0;
- qof_instance_release (&cm->inst);
- g_free(cm);
+ qof_instance_release (Qcm->priv->NSTANCE (cm));
+
}
void
@@ -614,7 +848,7 @@
gnc_commodity *
gnc_commodity_clone(gnc_commodity *src)
{
- gnc_commodity * dest = g_new0(gnc_commodity, 1);
+ gnc_commodity * dest = g_object_new (GNC_TYPE_COMMODITY, NULL);
dest->fullname = CACHE_INSERT(src->fullname);
dest->mnemonic = CACHE_INSERT(src->mnemonic);
@@ -643,7 +877,7 @@
gnc_commodity_get_mnemonic(const gnc_commodity * cm)
{
if(!cm) return NULL;
- return cm->mnemonic;
+ return cm->priv->mnemonic;
}
/********************************************************************
@@ -654,7 +888,7 @@
gnc_commodity_get_printname(const gnc_commodity * cm)
{
if(!cm) return NULL;
- return cm->printname;
+ return cm->priv->printname;
}
@@ -666,25 +900,25 @@
gnc_commodity_get_namespace(const gnc_commodity * cm)
{
if(!cm) return NULL;
- return gnc_commodity_namespace_get_name(cm->namespace);
+ return gnc_commodity_namespace_get_name(cm->priv->namespace);
}
const char *
gnc_commodity_get_namespace_compat(const gnc_commodity * cm)
{
- if (!cm || !cm->namespace) return NULL;
- if (cm->namespace->iso4217) {
+ if (!cm || !cm->priv->namespace) return NULL;
+ if (cm->priv->namespace->iso4217) {
/* Data files are still written with ISO4217. */
return GNC_COMMODITY_NS_ISO;
}
- return gnc_commodity_namespace_get_name(cm->namespace);
+ return gnc_commodity_namespace_get_name(cm->priv->namespace);
}
gnc_commodity_namespace *
gnc_commodity_get_namespace_ds(const gnc_commodity * cm)
{
if(!cm) return NULL;
- return cm->namespace;
+ return cm->priv->namespace;
}
/********************************************************************
@@ -695,7 +929,7 @@
gnc_commodity_get_fullname(const gnc_commodity * cm)
{
if(!cm) return NULL;
- return cm->fullname;
+ return cm->priv->fullname;
}
@@ -707,7 +941,7 @@
gnc_commodity_get_unique_name(const gnc_commodity * cm)
{
if(!cm) return NULL;
- return cm->unique_name;
+ return cm->priv->unique_name;
}
@@ -719,7 +953,7 @@
gnc_commodity_get_cusip(const gnc_commodity * cm)
{
if(!cm) return NULL;
- return cm->cusip;
+ return cm->priv->cusip;
}
/********************************************************************
@@ -730,7 +964,7 @@
gnc_commodity_get_fraction(const gnc_commodity * cm)
{
if(!cm) return 0;
- return cm->fraction;
+ return cm->priv->fraction;
}
/********************************************************************
@@ -741,7 +975,7 @@
gnc_commodity_get_mark(const gnc_commodity * cm)
{
if(!cm) return 0;
- return cm->mark;
+ return cm->priv->mark;
}
/********************************************************************
@@ -752,7 +986,7 @@
gnc_commodity_get_quote_flag(const gnc_commodity *cm)
{
if(!cm) return FALSE;
- return (cm->quote_flag);
+ return (cm->priv->quote_flag);
}
/********************************************************************
@@ -763,9 +997,9 @@
gnc_commodity_get_quote_source(const gnc_commodity *cm)
{
if(!cm) return NULL;
- if (!cm->quote_source && gnc_commodity_is_iso(cm))
+ if (!cm->priv->quote_source && gnc_commodity_is_iso(cm))
return ¤cy_quote_source;
- return cm->quote_source;
+ return cm->priv->quote_source;
}
gnc_quote_source*
@@ -785,7 +1019,7 @@
gnc_commodity_get_quote_tz(const gnc_commodity *cm)
{
if(!cm) return NULL;
- return cm->quote_tz;
+ return cm->priv->quote_tz;
}
/********************************************************************
@@ -796,11 +1030,11 @@
gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic)
{
if(!cm) return;
- if(cm->mnemonic == mnemonic) return;
+ if(cm->priv->mnemonic == mnemonic) return;
gnc_commodity_begin_edit(cm);
- CACHE_REMOVE (cm->mnemonic);
- cm->mnemonic = CACHE_INSERT(mnemonic);
+ CACHE_REMOVE (cm->priv->mnemonic);
+ cm->priv->mnemonic = CACHE_INSERT(mnemonic);
mark_commodity_dirty (cm);
reset_printname(cm);
@@ -820,16 +1054,16 @@
gnc_commodity_namespace *nsp;
if(!cm) return;
- book = qof_instance_get_book (&cm->inst);
+ book = qof_instance_get_book (QOF_INSTANCE (cm));
table = gnc_commodity_table_get_table(book);
nsp = gnc_commodity_table_add_namespace(table, namespace, book);
- if (cm->namespace == nsp)
+ if (cm->priv->namespace == nsp)
return;
gnc_commodity_begin_edit(cm);
- cm->namespace = nsp;
+ cm->priv->namespace = nsp;
if (nsp->iso4217)
- cm->quote_source = gnc_quote_source_lookup_by_internal("currency");
+ cm->priv->quote_source = gnc_quote_source_lookup_by_internal("currency");
mark_commodity_dirty(cm);
reset_printname(cm);
reset_unique_name(cm);
@@ -844,10 +1078,10 @@
gnc_commodity_set_fullname(gnc_commodity * cm, const char * fullname)
{
if(!cm) return;
- if(cm->fullname == fullname) return;
+ if(cm->priv->fullname == fullname) return;
- CACHE_REMOVE (cm->fullname);
- cm->fullname = CACHE_INSERT (fullname);
+ CACHE_REMOVE (cm->priv->fullname);
+ cm->priv->fullname = CACHE_INSERT (fullname);
gnc_commodity_begin_edit(cm);
mark_commodity_dirty(cm);
@@ -864,11 +1098,11 @@
const char * cusip)
{
if(!cm) return;
- if(cm->cusip == cusip) return;
+ if(cm->priv->cusip == cusip) return;
gnc_commodity_begin_edit(cm);
- CACHE_REMOVE (cm->cusip);
- cm->cusip = CACHE_INSERT (cusip);
+ CACHE_REMOVE (cm->priv->cusip);
+ cm->priv->cusip = CACHE_INSERT (cusip);
mark_commodity_dirty(cm);
gnc_commodity_commit_edit(cm);
}
@@ -882,7 +1116,7 @@
{
if(!cm) return;
gnc_commodity_begin_edit(cm);
- cm->fraction = fraction;
+ cm->priv->fraction = fraction;
mark_commodity_dirty(cm);
gnc_commodity_commit_edit(cm);
}
@@ -895,7 +1129,7 @@
gnc_commodity_set_mark(gnc_commodity * cm, gint16 mark)
{
if(!cm) return;
- cm->mark = mark;
+ cm->priv->mark = mark;
}
/********************************************************************
@@ -909,7 +1143,7 @@
if(!cm) return;
gnc_commodity_begin_edit(cm);
- cm->quote_flag = flag;
+ cm->priv->quote_flag = flag;
mark_commodity_dirty(cm);
gnc_commodity_commit_edit(cm);
LEAVE(" ");
@@ -926,7 +1160,7 @@
if(!cm) return;
gnc_commodity_begin_edit(cm);
- cm->quote_source = src;
+ cm->priv->quote_source = src;
mark_commodity_dirty(cm);
gnc_commodity_commit_edit(cm);
LEAVE(" ");
@@ -941,11 +1175,11 @@
{
ENTER ("(cm=%p, tz=%s)", cm, tz);
- if(!cm || tz == cm->quote_tz) return;
+ if(!cm || tz == cm->priv->quote_tz) return;
gnc_commodity_begin_edit(cm);
- CACHE_REMOVE (cm->quote_tz);
- cm->quote_tz = CACHE_INSERT (tz);
+ CACHE_REMOVE (cm->priv->quote_tz);
+ cm->priv->quote_tz = CACHE_INSERT (tz);
mark_commodity_dirty(cm);
gnc_commodity_commit_edit(cm);
LEAVE(" ");
@@ -1395,8 +1629,8 @@
gboolean
gnc_commodity_is_iso(const gnc_commodity * cm)
{
- if (!cm || !cm->namespace) return FALSE;
- return cm->namespace->iso4217;
+ if (!cm || !cm->priv->namespace) return FALSE;
+ return cm->priv->namespace->iso4217;
}
gboolean
@@ -1405,7 +1639,7 @@
const char *ns_name;
if (!cm) return FALSE;
- ns_name = gnc_commodity_namespace_get_name(cm->namespace);
+ ns_name = gnc_commodity_namespace_get_name(cm->priv->namespace);
return (!safe_strcmp(ns_name, GNC_COMMODITY_NS_LEGACY) ||
!safe_strcmp(ns_name, GNC_COMMODITY_NS_CURRENCY));
}
@@ -1519,18 +1753,18 @@
ns = gnc_commodity_table_find_namespace(table, namespace);
if(!ns)
{
- ns = g_new0(gnc_commodity_namespace, 1);
+ ns = g_object_new (GNC_TYPE_COMMODITY_NAMESPACE, NULL);
ns->cm_table = g_hash_table_new(g_str_hash, g_str_equal);
ns->name = CACHE_INSERT((gpointer)namespace);
ns->iso4217 = gnc_commodity_namespace_is_iso(namespace);
- qof_instance_init (&ns->inst, GNC_ID_COMMODITY_NAMESPACE, book);
- qof_event_gen (&ns->inst.entity, QOF_EVENT_CREATE, NULL);
+ qof_instance_init (QOF_INSTANCE (ns), GNC_ID_COMMODITY_NAMESPACE, book);
+ qof_event_gen (QOF_ENTITY (ns), QOF_EVENT_CREATE, NULL);
g_hash_table_insert(table->ns_table,
(gpointer) ns->name,
(gpointer) ns);
table->ns_list = g_list_append(table->ns_list, ns);
- qof_event_gen (&ns->inst.entity, QOF_EVENT_ADD, NULL);
+ qof_event_gen (QOF_ENTITY (ns), QOF_EVENT_ADD, NULL);
}
return ns;
}
@@ -1607,7 +1841,6 @@
qof_event_gen (&ns->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_instance_release(&ns->inst);
- g_free(ns);
}
/********************************************************************
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-commodity.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -49,11 +49,66 @@
#include <glib.h>
#include "gnc-engine.h"
-#define GNC_IS_COMMODITY(obj) (QOF_CHECK_TYPE((obj), GNC_ID_COMMODITY))
-#define GNC_COMMODITY(obj) (QOF_CHECK_CAST((obj), GNC_ID_COMMODITY, gnc_commodity))
-#define GNC_IS_COMMODITY_NAMESPACE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_COMMODITY_NAMESPACE))
-#define GNC_COMMODITY_NAMESPACE(obj) (QOF_CHECK_CAST((obj), GNC_ID_COMMODITY_NAMESPACE, gnc_commodity_namespace))
+/* 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"
/** The commodity namespace definitions are used to tag a commodity by
@@ -252,7 +307,7 @@
*
* @param mnemonic An abbreviation for this stock. For publicly
* traced stocks, this field should contain the stock ticker
- * symbol. This field is used to get online price quotes, so it must
+ * symbol. This field is used to get online price quotes, so it mustgnc_commodity
* match the stock ticker symbol used by the exchange where you want
* to get automatic stock quote updates. E.G. ACME, ACME.US, etc.
*
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-lot-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-lot-p.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-lot-p.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -40,7 +40,7 @@
#include "gnc-lot.h"
#include "Account.h"
-struct gnc_lot_struct
+struct _GncLot
{
QofInstance inst;
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -50,6 +50,129 @@
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_LOT;
+/* GObject declarations */
+
+static void gnc_lot_class_init(GncLotClass *klass);
+static void gnc_lot_init(GncLot *sp);
+static void gnc_lot_finalize(GObject *object);
+
+struct _GncLotPrivate {
+ /* Private Members */
+};
+
+typedef struct _GncLotSignal GncLotSignal;
+typedef enum _GncLotSignalType GncLotSignalType;
+
+enum _GncLotSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncLotSignal {
+ GncLot *object;
+};
+
+static guint gnc_lot_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_lot_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncLotClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_lot_class_init,
+ NULL,
+ NULL,
+ sizeof (GncLot),
+ 0,
+ (GInstanceInitFunc)gnc_lot_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_ENTITY,
+ "GncLot", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_lot_class_init(GncLotClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_lot_finalize;
+ object_class->set_property = gnc_lot_set_property;
+ object_class->get_property = gnc_lot_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_lot_init(GncLot *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_lot_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_lot_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncLot *obj;
+
+ obj = GNC_LOT (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_lot_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncLot *obj;
+
+ obj = GNC_LOT(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
/* ============================================================= */
static void
@@ -71,7 +194,7 @@
GNCLot *lot;
g_return_val_if_fail (book, NULL);
- lot = g_new (GNCLot, 1);
+ lot = g_object_new (GNC_TYPE_LOT, NULL);
gnc_lot_init (lot, book);
qof_event_gen (&lot->inst.entity, QOF_EVENT_CREATE, NULL);
return lot;
@@ -182,7 +305,7 @@
gnc_lot_get_title (GNCLot *lot)
{
if (!lot) return NULL;
- return kvp_frame_get_string (lot->inst.kvp_data, "/title");
+ return kvp_frame_get_string (qof_instance_get_kvp_data (QOF_INSTANCE (lot)), "/title");
}
const char *
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-lot.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -47,7 +47,8 @@
* Lots have an implicit "opening date": the date of the earliest split in
* the lot. The "close date" is the date of the split that brought the lot
* item balance down to zero.
- *
+ *HECK_INSTANCE_TYPE ((o), GNC_TYPE_LOT))
+#define QOF_IS_INSTANCE_CLASS(k) (G_TYP
@{ */
/** @file gnc-lot.h
@@ -62,6 +63,31 @@
#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 *);
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb-p.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb-p.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -30,7 +30,7 @@
#include "gnc-engine.h"
#include "gnc-pricedb.h"
-struct gnc_price_s
+struct _GncPrice
{
/* 'public' data fields */
QofInstance inst; /* globally unique object identifier */
@@ -51,7 +51,7 @@
-struct gnc_price_db_s
+struct _GncPriceDb
{
QofInstance inst; /* globally unique object identifier */
GHashTable *commodity_hash;
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -35,6 +35,130 @@
static gboolean add_price(GNCPriceDB *db, GNCPrice *p);
static gboolean remove_price(GNCPriceDB *db, GNCPrice *p, gboolean cleanup);
+/* GObject declarations */
+
+static void gnc_price_class_init(GncPriceDbClass *klass);
+static void gnc_price_init(GncPriceDb *sp);
+static void gnc_price_finalize(GObject *object);
+
+struct _GncPriceDbPrivate {
+ /* Private Members */
+};
+
+typedef struct _GncPriceDbSignal GncPriceDbSignal;
+typedef enum _GncPriceDbSignalType GncPriceDbSignalType;
+
+enum _GncPriceDbSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncPriceDbSignal {
+ GncPriceDb *object;
+};
+
+static guint gnc_price_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_price_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncPriceDbClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_price_class_init,
+ NULL,
+ NULL,
+ sizeof (GncPriceDb),
+ 0,
+ (GInstanceInitFunc)gnc_price_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_ENTITY,
+ "GncPriceDb", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_price_class_init(GncPriceDbClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_price_finalize;
+ object_class->set_property = gnc_price_set_property;
+ object_class->get_property = gnc_price_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_price_init(GncPriceDb *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_price_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_price_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncPriceDb *obj;
+
+ obj = GNC_PRICE_DB (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_price_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncPriceDb *obj;
+
+ obj = GNC_PRICE_DB (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+
/* ==================================================================== */
/* GNCPrice functions
*/
@@ -47,7 +171,7 @@
g_return_val_if_fail (book, NULL);
- p = g_new0(GNCPrice, 1);
+ p = g_object_new (GNC_TYPE_PRICE, NULL);
p->refcount = 1;
p->version = 0;
@@ -72,8 +196,6 @@
if(p->source) CACHE_REMOVE(p->source);
qof_instance_release (&p->inst);
- memset(p, 0, sizeof(GNCPrice));
- g_free(p);
LEAVE (" ");
}
@@ -554,7 +676,131 @@
you want the prices for, and the second level key is the commodity
that the value is expressed in terms of.
*/
+
+ /* GObject declarations */
+static void gnc_pricedb_class_init(GncPriceDbClass *klass);
+static void gnc_pricedb_init(GncPriceDb *sp);
+static void gnc_pricedb_finalize(GObject *object);
+
+struct _GncPriceDbPrivate {
+ /* Private Members */
+};
+
+typedef struct _GncPriceDbSignal GncPriceDbSignal;
+typedef enum _GncPriceDbSignalType GncPriceDbSignalType;
+
+enum _GncPriceDbSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _GncPriceDbSignal {
+ GncPriceDb *object;
+};
+
+static guint gnc_pricedb_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+gnc_pricedb_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncPriceDbClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)gnc_pricedb_class_init,
+ NULL,
+ NULL,
+ sizeof (GncPriceDb),
+ 0,
+ (GInstanceInitFunc)gnc_pricedb_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_ENTITY,
+ "GncPriceDb", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnc_pricedb_class_init(GncPriceDbClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ object_class->finalize = gnc_pricedb_finalize;
+ object_class->set_property = gnc_pricedb_set_property;
+ object_class->get_property = gnc_pricedb_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+gnc_pricedb_init(GncPriceDb *obj)
+{
+ /* Initialize private members, etc. */
+}
+
+static void
+gnc_pricedb_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+gnc_pricedb_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GncPriceDb *obj;
+
+ obj = GNC_PRICE_DB (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_pricedb_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GncPriceDb *obj;
+
+ obj = GNC_PRICE_DB (object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+/********************/
+
static GNCPriceDB *
gnc_pricedb_create(QofBook * book)
{
@@ -574,7 +820,7 @@
return result;
}
- result = g_new0(GNCPriceDB, 1);
+ result = g_object_new (GNC_TYPE_PRICE_DB, NULL);
qof_instance_init (&result->inst, GNC_ID_PRICEDB, book);
qof_collection_mark_clean(col);
@@ -632,7 +878,6 @@
g_hash_table_destroy (db->commodity_hash);
db->commodity_hash = NULL;
qof_instance_release (&db->inst);
- g_free(db);
}
void
Modified: gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.h
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.h 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/gnc-pricedb.h 2007-02-08 05:49:51 UTC (rev 15522)
@@ -28,6 +28,30 @@
#include "gnc-commodity.h"
#include "gnc-engine.h"
+/**************************** GncPrice Object ****************/
+/* GObject declarations */
+
+#define GNC_TYPE_PRICE (gnc_price_get_type ())
+#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))
+#define GNC_IS_PRICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_PRICE))
+#define GNC_PRICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_PRICE, GncPriceClass))
+
+
+typedef struct _GncPriceClass GncPriceClass;
+typedef struct _GncPrice GncPrice;
+typedef struct GncPrice GNCPrice; /* Dummy type for backward compatilibity */
+
+struct _GncPriceClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_price_get_type ();
+
/** @addtogroup PriceDB
@{ */
/** @file gnc-pricedb.h
@@ -87,7 +111,7 @@
that it can be properly translated. (There are unfortunately
many strings in users databased, so this string must be
translated on output instead of always being used intranslated
- form.)
+ form.)
type: the type of quote - types possible right now are bid, ask,
last, nav, and unknown.
@@ -245,8 +269,28 @@
@{
*/
/** Data type */
-typedef struct gnc_price_db_s GNCPriceDB;
+#define GNC_TYPE_PRICE_DB (gnc_pricedb_get_type ())
+#define GNC_PRICE_DB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_PRICE_DB, GncPriceDb))
+#define GNC_PRICE_DB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_PRICE_DB, GncPriceDbClass))
+#define GNC_IS_PRICE_DB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_PRICE_DB))
+#define GNC_IS_PRICE_DB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_PRICE_DB))
+#define GNC_PRICE_DB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_PRICE_DB, GncPriceDbClass))
+
+
+typedef struct _GncPriceDbClass GncPriceDbClass;
+typedef struct _GncPriceDb GncPriceDb;
+typedef struct GncPriceDb GNCPriceDB; /* Dummy type for backward compatilibity */
+
+struct _GncPriceDbClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType gnc_pricedb_get_type ();
+
/* XXX backwards-compat defines, remove these someday */
#define gnc_book_get_pricedb gnc_pricedb_get_db
Modified: gnucash/branches/gobject-engine-dev/src/engine/test/test-book-merge.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/test/test-book-merge.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/test/test-book-merge.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -29,6 +29,168 @@
#include "test-stuff.h"
#include "gnc-engine.h"
+/* GObject declarations */
+
+#define TEST_TYPE_OBJ (test_obj_get_type ())
+#define TEST_OBJ(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_OBJ, TestObj))
+#define TEST_OBJ_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_OBJ, TestObjClass))
+#define TEST_IS_OBJ(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_OBJ))
+#define TEST_IS_OBJ_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TEST_TYPE_OBJ))
+#define TEST_OBJ_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TEST_TYPE_OBJ, TestObjClass))
+
+
+typedef struct _TestObjClass TestObjClass;
+typedef struct _TestObj TestObj;
+
+/* simple object structure */
+typedef struct _obj
+{
+ QofInstance inst;
+ char *Name;
+ gnc_numeric Amount;
+ const GUID *obj_guid;
+ Timespec date;
+ double discount; /* cheap pun, I know. */
+ gboolean active;
+ gint32 version;
+ gint64 minor;
+} myobj;
+
+struct _TestObjClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType test_obj_get_type ();
+
+/* GObject declarations */
+
+static void test_obj_class_init(TestObjClass *klass);
+static void test_obj_init(TestObj *sp);
+static void test_obj_finalize(GObject *object);
+
+struct _TestObjPrivate {
+ /* Private Members */
+};
+
+typedef struct _TestObjSignal TestObjSignal;
+typedef enum _TestObjSignalType TestObjSignalType;
+
+enum _TestObjSignalType {
+ /* Signals */
+ LAST_SIGNAL
+};
+
+/* properties */
+enum
+{
+ PROP_0
+};
+
+struct _TestObjSignal {
+ TestObj *object;
+};
+
+static guint test_obj_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+test_obj_get_type()
+{
+ static GType type = 0;
+
+ if(type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (TestObjClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)test_obj_class_init,
+ NULL,
+ NULL,
+ sizeof (TestObj),
+ 0,
+ (GInstanceInitFunc)test_obj_init,
+ };
+
+ type = g_type_register_static(QOF_TYPE_INSTANCE,
+ "TestObj", &our_info, 0);
+ }
+
+ return type;
+}
+
+static void
+test_obj_class_init(TestObjClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass)QofBook;
+ object_class->finalize = test_obj_finalize;
+ object_class->set_property = test_obj_set_property;
+ object_class->get_property = test_obj_get_property;
+
+ /* Install properties */
+
+ /* Create signals here:*/
+
+}
+
+static void
+test_obj_init(TestObj *obj)
+{
+ /* Initialize private members, etc. */QofBook
+}
+
+static void
+test_obj_finalize(GObject *object)
+{
+
+ /* Free private members, etc. */
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+test_obj_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TestObj *obj;
+
+ obj = QOF_BOOK (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
+test_obj_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TestObj *obj;
+
+ obj = QOF_BOOK(object);
+
+ switch (property_id) {
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
+ break;
+ }
+}
+
+
+/**********************************/
+
+
#define TEST_MODULE_NAME "book-merge-test"
#define TEST_MODULE_DESC "Test Book Merge"
#define OBJ_NAME "somename"
@@ -40,24 +202,12 @@
#define OBJ_MINOR "tiny"
#define OBJ_ACTIVE "ofcourse"
-static void test_rule_loop (QofBookMergeData*, QofBookMergeRule*, guint);
+static void test_rule_loop (TestObjMergeData*, TestObjMergeRule*, guint);
static void test_merge (void);
gboolean myobjRegister (void);
-/* simple object structure */
-typedef struct obj_s
-{
- QofInstance inst;
- char *Name;
- gnc_numeric Amount;
- const GUID *obj_guid;
- Timespec date;
- double discount; /* cheap pun, I know. */
- gboolean active;
- gint32 version;
- gint64 minor;
-}myobj;
+
myobj* obj_create(QofBook*);
/* obvious setter functions */
@@ -85,7 +235,7 @@
{
myobj *g;
g_return_val_if_fail(book, NULL);
- g = g_new(myobj, 1);
+ g = g_object_new (TEST_TYPE_OBJ, NULL);
qof_instance_init (&g->inst, TEST_MODULE_NAME, book);
obj_setGUID(g,qof_instance_get_guid(&g->inst));
g->date.tv_nsec = 0;
Modified: gnucash/branches/gobject-engine-dev/src/engine/test/test-recursive.c
===================================================================
--- gnucash/branches/gobject-engine-dev/src/engine/test/test-recursive.c 2007-02-08 01:04:45 UTC (rev 15521)
+++ gnucash/branches/gobject-engine-dev/src/engine/test/test-recursive.c 2007-02-08 05:49:51 UTC (rev 15522)
@@ -30,6 +30,29 @@
#include "test-engine-stuff.h"
#include "test-stuff.h"
+/* GObject declarations */
+
+#define TEST_TYPE_CHILD_OBJ (test_child_obj_get_type ())
+#define QOF_BOOK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_CHILD_OBJ, TestChildObj))
+#define QOF_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_CHILD_OBJ, TestChildObjClass))
+#define TEST_IS_CHILD_OBJ(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_CHILD_OBJ))
+#define TEST_IS_CHILD_OBJ_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TEST_TYPE_CHILD_OBJ))
+#define TEST_CHILD_OBJ_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TEST_TYPE_CHILD_OBJ, TestChildObjClass))
+
+
+typedef struct _TestChildObjClass TestChildObjClass;
+typedef struct _TestChildObj TestChildObj;
+
+struct _TestChildObjClass {
+ QofInstanceClass parent_class;
+ /* virtual table */
+
+ /* Add Signal Functions Here */
+};
+
+GType test_child_obj_get_type ();
+
+
#define GRAND_MODULE_NAME "recursive-grandparent"
#define PARENT_MODULE_NAME "recursive-parent"
#define CHILD_MODULE_NAME "recursive-child"
@@ -52,7 +75,7 @@
static gboolean debug = FALSE;
/* simple object structure */
-typedef struct child_s
+typedef struct _TestChildObj
{
QofInstance inst;
gchar *Name;
@@ -66,7 +89,7 @@
}mychild;
/* simple object structure */
-typedef struct parent_s
+typedef struct _TestParentObj
{
QofInstance inst;
mychild *child;
@@ -81,7 +104,7 @@
}myparent;
/* simple object structure */
-typedef struct grand_s
+typedef struct _TestGrandObj
{
QofInstance inst;
myparent *child;
@@ -764,7 +787,7 @@
(QofSetterFunc)child_setActive },
{ OBJ_VERSION, QOF_TYPE_INT32, (QofAccessFunc)child_getVersion,
(QofSetterFunc)child_setVersion },
- { OBJ_MINOR, QOF_TYPE_INT64, (QofAccessFunc)child_getMinor,
+ { OBJ_Mqof_bookINOR, QOF_TYPE_INT64, (QofAccessFunc)child_getMinor,
(QofSetterFunc)child_setMinor },
{ OBJ_FLAG, QOF_TYPE_CHAR, (QofAccessFunc)child_getFlag,
(QofSetterFunc)child_setFlag },
More information about the gnucash-changes
mailing list