r20622 - gnucash/trunk/src/engine - Add gncOnwer* convenience wrappers for BeginEdit, CommitEdit and Destroy. This allows to begin edit, commit edit or destroy an owner without knowing its type.

Geert Janssens gjanssens at code.gnucash.org
Wed May 11 17:51:27 EDT 2011


Author: gjanssens
Date: 2011-05-11 17:51:27 -0400 (Wed, 11 May 2011)
New Revision: 20622
Trac: http://svn.gnucash.org/trac/changeset/20622

Modified:
   gnucash/trunk/src/engine/gncOwner.c
   gnucash/trunk/src/engine/gncOwner.h
Log:
Add gncOnwer* convenience wrappers for BeginEdit, CommitEdit and Destroy. This allows to begin edit, commit edit or destroy an owner without knowing its type.

Modified: gnucash/trunk/src/engine/gncOwner.c
===================================================================
--- gnucash/trunk/src/engine/gncOwner.c	2011-05-11 21:51:17 UTC (rev 20621)
+++ gnucash/trunk/src/engine/gncOwner.c	2011-05-11 21:51:27 UTC (rev 20622)
@@ -61,6 +61,101 @@
     g_free (owner);
 }
 
+void gncOwnerBeginEdit (GncOwner *owner)
+{
+    if (!owner) return;
+    switch (owner->type)
+    {
+    case GNC_OWNER_NONE :
+    case GNC_OWNER_UNDEFINED :
+        break;
+    case GNC_OWNER_CUSTOMER :
+    {
+        gncCustomerBeginEdit(owner->owner.customer);
+        break;
+    }
+    case GNC_OWNER_JOB :
+    {
+        gncJobBeginEdit(owner->owner.job);
+        break;
+    }
+    case GNC_OWNER_VENDOR :
+    {
+        gncVendorBeginEdit(owner->owner.vendor);
+        break;
+    }
+    case GNC_OWNER_EMPLOYEE :
+    {
+        gncEmployeeBeginEdit(owner->owner.employee);
+        break;
+    }
+    }
+}
+
+
+void gncOwnerCommitEdit (GncOwner *owner)
+{
+    if (!owner) return;
+    switch (owner->type)
+    {
+    case GNC_OWNER_NONE :
+    case GNC_OWNER_UNDEFINED :
+        break;
+    case GNC_OWNER_CUSTOMER :
+    {
+        gncCustomerCommitEdit(owner->owner.customer);
+        break;
+    }
+    case GNC_OWNER_JOB :
+    {
+        gncJobCommitEdit(owner->owner.job);
+        break;
+    }
+    case GNC_OWNER_VENDOR :
+    {
+        gncVendorCommitEdit(owner->owner.vendor);
+        break;
+    }
+    case GNC_OWNER_EMPLOYEE :
+    {
+        gncEmployeeCommitEdit(owner->owner.employee);
+        break;
+    }
+    }
+}
+
+
+void gncOwnerDestroy (GncOwner *owner)
+{
+    if (!owner) return;
+    switch (owner->type)
+    {
+    case GNC_OWNER_NONE :
+    case GNC_OWNER_UNDEFINED :
+        break;
+    case GNC_OWNER_CUSTOMER :
+    {
+        gncCustomerDestroy(owner->owner.customer);
+        break;
+    }
+    case GNC_OWNER_JOB :
+    {
+        gncJobDestroy(owner->owner.job);
+        break;
+    }
+    case GNC_OWNER_VENDOR :
+    {
+        gncVendorDestroy(owner->owner.vendor);
+        break;
+    }
+    case GNC_OWNER_EMPLOYEE :
+    {
+        gncEmployeeDestroy(owner->owner.employee);
+        break;
+    }
+    }
+}
+
 void gncOwnerInitUndefined (GncOwner *owner, gpointer obj)
 {
     if (!owner) return;

Modified: gnucash/trunk/src/engine/gncOwner.h
===================================================================
--- gnucash/trunk/src/engine/gncOwner.h	2011-05-11 21:51:17 UTC (rev 20621)
+++ gnucash/trunk/src/engine/gncOwner.h	2011-05-11 21:51:27 UTC (rev 20622)
@@ -179,6 +179,16 @@
 GncOwner * gncOwnerNew (void);
 void gncOwnerFree (GncOwner *owner);
 
+
+/**
+ * These are convenience wrappers around gnc{Vender,Customer,Job,Employee}*
+ * functions. This allows you to begin edit, destroy commit edit an owner
+ * without knowing its type.
+ */
+void gncOwnerBeginEdit (GncOwner *owner);
+void gncOwnerCommitEdit (GncOwner *owner);
+void gncOwnerDestroy (GncOwner *owner);
+
 #endif /* GNC_OWNER_H_ */
 /** @} */
 /** @} */



More information about the gnucash-changes mailing list