emit gnc events for the business objects.

change the address API to know about its parents' guid, and emit events
 based upon the parent
get the job-select dialog to use events to update
fix a crash in the invoice and order dialogs when creating a new one.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6754 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2002-03-02 18:55:01 +00:00
parent 587430402d
commit e130451499
14 changed files with 216 additions and 74 deletions

View File

@ -10,12 +10,15 @@
#include "gnc-engine-util.h" /* safe_strcmp */
#include "QueryObject.h"
#include "guid.h"
#include "gnc-event-p.h"
#include "gncAddress.h"
#include "gncAddressP.h"
struct _gncAddress {
GNCBook * book;
const GUID * parent_guid;
gboolean dirty;
char * name;
char * addr1;
@ -33,9 +36,18 @@ struct _gncAddress {
#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
G_INLINE_FUNC void mark_address (GncAddress *address);
G_INLINE_FUNC void
mark_address (GncAddress *address)
{
address->dirty = TRUE;
gnc_engine_generate_event (address->parent_guid, GNC_EVENT_MODIFY);
}
/* Create/Destroy functions */
GncAddress * gncAddressCreate (GNCBook *book)
GncAddress * gncAddressCreate (GNCBook *book, const GUID *parent)
{
GncAddress *addr;
@ -44,6 +56,7 @@ GncAddress * gncAddressCreate (GNCBook *book)
addr = g_new0 (GncAddress, 1);
addr->book = book;
addr->dirty = FALSE;
addr->parent_guid = parent;
addr->name = CACHE_INSERT ("");
addr->addr1 = CACHE_INSERT ("");
@ -88,7 +101,7 @@ void gncAddressSetName (GncAddress *addr, const char *name)
if (!addr) return;
if (!name) return;
SET_STR(addr->name, name);
addr->dirty = TRUE;
mark_address (addr);
}
void gncAddressSetAddr1 (GncAddress *addr, const char *addr1)
@ -96,7 +109,7 @@ void gncAddressSetAddr1 (GncAddress *addr, const char *addr1)
if (!addr) return;
if (!addr1) return;
SET_STR(addr->addr1, addr1);
addr->dirty = TRUE;
mark_address (addr);
}
void gncAddressSetAddr2 (GncAddress *addr, const char *addr2)
@ -104,7 +117,7 @@ void gncAddressSetAddr2 (GncAddress *addr, const char *addr2)
if (!addr) return;
if (!addr2) return;
SET_STR(addr->addr2, addr2);
addr->dirty = TRUE;
mark_address (addr);
}
void gncAddressSetAddr3 (GncAddress *addr, const char *addr3)
@ -112,7 +125,7 @@ void gncAddressSetAddr3 (GncAddress *addr, const char *addr3)
if (!addr) return;
if (!addr3) return;
SET_STR(addr->addr3, addr3);
addr->dirty = TRUE;
mark_address (addr);
}
void gncAddressSetAddr4 (GncAddress *addr, const char *addr4)
@ -120,7 +133,7 @@ void gncAddressSetAddr4 (GncAddress *addr, const char *addr4)
if (!addr) return;
if (!addr4) return;
SET_STR(addr->addr4, addr4);
addr->dirty = TRUE;
mark_address (addr);
}
void gncAddressSetPhone (GncAddress *addr, const char *phone)
@ -128,7 +141,7 @@ void gncAddressSetPhone (GncAddress *addr, const char *phone)
if (!addr) return;
if (!phone) return;
SET_STR(addr->phone, phone);
addr->dirty = TRUE;
mark_address (addr);
}
void gncAddressSetFax (GncAddress *addr, const char *fax)
@ -136,7 +149,7 @@ void gncAddressSetFax (GncAddress *addr, const char *fax)
if (!addr) return;
if (!fax) return;
SET_STR(addr->fax, fax);
addr->dirty = TRUE;
mark_address (addr);
}
void gncAddressSetEmail (GncAddress *addr, const char *email)
@ -144,7 +157,7 @@ void gncAddressSetEmail (GncAddress *addr, const char *email)
if (!addr) return;
if (!email) return;
SET_STR(addr->email, email);
addr->dirty = TRUE;
mark_address (addr);
}
/* Get Functions */

View File

@ -16,7 +16,7 @@ typedef struct _gncAddress GncAddress;
/* Create/Destroy functions */
GncAddress * gncAddressCreate (GNCBook *book);
GncAddress * gncAddressCreate (GNCBook *book, const GUID *parent);
void gncAddressDestroy (GncAddress *addr);
/* Set functions */

View File

@ -16,6 +16,7 @@
#include "gnc-numeric.h"
#include "gncObject.h"
#include "QueryObject.h"
#include "gnc-event-p.h"
#include "gncBusiness.h"
#include "gncCustomer.h"
@ -47,6 +48,15 @@ struct _gncCustomer {
static void addObj (GncCustomer *cust);
static void remObj (GncCustomer *cust);
G_INLINE_FUNC void mark_customer (GncCustomer *customer);
G_INLINE_FUNC void
mark_customer (GncCustomer *customer)
{
customer->dirty = TRUE;
gnc_engine_generate_event (&customer->guid, GNC_EVENT_MODIFY);
}
/* Create/Destroy Functions */
GncCustomer *gncCustomerCreate (GNCBook *book)
@ -62,8 +72,8 @@ GncCustomer *gncCustomerCreate (GNCBook *book)
cust->name = CACHE_INSERT ("");
cust->notes = CACHE_INSERT ("");
cust->terms = CACHE_INSERT ("Net-30");
cust->addr = gncAddressCreate (book);
cust->shipaddr = gncAddressCreate (book);
cust->addr = gncAddressCreate (book, &cust->guid);
cust->shipaddr = gncAddressCreate (book, &cust->guid);
cust->discount = gnc_numeric_zero();
cust->credit = gnc_numeric_zero();
cust->taxincluded = FALSE;
@ -73,6 +83,8 @@ GncCustomer *gncCustomerCreate (GNCBook *book)
xaccGUIDNew (&cust->guid, book);
addObj (cust);
gnc_engine_generate_event (&cust->guid, GNC_EVENT_CREATE);
return cust;
}
@ -80,6 +92,8 @@ void gncCustomerDestroy (GncCustomer *cust)
{
if (!cust) return;
gnc_engine_generate_event (&cust->guid, GNC_EVENT_DESTROY);
CACHE_REMOVE (cust->id);
CACHE_REMOVE (cust->name);
CACHE_REMOVE (cust->notes);
@ -109,7 +123,7 @@ void gncCustomerSetID (GncCustomer *cust, const char *id)
if (!cust) return;
if (!id) return;
SET_STR(cust->id, id);
cust->dirty = TRUE;
mark_customer (cust);
}
void gncCustomerSetName (GncCustomer *cust, const char *name)
@ -117,7 +131,7 @@ void gncCustomerSetName (GncCustomer *cust, const char *name)
if (!cust) return;
if (!name) return;
SET_STR(cust->name, name);
cust->dirty = TRUE;
mark_customer (cust);
}
void gncCustomerSetNotes (GncCustomer *cust, const char *notes)
@ -125,7 +139,7 @@ void gncCustomerSetNotes (GncCustomer *cust, const char *notes)
if (!cust) return;
if (!notes) return;
SET_STR(cust->notes, notes);
cust->dirty = TRUE;
mark_customer (cust);
}
void gncCustomerSetGUID (GncCustomer *cust, const GUID *guid)
@ -142,7 +156,7 @@ void gncCustomerSetTerms (GncCustomer *cust, const char *terms)
{
if (!cust || !terms) return;
SET_STR(cust->terms, terms);
cust->dirty = TRUE;
mark_customer (cust);
}
void gncCustomerSetTaxIncluded (GncCustomer *cust, gboolean taxincl)
@ -150,7 +164,7 @@ void gncCustomerSetTaxIncluded (GncCustomer *cust, gboolean taxincl)
if (!cust) return;
if (taxincl == cust->taxincluded) return;
cust->taxincluded = taxincl;
cust->dirty = TRUE;
mark_customer (cust);
}
void gncCustomerSetActive (GncCustomer *cust, gboolean active)
@ -158,7 +172,7 @@ void gncCustomerSetActive (GncCustomer *cust, gboolean active)
if (!cust) return;
if (active == cust->active) return;
cust->active = active;
cust->dirty = TRUE;
mark_customer (cust);
}
void gncCustomerSetDiscount (GncCustomer *cust, gnc_numeric discount)
@ -166,7 +180,7 @@ void gncCustomerSetDiscount (GncCustomer *cust, gnc_numeric discount)
if (!cust) return;
if (gnc_numeric_equal (discount, cust->discount)) return;
cust->discount = discount;
cust->dirty = TRUE;
mark_customer (cust);
}
void gncCustomerSetCredit (GncCustomer *cust, gnc_numeric credit)
@ -174,7 +188,7 @@ void gncCustomerSetCredit (GncCustomer *cust, gnc_numeric credit)
if (!cust) return;
if (gnc_numeric_equal (credit, cust->credit)) return;
cust->credit = credit;
cust->dirty = TRUE;
mark_customer (cust);
}
/* Note that JobList changes do not affect the "dirtiness" of the customer */
@ -186,6 +200,8 @@ void gncCustomerAddJob (GncCustomer *cust, GncJob *job)
if (g_list_index(cust->jobs, job) == -1)
cust->jobs = g_list_insert_sorted (cust->jobs, job,
(GCompareFunc)gncJobCompare);
gnc_engine_generate_event (&cust->guid, GNC_EVENT_MODIFY);
}
void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
@ -202,6 +218,7 @@ void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
cust->jobs = g_list_remove_link (cust->jobs, node);
g_list_free_1 (node);
}
gnc_engine_generate_event (&cust->guid, GNC_EVENT_MODIFY);
}
void gncCustomerCommitEdit (GncCustomer *cust)

View File

@ -16,6 +16,7 @@
#include "GNCIdP.h"
#include "gncObject.h"
#include "QueryObject.h"
#include "gnc-event-p.h"
#include "gncBusiness.h"
#include "gncEmployee.h"
@ -44,6 +45,15 @@ struct _gncEmployee {
static void addObj (GncEmployee *employee);
static void remObj (GncEmployee *employee);
G_INLINE_FUNC void mark_employee (GncEmployee *employee);
G_INLINE_FUNC void
mark_employee (GncEmployee *employee)
{
employee->dirty = TRUE;
gnc_engine_generate_event (&employee->guid, GNC_EVENT_MODIFY);
}
/* Create/Destroy Functions */
GncEmployee *gncEmployeeCreate (GNCBook *book)
@ -60,7 +70,7 @@ GncEmployee *gncEmployeeCreate (GNCBook *book)
employee->username = CACHE_INSERT ("");
employee->language = CACHE_INSERT ("");
employee->acl = CACHE_INSERT ("");
employee->addr = gncAddressCreate (book);
employee->addr = gncAddressCreate (book, &employee->guid);
employee->workday = gnc_numeric_zero();
employee->rate = gnc_numeric_zero();
employee->active = TRUE;
@ -68,6 +78,8 @@ GncEmployee *gncEmployeeCreate (GNCBook *book)
xaccGUIDNew (&employee->guid, book);
addObj (employee);
gnc_engine_generate_event (&employee->guid, GNC_EVENT_CREATE);
return employee;
}
@ -75,6 +87,8 @@ void gncEmployeeDestroy (GncEmployee *employee)
{
if (!employee) return;
gnc_engine_generate_event (&employee->guid, GNC_EVENT_DESTROY);
CACHE_REMOVE (employee->id);
CACHE_REMOVE (employee->username);
CACHE_REMOVE (employee->language);
@ -101,7 +115,7 @@ void gncEmployeeSetID (GncEmployee *employee, const char *id)
if (!employee) return;
if (!id) return;
SET_STR(employee->id, id);
employee->dirty = TRUE;
mark_employee (employee);
}
void gncEmployeeSetUsername (GncEmployee *employee, const char *username)
@ -109,7 +123,7 @@ void gncEmployeeSetUsername (GncEmployee *employee, const char *username)
if (!employee) return;
if (!username) return;
SET_STR(employee->username, username);
employee->dirty = TRUE;
mark_employee (employee);
}
void gncEmployeeSetLanguage (GncEmployee *employee, const char *language)
@ -117,7 +131,7 @@ void gncEmployeeSetLanguage (GncEmployee *employee, const char *language)
if (!employee) return;
if (!language) return;
SET_STR(employee->language, language);
employee->dirty = TRUE;
mark_employee (employee);
}
void gncEmployeeSetGUID (GncEmployee *employee, const GUID *guid)
@ -134,7 +148,7 @@ void gncEmployeeSetAcl (GncEmployee *employee, const char *acl)
if (!employee) return;
if (!acl) return;
SET_STR(employee->acl, acl);
employee->dirty = TRUE;
mark_employee (employee);
}
void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday)
@ -142,7 +156,7 @@ void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday)
if (!employee) return;
if (gnc_numeric_equal (workday, employee->workday)) return;
employee->workday = workday;
employee->dirty = TRUE;
mark_employee (employee);
}
void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate)
@ -150,7 +164,7 @@ void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate)
if (!employee) return;
if (gnc_numeric_equal (rate, employee->rate)) return;
employee->rate = rate;
employee->dirty = TRUE;
mark_employee (employee);
}
void gncEmployeeSetActive (GncEmployee *employee, gboolean active)
@ -158,7 +172,7 @@ void gncEmployeeSetActive (GncEmployee *employee, gboolean active)
if (!employee) return;
if (active == employee->active) return;
employee->active = active;
employee->dirty = TRUE;
mark_employee (employee);
}
/* Get Functions */

View File

@ -17,6 +17,7 @@
#include "gnc-book-p.h"
#include "GNCIdP.h"
#include "QueryObject.h"
#include "gnc-event-p.h"
#include "gncBusiness.h"
#include "gncEntry.h"
@ -69,6 +70,15 @@ struct _gncInvoice {
static void addObj (GncInvoice *invoice);
static void remObj (GncInvoice *invoice);
G_INLINE_FUNC void mark_invoice (GncInvoice *invoice);
G_INLINE_FUNC void
mark_invoice (GncInvoice *invoice)
{
invoice->dirty = TRUE;
gnc_engine_generate_event (&invoice->guid, GNC_EVENT_MODIFY);
}
/* Create/Destroy Functions */
GncInvoice *gncInvoiceCreate (GNCBook *book)
@ -89,6 +99,8 @@ GncInvoice *gncInvoiceCreate (GNCBook *book)
xaccGUIDNew (&invoice->guid, book);
addObj (invoice);
gnc_engine_generate_event (&invoice->guid, GNC_EVENT_CREATE);
return invoice;
}
@ -96,6 +108,8 @@ void gncInvoiceDestroy (GncInvoice *invoice)
{
if (!invoice) return;
gnc_engine_generate_event (&invoice->guid, GNC_EVENT_DESTROY);
CACHE_REMOVE (invoice->id);
CACHE_REMOVE (invoice->notes);
g_list_free (invoice->entries);
@ -122,63 +136,63 @@ void gncInvoiceSetID (GncInvoice *invoice, const char *id)
{
if (!invoice || !id) return;
SET_STR (invoice->id, id);
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner)
{
if (!invoice || !owner) return;
gncOwnerCopy (owner, &invoice->owner);
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date)
{
if (!invoice) return;
invoice->date_opened = date;
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date)
{
if (!invoice) return;
invoice->date_posted = date;
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetDateDue (GncInvoice *invoice, Timespec date)
{
if (!invoice) return;
invoice->date_due = date;
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetDatePaid (GncInvoice *invoice, Timespec date)
{
if (!invoice) return;
invoice->date_paid = date;
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetTerms (GncInvoice *invoice, const char *terms)
{
if (!invoice) return;
SET_STR (invoice->terms, terms);
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes)
{
if (!invoice || !notes) return;
SET_STR (invoice->notes, notes);
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetActive (GncInvoice *invoice, gboolean active)
{
if (!invoice) return;
invoice->active = active;
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetDirty (GncInvoice *invoice, gboolean dirty)
@ -192,7 +206,7 @@ void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn)
if (!invoice) return;
invoice->posted_txn = txn;
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetPaidTxn (GncInvoice *invoice, Transaction *txn)
@ -200,7 +214,7 @@ void gncInvoiceSetPaidTxn (GncInvoice *invoice, Transaction *txn)
if (!invoice) return;
invoice->paid_txn = txn;
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc)
@ -208,7 +222,7 @@ void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc)
if (!invoice) return;
invoice->posted_acc = acc;
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceAddEntry (GncInvoice *invoice, GncEntry *entry)
@ -224,7 +238,7 @@ void gncInvoiceAddEntry (GncInvoice *invoice, GncEntry *entry)
gncEntrySetInvoice (entry, invoice);
invoice->entries = g_list_insert_sorted (invoice->entries, entry,
(GCompareFunc)gncEntryCompare);
invoice->dirty = TRUE;
mark_invoice (invoice);
}
void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry)
@ -233,7 +247,7 @@ void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry)
gncEntrySetInvoice (entry, NULL);
invoice->entries = g_list_remove (invoice->entries, entry);
invoice->dirty = TRUE;
mark_invoice (invoice);
}
/* Get Functions */

View File

@ -16,6 +16,7 @@
#include "gnc-book-p.h"
#include "GNCIdP.h"
#include "QueryObject.h"
#include "gnc-event-p.h"
#include "gncBusiness.h"
#include "gncJob.h"
@ -40,6 +41,15 @@ struct _gncJob {
static void addObj (GncJob *job);
static void remObj (GncJob *job);
G_INLINE_FUNC void mark_job (GncJob *job);
G_INLINE_FUNC void
mark_job (GncJob *job)
{
job->dirty = TRUE;
gnc_engine_generate_event (&job->guid, GNC_EVENT_MODIFY);
}
/* Create/Destroy Functions */
GncJob *gncJobCreate (GNCBook *book)
@ -60,6 +70,8 @@ GncJob *gncJobCreate (GNCBook *book)
xaccGUIDNew (&job->guid, book);
addObj (job);
gnc_engine_generate_event (&job->guid, GNC_EVENT_CREATE);
return job;
}
@ -67,6 +79,8 @@ void gncJobDestroy (GncJob *job)
{
if (!job) return;
gnc_engine_generate_event (&job->guid, GNC_EVENT_DESTROY);
CACHE_REMOVE (job->id);
CACHE_REMOVE (job->name);
CACHE_REMOVE (job->desc);
@ -101,7 +115,7 @@ void gncJobSetID (GncJob *job, const char *id)
if (!job) return;
if (!id) return;
SET_STR(job->id, id);
job->dirty = TRUE;
mark_job (job);
}
void gncJobSetName (GncJob *job, const char *name)
@ -109,7 +123,7 @@ void gncJobSetName (GncJob *job, const char *name)
if (!job) return;
if (!name) return;
SET_STR(job->name, name);
job->dirty = TRUE;
mark_job (job);
}
void gncJobSetReference (GncJob *job, const char *desc)
@ -117,7 +131,7 @@ void gncJobSetReference (GncJob *job, const char *desc)
if (!job) return;
if (!desc) return;
SET_STR(job->desc, desc);
job->dirty = TRUE;
mark_job (job);
}
void gncJobSetGUID (GncJob *job, const GUID *guid)
@ -159,7 +173,7 @@ void gncJobSetOwner (GncJob *job, GncOwner *owner)
default:
}
job->dirty = TRUE;
mark_job (job);
}
void gncJobSetActive (GncJob *job, gboolean active)
@ -167,7 +181,7 @@ void gncJobSetActive (GncJob *job, gboolean active)
if (!job) return;
if (active == job->active) return;
job->active = active;
job->dirty = TRUE;
mark_job (job);
}
void gncJobCommitEdit (GncJob *job)

View File

@ -15,6 +15,7 @@
#include "gnc-book-p.h"
#include "GNCIdP.h"
#include "QueryObject.h"
#include "gnc-event-p.h"
#include "gncBusiness.h"
#include "gncEntry.h"
@ -57,6 +58,15 @@ struct _gncOrder {
static void addObj (GncOrder *order);
static void remObj (GncOrder *order);
G_INLINE_FUNC void mark_order (GncOrder *order);
G_INLINE_FUNC void
mark_order (GncOrder *order)
{
order->dirty = TRUE;
gnc_engine_generate_event (&order->guid, GNC_EVENT_MODIFY);
}
/* Create/Destroy Functions */
GncOrder *gncOrderCreate (GNCBook *book)
@ -77,6 +87,8 @@ GncOrder *gncOrderCreate (GNCBook *book)
xaccGUIDNew (&order->guid, book);
addObj (order);
gnc_engine_generate_event (&order->guid, GNC_EVENT_CREATE);
return order;
}
@ -84,6 +96,8 @@ void gncOrderDestroy (GncOrder *order)
{
if (!order) return;
gnc_engine_generate_event (&order->guid, GNC_EVENT_DESTROY);
g_list_free (order->entries);
CACHE_REMOVE (order->id);
CACHE_REMOVE (order->notes);
@ -111,7 +125,7 @@ void gncOrderSetID (GncOrder *order, const char *id)
{
if (!order || !id) return;
SET_STR (order->id, id);
order->dirty = TRUE;
mark_order (order);
}
void gncOrderSetOwner (GncOrder *order, GncOwner *owner)
@ -119,42 +133,42 @@ void gncOrderSetOwner (GncOrder *order, GncOwner *owner)
if (!order || !owner) return;
gncOwnerCopy (owner, &order->owner);
order->dirty = TRUE;
mark_order (order);
}
void gncOrderSetDateOpened (GncOrder *order, Timespec date)
{
if (!order) return;
order->opened = date;
order->dirty = TRUE;
mark_order (order);
}
void gncOrderSetDateClosed (GncOrder *order, Timespec date)
{
if (!order) return;
order->closed = date;
order->dirty = TRUE;
mark_order (order);
}
void gncOrderSetNotes (GncOrder *order, const char *notes)
{
if (!order || !notes) return;
SET_STR (order->notes, notes);
order->dirty = TRUE;
mark_order (order);
}
void gncOrderSetReference (GncOrder *order, const char *reference)
{
if (!order || !reference) return;
SET_STR (order->reference, reference);
order->dirty = TRUE;
mark_order (order);
}
void gncOrderSetActive (GncOrder *order, gboolean active)
{
if (!order) return;
order->active = active;
order->dirty = TRUE;
mark_order (order);
}
void gncOrderSetDirty (GncOrder *order, gboolean dirty)
@ -179,7 +193,7 @@ void gncOrderAddEntry (GncOrder *order, GncEntry *entry)
/* This will send out an event -- make sure we're attached */
gncEntrySetOrder (entry, order);
order->dirty = TRUE;
mark_order (order);
}
void gncOrderRemoveEntry (GncOrder *order, GncEntry *entry)
@ -188,7 +202,7 @@ void gncOrderRemoveEntry (GncOrder *order, GncEntry *entry)
gncEntrySetOrder (entry, NULL);
order->entries = g_list_remove (order->entries, entry);
order->dirty = TRUE;
mark_order (order);
}
/* Get Functions */

View File

@ -15,6 +15,7 @@
#include "gnc-book-p.h"
#include "GNCIdP.h"
#include "QueryObject.h"
#include "gnc-event-p.h"
#include "gncBusiness.h"
#include "gncVendor.h"
@ -43,6 +44,15 @@ struct _gncVendor {
static void addObj (GncVendor *vendor);
static void remObj (GncVendor *vendor);
G_INLINE_FUNC void mark_vendor (GncVendor *vendor);
G_INLINE_FUNC void
mark_vendor (GncVendor *vendor)
{
vendor->dirty = TRUE;
gnc_engine_generate_event (&vendor->guid, GNC_EVENT_MODIFY);
}
/* Create/Destroy Functions */
GncVendor *gncVendorCreate (GNCBook *book)
@ -58,13 +68,15 @@ GncVendor *gncVendorCreate (GNCBook *book)
vendor->name = CACHE_INSERT ("");
vendor->notes = CACHE_INSERT ("");
vendor->terms = CACHE_INSERT ("");
vendor->addr = gncAddressCreate (book);
vendor->addr = gncAddressCreate (book, &vendor->guid);
vendor->taxincluded = FALSE;
vendor->active = TRUE;
xaccGUIDNew (&vendor->guid, book);
addObj (vendor);
gnc_engine_generate_event (&vendor->guid, GNC_EVENT_CREATE);
return vendor;
}
@ -72,6 +84,8 @@ void gncVendorDestroy (GncVendor *vendor)
{
if (!vendor) return;
gnc_engine_generate_event (&vendor->guid, GNC_EVENT_DESTROY);
CACHE_REMOVE (vendor->id);
CACHE_REMOVE (vendor->name);
CACHE_REMOVE (vendor->notes);
@ -100,7 +114,7 @@ void gncVendorSetID (GncVendor *vendor, const char *id)
if (!vendor) return;
if (!id) return;
SET_STR(vendor->id, id);
vendor->dirty = TRUE;
mark_vendor (vendor);
}
void gncVendorSetName (GncVendor *vendor, const char *name)
@ -108,7 +122,7 @@ void gncVendorSetName (GncVendor *vendor, const char *name)
if (!vendor) return;
if (!name) return;
SET_STR(vendor->name, name);
vendor->dirty = TRUE;
mark_vendor (vendor);
}
void gncVendorSetNotes (GncVendor *vendor, const char *notes)
@ -116,7 +130,7 @@ void gncVendorSetNotes (GncVendor *vendor, const char *notes)
if (!vendor) return;
if (!notes) return;
SET_STR(vendor->notes, notes);
vendor->dirty = TRUE;
mark_vendor (vendor);
}
void gncVendorSetGUID (GncVendor *vendor, const GUID *guid)
@ -133,7 +147,7 @@ void gncVendorSetTerms (GncVendor *vendor, const char *terms)
{
if (!vendor || !terms) return;
SET_STR(vendor->terms, terms);
vendor->dirty = TRUE;
mark_vendor (vendor);
}
void gncVendorSetTaxIncluded (GncVendor *vendor, gboolean taxincl)
@ -141,7 +155,7 @@ void gncVendorSetTaxIncluded (GncVendor *vendor, gboolean taxincl)
if (!vendor) return;
if (taxincl == vendor->taxincluded) return;
vendor->taxincluded = taxincl;
vendor->dirty = TRUE;
mark_vendor (vendor);
}
void gncVendorSetActive (GncVendor *vendor, gboolean active)
@ -149,7 +163,7 @@ void gncVendorSetActive (GncVendor *vendor, gboolean active)
if (!vendor) return;
if (active == vendor->active) return;
vendor->active = active;
vendor->dirty = TRUE;
mark_vendor (vendor);
}
/* Get Functions */
@ -217,6 +231,8 @@ void gncVendorAddJob (GncVendor *vendor, GncJob *job)
if (g_list_index(vendor->jobs, job) == -1)
vendor->jobs = g_list_insert_sorted (vendor->jobs, job,
(GCompareFunc)gncJobCompare);
gnc_engine_generate_event (&vendor->guid, GNC_EVENT_MODIFY);
}
void gncVendorRemoveJob (GncVendor *vendor, GncJob *job)
@ -233,6 +249,8 @@ void gncVendorRemoveJob (GncVendor *vendor, GncJob *job)
vendor->jobs = g_list_remove_link (vendor->jobs, node);
g_list_free_1 (node);
}
gnc_engine_generate_event (&vendor->guid, GNC_EVENT_MODIFY);
}
void gncVendorCommitEdit (GncVendor *vendor)

View File

@ -22,8 +22,8 @@ test_address (void)
/* Test creation/destruction */
{
do_test (gncAddressCreate (NULL) == NULL, "address create NULL");
address = gncAddressCreate (book);
do_test (gncAddressCreate (NULL, NULL) == NULL, "address create NULL");
address = gncAddressCreate (book, NULL);
do_test (address != NULL, "address create");
gncAddressDestroy (address);
@ -32,7 +32,7 @@ test_address (void)
/* Test setting routines */
{
address = gncAddressCreate (book);
address = gncAddressCreate (book, NULL);
test_string_fcn (address, "Name", gncAddressSetName, gncAddressGetName);
test_string_fcn (address, "Addr1", gncAddressSetAddr1, gncAddressGetAddr1);
test_string_fcn (address, "Addr2", gncAddressSetAddr2, gncAddressGetAddr2);

View File

@ -60,7 +60,7 @@ test_customer (void)
test_string_fcn (book, "Name", gncCustomerSetName, gncCustomerGetName);
test_string_fcn (book, "Notes", gncCustomerSetNotes, gncCustomerGetNotes);
test_gint_fcn (book, "Terms", gncCustomerSetTerms, gncCustomerGetTerms);
test_string_fcn (book, "Terms", gncCustomerSetTerms, gncCustomerGetTerms);
test_numeric_fcn (book, "Discount", gncCustomerSetDiscount, gncCustomerGetDiscount);
test_numeric_fcn (book, "Credit", gncCustomerSetCredit, gncCustomerGetCredit);

View File

@ -62,7 +62,7 @@ test_vendor (void)
test_string_fcn (book, "Name", gncVendorSetName, gncVendorGetName);
test_string_fcn (book, "Notes", gncVendorSetNotes, gncVendorGetNotes);
test_gint_fcn (book, "Terms", gncVendorSetTerms, gncVendorGetTerms);
test_string_fcn (book, "Terms", gncVendorSetTerms, gncVendorGetTerms);
test_bool_fcn (book, "TaxIncluded", gncVendorSetTaxIncluded, gncVendorGetTaxIncluded);
test_bool_fcn (book, "Active", gncVendorSetActive, gncVendorGetActive);

View File

@ -963,7 +963,7 @@ new_invoice_cb (GtkWidget *parent, gpointer *invoice_p, gpointer user_data)
g_return_val_if_fail (invoice_p && user_data, TRUE);
*invoice_p = gnc_invoice_new (sw->parent, sw->owner, sw->book);
*invoice_p = gnc_invoice_new (parent, sw->owner, sw->book);
return sw->no_close;
}

View File

@ -15,6 +15,7 @@
#include "gncObject.h"
#include "gnc-general-select.h"
#include "window-help.h"
#include "gnc-component-manager.h"
#include "gncJob.h"
#include "business-utils.h"
@ -23,6 +24,8 @@
#include "dialog-order.h"
#include "dialog-invoice.h"
#define DIALOG_JOB_SELECT_CM_CLASS "dialog-job-select"
struct select_job_window {
GtkWidget * dialog;
GtkWidget * owner_hbox;
@ -32,6 +35,8 @@ struct select_job_window {
GtkWidget * parent;
gint component_id;
GNCBook * book;
GncJob * job;
GncOwner owner;
@ -50,6 +55,8 @@ update_job_select_picker (struct select_job_window *w)
/* Clear out the existing choices */
gtk_list_clear_items (GTK_LIST (w->job_list), 0, -1);
/* Clear the watches */
gnc_gui_component_clear_watches (w->component_id);
/*
* Fill out the list of jobs from the current owner
@ -72,6 +79,11 @@ update_job_select_picker (struct select_job_window *w)
saved_job = w->job;
w->job = NULL;
/* Watch the owner for changes */
gnc_gui_component_watch_entity (w->component_id,
gncOwnerGetGUID (&(w->owner)),
GNC_EVENT_MODIFY);
/* Get the list of jobs */
switch (gncOwnerGetType (&(w->owner))) {
case GNC_OWNER_CUSTOMER:
@ -98,6 +110,11 @@ update_job_select_picker (struct select_job_window *w)
itemlist = g_list_prepend (itemlist, li);
if (iterator->data == saved_job)
this_job = li;
/* Watch this item in case it changes */
gnc_gui_component_watch_entity (w->component_id,
gncJobGetGUID (iterator->data),
GNC_EVENT_MODIFY);
}
/* This will make sure we're in the right order at the end */
@ -141,7 +158,7 @@ gnc_ui_select_job_ok_cb(GtkButton * button, gpointer user_data)
struct select_job_window * w = user_data;
if(w->job) {
gnome_dialog_close(GNOME_DIALOG (w->dialog));
gnc_close_gui_component (w->component_id);
} else {
gnc_warning_dialog(_("You must select a job.\n"
"To create a new one, click \"New\""));
@ -205,8 +222,6 @@ gnc_ui_select_job_edit_cb(GtkButton * button, gpointer user_data)
return;
gnc_ui_job_window_create (w->job);
// gncOwnerCopy (gncJobGetOwner (w->job), &(w->owner));
// update_owner_select_picker (w);
}
static void
@ -216,7 +231,7 @@ gnc_ui_select_job_cancel_cb(GtkButton * button, gpointer user_data)
if (w) {
w->job = NULL;
gnome_dialog_close(GNOME_DIALOG (w->dialog));
gnc_close_gui_component (w->component_id);
}
}
@ -236,6 +251,22 @@ select_job_close (GnomeDialog *dialog, gpointer data)
return FALSE;
}
static void
refresh_handler (GHashTable *changes, gpointer data)
{
struct select_job_window * sw = data;
update_job_select_picker (sw);
}
static void
close_handler (gpointer data)
{
struct select_job_window * sw = data;
gnome_dialog_close (GNOME_DIALOG (sw->dialog));
}
static GncJob *
gnc_job_select (GtkWidget * parent, GncJob *start_job,
GncOwner *ownerp, GNCBook *book, gboolean provide_select)
@ -314,6 +345,10 @@ gnc_job_select (GtkWidget * parent, GncJob *start_job,
GTK_SIGNAL_FUNC (select_job_owner_changed_cb),
win);
win->component_id = gnc_register_gui_component (DIALOG_JOB_SELECT_CM_CLASS,
refresh_handler,
close_handler, win);
gtk_signal_connect (GTK_OBJECT(win->dialog), "close",
GTK_SIGNAL_FUNC(select_job_close), win);
@ -332,6 +367,9 @@ gnc_job_select (GtkWidget * parent, GncJob *start_job,
gtk_main();
/* exit */
gnc_unregister_gui_component (win->component_id);
retval = win->job;
g_free(win);

View File

@ -829,7 +829,7 @@ new_order_cb (GtkWidget *parent, gpointer *order_p, gpointer user_data)
g_return_val_if_fail (order_p && user_data, TRUE);
*order_p = gnc_order_new (sw->parent, sw->owner, sw->book);
*order_p = gnc_order_new (parent, sw->owner, sw->book);
return sw->no_close;
}