r15785 - gnucash/branches/gobject-engine-dev-warlord - Convert Account object to GObject

Derek Atkins warlord at cvs.gnucash.org
Tue Apr 3 18:58:44 EDT 2007


Author: warlord
Date: 2007-04-03 18:58:42 -0400 (Tue, 03 Apr 2007)
New Revision: 15785
Trac: http://svn.gnucash.org/trac/changeset/15785

Modified:
   gnucash/branches/gobject-engine-dev-warlord/
   gnucash/branches/gobject-engine-dev-warlord/src/engine/Account.c
   gnucash/branches/gobject-engine-dev-warlord/src/engine/Account.h
   gnucash/branches/gobject-engine-dev-warlord/src/engine/AccountP.h
Log:
Convert Account object to GObject



Property changes on: gnucash/branches/gobject-engine-dev-warlord
___________________________________________________________________
Name: svk:merge
   - 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/swig-redo:802
3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:1037
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord:14369
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord1:14379
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:14282
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk2:13366
   + 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/swig-redo:802
3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:1037
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord:14369
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord1:14383
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:14282
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk2:13366

Modified: gnucash/branches/gobject-engine-dev-warlord/src/engine/Account.c
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/src/engine/Account.c	2007-04-03 22:30:58 UTC (rev 15784)
+++ gnucash/branches/gobject-engine-dev-warlord/src/engine/Account.c	2007-04-03 22:58:42 UTC (rev 15785)
@@ -108,11 +108,23 @@
 /********************************************************************\
 \********************************************************************/
 
+QOF_GOBJECT_IMPL(gnc_account, Account, QOF_TYPE_INSTANCE);
+
 static void
+gnc_account_init(Account* acc)
+{
+}
+
+static void
+gnc_account_finalize_real(GObject* acctp)
+{
+}
+
+static void
 xaccInitAccount (Account * acc, QofBook *book)
 {
   ENTER ("book=%p\n", book);
-  qof_instance_init (&acc->inst, GNC_ID_ACCOUNT, book);
+  qof_instance_init_data (&acc->inst, GNC_ID_ACCOUNT, book);
 
   acc->parent   = NULL;
   acc->children = NULL;
@@ -231,7 +243,7 @@
 
   g_return_val_if_fail (book, NULL);
 
-  acc = g_new (Account, 1);
+  acc = g_object_new (GNC_TYPE_ACCOUNT, NULL);
   xaccInitAccount (acc, book);
   qof_event_gen (&acc->inst, QOF_EVENT_CREATE, NULL);
 
@@ -260,7 +272,7 @@
     if (!from || !book) return NULL;
     ENTER (" ");
 
-    ret = g_new (Account, 1);
+    ret = g_object_new (GNC_TYPE_ACCOUNT, NULL);
     g_return_val_if_fail (ret, NULL);
 
     xaccInitAccount (ret, book);
@@ -412,8 +424,8 @@
   acc->balance_dirty = FALSE;
   acc->sort_dirty = FALSE;
 
-  qof_instance_release (&acc->inst);
-  g_free(acc);
+  /* qof_instance_release (&acc->inst); */
+  g_object_unref(acc);
 }
 
 /********************************************************************\

Modified: gnucash/branches/gobject-engine-dev-warlord/src/engine/Account.h
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/src/engine/Account.h	2007-04-03 22:30:58 UTC (rev 15784)
+++ gnucash/branches/gobject-engine-dev-warlord/src/engine/Account.h	2007-04-03 22:58:42 UTC (rev 15785)
@@ -59,9 +59,22 @@
 typedef void (*AccountCb)(Account *a, gpointer data);
 typedef gpointer (*AccountCb2)(Account *a, gpointer data);
 
-#define GNC_IS_ACCOUNT(obj)  (QOF_CHECK_TYPE((obj), GNC_ID_ACCOUNT))
-#define GNC_ACCOUNT(obj)     (QOF_CHECK_CAST((obj), GNC_ID_ACCOUNT, Account))
+typedef struct _AccountClass AccountClass;
 
+/* --- type macros --- */
+#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))
+GType gnc_account_get_type(void);
+
 /** 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-warlord/src/engine/AccountP.h
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/src/engine/AccountP.h	2007-04-03 22:30:58 UTC (rev 15784)
+++ gnucash/branches/gobject-engine-dev-warlord/src/engine/AccountP.h	2007-04-03 22:58:42 UTC (rev 15785)
@@ -133,6 +133,11 @@
   guint32  idata;     /* used by the sql backend for kvp management */
 };
 
+struct _AccountClass
+{
+  QofInstanceClass parent_class;
+};
+
 /* The xaccAccountSortSplits() routine will resort the account's 
  * splits if the sort is dirty. If 'force' is true, the account 
  * is sorted even if the editlevel is not zero. 



More information about the gnucash-changes mailing list