Add gncOnwer* convenience wrappers for BeginEdit, CommitEdit and Destroy. This allows to begin edit, commit edit or destroy an owner without knowing its type.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20622 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2011-05-11 21:51:27 +00:00
parent dea629301a
commit 19b60850bf
2 changed files with 105 additions and 0 deletions

View File

@ -61,6 +61,101 @@ void gncOwnerFree (GncOwner *owner)
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;

View File

@ -179,6 +179,16 @@ KvpFrame* gncOwnerGetSlots(GncOwner* owner);
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_ */
/** @} */
/** @} */