Derek Atkins's business accounting patch.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5902 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-11-17 01:17:06 +00:00
parent d68ffe2d70
commit 94d8372af6
74 changed files with 10578 additions and 37 deletions

View File

@ -834,6 +834,10 @@ AC_OUTPUT(
src/tax/us/Makefile
src/tax/us/test/Makefile
src/test-core/Makefile
src/business/Makefile
src/business/business-core/Makefile
src/business/business-core/test/Makefile
src/business/business-gnome/Makefile
dnl # non-makefiles
dnl # Please read doc/build-system before adding *anything* here

View File

@ -158,7 +158,6 @@ src/engine/gnc-engine-util.c
src/app-file/gnc-file.c
src/app-file/gncmod-app-file.c
src/app-file/gnome/gnc-file-history.c
src/app-file/gnome/gncmod-app-file-gnome.c
src/app-file/gnome/gnc-file-dialog.c
src/experimental/cgi-bin/fastcgi-hello.c
src/experimental/cgi-bin/gnc-server.c
@ -232,7 +231,6 @@ src/gnome/gnucash.desktop.in
src/gnome/window-main-summarybar.c
src/gnome/argv-list-converters.c
src/gnome/file-utils.c
src/guile/tip-of-the-day.c
src/import-export/qif-import/dialog-account-picker.c
src/import-export/qif-import/druid-qif-import.c
src/import-export/qif-import/gncmod-qif-import.c

View File

@ -20,6 +20,7 @@ SUBDIRS = \
scm \
quotes \
pixmaps \
business \
optional
# Engine Makefile.am file.
@ -48,12 +49,12 @@ gnucash_LDADD = \
gnome/libgncguile.la \
gnome/libgncgnome.la \
gnome/libgncguile.la \
${GUILE_LIBS} \
${GUPPI_LIBS} \
${GNOME_LIBDIR} \
${GNOMEUI_LIBS} \
${GNOME_PRINT_LIBS} \
${G_WRAP_LINK_ARGS} \
${GUILE_LIBS} \
${GTKHTML_LIBS} \
${GHTTP_LIBS} \
${GLADE_LIBS} \

View File

@ -19,8 +19,7 @@ gncinclude_HEADERS = \
gnc-file-history-gnome.h
libgnc_app_file_gnome_la_LIBADD = \
${GUILE_LIBS} \
${GNOMEUI_LIBS} \
${GNOME_LIBDIR} \
${GLIB_LIBS} \
${GUILE_LIBS}
${GLIB_LIBS}

1
src/business/.cvsignore Normal file
View File

@ -0,0 +1 @@
Makefile

4
src/business/Makefile.am Normal file
View File

@ -0,0 +1,4 @@
SUBDIRS = \
business-core \
business-gnome

View File

@ -0,0 +1,6 @@
.scm-links
Makefile
gw-business-core.c
gw-business-core.h
gw-business-core.html
gw-business-core.scm

View File

@ -0,0 +1,70 @@
SUBDIRS = . test
pkglib_LTLIBRARIES = libgw-business-core.la libgncmod-business-core.la
AM_CFLAGS = \
-I${top_srcdir}/src \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
${G_WRAP_COMPILE_ARGS} \
${GUILE_INCS} \
${GLIB_CFLAGS}
libgncmod_business_core_la_SOURCES = \
businessmod-core.c \
gncAddress.c \
gncBusiness.c \
gncCustomer.c \
gncEmployee.c \
gncJob.c \
gncVendor.c
noinst_HEADERS = \
gncAddress.h \
gncBusiness.h \
gncCustomer.h \
gncCustomerP.h \
gncEmployee.h \
gncEmployeeP.h \
gncJob.h \
gncJobP.h \
gncVendor.h \
gncVendorP.h
libgncmod_business_core_la_LDFLAGS = -module
libgncmod_business_core_la_LIBADD = \
${GUILE_LIBS} \
${GLIB_LIBS} \
${EFENCE_LIBS}
# business-core-helpers.c
libgw_business_core_la_SOURCES = gw-business-core.c
libgw_business_core_la_LDFLAGS = -module ${G_WRAP_LINK_ARGS}
gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
gncmod_DATA = business-core.scm
gwmoddir = ${GNC_GWRAP_LIBDIR}
gwmod_DATA = \
gw-business-core.scm \
gw-business-core-spec.scm
.scm-links:
rm -f gnucash g-wrapped
ln -sf . gnucash
ln -sf . g-wrapped
touch .scm-links
gncmod-business-core.c: gw-business-core.h
gw-business-core.scm gw-business-core.c gw-business-core.h: .scm-links gw-business-core-spec.scm
FLAVOR=gnome guile -c \
"(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
(set! %load-path (cons \"${PWD}\" %load-path)) \
(set! %load-path (cons \"../../engine\" %load-path)) \
(primitive-load \"./gw-business-core-spec.scm\") \
(gw:generate-module \"gw-business-core\")"
BUILT_SOURCES = gw-business-core.scm gw-business-core.c gw-business-core.h
CLEANFILES = gw-business-core.scm gw-business-core.c gw-business-core.h gw-business-core.html

View File

@ -0,0 +1 @@
(define-module (gnucash business-core))

View File

@ -0,0 +1,72 @@
/*********************************************************************
* businessmod-core.c
* module definition/initialization for the core Business module
*
* Copyright (c) 2001 Derek Atkins <warlord@MIT.EDU>
*********************************************************************/
#include <stdio.h>
#include <guile/gh.h>
#include <glib.h>
#include "gnc-module.h"
#include "gnc-module-api.h"
#include "gw-business-core.h"
#include "gncBusinessP.h"
#include "gncCustomerP.h"
#include "gncEmployeeP.h"
#include "gncJobP.h"
#include "gncVendorP.h"
/* version of the gnc module system interface we require */
int gnc_module_system_interface = 0;
/* module versioning uses libtool semantics. */
int gnc_module_current = 0;
int gnc_module_revision = 0;
int gnc_module_age = 0;
char *
gnc_module_path(void)
{
return g_strdup("gnucash/business-core");
}
char *
gnc_module_description(void)
{
return g_strdup("The Gnucash business core");
}
int
gnc_module_init(int refcount)
{
/* load the engine (we depend on it) */
if(!gnc_module_load("gnucash/engine", 0)) {
return FALSE;
}
if(refcount == 0)
{
/* initialize the business engine on the first load */
gncBusinessInitialize (0, NULL);
/* initialize known types */
gncCustomerRegister ();
gncEmployeeRegister ();
gncJobRegister ();
gncVendorRegister ();
}
gh_eval_str("(use-modules (g-wrapped gw-business-core))");
gh_eval_str("(use-modules (gnucash business-core))");
return TRUE;
}
int
gnc_module_end(int refcount) {
return TRUE;
}

View File

@ -0,0 +1,205 @@
/*
* gncAddress.h -- an Address object
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <glib.h>
#include <string.h> /* for strcmp */
#include "gncAddress.h"
struct _gncAddress {
GncBusiness * business;
gboolean dirty;
char * name;
char * addr1;
char * addr2;
char * addr3;
char * addr4;
char * phone;
char * fax;
char * email;
};
#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));
/* Create/Destroy functions */
GncAddress * gncAddressCreate (GncBusiness *business)
{
GncAddress *addr;
if (!business) return NULL;
addr = g_new0 (GncAddress, 1);
addr->business = business;
addr->dirty = FALSE;
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 ("");
return addr;
}
void gncAddressDestroy (GncAddress *addr){
if (!addr) return;
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);
g_free (addr);
}
/* Set functions */
#define SET_STR(member, str) { \
char * tmp; \
\
if (!strcmp (member, str)) return; \
tmp = CACHE_INSERT (str); \
CACHE_REMOVE (member); \
member = tmp; \
}
void gncAddressSetName (GncAddress *addr, const char *name)
{
if (!addr) return;
if (!name) return;
SET_STR(addr->name, name);
addr->dirty = TRUE;
}
void gncAddressSetAddr1 (GncAddress *addr, const char *addr1)
{
if (!addr) return;
if (!addr1) return;
SET_STR(addr->addr1, addr1);
addr->dirty = TRUE;
}
void gncAddressSetAddr2 (GncAddress *addr, const char *addr2)
{
if (!addr) return;
if (!addr2) return;
SET_STR(addr->addr2, addr2);
addr->dirty = TRUE;
}
void gncAddressSetAddr3 (GncAddress *addr, const char *addr3)
{
if (!addr) return;
if (!addr3) return;
SET_STR(addr->addr3, addr3);
addr->dirty = TRUE;
}
void gncAddressSetAddr4 (GncAddress *addr, const char *addr4)
{
if (!addr) return;
if (!addr4) return;
SET_STR(addr->addr4, addr4);
addr->dirty = TRUE;
}
void gncAddressSetPhone (GncAddress *addr, const char *phone)
{
if (!addr) return;
if (!phone) return;
SET_STR(addr->phone, phone);
addr->dirty = TRUE;
}
void gncAddressSetFax (GncAddress *addr, const char *fax)
{
if (!addr) return;
if (!fax) return;
SET_STR(addr->fax, fax);
addr->dirty = TRUE;
}
void gncAddressSetEmail (GncAddress *addr, const char *email)
{
if (!addr) return;
if (!email) return;
SET_STR(addr->email, email);
addr->dirty = TRUE;
}
/* Get Functions */
const char * gncAddressGetName (const GncAddress *addr)
{
if (!addr) return NULL;
return addr->name;
}
const char * gncAddressGetAddr1 (const GncAddress *addr)
{
if (!addr) return NULL;
return addr->addr1;
}
const char * gncAddressGetAddr2 (const GncAddress *addr)
{
if (!addr) return NULL;
return addr->addr2;
}
const char * gncAddressGetAddr3 (const GncAddress *addr)
{
if (!addr) return NULL;
return addr->addr3;
}
const char * gncAddressGetAddr4 (const GncAddress *addr)
{
if (!addr) return NULL;
return addr->addr4;
}
const char * gncAddressGetPhone (const GncAddress *addr)
{
if (!addr) return NULL;
return addr->phone;
}
const char * gncAddressGetFax (const GncAddress *addr)
{
if (!addr) return NULL;
return addr->fax;
}
const char * gncAddressGetEmail (const GncAddress *addr)
{
if (!addr) return NULL;
return addr->email;
}
gboolean gncAddressIsDirty (const GncAddress *addr)
{
if (!addr) return FALSE;
return addr->dirty;
}
void gncAddressClearDirty (GncAddress *addr)
{
if (!addr) return;
addr->dirty = FALSE;
}

View File

@ -0,0 +1,44 @@
/*
* gncAddress.h -- an Address object
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_ADDRESS_H_
#define GNC_ADDRESS_H_
#include "gncBusiness.h"
struct _gncAddress;
typedef struct _gncAddress GncAddress;
/* Create/Destroy functions */
GncAddress * gncAddressCreate (GncBusiness *business);
void gncAddressDestroy (GncAddress *addr);
/* Set functions */
void gncAddressSetName (GncAddress *addr, const char *name);
void gncAddressSetAddr1 (GncAddress *addr, const char *addr1);
void gncAddressSetAddr2 (GncAddress *addr, const char *addr2);
void gncAddressSetAddr3 (GncAddress *addr, const char *addr3);
void gncAddressSetAddr4 (GncAddress *addr, const char *addr4);
void gncAddressSetPhone (GncAddress *addr, const char *phone);
void gncAddressSetFax (GncAddress *addr, const char *fax);
void gncAddressSetEmail (GncAddress *addr, const char *email);
void gncAddressClearDirty (GncAddress *address);
/* Get Functions */
const char * gncAddressGetName (const GncAddress *addr);
const char * gncAddressGetAddr1 (const GncAddress *addr);
const char * gncAddressGetAddr2 (const GncAddress *addr);
const char * gncAddressGetAddr3 (const GncAddress *addr);
const char * gncAddressGetAddr4 (const GncAddress *addr);
const char * gncAddressGetPhone (const GncAddress *addr);
const char * gncAddressGetFax (const GncAddress *addr);
const char * gncAddressGetEmail (const GncAddress *addr);
gboolean gncAddressIsDirty (const GncAddress *addr);
#endif /* GNC_ADDRESS_H_ */

View File

@ -0,0 +1,171 @@
/*
* gncBusiness.c -- the Core Business Object Registry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <glib.h>
#include <string.h>
#include "messages.h"
#include "gncBusiness.h"
#include "gncBusinessP.h"
static gboolean business_is_initialized = FALSE;
static GList *business_modules = NULL;
struct _gncBusiness {
GHashTable * objects;
GNCSession * session;
};
GncBusiness *gncBusinessCreate (GNCSession *session)
{
GncBusiness *bus;
GList *iter;
if (!session) return NULL;
bus = g_new0 (GncBusiness, 1);
bus->objects = g_hash_table_new (g_str_hash, g_str_equal);
bus->session = session;
/* Populate the objects hash table with hash tables for
* each of the business objects.
*/
for (iter = business_modules; iter; iter = iter->next) {
const GncBusinessObject *obj = iter->data;
g_hash_table_insert (bus->objects, (gpointer)obj->name,
guid_hash_table_new ());
}
return bus;
}
void gncBusinessDestroy (GncBusiness *bus)
{
if (!bus) return;
/* XXX: destroy the objects under us... */
g_hash_table_destroy (bus->objects);
g_free (bus);
}
GNCSession * gncBusinessGetSession (const GncBusiness *bus)
{
if (!bus) return NULL;
return bus->session;
}
gpointer
gncBusinessLookupGUID (GncBusiness *business, const char *type_name,
const GUID * guid)
{
GHashTable *table;
if (!business || !type_name || !guid) return NULL;
table = gncBusinessEntityTable (business, type_name);
if (!table) return NULL;
return g_hash_table_lookup (table, guid);
}
GList *
gncBusinessGetList (GncBusiness *business, const char *type_name,
gboolean show_all)
{
const GncBusinessObject *obj;
if (!business || !type_name) return NULL;
obj = gncBusinessLookup (type_name);
if (!obj) return NULL;
if (obj->get_list)
return ((*(obj->get_list))(business, show_all));
return NULL;
}
const char *
gncBusinessPrintable (GncBusiness *business, const char *type_name,
gpointer obj)
{
const GncBusinessObject *b_obj;
if (!business || !type_name || !obj) return NULL;
b_obj = gncBusinessLookup (type_name);
if (!b_obj) return NULL;
if (b_obj->printable)
return ((*(b_obj->printable))(obj));
return NULL;
}
const char * gncBusinessGetTypeLabel (const char *type_name)
{
const GncBusinessObject *obj;
if (!type_name) return NULL;
obj = gncBusinessLookup (type_name);
if (!obj) return NULL;
return _(obj->type_label);
}
/* INITIALIZATION and PRIVATE FUNCTIONS */
void
gncBusinessInitialize (int argc, char **argv)
{
if (business_is_initialized) return;
business_is_initialized = TRUE;
}
/* Register new types of business objects.
* Return TRUE if successful,
* return FALSE if it fails, invalid arguments, or if the object
* already exists
*/
gboolean gncBusinessRegister (const GncBusinessObject *object)
{
if (!object) return FALSE;
if (object->version != GNC_BUSINESS_VERSION) return FALSE;
if (!business_is_initialized) return FALSE;
if (g_list_index (business_modules, (gpointer)object) == -1)
business_modules = g_list_append (business_modules, (gpointer)object);
else
return FALSE;
return TRUE;
}
const GncBusinessObject * gncBusinessLookup (const char *name)
{
GList *iter;
const GncBusinessObject *obj;
if (!name) return NULL;
for (iter = business_modules; iter; iter = iter->next) {
obj = iter->data;
if (!strcmp (obj->name, name))
return obj;
}
return NULL;
}
GHashTable * gncBusinessEntityTable (GncBusiness *bus, const char *name)
{
if (!bus || !name) return NULL;
return (g_hash_table_lookup (bus->objects, name));
}

View File

@ -0,0 +1,64 @@
/*
* gncBusiness.h -- the Core Business Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_BUSINESS_H_
#define GNC_BUSINESS_H_
#include "gnc-session.h"
/* Defines the version of the core business object registration
* interface. Only business modules compiled against this version
* of the interface will load properly
*/
#define GNC_BUSINESS_VERSION 1
typedef struct _gncBusinessObject GncBusinessObject;
typedef struct _gncBusiness GncBusiness;
/* This is the Business Object descriptor */
struct _gncBusinessObject {
gint version;
const char * name;
const char * type_label;
void (*destroy)(GncBusiness *);
GList * (*get_list)(GncBusiness *, gboolean show_all);
const char * (*printable)(gpointer obj);
};
/* Create and Destroy the Gnc Business subsystem state */
GncBusiness *gncBusinessCreate (GNCSession *session);
void gncBusinessDestroy (GncBusiness *business);
/* Return the GNC Session from the Business Object */
GNCSession * gncBusinessGetSession (const GncBusiness *bus);
/* Obtain an object from the type and GUID */
gpointer gncBusinessLookupGUID (GncBusiness *business, const char *type_name,
const GUID * guid);
GList * gncBusinessGetList (GncBusiness *business, const char *type_name,
gboolean show_all);
const char * gncBusinessPrintable (GncBusiness *business,
const char *type_name,
gpointer obj);
/* Grab the entity table for an object */
GHashTable * gncBusinessEntityTable (GncBusiness *business, const char *name);
/* REGISTRATION AND REG-LOOKUP FUNCTIONS */
/* Register new types of business objects */
gboolean gncBusinessRegister (const GncBusinessObject *object);
/* Get the printable label for a type */
const char * gncBusinessGetTypeLabel (const char *type_name);
/* Lookup a business object */
const GncBusinessObject * gncBusinessLookup (const char *name);
#endif /* GNC_BUSINESS_H_ */

View File

@ -0,0 +1,15 @@
/*
* gncBusinessP.h -- the Core Business Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_BUSINESSP_H_
#define GNC_BUSINESSP_H_
#include "gncBusiness.h"
/* Initialize the business subsystem */
void gncBusinessInitialize (int argc, char **argv);
#endif /* GNC_BUSINESSP_H_ */

View File

@ -0,0 +1,398 @@
/*
* gncCustomer.c -- the Core Customer Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <glib.h>
#include <string.h>
#include "messages.h"
#include "gnc-numeric.h"
#include "gncCustomer.h"
#include "gncCustomerP.h"
#include "gncAddress.h"
#include "gncBusiness.h"
struct _gncCustomer {
GncBusiness * business;
GUID guid;
char * id;
char * name;
char * notes;
GncAddress * addr;
GncAddress * shipaddr;
gnc_numeric discount;
gnc_numeric credit;
gint terms;
gboolean taxincluded;
gboolean active;
GList * jobs;
gboolean dirty;
};
#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));
static void gncCustomerAdd (GncCustomer *cust);
static void gncCustomerRemove (GncCustomer *cust);
/* Create/Destroy Functions */
GncCustomer *gncCustomerCreate (GncBusiness *business)
{
GncCustomer *cust;
if (!business) return NULL;
cust = g_new0 (GncCustomer, 1);
cust->business = business;
cust->dirty = FALSE;
cust->id = CACHE_INSERT ("");
cust->name = CACHE_INSERT ("");
cust->notes = CACHE_INSERT ("");
cust->addr = gncAddressCreate (business);
cust->shipaddr = gncAddressCreate (business);
cust->discount = gnc_numeric_zero();
cust->credit = gnc_numeric_zero();
cust->terms = 30;
cust->taxincluded = FALSE;
cust->active = TRUE;
cust->jobs = NULL;
guid_new (&cust->guid);
gncCustomerAdd (cust);
return cust;
}
void gncCustomerDestroy (GncCustomer *cust)
{
if (!cust) return;
CACHE_REMOVE (cust->id);
CACHE_REMOVE (cust->name);
CACHE_REMOVE (cust->notes);
gncAddressDestroy (cust->addr);
gncAddressDestroy (cust->shipaddr);
g_list_free (cust->jobs);
gncCustomerRemove (cust);
g_free (cust);
}
/* Set Functions */
#define SET_STR(member, str) { \
char * tmp; \
\
if (!strcmp (member, str)) return; \
tmp = CACHE_INSERT (str); \
CACHE_REMOVE (member); \
member = tmp; \
}
void gncCustomerSetID (GncCustomer *cust, const char *id)
{
if (!cust) return;
if (!id) return;
SET_STR(cust->id, id);
cust->dirty = TRUE;
}
void gncCustomerSetName (GncCustomer *cust, const char *name)
{
if (!cust) return;
if (!name) return;
SET_STR(cust->name, name);
cust->dirty = TRUE;
}
void gncCustomerSetNotes (GncCustomer *cust, const char *notes)
{
if (!cust) return;
if (!notes) return;
SET_STR(cust->notes, notes);
cust->dirty = TRUE;
}
void gncCustomerSetGUID (GncCustomer *cust, const GUID *guid)
{
if (!cust || !guid) return;
if (guid_equal (guid, &cust->guid)) return;
gncCustomerRemove (cust);
cust->guid = *guid;
gncCustomerAdd (cust);
}
void gncCustomerSetTerms (GncCustomer *cust, gint terms)
{
if (!cust) return;
if (terms == cust->terms) return;
cust->terms = terms;
cust->dirty = TRUE;
}
void gncCustomerSetTaxIncluded (GncCustomer *cust, gboolean taxincl)
{
if (!cust) return;
if (taxincl == cust->taxincluded) return;
cust->taxincluded = taxincl;
cust->dirty = TRUE;
}
void gncCustomerSetActive (GncCustomer *cust, gboolean active)
{
if (!cust) return;
if (active == cust->active) return;
cust->active = active;
cust->dirty = TRUE;
}
void gncCustomerSetDiscount (GncCustomer *cust, gnc_numeric discount)
{
if (!cust) return;
if (gnc_numeric_equal (discount, cust->discount)) return;
cust->discount = discount;
cust->dirty = TRUE;
}
void gncCustomerSetCredit (GncCustomer *cust, gnc_numeric credit)
{
if (!cust) return;
if (gnc_numeric_equal (credit, cust->credit)) return;
cust->credit = credit;
cust->dirty = TRUE;
}
/* Note that JobList changes do not affect the "dirtiness" of the customer */
void gncCustomerAddJob (GncCustomer *cust, GncJob *job)
{
if (!cust) return;
if (!job) return;
if (g_list_index(cust->jobs, job) == -1)
cust->jobs = g_list_insert_sorted (cust->jobs, job, gncJobSortFunc);
}
void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
{
GList *node;
if (!cust) return;
if (!job) return;
node = g_list_find (cust->jobs, job);
if (!node) {
/* PERR ("split not in account"); */
} else {
cust->jobs = g_list_remove_link (cust->jobs, node);
g_list_free_1 (node);
}
}
void gncCustomerCommitEdit (GncCustomer *cust)
{
/* XXX COMMIT TO DATABASE */
cust->dirty = FALSE;
}
/* Get Functions */
GncBusiness * gncCustomerGetBusiness (GncCustomer *cust)
{
if (!cust) return NULL;
return cust->business;
}
const GUID * gncCustomerGetGUID (GncCustomer *cust)
{
if (!cust) return NULL;
return &cust->guid;
}
const char * gncCustomerGetID (GncCustomer *cust)
{
if (!cust) return NULL;
return cust->id;
}
const char * gncCustomerGetName (GncCustomer *cust)
{
if (!cust) return NULL;
return cust->name;
}
GncAddress * gncCustomerGetAddr (GncCustomer *cust)
{
if (!cust) return NULL;
return cust->addr;
}
GncAddress * gncCustomerGetShipAddr (GncCustomer *cust)
{
if (!cust) return NULL;
return cust->shipaddr;
}
const char * gncCustomerGetNotes (GncCustomer *cust)
{
if (!cust) return NULL;
return cust->notes;
}
gint gncCustomerGetTerms (GncCustomer *cust)
{
if (!cust) return 0;
return cust->terms;
}
gboolean gncCustomerGetTaxIncluded (GncCustomer *cust)
{
if (!cust) return FALSE;
return cust->taxincluded;
}
gboolean gncCustomerGetActive (GncCustomer *cust)
{
if (!cust) return FALSE;
return cust->active;
}
gnc_numeric gncCustomerGetDiscount (GncCustomer *cust)
{
if (!cust) return gnc_numeric_zero();
return cust->discount;
}
gnc_numeric gncCustomerGetCredit (GncCustomer *cust)
{
if (!cust) return gnc_numeric_zero();
return cust->credit;
}
GList * gncCustomerGetJoblist (GncCustomer *cust, gboolean show_all)
{
if (!cust) return NULL;
if (show_all) {
return (g_list_copy (cust->jobs));
} else {
GList *list = NULL, *iterator;
for (iterator = cust->jobs; iterator; iterator=iterator->next) {
GncJob *j = iterator->data;
if (gncJobGetActive (j))
list = g_list_append (list, j);
}
return list;
}
}
gboolean gncCustomerIsDirty (GncCustomer *cust)
{
if (!cust) return FALSE;
return (cust->dirty ||
gncAddressIsDirty (cust->addr) ||
gncAddressIsDirty (cust->shipaddr));
}
/* Other functions */
static gint gncCustomerSortFunc (gconstpointer a, gconstpointer b) {
GncCustomer *ca = (GncCustomer *) a;
GncCustomer *cb = (GncCustomer *) b;
return(strcmp(ca->name, cb->name));
}
/* Package-Private functions */
static void gncCustomerAdd (GncCustomer *cust)
{
GHashTable *ht = gncBusinessEntityTable (cust->business,
GNC_CUSTOMER_MODULE_NAME);
if (ht)
g_hash_table_insert (ht, &cust->guid, cust);
}
static void gncCustomerRemove (GncCustomer *cust)
{
GHashTable *ht = gncBusinessEntityTable (cust->business,
GNC_CUSTOMER_MODULE_NAME);
if (ht)
g_hash_table_remove (ht, &cust->guid);
}
struct _iterate {
GList *list;
gboolean show_all;
};
static void get_list (gpointer key, gpointer item, gpointer arg)
{
struct _iterate *iter = arg;
GncCustomer *cust = item;
if (iter->show_all || gncCustomerGetActive (cust)) {
iter->list = g_list_insert_sorted (iter->list, cust, gncCustomerSortFunc);
}
}
static GList * _gncCustomerGetList (GncBusiness *bus, gboolean show_all)
{
GHashTable *ht;
struct _iterate iter;
if (!bus) return NULL;
iter.list = NULL;
iter.show_all = show_all;
ht = gncBusinessEntityTable (bus, GNC_CUSTOMER_MODULE_NAME);
if (ht)
g_hash_table_foreach (ht, get_list, &iter);
return iter.list;
}
static const char * _gncCustomerPrintable (gpointer item)
{
GncCustomer *c;
if (!item) return NULL;
c = item;
return c->name;
}
static void _gncCustomerDestroy (GncBusiness *bus)
{
if (!bus) return;
/* XXX: should we be sure to destroy all the customer objects? */
}
static GncBusinessObject gncCustomerDesc = {
GNC_BUSINESS_VERSION,
GNC_CUSTOMER_MODULE_NAME,
"Customer",
_gncCustomerDestroy,
_gncCustomerGetList,
_gncCustomerPrintable
};
gboolean gncCustomerRegister (void)
{
return gncBusinessRegister (&gncCustomerDesc);
}
static gint lastCustomer = 27;
gint gncCustomerNextID (GncBusiness *business)
{
return ++lastCustomer; /* XXX: Look into Database! */
}

View File

@ -0,0 +1,61 @@
/*
* gncCustomer.h -- the Core Customer Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_CUSTOMER_H_
#define GNC_CUSTOMER_H_
struct _gncCustomer;
typedef struct _gncCustomer GncCustomer;
#include "gncBusiness.h"
#include "gncAddress.h"
#include "gncJob.h"
#include "gnc-numeric.h"
#define GNC_CUSTOMER_MODULE_NAME "gncCustomer"
/* Create/Destroy Functions */
GncCustomer *gncCustomerCreate (GncBusiness *business);
void gncCustomerDestroy (GncCustomer *customer);
/* Set Functions */
void gncCustomerSetID (GncCustomer *customer, const char *id);
void gncCustomerSetName (GncCustomer *customer, const char *name);
void gncCustomerSetNotes (GncCustomer *customer, const char *notes);
void gncCustomerSetTerms (GncCustomer *customer, gint terms);
void gncCustomerSetTaxIncluded (GncCustomer *customer, gboolean taxincl);
void gncCustomerSetActive (GncCustomer *customer, gboolean active);
void gncCustomerSetDiscount (GncCustomer *customer, gnc_numeric discount);
void gncCustomerSetCredit (GncCustomer *customer, gnc_numeric credit);
void gncCustomerAddJob (GncCustomer *customer, GncJob *job);
void gncCustomerRemoveJob (GncCustomer *customer, GncJob *job);
void gncCustomerCommitEdit (GncCustomer *customer);
/* Get Functions */
GncBusiness * gncCustomerGetBusiness (GncCustomer *business);
const GUID * gncCustomerGetGUID (GncCustomer *customer);
const char * gncCustomerGetID (GncCustomer *customer);
const char * gncCustomerGetName (GncCustomer *customer);
GncAddress * gncCustomerGetAddr (GncCustomer *customer);
GncAddress * gncCustomerGetShipAddr (GncCustomer *customer);
const char * gncCustomerGetNotes (GncCustomer *customer);
gint gncCustomerGetTerms (GncCustomer *customer);
gboolean gncCustomerGetTaxIncluded (GncCustomer *customer);
gboolean gncCustomerGetActive (GncCustomer *customer);
gnc_numeric gncCustomerGetDiscount (GncCustomer *customer);
gnc_numeric gncCustomerGetCredit (GncCustomer *customer);
GList * gncCustomerGetJoblist (GncCustomer *customer, gboolean show_all);
gboolean gncCustomerIsDirty (GncCustomer *customer);
#endif /* GNC_CUSTOMER_H_ */

View File

@ -0,0 +1,17 @@
/*
* gncCustomerP.h -- the Core Customer Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_CUSTOMERP_H_
#define GNC_CUSTOMERP_H_
#include "gncBusiness.h"
#include "gncCustomer.h"
gboolean gncCustomerRegister (void);
gint gncCustomerNextID (GncBusiness *business);
void gncCustomerSetGUID (GncCustomer *customer, const GUID *guid);
#endif /* GNC_CUSTOMERP_H_ */

View File

@ -0,0 +1,328 @@
/*
* gncEmployee.c -- the Core Employee Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <glib.h>
#include <string.h>
#include "guid.h"
#include "messages.h"
#include "gncEmployee.h"
#include "gncEmployeeP.h"
#include "gncAddress.h"
#include "gncBusiness.h"
struct _gncEmployee {
GncBusiness * business;
GUID guid;
char * id;
char * username;
char * language;
char * acl;
GncAddress * addr;
gnc_numeric workday;
gnc_numeric rate;
gboolean active;
gboolean dirty;
};
#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));
static void gncEmployeeAdd (GncEmployee *employee);
static void gncEmployeeRemove (GncEmployee *employee);
/* Create/Destroy Functions */
GncEmployee *gncEmployeeCreate (GncBusiness *business)
{
GncEmployee *employee;
if (!business) return NULL;
employee = g_new0 (GncEmployee, 1);
employee->business = business;
employee->dirty = FALSE;
employee->id = CACHE_INSERT ("");
employee->username = CACHE_INSERT ("");
employee->language = CACHE_INSERT ("");
employee->acl = CACHE_INSERT ("");
employee->addr = gncAddressCreate (business);
employee->workday = gnc_numeric_zero();
employee->rate = gnc_numeric_zero();
employee->active = TRUE;
guid_new (&employee->guid);
gncEmployeeAdd (employee);
return employee;
}
void gncEmployeeDestroy (GncEmployee *employee)
{
if (!employee) return;
CACHE_REMOVE (employee->id);
CACHE_REMOVE (employee->username);
CACHE_REMOVE (employee->language);
CACHE_REMOVE (employee->acl);
gncAddressDestroy (employee->addr);
gncEmployeeRemove (employee);
g_free (employee);
}
/* Set Functions */
#define SET_STR(member, str) { \
char * tmp; \
\
if (!strcmp (member, str)) return; \
tmp = CACHE_INSERT (str); \
CACHE_REMOVE (member); \
member = tmp; \
}
void gncEmployeeSetID (GncEmployee *employee, const char *id)
{
if (!employee) return;
if (!id) return;
SET_STR(employee->id, id);
employee->dirty = TRUE;
}
void gncEmployeeSetUsername (GncEmployee *employee, const char *username)
{
if (!employee) return;
if (!username) return;
SET_STR(employee->username, username);
employee->dirty = TRUE;
}
void gncEmployeeSetLanguage (GncEmployee *employee, const char *language)
{
if (!employee) return;
if (!language) return;
SET_STR(employee->language, language);
employee->dirty = TRUE;
}
void gncEmployeeSetGUID (GncEmployee *employee, const GUID *guid)
{
if (!employee || !guid) return;
if (guid_equal (guid, &employee->guid)) return;
gncEmployeeRemove (employee);
employee->guid = *guid;
gncEmployeeAdd (employee);
}
void gncEmployeeSetAcl (GncEmployee *employee, const char *acl)
{
if (!employee) return;
if (!acl) return;
SET_STR(employee->acl, acl);
employee->dirty = TRUE;
}
void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday)
{
if (!employee) return;
if (gnc_numeric_equal (workday, employee->workday)) return;
employee->workday = workday;
employee->dirty = TRUE;
}
void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate)
{
if (!employee) return;
if (gnc_numeric_equal (rate, employee->rate)) return;
employee->rate = rate;
employee->dirty = TRUE;
}
void gncEmployeeSetActive (GncEmployee *employee, gboolean active)
{
if (!employee) return;
if (active == employee->active) return;
employee->active = active;
employee->dirty = TRUE;
}
/* Get Functions */
GncBusiness * gncEmployeeGetBusiness (GncEmployee *employee)
{
if (!employee) return NULL;
return employee->business;
}
const GUID * gncEmployeeGetGUID (GncEmployee *employee)
{
if (!employee) return NULL;
return &employee->guid;
}
const char * gncEmployeeGetID (GncEmployee *employee)
{
if (!employee) return NULL;
return employee->id;
}
const char * gncEmployeeGetUsername (GncEmployee *employee)
{
if (!employee) return NULL;
return employee->username;
}
GncAddress * gncEmployeeGetAddr (GncEmployee *employee)
{
if (!employee) return NULL;
return employee->addr;
}
const char * gncEmployeeGetLanguage (GncEmployee *employee)
{
if (!employee) return NULL;
return employee->language;
}
const char * gncEmployeeGetAcl (GncEmployee *employee)
{
if (!employee) return NULL;
return employee->acl;
}
gnc_numeric gncEmployeeGetWorkday (GncEmployee *employee)
{
if (!employee) return gnc_numeric_zero();
return employee->workday;
}
gnc_numeric gncEmployeeGetRate (GncEmployee *employee)
{
if (!employee) return gnc_numeric_zero();
return employee->rate;
}
gboolean gncEmployeeGetActive (GncEmployee *employee)
{
if (!employee) return FALSE;
return employee->active;
}
gboolean gncEmployeeIsDirty (GncEmployee *employee)
{
if (!employee) return FALSE;
return (employee->dirty || gncAddressIsDirty (employee->addr));
}
void gncEmployeeCommitEdit (GncEmployee *employee)
{
/* XXX COMMIT TO DATABASE */
employee->dirty = FALSE;
}
/* Other functions */
static gint gncEmployeeSortFunc (gconstpointer a, gconstpointer b) {
GncEmployee *ea = (GncEmployee *) a;
GncEmployee *eb = (GncEmployee *) b;
return(strcmp(ea->username, eb->username));
}
/* Package-Private functions */
static void gncEmployeeAdd (GncEmployee *employee)
{
GHashTable *ht = gncBusinessEntityTable (employee->business,
GNC_EMPLOYEE_MODULE_NAME);
if (ht)
g_hash_table_insert (ht, &employee->guid, employee);
}
static void gncEmployeeRemove (GncEmployee *employee)
{
GHashTable *ht = gncBusinessEntityTable (employee->business,
GNC_EMPLOYEE_MODULE_NAME);
if (ht)
g_hash_table_remove (ht, &employee->guid);
}
struct _iterate {
GList *list;
gboolean show_all;
};
static void get_list (gpointer key, gpointer item, gpointer arg)
{
struct _iterate *iter = arg;
GncEmployee *employee = item;
if (iter->show_all || gncEmployeeGetActive (employee)) {
iter->list = g_list_insert_sorted (iter->list, employee, gncEmployeeSortFunc);
}
}
static GList * _gncEmployeeGetList (GncBusiness *bus, gboolean show_all)
{
GHashTable *ht;
struct _iterate iter;
if (!bus) return NULL;
iter.list = NULL;
iter.show_all = show_all;
ht = gncBusinessEntityTable (bus, GNC_EMPLOYEE_MODULE_NAME);
if (ht)
g_hash_table_foreach (ht, get_list, &iter);
return iter.list;
}
static const char * _gncEmployeePrintable (gpointer item)
{
GncEmployee *v;
if (!item) return NULL;
v = item;
return v->username;
}
static void _gncEmployeeDestroy (GncBusiness *bus)
{
if (!bus) return;
/* XXX: should we be sure to destroy all the employee objects? */
}
static GncBusinessObject gncEmployeeDesc = {
GNC_BUSINESS_VERSION,
GNC_EMPLOYEE_MODULE_NAME,
"Employee",
_gncEmployeeDestroy,
_gncEmployeeGetList,
_gncEmployeePrintable
};
gboolean gncEmployeeRegister (void)
{
return gncBusinessRegister (&gncEmployeeDesc);
}
static gint lastEmployee = 2;
gint gncEmployeeNextID (GncBusiness *business)
{
return ++lastEmployee; /* XXX: Look into Database! */
}

View File

@ -0,0 +1,50 @@
/*
* gncEmployee.h -- the Core Employee Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_EMPLOYEE_H_
#define GNC_EMPLOYEE_H_
struct _gncEmployee;
typedef struct _gncEmployee GncEmployee;
#include "gncBusiness.h"
#include "gncAddress.h"
#define GNC_EMPLOYEE_MODULE_NAME "gncEmployee"
/* Create/Destroy Functions */
GncEmployee *gncEmployeeCreate (GncBusiness *business);
void gncEmployeeDestroy (GncEmployee *employee);
/* Set Functions */
void gncEmployeeSetID (GncEmployee *employee, const char *id);
void gncEmployeeSetUsername (GncEmployee *employee, const char *username);
void gncEmployeeSetLanguage (GncEmployee *employee, const char *language);
void gncEmployeeSetAcl (GncEmployee *employee, const char *acl);
void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday);
void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate);
void gncEmployeeSetActive (GncEmployee *employee, gboolean active);
/* Get Functions */
GncBusiness * gncEmployeeGetBusiness (GncEmployee *employee);
const GUID * gncEmployeeGetGUID (GncEmployee *employee);
const char * gncEmployeeGetID (GncEmployee *employee);
const char * gncEmployeeGetUsername (GncEmployee *employee);
GncAddress * gncEmployeeGetAddr (GncEmployee *employee);
const char * gncEmployeeGetLanguage (GncEmployee *employee);
const char * gncEmployeeGetAcl (GncEmployee *employee);
gnc_numeric gncEmployeeGetWorkday (GncEmployee *employee);
gnc_numeric gncEmployeeGetRate (GncEmployee *employee);
gboolean gncEmployeeGetActive (GncEmployee *employee);
gboolean gncEmployeeIsDirty (GncEmployee *employee);
void gncEmployeeCommitEdit (GncEmployee *employee);
#endif /* GNC_EMPLOYEE_H_ */

View File

@ -0,0 +1,17 @@
/*
* gncEmployeeP.h -- the Core Employee Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_EMPLOYEEP_H_
#define GNC_EMPLOYEEP_H_
#include "gncBusiness.h"
#include "gncEmployee.h"
gboolean gncEmployeeRegister (void);
gint gncEmployeeNextID (GncBusiness *business);
void gncEmployeeSetGUID (GncEmployee *employee, const GUID *guid);
#endif /* GNC_EMPLOYEEP_H_ */

View File

@ -0,0 +1,276 @@
/*
* gncJob.c -- the Core Job Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <glib.h>
#include <string.h>
#include "guid.h"
#include "messages.h"
#include "gnc-numeric.h"
#include "gncJob.h"
#include "gncJobP.h"
#include "gncCustomer.h"
struct _gncJob {
GncBusiness * business;
GUID guid;
char * id;
char * name;
char * desc;
GncCustomer * cust;
gboolean active;
gboolean dirty;
};
static void _gncJobAdd (GncJob *job);
static void _gncJobRemove (GncJob *job);
#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));
/* Create/Destroy Functions */
GncJob *gncJobCreate (GncBusiness *business)
{
GncJob *job;
if (!business) return NULL;
job = g_new0 (GncJob, 1);
job->business = business;
job->dirty = FALSE;
job->id = CACHE_INSERT ("");
job->name = CACHE_INSERT ("");
job->desc = CACHE_INSERT ("");
job->cust = NULL;
job->active = TRUE;
guid_new (&job->guid);
_gncJobAdd (job);
return job;
}
void gncJobDestroy (GncJob *job)
{
if (!job) return;
CACHE_REMOVE (job->id);
CACHE_REMOVE (job->name);
CACHE_REMOVE (job->desc);
if (job->cust)
gncCustomerRemoveJob (job->cust, job);
_gncJobRemove (job);
g_free (job);
}
/* Set Functions */
#define SET_STR(member, str) { \
char * tmp; \
\
tmp = CACHE_INSERT (str); \
CACHE_REMOVE (member); \
member = tmp; \
}
void gncJobSetID (GncJob *job, const char *id)
{
if (!job) return;
if (!id) return;
SET_STR(job->id, id);
job->dirty = TRUE;
}
void gncJobSetName (GncJob *job, const char *name)
{
if (!job) return;
if (!name) return;
SET_STR(job->name, name);
job->dirty = TRUE;
}
void gncJobSetDesc (GncJob *job, const char *desc)
{
if (!job) return;
if (!desc) return;
SET_STR(job->desc, desc);
job->dirty = TRUE;
}
void gncJobSetGUID (GncJob *job, const GUID *guid)
{
if (!job) return;
if (!guid) return;
if (guid_equal (guid, &job->guid)) return;
_gncJobRemove (job);
job->guid = *guid;
_gncJobAdd (job);
}
void gncJobSetCustomer (GncJob *job, GncCustomer *cust)
{
if (!job) return;
if (!cust) return;
if (cust == job->cust) return;
/* XXX: Fail if we have ANY orders or invoices */
if (cust)
gncCustomerRemoveJob (job->cust, job);
job->cust = cust;
gncCustomerAddJob (cust, job);
job->dirty = TRUE;
}
void gncJobSetActive (GncJob *job, gboolean active)
{
if (!job) return;
if (active == job->active) return;
job->active = active;
job->dirty = TRUE;
}
void gncJobCommitEdit (GncJob *job)
{
/* XXX: COMMIT TO DATABASE */
job->dirty = FALSE;
}
/* Get Functions */
GncBusiness * gncJobGetBusiness (GncJob *job)
{
if (!job) return NULL;
return job->business;
}
const char * gncJobGetID (GncJob *job)
{
if (!job) return NULL;
return job->id;
}
const char * gncJobGetName (GncJob *job)
{
if (!job) return NULL;
return job->name;
}
const char * gncJobGetDesc (GncJob *job)
{
if (!job) return NULL;
return job->desc;
}
GncCustomer * gncJobGetCustomer (GncJob *job)
{
if (!job) return NULL;
return job->cust;
}
const GUID * gncJobGetGUID (GncJob *job)
{
if (!job) return NULL;
return &job->guid;
}
gboolean gncJobGetActive (GncJob *job)
{
if (!job) return FALSE;
return job->active;
}
gboolean gncJobIsDirty (GncJob *job)
{
if (!job) return FALSE;
return job->dirty;
}
/* Other functions */
gint gncJobSortFunc (gconstpointer a, gconstpointer b) {
GncJob *ja = (GncJob *) a;
GncJob *jb = (GncJob *) b;
if (!a || !b) return 0;
return (strcmp(ja->id, jb->id));
}
/* Package-Private functions */
static void _gncJobAdd (GncJob *job)
{
GHashTable *ht = gncBusinessEntityTable (job->business,
GNC_JOB_MODULE_NAME);
if (ht)
g_hash_table_insert (ht, &job->guid, job);
}
static void _gncJobRemove (GncJob *job)
{
GHashTable *ht = gncBusinessEntityTable (job->business,
GNC_JOB_MODULE_NAME);
if (ht)
g_hash_table_remove (ht, &job->guid);
}
static GList * _gncJobGetList (GncBusiness *obj, gboolean show_all)
{
if (!obj) return NULL;
/* XXX */
return NULL;
}
static const char * _gncJobPrintable (gpointer item)
{
GncJob *c;
if (!item) return NULL;
c = item;
return c->name;
}
static void _gncJobDestroy (GncBusiness *obj)
{
if (!obj) return;
/* XXX: should we be sure to destroy all the job objects? */
}
static GncBusinessObject gncJobDesc = {
GNC_BUSINESS_VERSION,
GNC_JOB_MODULE_NAME,
"Job",
_gncJobDestroy,
NULL,
_gncJobPrintable
};
gboolean gncJobRegister (void)
{
return gncBusinessRegister (&gncJobDesc);
}
static gint lastJob = 57;
gint gncJobNextID (GncBusiness *business)
{
return ++lastJob; /* XXX: Look into Database! */
}

View File

@ -0,0 +1,50 @@
/*
* gncJob.h -- the Core Job Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_JOB_H_
#define GNC_JOB_H_
struct _gncJob;
typedef struct _gncJob GncJob;
#include "gncBusiness.h"
#include "gncAddress.h"
#include "gncCustomer.h"
#define GNC_JOB_MODULE_NAME "gncJob"
/* Create/Destroy Functions */
GncJob *gncJobCreate (GncBusiness *business);
void gncJobDestroy (GncJob *job);
/* Set Functions */
void gncJobSetID (GncJob *job, const char *id);
void gncJobSetName (GncJob *job, const char *username);
void gncJobSetDesc (GncJob *job, const char *language);
void gncJobSetCustomer (GncJob *job, GncCustomer *customer);
void gncJobSetActive (GncJob *job, gboolean active);
void gncJobCommitEdit (GncJob *job);
/* Get Functions */
GncBusiness * gncJobGetBusiness (GncJob *job);
const GUID * gncJobGetGUID (GncJob *job);
const char * gncJobGetID (GncJob *job);
const char * gncJobGetName (GncJob *job);
const char * gncJobGetDesc (GncJob *job);
GncCustomer * gncJobGetCustomer (GncJob *job);
gboolean gncJobGetActive (GncJob *job);
gboolean gncJobIsDirty (GncJob *job);
/* Other functions */
gint gncJobSortFunc (gconstpointer a, gconstpointer b);
#endif /* GNC_JOB_H_ */

View File

@ -0,0 +1,17 @@
/*
* gncJobP.h -- the Core Job Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_JOBP_H_
#define GNC_JOBP_H_
#include "gncBusiness.h"
#include "gncJob.h"
gboolean gncJobRegister (void);
gint gncJobNextID (GncBusiness *business);
void gncJobSetGUID (GncJob *job, const GUID *guid);
#endif /* GNC_JOBP_H_ */

View File

@ -0,0 +1,310 @@
/*
* gncVendor.c -- the Core Vendor Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <glib.h>
#include <string.h>
#include "guid.h"
#include "messages.h"
#include "gncVendor.h"
#include "gncVendorP.h"
#include "gncAddress.h"
#include "gncBusiness.h"
struct _gncVendor {
GncBusiness * business;
GUID guid;
char * id;
char * name;
char * notes;
GncAddress * addr;
gint terms;
gboolean taxincluded;
gboolean active;
gboolean dirty;
};
#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));
static void gncVendorAdd (GncVendor *vendor);
static void gncVendorRemove (GncVendor *vendor);
/* Create/Destroy Functions */
GncVendor *gncVendorCreate (GncBusiness *business)
{
GncVendor *vendor;
if (!business) return NULL;
vendor = g_new0 (GncVendor, 1);
vendor->business = business;
vendor->dirty = FALSE;
vendor->id = CACHE_INSERT ("");
vendor->name = CACHE_INSERT ("");
vendor->notes = CACHE_INSERT ("");
vendor->addr = gncAddressCreate (business);
vendor->terms = 0;
vendor->taxincluded = FALSE;
vendor->active = TRUE;
guid_new (&vendor->guid);
gncVendorAdd (vendor);
return vendor;
}
void gncVendorDestroy (GncVendor *vendor)
{
if (!vendor) return;
CACHE_REMOVE (vendor->id);
CACHE_REMOVE (vendor->name);
CACHE_REMOVE (vendor->notes);
gncAddressDestroy (vendor->addr);
gncVendorRemove (vendor);
g_free (vendor);
}
/* Set Functions */
#define SET_STR(member, str) { \
char * tmp; \
\
if (!strcmp (member, str)) return; \
tmp = CACHE_INSERT (str); \
CACHE_REMOVE (member); \
member = tmp; \
}
void gncVendorSetID (GncVendor *vendor, const char *id)
{
if (!vendor) return;
if (!id) return;
SET_STR(vendor->id, id);
vendor->dirty = TRUE;
}
void gncVendorSetName (GncVendor *vendor, const char *name)
{
if (!vendor) return;
if (!name) return;
SET_STR(vendor->name, name);
vendor->dirty = TRUE;
}
void gncVendorSetNotes (GncVendor *vendor, const char *notes)
{
if (!vendor) return;
if (!notes) return;
SET_STR(vendor->notes, notes);
vendor->dirty = TRUE;
}
void gncVendorSetGUID (GncVendor *vendor, const GUID *guid)
{
if (!vendor || !guid) return;
if (guid_equal (guid, &vendor->guid)) return;
gncVendorRemove (vendor);
vendor->guid = *guid;
gncVendorAdd (vendor);
}
void gncVendorSetTerms (GncVendor *vendor, gint terms)
{
if (!vendor) return;
if (terms == vendor->terms) return;
vendor->terms = terms;
vendor->dirty = TRUE;
}
void gncVendorSetTaxIncluded (GncVendor *vendor, gboolean taxincl)
{
if (!vendor) return;
if (taxincl == vendor->taxincluded) return;
vendor->taxincluded = taxincl;
vendor->dirty = TRUE;
}
void gncVendorSetActive (GncVendor *vendor, gboolean active)
{
if (!vendor) return;
if (active == vendor->active) return;
vendor->active = active;
vendor->dirty = TRUE;
}
/* Get Functions */
GncBusiness * gncVendorGetBusiness (GncVendor *vendor)
{
if (!vendor) return NULL;
return vendor->business;
}
const GUID * gncVendorGetGUID (GncVendor *vendor)
{
if (!vendor) return NULL;
return &vendor->guid;
}
const char * gncVendorGetID (GncVendor *vendor)
{
if (!vendor) return NULL;
return vendor->id;
}
const char * gncVendorGetName (GncVendor *vendor)
{
if (!vendor) return NULL;
return vendor->name;
}
GncAddress * gncVendorGetAddr (GncVendor *vendor)
{
if (!vendor) return NULL;
return vendor->addr;
}
const char * gncVendorGetNotes (GncVendor *vendor)
{
if (!vendor) return NULL;
return vendor->notes;
}
gint gncVendorGetTerms (GncVendor *vendor)
{
if (!vendor) return 0;
return vendor->terms;
}
gboolean gncVendorGetTaxIncluded (GncVendor *vendor)
{
if (!vendor) return FALSE;
return vendor->taxincluded;
}
gboolean gncVendorGetActive (GncVendor *vendor)
{
if (!vendor) return FALSE;
return vendor->active;
}
gboolean gncVendorIsDirty (GncVendor *vendor)
{
if (!vendor) return FALSE;
return (vendor->dirty || gncAddressIsDirty (vendor->addr));
}
void gncVendorCommitEdit (GncVendor *vendor)
{
/* XXX COMMIT TO DATABASE */
vendor->dirty = FALSE;
}
/* Other functions */
static gint gncVendorSortFunc (gconstpointer a, gconstpointer b) {
GncVendor *va = (GncVendor *) a;
GncVendor *vb = (GncVendor *) b;
return(strcmp(va->name, vb->name));
}
/* Package-Private functions */
static void gncVendorAdd (GncVendor *vendor)
{
GHashTable *ht = gncBusinessEntityTable (vendor->business,
GNC_VENDOR_MODULE_NAME);
if (ht)
g_hash_table_insert (ht, &vendor->guid, vendor);
}
static void gncVendorRemove (GncVendor *vendor)
{
GHashTable *ht = gncBusinessEntityTable (vendor->business,
GNC_VENDOR_MODULE_NAME);
if (ht)
g_hash_table_remove (ht, &vendor->guid);
}
struct _iterate {
GList *list;
gboolean show_all;
};
static void get_list (gpointer key, gpointer item, gpointer arg)
{
struct _iterate *iter = arg;
GncVendor *vendor = item;
if (iter->show_all || gncVendorGetActive (vendor)) {
iter->list = g_list_insert_sorted (iter->list, vendor, gncVendorSortFunc);
}
}
static GList * _gncVendorGetList (GncBusiness *bus, gboolean show_all)
{
GHashTable *ht;
struct _iterate iter;
if (!bus) return NULL;
iter.list = NULL;
iter.show_all = show_all;
ht = gncBusinessEntityTable (bus, GNC_VENDOR_MODULE_NAME);
if (ht)
g_hash_table_foreach (ht, get_list, &iter);
return iter.list;
}
static const char * _gncVendorPrintable (gpointer item)
{
GncVendor *v;
if (!item) return NULL;
v = item;
return v->name;
}
static void _gncVendorDestroy (GncBusiness *obj)
{
if (!obj) return;
/* XXX: should we be sure to destroy all the vendor objects? */
}
static GncBusinessObject gncVendorDesc = {
GNC_BUSINESS_VERSION,
GNC_VENDOR_MODULE_NAME,
"Vendor",
_gncVendorDestroy,
_gncVendorGetList,
_gncVendorPrintable
};
gboolean gncVendorRegister (void)
{
return gncBusinessRegister (&gncVendorDesc);
}
static gint lastVendor = 17;
gint gncVendorNextID (GncBusiness *business)
{
return ++lastVendor; /* XXX: Look into Database! */
}

View File

@ -0,0 +1,48 @@
/*
* gncVendor.h -- the Core Vendor Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_VENDOR_H_
#define GNC_VENDOR_H_
struct _gncVendor;
typedef struct _gncVendor GncVendor;
#include "gncBusiness.h"
#include "gncAddress.h"
#define GNC_VENDOR_MODULE_NAME "gncVendor"
/* Create/Destroy Functions */
GncVendor *gncVendorCreate (GncBusiness *business);
void gncVendorDestroy (GncVendor *vendor);
/* Set Functions */
void gncVendorSetID (GncVendor *vendor, const char *id);
void gncVendorSetName (GncVendor *vendor, const char *name);
void gncVendorSetNotes (GncVendor *vendor, const char *notes);
void gncVendorSetTerms (GncVendor *vendor, gint terms);
void gncVendorSetTaxIncluded (GncVendor *vendor, gboolean taxincl);
void gncVendorSetActive (GncVendor *vendor, gboolean active);
void gncVendorCommitEdit (GncVendor *vendor);
/* Get Functions */
GncBusiness * gncVendorGetBusiness (GncVendor *vendor);
const GUID * gncVendorGetGUID (GncVendor *vendor);
const char * gncVendorGetID (GncVendor *vendor);
const char * gncVendorGetName (GncVendor *vendor);
GncAddress * gncVendorGetAddr (GncVendor *vendor);
const char * gncVendorGetNotes (GncVendor *vendor);
gint gncVendorGetTerms (GncVendor *vendor);
gboolean gncVendorGetTaxIncluded (GncVendor *vendor);
gboolean gncVendorGetActive (GncVendor *vendor);
gboolean gncVendorIsDirty (GncVendor *vendor);
#endif /* GNC_VENDOR_H_ */

View File

@ -0,0 +1,17 @@
/*
* gncVendorP.h -- the Core Vendor Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_VENDORP_H_
#define GNC_VENDORP_H_
#include "gncBusiness.h"
#include "gncVendor.h"
gboolean gncVendorRegister (void);
gint gncVendorNextID (GncBusiness *business);
void gncVendorSetGUID (GncVendor *vendor, const GUID *guid);
#endif /* GNC_VENDORP_H_ */

View File

@ -0,0 +1,107 @@
;;; -*-scheme-*-
(use-modules (g-wrap))
(debug-set! maxdepth 100000)
(debug-set! stack 2000000)
(define-module (g-wrapped gw-business-core-spec)
:use-module (g-wrap))
(use-modules (g-wrapped gw-engine-spec))
(let ((mod (gw:new-module "gw-business-core")))
(define (standard-c-call-gen result func-call-code)
(list (gw:result-get-c-name result) " = " func-call-code ";\n"))
(define (add-standard-result-handlers! type c->scm-converter)
(define (standard-pre-handler result)
(let* ((ret-type-name (gw:result-get-proper-c-type-name result))
(ret-var-name (gw:result-get-c-name result)))
(list "{\n"
" " ret-type-name " " ret-var-name ";\n")))
(gw:type-set-pre-call-result-ccodegen! type standard-pre-handler)
(gw:type-set-post-call-result-ccodegen!
type
(lambda (result)
(let* ((scm-name (gw:result-get-scm-name result))
(c-name (gw:result-get-c-name result)))
(list
(c->scm-converter scm-name c-name)
" }\n")))))
(gw:module-depends-on mod "gw-runtime")
(gw:module-depends-on mod "gw-engine")
(gw:module-set-guile-module! mod '(g-wrapped gw-business-core))
(gw:module-set-declarations-ccodegen!
mod
(lambda (client-only?)
(list
"#include <gncBusiness.h>\n"
"#include <gncAddress.h>\n"
"#include <gncCustomer.h>\n"
"#include <gncEmployee.h>\n"
"#include <gncJob.h>\n"
"#include <gncVendor.h>\n"
)))
(gw:module-set-init-ccodegen!
mod
(lambda (client-only?)
(if client-only?
'()
(gw:inline-scheme '(use-modules (gnucash business-core))))))
;; The core Business Object
(gw:wrap-non-native-type mod '<gnc:GncBusiness*> "GncBusiness*"
"const GncBusiness*")
;; The core Business Object Types
;; XXX: Need to add lists of all of these!
(gw:wrap-non-native-type mod '<gnc:GncAddress*> "GncAddress*"
"const GncAddress*")
(gw:wrap-non-native-type mod '<gnc:GncCustomer*> "GncCustomer*"
"const GncCustomer*")
(gw:wrap-non-native-type mod '<gnc:GncEmployee*> "GncEmployee*"
"const GncEmployee*")
(gw:wrap-non-native-type mod '<gnc:GncJob*> "GncJob*"
"const GncJob*")
(gw:wrap-non-native-type mod '<gnc:GncVendor*> "GncVendor*"
"const GncVendor*")
;;
;; gncBusiness.h
;;
(gw:wrap-function
mod
'gnc:business-create
'<gnc:GncBusiness*>
"gncBusinessCreate"
'((<gnc:Session*> session))
"Return a newly-created GncBusiness state object.")
(gw:wrap-function
mod
'gnc:business-destroy
'<gw:void>
"gncBusinessDestroy"
'((<gnc:GncBusiness*> business))
"Destroy a GncBusiness object")
;; gncAddress.h
;; gncCustomer.h
;; gncEmployee.h
;; gncJob.h
;; gncVendor.h
)

View File

@ -0,0 +1,7 @@
Makefile
test-address
test-business
test-customer
test-employee
test-job
test-vendor

View File

@ -0,0 +1,42 @@
AM_CFLAGS = \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/test-core \
-I${top_srcdir}/src/engine \
-I.. \
${GUILE_INCS} \
${GLIB_CFLAGS}
LDADD = \
${top_srcdir}/src/gnc-module/libgncmodule.la \
${top_srcdir}/src/test-core/libgncmod-test.la \
${top_srcdir}/src/engine/libgncmod-engine.la \
${top_srcdir}/src/engine/libgw-engine.la \
../libgncmod-business-core.la \
../libgw-business-core.la \
${GLIB_LIBS} \
-lltdl
TESTS = \
test-business \
test-address \
test-customer \
test-vendor \
test-employee \
test-job
TESTS_ENVIRONMENT = \
GNC_MODULE_PATH="..:${top_srcdir}/src/engine" \
GUILE_LOAD_PATH="${G_WRAP_MODULE_DIR}:..:../../../gnc-module:${top_srcdir}/src/scm" \
LTDL_LIBRARY_PATH=${top_srcdir}/src/gnc-module:..:${top_srcdir}/src/engine \
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:..:${top_srcdir}/src/engine:${top_srcdir}/src/gnc-module
noinst_PROGRAMS = \
test-business \
test-address \
test-customer \
test-vendor \
test-employee \
test-job
EXTRA_DIST =

View File

@ -0,0 +1,77 @@
#include <glib.h>
#include <guile/gh.h>
#include "guid.h"
#include "gnc-module.h"
#include "gnc-engine-util.h"
#include "gncBusiness.h"
#include "gncAddress.h"
#include "test-stuff.h"
static void
test_string_fcn (GncAddress *address, const char *message,
void (*set) (GncAddress *, const char *str),
const char * (*get)(const GncAddress *));
static void
test_address (void)
{
GncBusiness *bus;
GncAddress *address;
bus = gncBusinessCreate ((GNCSession *)1);
/* Test creation/destruction */
{
do_test (gncAddressCreate (NULL) == NULL, "address create NULL");
address = gncAddressCreate (bus);
do_test (address != NULL, "address create");
gncAddressDestroy (address);
success ("create/destroy");
}
/* Test setting routines */
{
address = gncAddressCreate (bus);
test_string_fcn (address, "Name", gncAddressSetName, gncAddressGetName);
test_string_fcn (address, "Addr1", gncAddressSetAddr1, gncAddressGetAddr1);
test_string_fcn (address, "Addr2", gncAddressSetAddr2, gncAddressGetAddr2);
test_string_fcn (address, "Addr3", gncAddressSetAddr3, gncAddressGetAddr3);
test_string_fcn (address, "Addr4", gncAddressSetAddr4, gncAddressGetAddr4);
test_string_fcn (address, "Phone", gncAddressSetPhone, gncAddressGetPhone);
test_string_fcn (address, "Fax", gncAddressSetFax, gncAddressGetFax);
test_string_fcn (address, "Email", gncAddressSetEmail, gncAddressGetEmail);
}
}
static void
test_string_fcn (GncAddress *address, const char *message,
void (*set) (GncAddress *, const char *str),
const char * (*get)(const GncAddress *))
{
char const *str = get_random_string ();
do_test (!gncAddressIsDirty (address), "test if start dirty");
set (address, str);
do_test (gncAddressIsDirty (address), "test dirty later");
do_test (safe_strcmp (get (address), str) == 0, message);
gncAddressClearDirty (address);
}
static void
main_helper (int argc, char **argv)
{
gnc_module_load("gnucash/business-core", 0);
test_address();
print_test_results();
exit(get_rv());
}
int
main (int argc, char **argv)
{
gh_enter (argc, argv, main_helper);
return 0;
}

View File

@ -0,0 +1,195 @@
#include <glib.h>
#include <guile/gh.h>
#include "guid.h"
#include "gnc-module.h"
#include "gnc-engine-util.h"
#include "messages.h"
#include "gncBusiness.h"
#include "test-stuff.h"
#define TEST_MODULE_NAME "business-test"
#define TEST_MODULE_DESC "Test Business"
static GList * get_list (GncBusiness *, gboolean show_all);
static const char * printable (gpointer obj);
static void test_printable (GncBusiness *bus, const char *name, gpointer obj);
static GncBusinessObject bus_obj = {
GNC_BUSINESS_VERSION,
TEST_MODULE_NAME,
TEST_MODULE_DESC,
NULL, /* destroy */
get_list,
printable,
};
static void test_business (void)
{
GncBusiness *bus;
/* Test the global registration and lookup functions */
{
do_test (!gncBusinessRegister (NULL), "register NULL");
do_test (gncBusinessRegister (&bus_obj), "register test object");
do_test (!gncBusinessRegister (&bus_obj), "register test object again");
do_test (gncBusinessLookup (TEST_MODULE_NAME) == &bus_obj,
"lookup our installed object");
do_test (gncBusinessLookup ("snm98sn snml say dyikh9y9ha") == NULL,
"lookup non-existant business object");
do_test (!safe_strcmp (gncBusinessGetTypeLabel (TEST_MODULE_NAME),
_(TEST_MODULE_DESC)),
"test description return");
}
/* Test creation and session handling */
{
bus = gncBusinessCreate (NULL);
do_test (bus == NULL, "business create NULL");
bus = gncBusinessCreate ((GNCSession *)1);
do_test (bus != NULL, "business create non-NULL");
do_test (gncBusinessGetSession (NULL) == NULL,
"business get session NULL");
do_test (gncBusinessGetSession (bus) == (GNCSession *)1,
"business get session");
gncBusinessDestroy (bus);
success ("business create and destroy");
}
/* Test the entity tables */
{
GUID guid;
gpointer ptr, res;
GHashTable *ht;
bus = gncBusinessCreate ((GNCSession *)1);
do_test (gncBusinessEntityTable (NULL, NULL) == NULL,
"business entity table NULL NULL");
do_test (gncBusinessEntityTable (NULL, TEST_MODULE_NAME) == NULL,
"business entity table NULL module_name");
do_test (gncBusinessEntityTable (bus, NULL) == NULL,
"business entity table bus NULL");
ht = gncBusinessEntityTable (bus, TEST_MODULE_NAME);
do_test (ht != NULL, "business entity table bus, module_name");
guid_new (&guid);
/* Check the lookup functions before we add anything to the table */
do_test (gncBusinessLookupGUID (NULL, NULL, NULL) == NULL,
"business: lookupGUID: NULL, NULL, NULL");
do_test (gncBusinessLookupGUID (NULL, NULL, &guid) == NULL,
"business: lookupGUID: NULL, NULL, guid");
do_test (gncBusinessLookupGUID (NULL, TEST_MODULE_NAME, NULL) == NULL,
"business: lookupGUID: NULL, mod_name, NULL");
do_test (gncBusinessLookupGUID (NULL, TEST_MODULE_NAME, &guid) == NULL,
"business: lookupGUID: NULL, mod_name, guid");
do_test (gncBusinessLookupGUID (bus, NULL, NULL) == NULL,
"business: lookupGUID: bus, NULL, NULL");
do_test (gncBusinessLookupGUID (bus, NULL, &guid) == NULL,
"business: lookupGUID: bus, NULL, guid");
do_test (gncBusinessLookupGUID (bus, TEST_MODULE_NAME, NULL) == NULL,
"business: lookupGUID: bus, mod_name, NULL");
do_test (gncBusinessLookupGUID (bus, TEST_MODULE_NAME, &guid) == NULL,
"business: lookupGUID: bus, mod_name, guid");
/* Now add to the table and look up again */
ptr = get_random_string ();
g_hash_table_insert (ht, &guid, ptr);
/* now let's see if we can look for it */
do_test (gncBusinessLookupGUID (NULL, NULL, NULL) == NULL,
"business: lookupGUID(2): NULL, NULL, NULL");
do_test (gncBusinessLookupGUID (NULL, NULL, &guid) == NULL,
"business: lookupGUID(2): NULL, NULL, guid");
do_test (gncBusinessLookupGUID (NULL, TEST_MODULE_NAME, NULL) == NULL,
"business: lookupGUID(2): NULL, mod_name, NULL");
do_test (gncBusinessLookupGUID (NULL, TEST_MODULE_NAME, &guid) == NULL,
"business: lookupGUID(2): NULL, mod_name, guid");
do_test (gncBusinessLookupGUID (bus, NULL, NULL) == NULL,
"business: lookupGUID(2): bus, NULL, NULL");
do_test (gncBusinessLookupGUID (bus, NULL, &guid) == NULL,
"business: lookupGUID(2): bus, NULL, guid");
do_test (gncBusinessLookupGUID (bus, TEST_MODULE_NAME, NULL) == NULL,
"business: lookupGUID(2): bus, mod_name, NULL");
res = gncBusinessLookupGUID (bus, TEST_MODULE_NAME, &guid);
do_test (res != NULL, "business: lookupGUID(2): bus, mod_name, guid");
do_test (res == ptr, "business: lookupGUID(2): check the same pointer");
test_printable (bus, TEST_MODULE_NAME, ptr);
}
}
static GList *
get_list (GncBusiness *bus, gboolean show_all)
{
do_test (bus != NULL, "get_list: NULL business");
success ("called get_list callback");
return ((GList *)1);
}
static const char *
printable (gpointer obj)
{
do_test (obj != NULL, "printable: object is NULL");
success ("called printable callback");
return ((const char *)obj);
}
static void
test_get_list (GncBusiness *bus, const char *name)
{
GList *res;
do_test (gncBusinessGetList (NULL, NULL, FALSE) == NULL,
"business: GetList: NULL, NULL, FALSE");
do_test (gncBusinessGetList (NULL, name, FALSE) == NULL,
"business: GetList: NULL, mod_name, FALSE");
do_test (gncBusinessGetList (bus, NULL, FALSE) == NULL,
"business: GetList: bus, NULL, FALSE");
res = gncBusinessGetList (bus, name, FALSE);
do_test (res != NULL, "business: GetList: bus, mod_name, FALSE");
}
static void
test_printable (GncBusiness *bus, const char *name, gpointer obj)
{
const char *res;
do_test (gncBusinessPrintable (NULL, NULL, NULL) == NULL,
"business: Printable: NULL, NULL, NULL");
do_test (gncBusinessPrintable (NULL, NULL, obj) == NULL,
"business: Printable: NULL, NULL, object");
do_test (gncBusinessPrintable (NULL, name, NULL) == NULL,
"business: Printable: NULL, mod_name, NULL");
do_test (gncBusinessPrintable (NULL, name, obj) == NULL,
"business: Printable: NULL, mod_name, object");
do_test (gncBusinessPrintable (bus, NULL, NULL) == NULL,
"business: Printable: bus, NULL, NULL");
do_test (gncBusinessPrintable (bus, NULL, obj) == NULL,
"business: Printable: bus, NULL, object");
do_test (gncBusinessPrintable (bus, name, NULL) == NULL,
"business: Printable: bus, mod_name, NULL");
res = gncBusinessPrintable (bus, name, obj);
do_test (res != NULL, "business: Printable: bus, mod_name, object");
}
static void
main_helper (int argc, char **argv)
{
gnc_module_load("gnucash/business-core", 0);
test_business();
print_test_results();
exit(get_rv());
}
int
main (int argc, char **argv)
{
gh_enter (argc, argv, main_helper);
return 0;
}

View File

@ -0,0 +1,196 @@
#include <glib.h>
#include <guile/gh.h>
#include "guid.h"
#include "gnc-module.h"
#include "gnc-engine-util.h"
#include "gncBusiness.h"
#include "gncCustomer.h"
#include "gncCustomerP.h"
#include "test-stuff.h"
static int count = 0;
static void
test_string_fcn (GncBusiness *bus, const char *message,
void (*set) (GncCustomer *, const char *str),
const char * (*get)(GncCustomer *));
static void
test_numeric_fcn (GncBusiness *bus, const char *message,
void (*set) (GncCustomer *, gnc_numeric),
gnc_numeric (*get)(GncCustomer *));
static void
test_bool_fcn (GncBusiness *bus, const char *message,
void (*set) (GncCustomer *, gboolean),
gboolean (*get) (GncCustomer *));
static void
test_gint_fcn (GncBusiness *bus, const char *message,
void (*set) (GncCustomer *, gint),
gint (*get) (GncCustomer *));
static void
test_customer (void)
{
GncBusiness *bus;
GncCustomer *customer;
bus = gncBusinessCreate ((GNCSession *)1);
/* Test creation/destruction */
{
do_test (gncCustomerCreate (NULL) == NULL, "customer create NULL");
customer = gncCustomerCreate (bus);
do_test (customer != NULL, "customer create");
do_test (gncCustomerGetBusiness (customer) == bus,
"getbusiness");
gncCustomerDestroy (customer);
success ("create/destroy");
}
/* Test setting/getting routines; does the active flag get set right? */
{
GUID guid;
test_string_fcn (bus, "Id", gncCustomerSetID, gncCustomerGetID);
test_string_fcn (bus, "Name", gncCustomerSetName, gncCustomerGetName);
test_string_fcn (bus, "Notes", gncCustomerSetNotes, gncCustomerGetNotes);
test_gint_fcn (bus, "Terms", gncCustomerSetTerms, gncCustomerGetTerms);
test_numeric_fcn (bus, "Discount", gncCustomerSetDiscount, gncCustomerGetDiscount);
test_numeric_fcn (bus, "Credit", gncCustomerSetCredit, gncCustomerGetCredit);
test_bool_fcn (bus, "TaxIncluded", gncCustomerSetTaxIncluded, gncCustomerGetTaxIncluded);
test_bool_fcn (bus, "Active", gncCustomerSetActive, gncCustomerGetActive);
do_test (gncCustomerGetAddr (customer) != NULL, "Addr");
do_test (gncCustomerGetShipAddr (customer) != NULL, "ShipAddr");
guid_new (&guid);
customer = gncCustomerCreate (bus); count++;
gncCustomerSetGUID (customer, &guid);
do_test (guid_equal (&guid, gncCustomerGetGUID (customer)), "guid compare");
}
{
GList *list;
list = gncBusinessGetList (bus, GNC_CUSTOMER_MODULE_NAME, TRUE);
do_test (list != NULL, "getList all");
do_test (g_list_length (list) == count, "correct length: all");
g_list_free (list);
list = gncBusinessGetList (bus, GNC_CUSTOMER_MODULE_NAME, FALSE);
do_test (list != NULL, "getList active");
do_test (g_list_length (list) == 1, "correct length: active");
g_list_free (list);
}
{
const char *str = get_random_string();
const char *res;
gncCustomerSetName (customer, str);
res = gncBusinessPrintable (bus, GNC_CUSTOMER_MODULE_NAME, customer);
do_test (res != NULL, "Printable NULL?");
do_test (safe_strcmp (str, res) == 0, "Printable equals");
}
do_test (gncCustomerGetJoblist (customer, TRUE) == NULL, "joblist empty");
/* Test the Entity Table */
{
const GUID *guid;
guid = gncCustomerGetGUID (customer);
do_test (gncBusinessLookupGUID (bus, GNC_CUSTOMER_MODULE_NAME, guid)
== customer, "Entity Table");
}
/* Note: JobList is tested from the Job tests */
}
static void
test_string_fcn (GncBusiness *bus, const char *message,
void (*set) (GncCustomer *, const char *str),
const char * (*get)(GncCustomer *))
{
GncCustomer *customer = gncCustomerCreate (bus);
char const *str = get_random_string ();
do_test (!gncCustomerIsDirty (customer), "test if start dirty");
set (customer, str);
do_test (gncCustomerIsDirty (customer), "test dirty later");
do_test (safe_strcmp (get (customer), str) == 0, message);
gncCustomerSetActive (customer, FALSE);
count++;
}
static void
test_numeric_fcn (GncBusiness *bus, const char *message,
void (*set) (GncCustomer *, gnc_numeric),
gnc_numeric (*get)(GncCustomer *))
{
GncCustomer *customer = gncCustomerCreate (bus);
gnc_numeric num = gnc_numeric_create (17, 1);
do_test (!gncCustomerIsDirty (customer), "test if start dirty");
set (customer, num);
do_test (gncCustomerIsDirty (customer), "test dirty later");
do_test (gnc_numeric_equal (get (customer), num), message);
gncCustomerSetActive (customer, FALSE);
count++;
}
static void
test_bool_fcn (GncBusiness *bus, const char *message,
void (*set) (GncCustomer *, gboolean),
gboolean (*get) (GncCustomer *))
{
GncCustomer *customer = gncCustomerCreate (bus);
gboolean num = get_random_boolean ();
do_test (!gncCustomerIsDirty (customer), "test if start dirty");
set (customer, FALSE);
set (customer, TRUE);
set (customer, num);
do_test (gncCustomerIsDirty (customer), "test dirty later");
do_test (get (customer) == num, message);
gncCustomerSetActive (customer, FALSE);
count++;
}
static void
test_gint_fcn (GncBusiness *bus, const char *message,
void (*set) (GncCustomer *, gint),
gint (*get) (GncCustomer *))
{
GncCustomer *customer = gncCustomerCreate (bus);
gint num = 17;
do_test (!gncCustomerIsDirty (customer), "test if start dirty");
set (customer, num);
do_test (gncCustomerIsDirty (customer), "test dirty later");
do_test (get (customer) == num, message);
gncCustomerSetActive (customer, FALSE);
count++;
}
static void
main_helper (int argc, char **argv)
{
gnc_module_load("gnucash/business-core", 0);
test_customer();
print_test_results();
exit(get_rv());
}
int
main (int argc, char **argv)
{
gh_enter (argc, argv, main_helper);
return 0;
}

View File

@ -0,0 +1,180 @@
#include <glib.h>
#include <guile/gh.h>
#include "guid.h"
#include "gnc-module.h"
#include "gnc-engine-util.h"
#include "gncBusiness.h"
#include "gncEmployee.h"
#include "gncEmployeeP.h"
#include "test-stuff.h"
static int count = 0;
static void
test_string_fcn (GncBusiness *bus, const char *message,
void (*set) (GncEmployee *, const char *str),
const char * (*get)(GncEmployee *));
static void
test_numeric_fcn (GncBusiness *bus, const char *message,
void (*set) (GncEmployee *, gnc_numeric),
gnc_numeric (*get)(GncEmployee *));
static void
test_bool_fcn (GncBusiness *bus, const char *message,
void (*set) (GncEmployee *, gboolean),
gboolean (*get) (GncEmployee *));
static void
test_gint_fcn (GncBusiness *bus, const char *message,
void (*set) (GncEmployee *, gint),
gint (*get) (GncEmployee *));
static void
test_employee (void)
{
GncBusiness *bus;
GncEmployee *employee;
bus = gncBusinessCreate ((GNCSession *)1);
/* Test creation/destruction */
{
do_test (gncEmployeeCreate (NULL) == NULL, "employee create NULL");
employee = gncEmployeeCreate (bus);
do_test (employee != NULL, "employee create");
do_test (gncEmployeeGetBusiness (employee) == bus,
"getbusiness");
gncEmployeeDestroy (employee);
success ("create/destroy");
}
/* Test setting/getting routines; does the active flag get set right? */
{
GUID guid;
test_string_fcn (bus, "Id", gncEmployeeSetID, gncEmployeeGetID);
test_string_fcn (bus, "Username", gncEmployeeSetUsername, gncEmployeeGetUsername);
test_string_fcn (bus, "Language", gncEmployeeSetLanguage, gncEmployeeGetLanguage);
test_string_fcn (bus, "Acl", gncEmployeeSetAcl, gncEmployeeGetAcl);
test_numeric_fcn (bus, "Workday", gncEmployeeSetWorkday, gncEmployeeGetWorkday);
test_numeric_fcn (bus, "Rate", gncEmployeeSetRate, gncEmployeeGetRate);
test_bool_fcn (bus, "Active", gncEmployeeSetActive, gncEmployeeGetActive);
do_test (gncEmployeeGetAddr (employee) != NULL, "Addr");
guid_new (&guid);
employee = gncEmployeeCreate (bus); count++;
gncEmployeeSetGUID (employee, &guid);
do_test (guid_equal (&guid, gncEmployeeGetGUID (employee)), "guid compare");
}
{
GList *list;
list = gncBusinessGetList (bus, GNC_EMPLOYEE_MODULE_NAME, TRUE);
do_test (list != NULL, "getList all");
do_test (g_list_length (list) == count, "correct length: all");
g_list_free (list);
list = gncBusinessGetList (bus, GNC_EMPLOYEE_MODULE_NAME, FALSE);
do_test (list != NULL, "getList active");
do_test (g_list_length (list) == 1, "correct length: active");
g_list_free (list);
}
{
const char *str = get_random_string();
const char *res;
gncEmployeeSetUsername (employee, str);
res = gncBusinessPrintable (bus, GNC_EMPLOYEE_MODULE_NAME, employee);
do_test (res != NULL, "Printable NULL?");
do_test (safe_strcmp (str, res) == 0, "Printable equals");
}
}
static void
test_string_fcn (GncBusiness *bus, const char *message,
void (*set) (GncEmployee *, const char *str),
const char * (*get)(GncEmployee *))
{
GncEmployee *employee = gncEmployeeCreate (bus);
char const *str = get_random_string ();
do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
set (employee, str);
do_test (gncEmployeeIsDirty (employee), "test dirty later");
do_test (safe_strcmp (get (employee), str) == 0, message);
gncEmployeeSetActive (employee, FALSE);
count++;
}
static void
test_numeric_fcn (GncBusiness *bus, const char *message,
void (*set) (GncEmployee *, gnc_numeric),
gnc_numeric (*get)(GncEmployee *))
{
GncEmployee *employee = gncEmployeeCreate (bus);
gnc_numeric num = gnc_numeric_create (17, 1);
do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
set (employee, num);
do_test (gncEmployeeIsDirty (employee), "test dirty later");
do_test (gnc_numeric_equal (get (employee), num), message);
gncEmployeeSetActive (employee, FALSE);
count++;
}
static void
test_bool_fcn (GncBusiness *bus, const char *message,
void (*set) (GncEmployee *, gboolean),
gboolean (*get) (GncEmployee *))
{
GncEmployee *employee = gncEmployeeCreate (bus);
gboolean num = get_random_boolean ();
do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
set (employee, FALSE);
set (employee, TRUE);
set (employee, num);
do_test (gncEmployeeIsDirty (employee), "test dirty later");
do_test (get (employee) == num, message);
gncEmployeeSetActive (employee, FALSE);
count++;
}
static void
test_gint_fcn (GncBusiness *bus, const char *message,
void (*set) (GncEmployee *, gint),
gint (*get) (GncEmployee *))
{
GncEmployee *employee = gncEmployeeCreate (bus);
gint num = 17;
do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
set (employee, num);
do_test (gncEmployeeIsDirty (employee), "test dirty later");
do_test (get (employee) == num, message);
gncEmployeeSetActive (employee, FALSE);
count++;
}
static void
main_helper (int argc, char **argv)
{
gnc_module_load("gnucash/business-core", 0);
test_employee();
print_test_results();
exit(get_rv());
}
int
main (int argc, char **argv)
{
gh_enter (argc, argv, main_helper);
return 0;
}

View File

@ -0,0 +1,191 @@
#include <glib.h>
#include <guile/gh.h>
#include "guid.h"
#include "gnc-module.h"
#include "gnc-engine-util.h"
#include "gncBusiness.h"
#include "gncJob.h"
#include "gncJobP.h"
#include "test-stuff.h"
static int count = 0;
static void
test_string_fcn (GncBusiness *bus, const char *message,
void (*set) (GncJob *, const char *str),
const char * (*get)(GncJob *));
static void
test_numeric_fcn (GncBusiness *bus, const char *message,
void (*set) (GncJob *, gnc_numeric),
gnc_numeric (*get)(GncJob *));
static void
test_bool_fcn (GncBusiness *bus, const char *message,
void (*set) (GncJob *, gboolean),
gboolean (*get) (GncJob *));
static void
test_gint_fcn (GncBusiness *bus, const char *message,
void (*set) (GncJob *, gint),
gint (*get) (GncJob *));
static void
test_job (void)
{
GncBusiness *bus;
GncJob *job;
bus = gncBusinessCreate ((GNCSession *)1);
/* Test creation/destruction */
{
do_test (gncJobCreate (NULL) == NULL, "job create NULL");
job = gncJobCreate (bus);
do_test (job != NULL, "job create");
do_test (gncJobGetBusiness (job) == bus,
"getbusiness");
gncJobDestroy (job);
success ("create/destroy");
}
/* Test setting/getting routines; does the active flag get set right? */
{
GUID guid;
test_string_fcn (bus, "Id", gncJobSetID, gncJobGetID);
test_string_fcn (bus, "Name", gncJobSetName, gncJobGetName);
test_string_fcn (bus, "Desc", gncJobSetDesc, gncJobGetDesc);
test_bool_fcn (bus, "Active", gncJobSetActive, gncJobGetActive);
guid_new (&guid);
job = gncJobCreate (bus); count++;
gncJobSetGUID (job, &guid);
do_test (guid_equal (&guid, gncJobGetGUID (job)), "guid compare");
}
#if 0
{
GList *list;
list = gncBusinessGetList (bus, GNC_JOB_MODULE_NAME, TRUE);
do_test (list != NULL, "getList all");
do_test (g_list_length (list) == count, "correct length: all");
g_list_free (list);
list = gncBusinessGetList (bus, GNC_JOB_MODULE_NAME, FALSE);
do_test (list != NULL, "getList active");
do_test (g_list_length (list) == 1, "correct length: active");
g_list_free (list);
}
#endif
{
const char *str = get_random_string();
const char *res;
gncJobSetName (job, str);
res = gncBusinessPrintable (bus, GNC_JOB_MODULE_NAME, job);
do_test (res != NULL, "Printable NULL?");
do_test (safe_strcmp (str, res) == 0, "Printable equals");
}
{
GList *list;
GncCustomer *cust = gncCustomerCreate (bus);
do_test (gncCustomerGetJoblist (cust, TRUE) == NULL, "empty list at start");
gncJobSetCustomer (job, cust);
list = gncCustomerGetJoblist (cust, FALSE);
do_test (list != NULL, "added to cust");
do_test (g_list_length (list) == 1, "correct joblist length");
do_test (list->data == job, "verify job in list");
gncJobSetActive (job, FALSE);
list = gncCustomerGetJoblist (cust, FALSE);
do_test (list == NULL, "no active jobs");
list = gncCustomerGetJoblist (cust, TRUE);
do_test (list != NULL, "all jobs");
gncJobDestroy (job);
list = gncCustomerGetJoblist (cust, TRUE);
do_test (list == NULL, "no more jobs");
}
}
static void
test_string_fcn (GncBusiness *bus, const char *message,
void (*set) (GncJob *, const char *str),
const char * (*get)(GncJob *))
{
GncJob *job = gncJobCreate (bus);
char const *str = get_random_string ();
do_test (!gncJobIsDirty (job), "test if start dirty");
set (job, str);
do_test (gncJobIsDirty (job), "test dirty later");
do_test (safe_strcmp (get (job), str) == 0, message);
gncJobSetActive (job, FALSE); count++;
}
static void
test_numeric_fcn (GncBusiness *bus, const char *message,
void (*set) (GncJob *, gnc_numeric),
gnc_numeric (*get)(GncJob *))
{
GncJob *job = gncJobCreate (bus);
gnc_numeric num = gnc_numeric_create (17, 1);
do_test (!gncJobIsDirty (job), "test if start dirty");
set (job, num);
do_test (gncJobIsDirty (job), "test dirty later");
do_test (gnc_numeric_equal (get (job), num), message);
gncJobSetActive (job, FALSE); count++;
}
static void
test_bool_fcn (GncBusiness *bus, const char *message,
void (*set) (GncJob *, gboolean),
gboolean (*get) (GncJob *))
{
GncJob *job = gncJobCreate (bus);
gboolean num = get_random_boolean ();
do_test (!gncJobIsDirty (job), "test if start dirty");
set (job, FALSE);
set (job, TRUE);
set (job, num);
do_test (gncJobIsDirty (job), "test dirty later");
do_test (get (job) == num, message);
gncJobSetActive (job, FALSE); count++;
}
static void
test_gint_fcn (GncBusiness *bus, const char *message,
void (*set) (GncJob *, gint),
gint (*get) (GncJob *))
{
GncJob *job = gncJobCreate (bus);
gint num = 17;
do_test (!gncJobIsDirty (job), "test if start dirty");
set (job, num);
do_test (gncJobIsDirty (job), "test dirty later");
do_test (get (job) == num, message);
gncJobSetActive (job, FALSE); count++;
}
static void
main_helper (int argc, char **argv)
{
gnc_module_load("gnucash/business-core", 0);
test_job();
print_test_results();
exit(get_rv());
}
int
main (int argc, char **argv)
{
gh_enter (argc, argv, main_helper);
return 0;
}

View File

@ -0,0 +1,175 @@
#include <glib.h>
#include <guile/gh.h>
#include "guid.h"
#include "gnc-module.h"
#include "gnc-engine-util.h"
#include "gncBusiness.h"
#include "gncVendor.h"
#include "gncVendorP.h"
#include "test-stuff.h"
static int count = 0;
static void
test_string_fcn (GncBusiness *bus, const char *message,
void (*set) (GncVendor *, const char *str),
const char * (*get)(GncVendor *));
static void
test_numeric_fcn (GncBusiness *bus, const char *message,
void (*set) (GncVendor *, gnc_numeric),
gnc_numeric (*get)(GncVendor *));
static void
test_bool_fcn (GncBusiness *bus, const char *message,
void (*set) (GncVendor *, gboolean),
gboolean (*get) (GncVendor *));
static void
test_gint_fcn (GncBusiness *bus, const char *message,
void (*set) (GncVendor *, gint),
gint (*get) (GncVendor *));
static void
test_vendor (void)
{
GncBusiness *bus;
GncVendor *vendor;
bus = gncBusinessCreate ((GNCSession *)1);
/* Test creation/destruction */
{
do_test (gncVendorCreate (NULL) == NULL, "vendor create NULL");
vendor = gncVendorCreate (bus);
do_test (vendor != NULL, "vendor create");
do_test (gncVendorGetBusiness (vendor) == bus,
"getbusiness");
gncVendorDestroy (vendor);
success ("create/destroy");
}
/* Test setting/getting routines; does the active flag get set right? */
{
GUID guid;
test_string_fcn (bus, "Id", gncVendorSetID, gncVendorGetID);
test_string_fcn (bus, "Name", gncVendorSetName, gncVendorGetName);
test_string_fcn (bus, "Notes", gncVendorSetNotes, gncVendorGetNotes);
test_gint_fcn (bus, "Terms", gncVendorSetTerms, gncVendorGetTerms);
test_bool_fcn (bus, "TaxIncluded", gncVendorSetTaxIncluded, gncVendorGetTaxIncluded);
test_bool_fcn (bus, "Active", gncVendorSetActive, gncVendorGetActive);
do_test (gncVendorGetAddr (vendor) != NULL, "Addr");
guid_new (&guid);
vendor = gncVendorCreate (bus); count++;
gncVendorSetGUID (vendor, &guid);
do_test (guid_equal (&guid, gncVendorGetGUID (vendor)), "guid compare");
}
{
GList *list;
list = gncBusinessGetList (bus, GNC_VENDOR_MODULE_NAME, TRUE);
do_test (list != NULL, "getList all");
do_test (g_list_length (list) == count, "correct length: all");
g_list_free (list);
list = gncBusinessGetList (bus, GNC_VENDOR_MODULE_NAME, FALSE);
do_test (list != NULL, "getList active");
do_test (g_list_length (list) == 1, "correct length: active");
g_list_free (list);
}
{
const char *str = get_random_string();
const char *res;
gncVendorSetName (vendor, str);
res = gncBusinessPrintable (bus, GNC_VENDOR_MODULE_NAME, vendor);
do_test (res != NULL, "Printable NULL?");
do_test (safe_strcmp (str, res) == 0, "Printable equals");
}
}
static void
test_string_fcn (GncBusiness *bus, const char *message,
void (*set) (GncVendor *, const char *str),
const char * (*get)(GncVendor *))
{
GncVendor *vendor = gncVendorCreate (bus);
char const *str = get_random_string ();
do_test (!gncVendorIsDirty (vendor), "test if start dirty");
set (vendor, str);
do_test (gncVendorIsDirty (vendor), "test dirty later");
do_test (safe_strcmp (get (vendor), str) == 0, message);
gncVendorSetActive (vendor, FALSE); count++;
}
static void
test_numeric_fcn (GncBusiness *bus, const char *message,
void (*set) (GncVendor *, gnc_numeric),
gnc_numeric (*get)(GncVendor *))
{
GncVendor *vendor = gncVendorCreate (bus);
gnc_numeric num = gnc_numeric_create (17, 1);
do_test (!gncVendorIsDirty (vendor), "test if start dirty");
set (vendor, num);
do_test (gncVendorIsDirty (vendor), "test dirty later");
do_test (gnc_numeric_equal (get (vendor), num), message);
gncVendorSetActive (vendor, FALSE); count++;
}
static void
test_bool_fcn (GncBusiness *bus, const char *message,
void (*set) (GncVendor *, gboolean),
gboolean (*get) (GncVendor *))
{
GncVendor *vendor = gncVendorCreate (bus);
gboolean num = get_random_boolean ();
do_test (!gncVendorIsDirty (vendor), "test if start dirty");
set (vendor, FALSE);
set (vendor, TRUE);
set (vendor, num);
do_test (gncVendorIsDirty (vendor), "test dirty later");
do_test (get (vendor) == num, message);
gncVendorSetActive (vendor, FALSE); count++;
}
static void
test_gint_fcn (GncBusiness *bus, const char *message,
void (*set) (GncVendor *, gint),
gint (*get) (GncVendor *))
{
GncVendor *vendor = gncVendorCreate (bus);
gint num = 17;
do_test (!gncVendorIsDirty (vendor), "test if start dirty");
set (vendor, num);
do_test (gncVendorIsDirty (vendor), "test dirty later");
do_test (get (vendor) == num, message);
gncVendorSetActive (vendor, FALSE); count++;
}
static void
main_helper (int argc, char **argv)
{
gnc_module_load("gnucash/business-core", 0);
test_vendor();
print_test_results();
exit(get_rv());
}
int
main (int argc, char **argv)
{
gh_enter (argc, argv, main_helper);
return 0;
}

View File

@ -0,0 +1,6 @@
.scm-links
Makefile
gw-business-gnome.c
gw-business-gnome.h
gw-business-gnome.html
gw-business-gnome.scm

View File

@ -0,0 +1,92 @@
pkglib_LTLIBRARIES = libgncmod-business-gnome.la libgw-business-gnome.la
AM_CFLAGS = \
-I${top_srcdir}/src \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/gnome-utils \
-I${top_srcdir}/src/gnome \
-I${top_srcdir}/src/app-utils \
-I${top_srcdir}/src/business/business-core \
${GUILE_INCS} \
${GNOME_INCLUDEDIR} \
${GLADE_CFLAGS} \
${GTKHTML_CFLAGS} \
${G_WRAP_COMPILE_ARGS} \
${GLIB_CFLAGS} \
-I${top_srcdir}/src/register/ledger-core \
-I${top_srcdir}/src/register/register-core
libgncmod_business_gnome_la_SOURCES = \
businessmod-gnome.c \
business-chooser.c \
dialog-customer.c \
dialog-employee.c \
dialog-job.c \
dialog-job-select.c \
dialog-vendor.c
noinst_HEADERS = \
business-chooser.h \
dialog-customer.h \
dialog-employee.h \
dialog-job.h \
dialog-job-select.h \
dialog-vendor.h
libgncmod_business_gnome_la_LDFLAGS = -module
libgncmod_business_gnome_la_LIBADD = \
../business-core/libgncmod-business-core.la \
${top_srcdir}/src/gnc-module/libgncmodule.la \
${top_srcdir}/src/engine/libgncmod-engine.la \
${top_srcdir}/src/app-utils/libgncmod-app-utils.la \
${top_srcdir}/src/gnome-utils/libgncmod-gnome-utils.la \
${GUILE_LIBS} \
${GNOMEUI_LIBS} \
${G_WRAP_LINK_ARGS} \
${GLIB_LIBS} \
${EFENCE_LIBS}
libgw_business_gnome_la_SOURCES = gw-business-gnome.c
libgw_business_gnome_la_LDFLAGS = -module ${G_WRAP_LINK_ARGS}
gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
gncmod_DATA = business-gnome.scm
gladedir = $(GNC_GLADE_DIR)
glade_DATA = \
business-chooser.glade \
customer.glade \
employee.glade \
job.glade \
vendor.glade
EXTRA_DIST = $(glade_DATA)
gwmoddir = ${GNC_GWRAP_LIBDIR}
gwmod_DATA = \
gw-business-gnome.scm \
gw-business-gnome-spec.scm
.scm-links:
rm -f gnucash g-wrapped
ln -sf . gnucash
ln -sf . g-wrapped
touch .scm-links
gncmod-business-gnome.c: gw-business-gnome.h
gw-business-gnome.scm gw-business-gnome.c gw-business-gnome.h: .scm-links gw-business-gnome-spec.scm
FLAVOR=gnome guile -c \
"(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
(set! %load-path (cons \"${PWD}\" %load-path)) \
(set! %load-path (cons \"../business-core\" %load-path)) \
(set! %load-path (cons \"../../engine\" %load-path)) \
(set! %load-path (cons \"../../gnome\" %load-path)) \
(primitive-load \"./gw-business-gnome-spec.scm\") \
(gw:generate-module \"gw-business-gnome\")"
BUILT_SOURCES = gw-business-gnome.scm gw-business-gnome.c gw-business-gnome.h
CLEANFILES = gw-business-gnome.scm gw-business-gnome.c gw-business-gnome.h gw-business-gnome.html

View File

@ -0,0 +1,249 @@
/*
* business-chooser.c -- General Selection Dialog for GNC Business Objects
*
* Written By: Derek Atkins <warlord@MIT.EDU>
* Copyright (C) 2001
*/
#include "config.h"
#include <gnome.h>
#include "dialog-utils.h"
#include "gnc-ui.h"
#include "gnc-gui-query.h"
#include "gncBusiness.h"
#include "business-chooser.h"
struct business_chooser_window {
GtkWidget * dialog;
GtkWidget * choice_combo;
GtkWidget * choice_entry;
GtkWidget * showall_check;
GncBusiness * business;
const GncBusinessObject * obj_type;
gnc_business_chooser_new_cb new_cb;
gnc_business_chooser_edit_cb edit_cb;
gpointer cb_arg;
gpointer selected;
};
static void
chooser_choice_changed_cb(GtkList *list, GtkWidget *li, gpointer user_data)
{
struct business_chooser_window * w = user_data;
w->selected = gtk_object_get_data (GTK_OBJECT (li), "list-item-pointer");
}
static void
update_selection_picker (struct business_chooser_window *w)
{
GList *objs, *iterator;
GtkWidget *li;
GList *obj_list;
gpointer selected;
gboolean show_all = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(w->showall_check));
/* Clear out the existing choices */
gtk_list_clear_items (GTK_LIST (GTK_COMBO (w->choice_combo)->list), 0, -1);
/* Save the existing selection */
selected = w->selected;
/* Get the list of objects */
obj_list = (*(w->obj_type->get_list))(w->business, show_all);
/* Build a list of strings (objs is pre-sorted, so keep the order!) */
for (iterator = obj_list; iterator; iterator = iterator->next) {
const gchar *label = (*(w->obj_type->printable))(iterator->data);
li = gtk_list_item_new_with_label (label);
gtk_object_set_data (GTK_OBJECT (li), "list-item-pointer", iterator->data);
gtk_widget_show (li);
gtk_container_add (GTK_CONTAINER (GTK_COMBO (w->choice_combo)->list), li);
}
/* revert the existing selection */
w->selected = selected;
/* If no selection, choose the first one in the list */
if (!w->selected && obj_list)
w->selected = obj_list->data;
/* XXX: Should we verify that w->selected is a memeber of obj_list? */
/* And set the current-selected item */
gtk_entry_set_text (GTK_ENTRY (w->choice_entry),
((w->selected) ?
(*(w->obj_type->printable))(w->selected) : ""));
g_list_free (obj_list);
}
static void
gnc_ui_business_chooser_ok_cb(GtkButton * button, gpointer user_data)
{
struct business_chooser_window * w = user_data;
if(w->selected) {
gnome_dialog_close(GNOME_DIALOG (w->dialog));
} else {
gnc_warning_dialog(_("You must make a selection.\n"
"To create a new one, click \"New\""));
}
}
static void
gnc_ui_business_chooser_new_cb(GtkButton * button, gpointer user_data)
{
struct business_chooser_window * w = user_data;
if (w->new_cb) {
gpointer new_selection;
GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
new_selection = (*(w->new_cb))(w->cb_arg, toplevel);
if (new_selection) {
w->selected = new_selection;
update_selection_picker (w);
}
}
}
static void
gnc_ui_business_chooser_edit_cb(GtkButton * button, gpointer user_data)
{
struct business_chooser_window * w = user_data;
if (! w->selected) {
gnc_warning_dialog(_("You must choose a selection to edit.\n"));
return;
}
if (w->edit_cb) {
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
(*(w->edit_cb))(w->cb_arg, w->selected, toplevel);
}
update_selection_picker (w);
}
static void
gnc_ui_business_chooser_cancel_cb(GtkButton * button, gpointer user_data)
{
struct business_chooser_window * w = user_data;
if (w)
gnome_dialog_close(GNOME_DIALOG (w->dialog));
}
static void
gnc_ui_business_chooser_showall_toggled_cb(GtkCheckButton * entry,
gpointer user_data)
{
struct business_chooser_window * w = user_data;
update_selection_picker (w);
}
static gint
business_chooser_close (GnomeDialog *dialog, gpointer data)
{
gtk_main_quit ();
return FALSE;
}
gpointer
gnc_ui_business_chooser_new (GtkWidget * parent,
gpointer orig_sel,
GncBusiness *business, const char *type_name,
gnc_business_chooser_new_cb new_cb,
gnc_business_chooser_edit_cb edit_cb,
gpointer cbarg)
{
struct business_chooser_window * win =
g_new0(struct business_chooser_window, 1);
GladeXML *xml;
GtkWidget *choice_name_label;
gpointer retval;
if (!business || !type_name) return NULL;
xml = gnc_glade_xml_new ("business-chooser.glade",
"Business Chooser Dialog");
/* Grab the widgets */
win->dialog = glade_xml_get_widget (xml, "Business Chooser Dialog");
win->choice_combo = glade_xml_get_widget (xml, "choice_combo");
win->choice_entry = glade_xml_get_widget (xml, "choice_entry");
win->showall_check = glade_xml_get_widget (xml, "showall_check");
/* Set the label */
choice_name_label = glade_xml_get_widget (xml, "choice_name_label");
gtk_label_set_text (GTK_LABEL (choice_name_label),
gncBusinessGetTypeLabel (type_name));
if(parent) {
gnome_dialog_set_parent(GNOME_DIALOG(win->dialog), GTK_WINDOW(parent));
}
/* Setup the signals */
glade_xml_signal_connect_data
(xml, "gnc_ui_business_chooser_ok_cb",
GTK_SIGNAL_FUNC (gnc_ui_business_chooser_ok_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_business_chooser_new_cb",
GTK_SIGNAL_FUNC (gnc_ui_business_chooser_new_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_business_chooser_edit_cb",
GTK_SIGNAL_FUNC (gnc_ui_business_chooser_edit_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_business_chooser_cancel_cb",
GTK_SIGNAL_FUNC (gnc_ui_business_chooser_cancel_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_business_chooser_showall_toggled_cb",
GTK_SIGNAL_FUNC (gnc_ui_business_chooser_showall_toggled_cb), win);
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (win->choice_combo)->list),
"select-child",
GTK_SIGNAL_FUNC(chooser_choice_changed_cb), win);
gtk_signal_connect (GTK_OBJECT(win->dialog), "close",
GTK_SIGNAL_FUNC(business_chooser_close), win);
/* Save the callbacks */
win->business = business;
win->obj_type = gncBusinessLookup (type_name);
win->new_cb = new_cb;
win->edit_cb = edit_cb;
win->cb_arg = cbarg;
/* Setup the menu */
win->selected = orig_sel;
update_selection_picker (win);
/* Run the widget */
gtk_window_set_modal(GTK_WINDOW(win->dialog), TRUE);
gtk_widget_show (win->dialog);
gtk_main();
/* And exit */
retval = win->selected;
g_free(win);
return retval;
}

View File

@ -0,0 +1,209 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Business-chooser</name>
<program_name>business-chooser</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<output_main_file>False</output_main_file>
<output_support_files>False</output_support_files>
<output_build_files>False</output_build_files>
<backup_source_files>False</backup_source_files>
</project>
<widget>
<class>GnomeDialog</class>
<name>Business Chooser Dialog</name>
<title>Chooser</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>True</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>hbuttonbox1</name>
<layout_style>GTK_BUTTONBOX_SPREAD</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button1</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>gnc_ui_business_chooser_ok_cb</handler>
<data>Business_Chooser_Dialog</data>
<last_modification_time>Sat, 10 Nov 2001 23:06:48 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button2</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>gnc_ui_business_chooser_new_cb</handler>
<data>Business_Chooser_Dialog</data>
<last_modification_time>Sat, 10 Nov 2001 23:07:01 GMT</last_modification_time>
</signal>
<label>New...</label>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>gnc_ui_business_chooser_edit_cb</handler>
<data>Business_Chooser_Dialog</data>
<last_modification_time>Sun, 11 Nov 2001 02:16:31 GMT</last_modification_time>
</signal>
<label>Edit...</label>
</widget>
<widget>
<class>GtkButton</class>
<name>button4</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>gnc_ui_business_chooser_cancel_cb</handler>
<data>Business_Chooser_Dialog</data>
<last_modification_time>Sat, 10 Nov 2001 23:07:12 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox3</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkCheckButton</class>
<name>showall_check</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>gnc_ui_business_chooser_showall_toggled_cb</handler>
<data>Business_Chooser_Dialog</data>
<last_modification_time>Thu, 15 Nov 2001 15:49:23 GMT</last_modification_time>
</signal>
<label>Show All</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox2</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>choice_name_label</name>
<label>Current Choice:</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>3</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkCombo</class>
<name>choice_combo</name>
<width>250</width>
<value_in_list>True</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items></items>
<child>
<padding>3</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>choice_entry</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@ -0,0 +1,35 @@
/*
* business-chooser.h -- General Selection Dialog for GNC Business Objects
*
* Written By: Derek Atkins <warlord@MIT.EDU>
* Copyright (C) 2001
*/
#ifndef GNC_BUSINESS_CHOOSER_H_
#define GNC_BUSINESS_CHOOSER_H_
/*
* Generic function to choose business objects. This function
* is only called from within the business objects, but is made
* available here so other objects can use it. You provide the
* original selection, the Object Type Name (as registered),
* callbacks to call to create a new object or to edit an existing
* one, and a callback argument that is passed to the callbacks.
*
* Note that if a callback function is NULL, the associated button
* will still be clickable but will do nothing. XXXX -- this is a bug
*/
typedef gpointer (*gnc_business_chooser_new_cb)(gpointer cbarg, GtkWidget *toplevel);
typedef void (*gnc_business_chooser_edit_cb)(gpointer cbarg, gpointer sel_obj, GtkWidget *toplevel);
gpointer
gnc_ui_business_chooser_new (GtkWidget * parent,
gpointer orig_sel,
GncBusiness *business, const char *type_name,
gnc_business_chooser_new_cb new_cb,
gnc_business_chooser_edit_cb edit_cb,
gpointer cbarg);
#endif /* GNC_BUSINESS_CHOOSER_H_ */

View File

@ -0,0 +1 @@
(define-module (gnucash business-gnome))

View File

@ -0,0 +1,54 @@
/*********************************************************************
* businessmod-core.c
* module definition/initialization for the Business GNOME UI module
*
* Copyright (c) 2001 Derek Atkins <warlord@MIT.EDU>
*********************************************************************/
#include <stdio.h>
#include <guile/gh.h>
#include <glib.h>
#include "gnc-module.h"
#include "gnc-module-api.h"
#include "gw-business-gnome.h"
/* version of the gnc module system interface we require */
int gnc_module_system_interface = 0;
/* module versioning uses libtool semantics. */
int gnc_module_current = 0;
int gnc_module_revision = 0;
int gnc_module_age = 0;
char *
gnc_module_path(void)
{
return g_strdup("gnucash/business-gnome");
}
char *
gnc_module_description(void)
{
return g_strdup("The Gnucash business module GNOME UI");
}
int
gnc_module_init(int refcount)
{
/* load business-core: we depend on it */
if (!gnc_module_load ("gnucash/business-core", 0)) {
return FALSE;
}
gh_eval_str("(use-modules (g-wrapped gw-business-gnome))");
gh_eval_str("(use-modules (gnucash business-gnome))");
return TRUE;
}
int
gnc_module_end(int refcount) {
return TRUE;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,683 @@
/*
* dialog-customer.c -- Dialog for Customer entry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <gnome.h>
#include "dialog-utils.h"
#include "global-options.h"
#include "gnc-amount-edit.h"
#include "gnc-component-manager.h"
#include "gnc-ui.h"
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
#include "gnc-engine-util.h"
#include "window-help.h"
#include "gncBusiness.h"
#include "gncAddress.h"
#include "gncCustomer.h"
#include "gncCustomerP.h"
#include "dialog-customer.h"
#include "business-chooser.h"
#define DIALOG_NEW_CUSTOMER_CM_CLASS "dialog-new-customer"
#define DIALOG_EDIT_CUSTOMER_CM_CLASS "dialog-edit-customer"
typedef enum
{
NEW_CUSTOMER,
EDIT_CUSTOMER
} CustomerDialogType;
struct _customer_select_window {
GncBusiness * business;
};
typedef struct _customer_window {
GtkWidget * dialog;
GtkWidget * id_entry;
GtkWidget * company_entry;
GtkWidget * name_entry;
GtkWidget * addr1_entry;
GtkWidget * addr2_entry;
GtkWidget * addr3_entry;
GtkWidget * addr4_entry;
GtkWidget * phone_entry;
GtkWidget * fax_entry;
GtkWidget * email_entry;
GtkWidget * shipname_entry;
GtkWidget * shipaddr1_entry;
GtkWidget * shipaddr2_entry;
GtkWidget * shipaddr3_entry;
GtkWidget * shipaddr4_entry;
GtkWidget * shipphone_entry;
GtkWidget * shipfax_entry;
GtkWidget * shipemail_entry;
GtkWidget * terms_amount;
GtkWidget * discount_amount;
GtkWidget * credit_amount;
GtkWidget * active_check;
GtkWidget * taxincluded_check;
GtkWidget * notes_text;
CustomerDialogType dialog_type;
GUID customer_guid;
gint component_id;
GncBusiness * business;
GncCustomer * created_customer;
} CustomerWindow;
static GncCustomer *
cw_get_customer (CustomerWindow *cw)
{
if (!cw)
return NULL;
return gncBusinessLookupGUID (cw->business, GNC_CUSTOMER_MODULE_NAME,
&cw->customer_guid);
}
static void gnc_ui_to_customer (CustomerWindow *cw, GncCustomer *cust)
{
GncAddress *addr, *shipaddr;
gnc_numeric num;
addr = gncCustomerGetAddr (cust);
shipaddr = gncCustomerGetShipAddr (cust);
gnc_suspend_gui_refresh ();
gncCustomerSetID (cust, gtk_editable_get_chars
(GTK_EDITABLE (cw->id_entry), 0, -1));
gncCustomerSetName (cust, gtk_editable_get_chars
(GTK_EDITABLE (cw->company_entry), 0, -1));
gncAddressSetName (addr, gtk_editable_get_chars
(GTK_EDITABLE (cw->name_entry), 0, -1));
gncAddressSetAddr1 (addr, gtk_editable_get_chars
(GTK_EDITABLE (cw->addr1_entry), 0, -1));
gncAddressSetAddr2 (addr, gtk_editable_get_chars
(GTK_EDITABLE (cw->addr2_entry), 0, -1));
gncAddressSetAddr3 (addr, gtk_editable_get_chars
(GTK_EDITABLE (cw->addr3_entry), 0, -1));
gncAddressSetAddr4 (addr, gtk_editable_get_chars
(GTK_EDITABLE (cw->addr4_entry), 0, -1));
gncAddressSetPhone (addr, gtk_editable_get_chars
(GTK_EDITABLE (cw->phone_entry), 0, -1));
gncAddressSetFax (addr, gtk_editable_get_chars
(GTK_EDITABLE (cw->fax_entry), 0, -1));
gncAddressSetEmail (addr, gtk_editable_get_chars
(GTK_EDITABLE (cw->email_entry), 0, -1));
gncAddressSetName (shipaddr, gtk_editable_get_chars
(GTK_EDITABLE (cw->shipname_entry), 0, -1));
gncAddressSetAddr1 (shipaddr, gtk_editable_get_chars
(GTK_EDITABLE (cw->shipaddr1_entry), 0, -1));
gncAddressSetAddr2 (shipaddr, gtk_editable_get_chars
(GTK_EDITABLE (cw->shipaddr2_entry), 0, -1));
gncAddressSetAddr3 (shipaddr, gtk_editable_get_chars
(GTK_EDITABLE (cw->shipaddr3_entry), 0, -1));
gncAddressSetAddr4 (shipaddr, gtk_editable_get_chars
(GTK_EDITABLE (cw->shipaddr4_entry), 0, -1));
gncAddressSetPhone (shipaddr, gtk_editable_get_chars
(GTK_EDITABLE (cw->shipphone_entry), 0, -1));
gncAddressSetFax (shipaddr, gtk_editable_get_chars
(GTK_EDITABLE (cw->shipfax_entry), 0, -1));
gncAddressSetEmail (shipaddr, gtk_editable_get_chars
(GTK_EDITABLE (cw->shipemail_entry), 0, -1));
gncCustomerSetActive (cust, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (cw->active_check)));
gncCustomerSetTaxIncluded (cust, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (cw->taxincluded_check)));
gncCustomerSetNotes (cust, gtk_editable_get_chars
(GTK_EDITABLE (cw->notes_text), 0, -1));
/* Parse and set the terms, discount, and credit amounts */
num = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (cw->terms_amount));
gncCustomerSetTerms (cust, gnc_numeric_num (num));
gncCustomerSetDiscount (cust, gnc_amount_edit_get_amount
(GNC_AMOUNT_EDIT (cw->discount_amount)));
gncCustomerSetCredit (cust, gnc_amount_edit_get_amount
(GNC_AMOUNT_EDIT (cw->credit_amount)));
gncCustomerCommitEdit (cust);
gnc_resume_gui_refresh ();
}
static gboolean check_edit_amount (GtkWidget *dialog, GtkWidget *amount,
gnc_numeric *min, gnc_numeric *max,
const char * error_message)
{
if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (amount))) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
/* We've got a valid-looking number; check mix/max */
if (min || max) {
gnc_numeric val = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (amount));
if ((min && gnc_numeric_compare (*min, val) > 0) ||
(max && gnc_numeric_compare (val, *max) > 0)) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
}
return FALSE;
}
static gboolean check_entry_nonempty (GtkWidget *dialog, GtkWidget *entry,
const char * error_message)
{
const char *res = gtk_entry_get_text (GTK_ENTRY (entry));
if (safe_strcmp (res, "") == 0) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
return FALSE;
}
static void
gnc_customer_window_ok_cb (GtkWidget *widget, gpointer data)
{
CustomerWindow *cw = data;
char *res;
GncCustomer *cust;
gnc_numeric min, max;
/* Check for valid id */
if (check_entry_nonempty (cw->dialog, cw->id_entry,
_("The Customer must be given an ID.")))
return;
/* Check for valid company name */
if (check_entry_nonempty (cw->dialog, cw->company_entry,
_("You must enter a company name.")))
return;
/* Make sure we have an address */
if (check_entry_nonempty (cw->dialog, cw->addr1_entry, NULL) &&
check_entry_nonempty (cw->dialog, cw->addr2_entry, NULL) &&
check_entry_nonempty (cw->dialog, cw->addr3_entry, NULL) &&
check_entry_nonempty (cw->dialog, cw->addr4_entry, NULL)) {
const char *msg = _("You must enter a billing address.");
gnc_error_dialog_parented (GTK_WINDOW (cw->dialog), msg);
return;
}
/* Verify terms, discount, and credit are valid (or empty) */
min = gnc_numeric_zero ();
max = gnc_numeric_create (100, 1);
if (check_edit_amount (cw->dialog, cw->terms_amount, &min, NULL,
_("Terms must be a positive integer or "
"you must leave it blank.")))
return;
if (check_edit_amount (cw->dialog, cw->discount_amount, &min, &max,
_("Discount percentage must be between 0-100 "
"or you must leave it blank.")))
return;
if (check_edit_amount (cw->dialog, cw->credit_amount, &min, NULL,
_("Credit must be a positive amount or "
"you must leave it blank.")))
return;
/* Now save it off */
{
GncCustomer *customer = cw_get_customer (cw);
if (customer) {
gnc_ui_to_customer (cw, customer);
}
cw->created_customer = customer;
cw->customer_guid = *xaccGUIDNULL ();
}
gnc_close_gui_component (cw->component_id);
}
static void
gnc_customer_window_cancel_cb (GtkWidget *widget, gpointer data)
{
CustomerWindow *cw = data;
gnc_close_gui_component (cw->component_id);
}
static void
gnc_customer_window_help_cb (GtkWidget *widget, gpointer data)
{
CustomerWindow *cw = data;
char *help_file = ""; /* xxx */
helpWindow(NULL, NULL, help_file);
}
static void
gnc_customer_window_destroy_cb (GtkWidget *widget, gpointer data)
{
CustomerWindow *cw = data;
GncCustomer *customer = cw_get_customer (cw);
gnc_suspend_gui_refresh ();
if (cw->dialog_type == NEW_CUSTOMER && customer != NULL) {
gncCustomerDestroy (customer);
cw->customer_guid = *xaccGUIDNULL ();
}
gnc_unregister_gui_component (cw->component_id);
gnc_resume_gui_refresh ();
g_free (cw);
}
static void
gnc_customer_name_changed_cb (GtkWidget *widget, gpointer data)
{
CustomerWindow *cw = data;
char *name, *id, *fullname, *title;
if (!cw)
return;
name = gtk_entry_get_text (GTK_ENTRY (cw->name_entry));
if (!name || *name == '\0')
name = _("<No name>");
id = gtk_entry_get_text (GTK_ENTRY (cw->id_entry));
fullname = g_strconcat (name, " (", id, ")", NULL);
if (cw->dialog_type == EDIT_CUSTOMER)
title = g_strconcat (_("Edit Customer"), " - ", fullname, NULL);
else
title = g_strconcat (_("New Customer"), " - ", fullname, NULL);
gtk_window_set_title (GTK_WINDOW (cw->dialog), title);
g_free (fullname);
g_free (title);
}
static int
gnc_customer_on_close_cb (GnomeDialog *dialog, gpointer data)
{
CustomerWindow *cw;
GncCustomer **created_customer = data;
if (data) {
cw = gtk_object_get_data (GTK_OBJECT (dialog), "dialog_info");
*created_customer = cw->created_customer;
}
gtk_main_quit ();
return FALSE;
}
static void
gnc_customer_window_close_handler (gpointer user_data)
{
CustomerWindow *cw = user_data;
gnome_dialog_close (GNOME_DIALOG (cw->dialog));
}
static void
gnc_customer_window_refresh_handler (GHashTable *changes, gpointer user_data)
{
CustomerWindow *cw = user_data;
const EventInfo *info;
GncCustomer *customer = cw_get_customer (cw);
/* If there isn't a customer behind us, close down */
if (!customer) {
gnc_close_gui_component (cw->component_id);
return;
}
/* Next, close if this is a destroy event */
if (changes) {
info = gnc_gui_get_entity_events (changes, &cw->customer_guid);
if (info && (info->event_mask & GNC_EVENT_DESTROY)) {
gnc_close_gui_component (cw->component_id);
return;
}
}
}
static CustomerWindow *
gnc_customer_new_window (GtkWidget *parent, GncBusiness *bus,
GncCustomer *cust)
{
CustomerWindow *cw;
GladeXML *xml;
GtkWidget *hbox, *edit;
GnomeDialog *cwd;
gnc_commodity *commodity;
GNCPrintAmountInfo print_info;
cw = g_new0 (CustomerWindow, 1);
cw->business = bus;
/* Find the dialog */
xml = gnc_glade_xml_new ("customer.glade", "Customer Dialog");
cw->dialog = glade_xml_get_widget (xml, "Customer Dialog");
cwd = GNOME_DIALOG (cw->dialog);
gtk_object_set_data (GTK_OBJECT (cw->dialog), "dialog_info", cw);
/* default to ok */
gnome_dialog_set_default (cwd, 0);
if (parent)
gnome_dialog_set_parent (cwd, GTK_WINDOW (parent));
/* Get entry points */
cw->id_entry = glade_xml_get_widget (xml, "id_entry");
cw->company_entry = glade_xml_get_widget (xml, "company_entry");
cw->name_entry = glade_xml_get_widget (xml, "name_entry");
cw->addr1_entry = glade_xml_get_widget (xml, "addr1_entry");
cw->addr2_entry = glade_xml_get_widget (xml, "addr2_entry");
cw->addr3_entry = glade_xml_get_widget (xml, "addr3_entry");
cw->addr4_entry = glade_xml_get_widget (xml, "addr4_entry");
cw->phone_entry = glade_xml_get_widget (xml, "phone_entry");
cw->fax_entry = glade_xml_get_widget (xml, "fax_entry");
cw->email_entry = glade_xml_get_widget (xml, "email_entry");
cw->shipname_entry = glade_xml_get_widget (xml, "shipname_entry");
cw->shipaddr1_entry = glade_xml_get_widget (xml, "shipaddr1_entry");
cw->shipaddr2_entry = glade_xml_get_widget (xml, "shipaddr2_entry");
cw->shipaddr3_entry = glade_xml_get_widget (xml, "shipaddr3_entry");
cw->shipaddr4_entry = glade_xml_get_widget (xml, "shipaddr4_entry");
cw->shipphone_entry = glade_xml_get_widget (xml, "shipphone_entry");
cw->shipfax_entry = glade_xml_get_widget (xml, "shipfax_entry");
cw->shipemail_entry = glade_xml_get_widget (xml, "shipemail_entry");
cw->active_check = glade_xml_get_widget (xml, "active_check");
cw->taxincluded_check = glade_xml_get_widget (xml, "tax_included_check");
cw->notes_text = glade_xml_get_widget (xml, "notes_text");
/* TERMS: Integer Value */
edit = gnc_amount_edit_new();
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
print_info = gnc_integral_print_info ();
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 1);
cw->terms_amount = edit;
gtk_widget_show (edit);
hbox = glade_xml_get_widget (xml, "terms_box");
gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
/* DISCOUNT: Percentage Value */
edit = gnc_amount_edit_new();
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
print_info.max_decimal_places = 5;
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 100000);
cw->discount_amount = edit;
gtk_widget_show (edit);
hbox = glade_xml_get_widget (xml, "discount_box");
gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
/* CREDIT: Monetary Value */
edit = gnc_amount_edit_new();
commodity = gnc_default_currency ();
print_info = gnc_commodity_print_info (commodity, FALSE);
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit),
gnc_commodity_get_fraction (commodity));
cw->credit_amount = edit;
gtk_widget_show (edit);
hbox = glade_xml_get_widget (xml, "credit_box");
gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
/* Setup Dialog for Editing */
gnome_dialog_set_default (cwd, 0);
/* Attach <Enter> to default button */
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->id_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->company_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->name_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->addr1_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->addr2_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->addr3_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->addr4_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->phone_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->fax_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->email_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->shipname_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->shipaddr1_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->shipaddr2_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->shipaddr3_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->shipaddr4_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->shipphone_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->shipfax_entry));
gnome_dialog_editable_enters (cwd, GTK_EDITABLE (cw->shipemail_entry));
/* Set focus to company name */
gtk_widget_grab_focus (cw->company_entry);
/* Setup signals */
gnome_dialog_button_connect
(cwd, 0, GTK_SIGNAL_FUNC(gnc_customer_window_ok_cb), cw);
gnome_dialog_button_connect
(cwd, 1, GTK_SIGNAL_FUNC(gnc_customer_window_cancel_cb), cw);
gnome_dialog_button_connect
(cwd, 2, GTK_SIGNAL_FUNC(gnc_customer_window_help_cb), cw);
gtk_signal_connect (GTK_OBJECT (cw->dialog), "destroy",
GTK_SIGNAL_FUNC(gnc_customer_window_destroy_cb), cw);
gtk_signal_connect(GTK_OBJECT (cw->id_entry), "changed",
GTK_SIGNAL_FUNC(gnc_customer_name_changed_cb), cw);
gtk_signal_connect(GTK_OBJECT (cw->company_entry), "changed",
GTK_SIGNAL_FUNC(gnc_customer_name_changed_cb), cw);
/* Setup initial values */
if (cust != NULL) {
GncAddress *addr, *shipaddr;
const char *string;
gint pos = 0;
cw->dialog_type = EDIT_CUSTOMER;
cw->customer_guid = *gncCustomerGetGUID (cust);
addr = gncCustomerGetAddr (cust);
shipaddr = gncCustomerGetShipAddr (cust);
gtk_entry_set_text (GTK_ENTRY (cw->id_entry), gncCustomerGetID (cust));
gtk_entry_set_editable (GTK_ENTRY (cw->id_entry), FALSE);
gtk_entry_set_text (GTK_ENTRY (cw->company_entry), gncCustomerGetName (cust));
/* Setup Address */
gtk_entry_set_text (GTK_ENTRY (cw->name_entry), gncAddressGetName (addr));
gtk_entry_set_text (GTK_ENTRY (cw->addr1_entry), gncAddressGetAddr1 (addr));
gtk_entry_set_text (GTK_ENTRY (cw->addr2_entry), gncAddressGetAddr2 (addr));
gtk_entry_set_text (GTK_ENTRY (cw->addr3_entry), gncAddressGetAddr3 (addr));
gtk_entry_set_text (GTK_ENTRY (cw->addr4_entry), gncAddressGetAddr4 (addr));
gtk_entry_set_text (GTK_ENTRY (cw->phone_entry), gncAddressGetPhone (addr));
gtk_entry_set_text (GTK_ENTRY (cw->fax_entry), gncAddressGetFax (addr));
gtk_entry_set_text (GTK_ENTRY (cw->email_entry), gncAddressGetEmail (addr));
/* Setup Ship-to Address */
gtk_entry_set_text (GTK_ENTRY (cw->shipname_entry), gncAddressGetName (shipaddr));
gtk_entry_set_text (GTK_ENTRY (cw->shipaddr1_entry), gncAddressGetAddr1 (shipaddr));
gtk_entry_set_text (GTK_ENTRY (cw->shipaddr2_entry), gncAddressGetAddr2 (shipaddr));
gtk_entry_set_text (GTK_ENTRY (cw->shipaddr3_entry), gncAddressGetAddr3 (shipaddr));
gtk_entry_set_text (GTK_ENTRY (cw->shipaddr4_entry), gncAddressGetAddr4 (shipaddr));
gtk_entry_set_text (GTK_ENTRY (cw->shipphone_entry), gncAddressGetPhone (shipaddr));
gtk_entry_set_text (GTK_ENTRY (cw->shipfax_entry), gncAddressGetFax (shipaddr));
gtk_entry_set_text (GTK_ENTRY (cw->shipemail_entry), gncAddressGetEmail (shipaddr));
/* Set toggle buttons */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->active_check),
gncCustomerGetActive (cust));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->taxincluded_check),
gncCustomerGetTaxIncluded (cust));
string = gncCustomerGetNotes (cust);
gtk_editable_delete_text (GTK_EDITABLE (cw->notes_text), 0, -1);
gtk_editable_insert_text (GTK_EDITABLE (cw->notes_text), string,
strlen(string), &pos);
cw->component_id =
gnc_register_gui_component (DIALOG_EDIT_CUSTOMER_CM_CLASS,
gnc_customer_window_refresh_handler,
gnc_customer_window_close_handler,
cw);
} else {
gnc_numeric num;
cust = gncCustomerCreate (bus);
cw->customer_guid = *gncCustomerGetGUID (cust);
cw->dialog_type = NEW_CUSTOMER;
gtk_entry_set_text (GTK_ENTRY (cw->id_entry),
g_strdup_printf ("%.6d", gncCustomerNextID(bus)));
cw->component_id =
gnc_register_gui_component (DIALOG_NEW_CUSTOMER_CM_CLASS,
gnc_customer_window_refresh_handler,
gnc_customer_window_close_handler,
cw);
}
/* I know that cust exists here -- either passed in or just created */
{
gnc_numeric terms;
/* Set the Terms, Discount, and Credit amounts */
terms = gnc_numeric_create (gncCustomerGetTerms (cust), 1);
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->terms_amount), terms);
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->discount_amount),
gncCustomerGetDiscount (cust));
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->credit_amount),
gncCustomerGetCredit (cust));
}
gnc_gui_component_watch_entity_type (cw->component_id,
GNC_ID_NONE,
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
gtk_widget_show_all (cw->dialog);
return cw;
}
GncCustomer *
gnc_customer_new (GtkWidget *parent, GncBusiness *bus)
{
CustomerWindow *cw;
GncCustomer *created_customer = NULL;
/* Make sure required options exist */
if (!bus) return NULL;
cw = gnc_customer_new_window (parent, bus, NULL);
gtk_signal_connect (GTK_OBJECT (cw->dialog), "close",
GTK_SIGNAL_FUNC (gnc_customer_on_close_cb),
&created_customer);
gtk_window_set_modal (GTK_WINDOW (cw->dialog), TRUE);
gtk_main ();
return created_customer;
}
void
gnc_customer_edit (GtkWidget *parent, GncCustomer *cust)
{
CustomerWindow *cw;
if (!cust) return;
cw = gnc_customer_new_window (parent, gncCustomerGetBusiness(cust), cust);
gtk_signal_connect (GTK_OBJECT (cw->dialog), "close",
GTK_SIGNAL_FUNC (gnc_customer_on_close_cb),
NULL);
gtk_window_set_modal (GTK_WINDOW (cw->dialog), TRUE);
gtk_main ();
return;
}
/* Functions for widgets for customer selection */
static gpointer gnc_customer_edit_new_cb (gpointer arg, GtkWidget *toplevel)
{
struct _customer_select_window *sw = arg;
if (!arg) return NULL;
return gnc_customer_new (toplevel, sw->business);
}
static void gnc_customer_edit_edit_cb (gpointer arg, gpointer obj, GtkWidget *toplevel)
{
GncCustomer *cust = obj;
struct _customer_select_window *sw = arg;
if (!arg || !obj) return;
gnc_customer_edit (toplevel, cust);
}
gpointer gnc_customer_edit_new_select (gpointer bus, gpointer cust,
GtkWidget *toplevel)
{
GncBusiness *business = bus;
struct _customer_select_window sw;
g_return_val_if_fail (bus != NULL, NULL);
sw.business = business;
return
gnc_ui_business_chooser_new (toplevel, cust,
business, GNC_CUSTOMER_MODULE_NAME,
gnc_customer_edit_new_cb,
gnc_customer_edit_edit_cb, &sw);
}
gpointer gnc_customer_edit_new_edit (gpointer bus, gpointer cust,
GtkWidget *toplevel)
{
GncBusiness *busiess = bus;
GncCustomer *customer = cust;
g_return_val_if_fail (cust != NULL, NULL);
gnc_customer_edit (toplevel, cust);
return cust;
}

View File

@ -0,0 +1,27 @@
/*
* dialog-customer.h -- Dialog(s) for Customer search and entry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_DIALOG_CUSTOMER_H_
#define GNC_DIALOG_CUSTOMER_H_
/* Functions to create and edit customers */
GncCustomer * gnc_customer_new (GtkWidget *parent, GncBusiness *bus);
void gnc_customer_edit (GtkWidget *parent, GncCustomer *cust);
/* Callbacks to select a customer that match the necessary functions
* for use with the gnc_general_select widget.
*
* new_select provides a selection and the ability to create and edit
* customers.
* new_edit provides only the ability to edit the current selection
*/
gpointer gnc_customer_edit_new_select (gpointer bus, gpointer c,
GtkWidget *toplevel);
gpointer gnc_customer_edit_new_edit (gpointer bus, gpointer cust,
GtkWidget *toplevel);
#endif /* GNC_DIALOG_CUSTOMER_H_ */

View File

@ -0,0 +1,590 @@
/*
* dialog-employee.c -- Dialog for Employee entry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <gnome.h>
#include "dialog-utils.h"
#include "global-options.h"
#include "gnc-amount-edit.h"
#include "gnc-component-manager.h"
#include "gnc-ui.h"
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
#include "gnc-engine-util.h"
#include "window-help.h"
#include "gncBusiness.h"
#include "gncAddress.h"
#include "gncEmployee.h"
#include "gncEmployeeP.h"
#include "dialog-employee.h"
#include "business-chooser.h"
#define DIALOG_NEW_EMPLOYEE_CM_CLASS "dialog-new-employee"
#define DIALOG_EDIT_EMPLOYEE_CM_CLASS "dialog-edit-employee"
typedef enum
{
NEW_EMPLOYEE,
EDIT_EMPLOYEE
} EmployeeDialogType;
struct _employee_select_window {
GncBusiness * business;
};
typedef struct _employee_window {
GtkWidget * dialog;
GtkWidget * id_entry;
GtkWidget * username_entry;
GtkWidget * name_entry;
GtkWidget * addr1_entry;
GtkWidget * addr2_entry;
GtkWidget * addr3_entry;
GtkWidget * addr4_entry;
GtkWidget * phone_entry;
GtkWidget * fax_entry;
GtkWidget * email_entry;
GtkWidget * language_entry;
GtkWidget * workday_amount;
GtkWidget * rate_amount;
GtkWidget * active_check;
/* ACL? */
EmployeeDialogType dialog_type;
GUID employee_guid;
gint component_id;
GncBusiness * business;
GncEmployee * created_employee;
} EmployeeWindow;
static GncEmployee *
ew_get_employee (EmployeeWindow *ew)
{
if (!ew)
return NULL;
return gncBusinessLookupGUID (ew->business, GNC_EMPLOYEE_MODULE_NAME,
&ew->employee_guid);
}
static void gnc_ui_to_employee (EmployeeWindow *ew, GncEmployee *employee)
{
GncAddress *addr;
gnc_numeric num;
addr = gncEmployeeGetAddr (employee);
gnc_suspend_gui_refresh ();
gncEmployeeSetID (employee, gtk_editable_get_chars
(GTK_EDITABLE (ew->id_entry), 0, -1));
gncEmployeeSetUsername (employee, gtk_editable_get_chars
(GTK_EDITABLE (ew->username_entry), 0, -1));
gncAddressSetName (addr, gtk_editable_get_chars
(GTK_EDITABLE (ew->name_entry), 0, -1));
gncAddressSetAddr1 (addr, gtk_editable_get_chars
(GTK_EDITABLE (ew->addr1_entry), 0, -1));
gncAddressSetAddr2 (addr, gtk_editable_get_chars
(GTK_EDITABLE (ew->addr2_entry), 0, -1));
gncAddressSetAddr3 (addr, gtk_editable_get_chars
(GTK_EDITABLE (ew->addr3_entry), 0, -1));
gncAddressSetAddr4 (addr, gtk_editable_get_chars
(GTK_EDITABLE (ew->addr4_entry), 0, -1));
gncAddressSetPhone (addr, gtk_editable_get_chars
(GTK_EDITABLE (ew->phone_entry), 0, -1));
gncAddressSetFax (addr, gtk_editable_get_chars
(GTK_EDITABLE (ew->fax_entry), 0, -1));
gncAddressSetEmail (addr, gtk_editable_get_chars
(GTK_EDITABLE (ew->email_entry), 0, -1));
gncEmployeeSetActive (employee, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (ew->active_check)));
gncEmployeeSetLanguage (employee, gtk_editable_get_chars
(GTK_EDITABLE (ew->language_entry), 0, -1));
/* Parse and set the workday and rate amounts */
gncEmployeeSetWorkday (employee, gnc_amount_edit_get_amount
(GNC_AMOUNT_EDIT (ew->workday_amount)));
gncEmployeeSetRate (employee, gnc_amount_edit_get_amount
(GNC_AMOUNT_EDIT (ew->rate_amount)));
gncEmployeeCommitEdit (employee);
gnc_resume_gui_refresh ();
}
static gboolean check_edit_amount (GtkWidget *dialog, GtkWidget *amount,
gnc_numeric *min, gnc_numeric *max,
const char * error_message)
{
if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (amount))) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
/* We've got a valid-looking number; check mix/max */
if (min || max) {
gnc_numeric val = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (amount));
if ((min && gnc_numeric_compare (*min, val) > 0) ||
(max && gnc_numeric_compare (val, *max) > 0)) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
}
return FALSE;
}
static gboolean check_entry_nonempty (GtkWidget *dialog, GtkWidget *entry,
const char * error_message)
{
const char *res = gtk_entry_get_text (GTK_ENTRY (entry));
if (safe_strcmp (res, "") == 0) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
return FALSE;
}
static void
gnc_employee_window_ok_cb (GtkWidget *widget, gpointer data)
{
EmployeeWindow *ew = data;
char *res;
GncEmployee *employee;
gnc_numeric min, max;
/* Check for valid id */
if (check_entry_nonempty (ew->dialog, ew->id_entry,
_("The Employee must be given an ID.")))
return;
/* Check for valid username */
if (check_entry_nonempty (ew->dialog, ew->username_entry,
_("You must enter a username.")))
return;
/* Check for valid username */
if (check_entry_nonempty (ew->dialog, ew->name_entry,
_("You must enter the employee's name.")))
return;
/* Make sure we have an address */
if (check_entry_nonempty (ew->dialog, ew->addr1_entry, NULL) &&
check_entry_nonempty (ew->dialog, ew->addr2_entry, NULL) &&
check_entry_nonempty (ew->dialog, ew->addr3_entry, NULL) &&
check_entry_nonempty (ew->dialog, ew->addr4_entry, NULL)) {
const char *msg = _("You must enter an address.");
gnc_error_dialog_parented (GTK_WINDOW (ew->dialog), msg);
return;
}
/* Now save it off */
{
GncEmployee *employee = ew_get_employee (ew);
if (employee) {
gnc_ui_to_employee (ew, employee);
}
ew->created_employee = employee;
ew->employee_guid = *xaccGUIDNULL ();
}
gnc_close_gui_component (ew->component_id);
}
static void
gnc_employee_window_cancel_cb (GtkWidget *widget, gpointer data)
{
EmployeeWindow *ew = data;
gnc_close_gui_component (ew->component_id);
}
static void
gnc_employee_window_help_cb (GtkWidget *widget, gpointer data)
{
EmployeeWindow *ew = data;
char *help_file = ""; /* xxx */
helpWindow(NULL, NULL, help_file);
}
static void
gnc_employee_window_destroy_cb (GtkWidget *widget, gpointer data)
{
EmployeeWindow *ew = data;
GncEmployee *employee = ew_get_employee (ew);
gnc_suspend_gui_refresh ();
if (ew->dialog_type == NEW_EMPLOYEE && employee != NULL) {
gncEmployeeDestroy (employee);
ew->employee_guid = *xaccGUIDNULL ();
}
gnc_unregister_gui_component (ew->component_id);
gnc_resume_gui_refresh ();
g_free (ew);
}
static void
gnc_employee_name_changed_cb (GtkWidget *widget, gpointer data)
{
EmployeeWindow *ew = data;
char *name, *id, *fullname, *title;
if (!ew)
return;
name = gtk_entry_get_text (GTK_ENTRY (ew->name_entry));
if (!name || *name == '\0')
name = _("<No name>");
id = gtk_entry_get_text (GTK_ENTRY (ew->id_entry));
fullname = g_strconcat (name, " (", id, ")", NULL);
if (ew->dialog_type == EDIT_EMPLOYEE)
title = g_strconcat (_("Edit Employee"), " - ", fullname, NULL);
else
title = g_strconcat (_("New Employee"), " - ", fullname, NULL);
gtk_window_set_title (GTK_WINDOW (ew->dialog), title);
g_free (fullname);
g_free (title);
}
static int
gnc_employee_on_close_cb (GnomeDialog *dialog, gpointer data)
{
EmployeeWindow *ew;
GncEmployee **created_employee = data;
if (data) {
ew = gtk_object_get_data (GTK_OBJECT (dialog), "dialog_info");
*created_employee = ew->created_employee;
}
gtk_main_quit ();
return FALSE;
}
static void
gnc_employee_window_close_handler (gpointer user_data)
{
EmployeeWindow *ew = user_data;
gnome_dialog_close (GNOME_DIALOG (ew->dialog));
}
static void
gnc_employee_window_refresh_handler (GHashTable *changes, gpointer user_data)
{
EmployeeWindow *ew = user_data;
const EventInfo *info;
GncEmployee *employee = ew_get_employee (ew);
/* If there isn't a employee behind us, close down */
if (!employee) {
gnc_close_gui_component (ew->component_id);
return;
}
/* Next, close if this is a destroy event */
if (changes) {
info = gnc_gui_get_entity_events (changes, &ew->employee_guid);
if (info && (info->event_mask & GNC_EVENT_DESTROY)) {
gnc_close_gui_component (ew->component_id);
return;
}
}
}
static EmployeeWindow *
gnc_employee_new_window (GtkWidget *parent, GncBusiness *bus,
GncEmployee *employee)
{
EmployeeWindow *ew;
GladeXML *xml;
GtkWidget *hbox, *edit;
GnomeDialog *ewd;
gnc_commodity *commodity;
GNCPrintAmountInfo print_info;
ew = g_new0 (EmployeeWindow, 1);
ew->business = bus;
/* Find the dialog */
xml = gnc_glade_xml_new ("employee.glade", "Employee Dialog");
ew->dialog = glade_xml_get_widget (xml, "Employee Dialog");
ewd = GNOME_DIALOG (ew->dialog);
gtk_object_set_data (GTK_OBJECT (ew->dialog), "dialog_info", ew);
/* default to ok */
gnome_dialog_set_default (ewd, 0);
if (parent)
gnome_dialog_set_parent (ewd, GTK_WINDOW (parent));
/* Get entry points */
ew->id_entry = glade_xml_get_widget (xml, "id_entry");
ew->username_entry = glade_xml_get_widget (xml, "username_entry");
ew->name_entry = glade_xml_get_widget (xml, "name_entry");
ew->addr1_entry = glade_xml_get_widget (xml, "addr1_entry");
ew->addr2_entry = glade_xml_get_widget (xml, "addr2_entry");
ew->addr3_entry = glade_xml_get_widget (xml, "addr3_entry");
ew->addr4_entry = glade_xml_get_widget (xml, "addr4_entry");
ew->phone_entry = glade_xml_get_widget (xml, "phone_entry");
ew->fax_entry = glade_xml_get_widget (xml, "fax_entry");
ew->email_entry = glade_xml_get_widget (xml, "email_entry");
ew->language_entry = glade_xml_get_widget (xml, "language_entry");
ew->active_check = glade_xml_get_widget (xml, "active_check");
/* WORKDAY: Value */
edit = gnc_amount_edit_new();
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
print_info = gnc_integral_print_info ();
print_info.max_decimal_places = 5;
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 100000);
ew->workday_amount = edit;
gtk_widget_show (edit);
hbox = glade_xml_get_widget (xml, "hours_hbox");
gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
/* RATE: Monetary Value */
edit = gnc_amount_edit_new();
commodity = gnc_default_currency ();
print_info = gnc_commodity_print_info (commodity, FALSE);
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit),
gnc_commodity_get_fraction (commodity));
ew->rate_amount = edit;
gtk_widget_show (edit);
hbox = glade_xml_get_widget (xml, "rate_hbox");
gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
/* Setup Dialog for Editing */
gnome_dialog_set_default (ewd, 0);
/* Attach <Enter> to default button */
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->id_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->username_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->name_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->addr1_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->addr2_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->addr3_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->addr4_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->phone_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->fax_entry));
gnome_dialog_editable_enters (ewd, GTK_EDITABLE (ew->email_entry));
/* Set focus to username */
gtk_widget_grab_focus (ew->username_entry);
/* Setup signals */
gnome_dialog_button_connect
(ewd, 0, GTK_SIGNAL_FUNC(gnc_employee_window_ok_cb), ew);
gnome_dialog_button_connect
(ewd, 1, GTK_SIGNAL_FUNC(gnc_employee_window_cancel_cb), ew);
gnome_dialog_button_connect
(ewd, 2, GTK_SIGNAL_FUNC(gnc_employee_window_help_cb), ew);
gtk_signal_connect (GTK_OBJECT (ew->dialog), "destroy",
GTK_SIGNAL_FUNC(gnc_employee_window_destroy_cb), ew);
gtk_signal_connect(GTK_OBJECT (ew->id_entry), "changed",
GTK_SIGNAL_FUNC(gnc_employee_name_changed_cb), ew);
gtk_signal_connect(GTK_OBJECT (ew->username_entry), "changed",
GTK_SIGNAL_FUNC(gnc_employee_name_changed_cb), ew);
/* Setup initial values */
if (employee != NULL) {
GncAddress *addr;
const char *string;
gint pos = 0;
ew->dialog_type = EDIT_EMPLOYEE;
ew->employee_guid = *gncEmployeeGetGUID (employee);
addr = gncEmployeeGetAddr (employee);
gtk_entry_set_text (GTK_ENTRY (ew->id_entry), gncEmployeeGetID (employee));
gtk_entry_set_editable (GTK_ENTRY (ew->id_entry), FALSE);
gtk_entry_set_text (GTK_ENTRY (ew->username_entry), gncEmployeeGetUsername (employee));
/* Setup Address */
gtk_entry_set_text (GTK_ENTRY (ew->name_entry), gncAddressGetName (addr));
gtk_entry_set_text (GTK_ENTRY (ew->addr1_entry), gncAddressGetAddr1 (addr));
gtk_entry_set_text (GTK_ENTRY (ew->addr2_entry), gncAddressGetAddr2 (addr));
gtk_entry_set_text (GTK_ENTRY (ew->addr3_entry), gncAddressGetAddr3 (addr));
gtk_entry_set_text (GTK_ENTRY (ew->addr4_entry), gncAddressGetAddr4 (addr));
gtk_entry_set_text (GTK_ENTRY (ew->phone_entry), gncAddressGetPhone (addr));
gtk_entry_set_text (GTK_ENTRY (ew->fax_entry), gncAddressGetFax (addr));
gtk_entry_set_text (GTK_ENTRY (ew->email_entry), gncAddressGetEmail (addr));
gtk_entry_set_text (GTK_ENTRY (ew->language_entry),
gncEmployeeGetLanguage (employee));
/* Set toggle buttons */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->active_check),
gncEmployeeGetActive (employee));
ew->component_id =
gnc_register_gui_component (DIALOG_EDIT_EMPLOYEE_CM_CLASS,
gnc_employee_window_refresh_handler,
gnc_employee_window_close_handler,
ew);
} else {
gnc_numeric num;
employee = gncEmployeeCreate (bus);
ew->employee_guid = *gncEmployeeGetGUID (employee);
ew->dialog_type = NEW_EMPLOYEE;
gtk_entry_set_text (GTK_ENTRY (ew->id_entry),
g_strdup_printf ("%.6d", gncEmployeeNextID(bus)));
ew->component_id =
gnc_register_gui_component (DIALOG_NEW_EMPLOYEE_CM_CLASS,
gnc_employee_window_refresh_handler,
gnc_employee_window_close_handler,
ew);
}
/* I know that employee exists here -- either passed in or just created */
/* Set the workday and rate values */
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (ew->workday_amount),
gncEmployeeGetWorkday (employee));
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (ew->rate_amount),
gncEmployeeGetRate (employee));
/* XXX: Set the ACL */
gnc_gui_component_watch_entity_type (ew->component_id,
GNC_ID_NONE,
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
gtk_widget_show_all (ew->dialog);
return ew;
}
GncEmployee *
gnc_employee_new (GtkWidget *parent, GncBusiness *bus)
{
EmployeeWindow *ew;
GncEmployee *created_employee = NULL;
/* Make sure required options exist */
if (!bus) return NULL;
ew = gnc_employee_new_window (parent, bus, NULL);
gtk_signal_connect (GTK_OBJECT (ew->dialog), "close",
GTK_SIGNAL_FUNC (gnc_employee_on_close_cb),
&created_employee);
gtk_window_set_modal (GTK_WINDOW (ew->dialog), TRUE);
gtk_main ();
return created_employee;
}
void
gnc_employee_edit (GtkWidget *parent, GncEmployee *employee)
{
EmployeeWindow *ew;
if (!employee) return;
ew = gnc_employee_new_window (parent, gncEmployeeGetBusiness(employee), employee);
gtk_signal_connect (GTK_OBJECT (ew->dialog), "close",
GTK_SIGNAL_FUNC (gnc_employee_on_close_cb),
NULL);
gtk_window_set_modal (GTK_WINDOW (ew->dialog), TRUE);
gtk_main ();
return;
}
/* Functions for widgets for employee selection */
static gpointer gnc_employee_edit_new_cb (gpointer arg, GtkWidget *toplevel)
{
struct _employee_select_window *sw = arg;
if (!arg) return NULL;
return gnc_employee_new (toplevel, sw->business);
}
static void gnc_employee_edit_edit_cb (gpointer arg, gpointer obj, GtkWidget *toplevel)
{
GncEmployee *employee = obj;
struct _employee_select_window *sw = arg;
if (!arg || !obj) return;
gnc_employee_edit (toplevel, employee);
}
gpointer gnc_employee_edit_new_select (gpointer bus, gpointer employee,
GtkWidget *toplevel)
{
GncBusiness *business = bus;
struct _employee_select_window sw;
g_return_val_if_fail (bus != NULL, NULL);
sw.business = business;
return
gnc_ui_business_chooser_new (toplevel, employee,
business, GNC_EMPLOYEE_MODULE_NAME,
gnc_employee_edit_new_cb,
gnc_employee_edit_edit_cb, &sw);
}
gpointer gnc_employee_edit_new_edit (gpointer bus, gpointer v,
GtkWidget *toplevel)
{
GncBusiness *busiess = bus;
GncEmployee *employee = v;
g_return_val_if_fail (employee != NULL, NULL);
gnc_employee_edit (toplevel, employee);
return employee;
}

View File

@ -0,0 +1,27 @@
/*
* dialog-employee.h -- Dialog(s) for Employee search and entry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_DIALOG_EMPLOYEE_H_
#define GNC_DIALOG_EMPLOYEE_H_
/* Functions to create and edit employees */
GncEmployee * gnc_employee_new (GtkWidget *parent, GncBusiness *bus);
void gnc_employee_edit (GtkWidget *parent, GncEmployee *employee);
/* Callbacks to select a employee that match the necessary functions
* for use with the gnc_general_select widget.
*
* new_select provides a selection and the ability to create and edit
* employees.
* new_edit provides only the ability to edit the current selection
*/
gpointer gnc_employee_edit_new_select (gpointer bus, gpointer c,
GtkWidget *toplevel);
gpointer gnc_employee_edit_new_edit (gpointer bus, gpointer employee,
GtkWidget *toplevel);
#endif /* GNC_DIALOG_EMPLOYEE_H_ */

View File

@ -0,0 +1,344 @@
/*
* dialog-job-select.c -- Job Selection Dialog for GNC Business Objects
*
* Written By: Derek Atkins <warlord@MIT.EDU>
* Copyright (C) 2001
*/
#include "config.h"
#include <gnome.h>
#include "dialog-utils.h"
#include "gnc-ui.h"
#include "gnc-gui-query.h"
#include "gncBusiness.h"
#include "gncCustomer.h"
#include "gncJob.h"
#include "dialog-job-select.h"
#include "dialog-job.h"
struct select_job_window {
GtkWidget * dialog;
GtkWidget * customer_combo;
GtkWidget * customer_entry;
GtkWidget * job_combo;
GtkWidget * job_entry;
GtkWidget * showcust_check;
GtkWidget * showjobs_check;
GncBusiness * business;
GncCustomer * customer;
GncJob * job;
const GncBusinessObject *job_type, *cust_type;
};
static void
update_job_select_picker (struct select_job_window *w)
{
GList *objs = NULL, *iterator;
GtkWidget *li;
GncJob *saved_job;
gboolean show_all = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(w->showjobs_check));
/* Clear out the existing choices */
gtk_list_clear_items (GTK_LIST (GTK_COMBO (w->job_combo)->list), 0, -1);
/* Get the list of objects */
if (w->customer == NULL) {
w->job = NULL;
} else {
/* Save the current job */
saved_job = w->job;
objs = gncCustomerGetJoblist (w->customer, show_all);
/* Build a list of strings (objs is pre-sorted, so keep the order!) */
for (iterator = objs; iterator; iterator = iterator->next) {
const gchar *label = (*(w->job_type->printable))(iterator->data);
li = gtk_list_item_new_with_label (label);
gtk_object_set_data (GTK_OBJECT (li), "item-list-pointer", iterator->data);
gtk_widget_show (li);
gtk_container_add (GTK_CONTAINER (GTK_COMBO (w->job_combo)->list), li);
}
/* And revert */
w->job = saved_job;
}
/* No job list. Eit */
if (!objs)
w->job = NULL;
else if (g_list_index (objs, w->job) == -1) {
/* job doesn't exist anymore!?! Choose something reasonable */
w->job = objs->data;
}
/* And set the text label */
{
const char * label;
if (w->job)
label = (*(w->job_type->printable))(w->job);
else
label = "";
gtk_entry_set_text (GTK_ENTRY (w->job_entry), label);
}
g_list_free (objs);
}
static void
update_customer_select_picker (struct select_job_window *w)
{
GList *custs, *iterator;
GtkWidget *li;
GncCustomer * saved_cust;
gboolean show_all = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(w->showcust_check));
/* Clear out the existing choices */
gtk_list_clear_items (GTK_LIST (GTK_COMBO (w->customer_combo)->list), 0, -1);
/* Save the existing selection */
saved_cust = w->customer;
/* Get the list of objects */
custs = (*(w->cust_type->get_list))(w->business, show_all);
/* Build a list of strings (objs is pre-sorted, so keep the order!) */
for (iterator = custs; iterator; iterator = iterator->next) {
const gchar *label = (*(w->cust_type->printable))(iterator->data);
li = gtk_list_item_new_with_label (label);
gtk_object_set_data (GTK_OBJECT (li), "item-list-pointer", iterator->data);
gtk_widget_show (li);
gtk_container_add (GTK_CONTAINER (GTK_COMBO (w->customer_combo)->list), li);
}
/* Revert the saved customer */
w->customer = saved_cust;
if (! custs) {
/* no customers -- update the job picker (it will clear itself) */
w->customer = NULL;
update_job_select_picker (w);
} else if (g_list_index (custs, w->customer) == -1) {
/* customer doesn't exist anymore!?! Clear out the job, too */
w->customer = custs->data;
update_job_select_picker (w);
}
/* And now set the current-selected item */
{
const char * label;
if (w->customer)
label = (*(w->cust_type->printable))(w->customer);
else
label = "";
gtk_entry_set_text (GTK_ENTRY (w->customer_entry), label);
}
g_list_free (custs);
}
static void
select_job_customer_changed_cb(GtkList *list, GtkWidget *li,
gpointer user_data)
{
struct select_job_window * w = user_data;
GList *node;
if (!li)
return;
w->customer = gtk_object_get_data (GTK_OBJECT (li), "item-list-pointer");
w->job = NULL;
update_job_select_picker (w);
}
static void
select_job_job_changed_cb(GtkList *list, GtkWidget *li, gpointer user_data)
{
struct select_job_window * w = user_data;
GList *node;
if (!li)
return;
w->job = gtk_object_get_data (GTK_OBJECT (li), "item-list-pointer");
}
static void
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));
} else {
gnc_warning_dialog(_("You must select a job.\n"
"To create a new one, click \"New\""));
}
}
static void
gnc_ui_select_job_new_cb(GtkButton * button, gpointer user_data)
{
struct select_job_window * w = user_data;
GncJob * new_selection = gnc_job_new (w->dialog, w->business, w->customer);
if (new_selection) {
w->customer = gncJobGetCustomer (new_selection);
update_customer_select_picker (w);
w->job = new_selection;
update_job_select_picker (w);
}
}
static void
gnc_ui_select_job_edit_cb(GtkButton * button, gpointer user_data)
{
struct select_job_window * w = user_data;
if (w->job == NULL)
return;
gnc_job_edit (w->dialog, w->job);
w->customer = gncJobGetCustomer (w->job);
update_customer_select_picker (w);
update_job_select_picker (w);
}
static void
gnc_ui_select_job_cancel_cb(GtkButton * button, gpointer user_data)
{
struct select_job_window * w = user_data;
if (w)
gnome_dialog_close(GNOME_DIALOG (w->dialog));
}
static void
gnc_ui_select_job_showcust_toggled_cb(GtkCheckButton * entry,
gpointer user_data)
{
struct select_job_window * w = user_data;
update_customer_select_picker (w);
}
static void
gnc_ui_select_job_showjobs_toggled_cb(GtkCheckButton * entry,
gpointer user_data)
{
struct select_job_window * w = user_data;
update_job_select_picker (w);
}
static gint
select_job_close (GnomeDialog *dialog, gpointer data)
{
gtk_main_quit ();
return FALSE;
}
GncJob *
gnc_ui_select_job_new (GtkWidget * parent, GncBusiness *business,
GncCustomer *cust, GncJob *job)
{
struct select_job_window * win =
g_new0(struct select_job_window, 1);
GladeXML *xml;
GtkWidget *choice_name_label;
GncJob *retval;
g_return_val_if_fail (business != NULL, NULL);
win->business = business;
win->cust_type = gncBusinessLookup (GNC_CUSTOMER_MODULE_NAME);
win->job_type = gncBusinessLookup (GNC_JOB_MODULE_NAME);
xml = gnc_glade_xml_new ("job.glade",
"Job Selector Dialog");
/* Grab the widgets */
win->dialog = glade_xml_get_widget (xml, "Job Selector Dialog");
win->customer_combo = glade_xml_get_widget (xml, "customer_combo");
win->customer_entry = glade_xml_get_widget (xml, "customer_entry");
win->showcust_check = glade_xml_get_widget (xml, "showcust_check");
win->job_combo = glade_xml_get_widget (xml, "job_combo");
win->job_entry = glade_xml_get_widget (xml, "job_entry");
win->showjobs_check = glade_xml_get_widget (xml, "showjobs_check");
if(parent) {
gnome_dialog_set_parent(GNOME_DIALOG(win->dialog), GTK_WINDOW(parent));
}
/* Setup the signals */
glade_xml_signal_connect_data
(xml, "gnc_ui_select_job_ok_cb",
GTK_SIGNAL_FUNC (gnc_ui_select_job_ok_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_select_job_new_cb",
GTK_SIGNAL_FUNC (gnc_ui_select_job_new_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_select_job_edit_cb",
GTK_SIGNAL_FUNC (gnc_ui_select_job_edit_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_select_job_cancel_cb",
GTK_SIGNAL_FUNC (gnc_ui_select_job_cancel_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_select_job_showjobs_toggled_cb",
GTK_SIGNAL_FUNC (gnc_ui_select_job_showjobs_toggled_cb), win);
glade_xml_signal_connect_data
(xml, "gnc_ui_select_job_showcust_toggled_cb",
GTK_SIGNAL_FUNC (gnc_ui_select_job_showcust_toggled_cb), win);
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (win->customer_combo)->list),
"select-child",
GTK_SIGNAL_FUNC(select_job_customer_changed_cb), win);
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (win->job_combo)->list),
"select-child",
GTK_SIGNAL_FUNC(select_job_job_changed_cb), win);
gtk_signal_connect (GTK_OBJECT(win->dialog), "close",
GTK_SIGNAL_FUNC(select_job_close), win);
/* Setup the menu */
win->customer = cust;
update_customer_select_picker (win);
win->job = job;
update_job_select_picker (win);
/* Run the widget */
gtk_window_set_modal(GTK_WINDOW(win->dialog), TRUE);
gtk_widget_show (win->dialog);
gtk_main();
/* exit */
retval = win->job;
g_free(win);
return retval;
}

View File

@ -0,0 +1,18 @@
/*
* dialog-job-select.h -- Job Selection Dialog for GNC Business Objects
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_DIALOG_JOB_SELECT_H_
#define GNC_DIALOG_JOB_SELECT_H_
/* Create a dialog to select a job based upon potentially-existing
* customer and jobs. Allows creation of both jobs and customers.
*/
GncJob *
gnc_ui_select_job_new (GtkWidget * parent, GncBusiness *business,
GncCustomer *cust, GncJob *job);
#endif /* GNC_DIALOG_JOB_SELECT_H_ */

View File

@ -0,0 +1,461 @@
/*
* dialog-job.c -- Dialog for Job entry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <gnome.h>
#include "dialog-utils.h"
#include "gnc-component-manager.h"
#include "gnc-ui.h"
#include "gnc-gui-query.h"
#include "gnc-engine-util.h"
#include "window-help.h"
#include "gncBusiness.h"
#include "gncCustomer.h"
#include "gncJob.h"
#include "gncJobP.h"
#include "gnc-general-select.h"
#include "dialog-customer.h"
#include "business-chooser.h"
#include "dialog-job-select.h"
#define DIALOG_NEW_JOB_CM_CLASS "dialog-new-job"
#define DIALOG_EDIT_JOB_CM_CLASS "dialog-edit-job"
typedef enum
{
NEW_JOB,
EDIT_JOB
} JobDialogType;
struct _job_select_window {
GtkWidget * toplevel;
GncBusiness * business;
};
typedef struct _job_window {
GtkWidget * dialog;
GtkWidget * id_entry;
GtkWidget * cust_edit;
GtkWidget * name_entry;
GtkWidget * desc_entry;
GtkWidget * active_check;
JobDialogType dialog_type;
GUID job_guid;
gint component_id;
GncBusiness * business;
GncJob * created_job;
GNCGeneralSelectGetStringCB cust_print;
} JobWindow;
static GncJob *
jw_get_job (JobWindow *jw)
{
if (!jw)
return NULL;
return gncBusinessLookupGUID (jw->business, GNC_JOB_MODULE_NAME,
&jw->job_guid);
}
static void gnc_ui_to_job (JobWindow *jw, GncJob *job)
{
gnc_suspend_gui_refresh ();
gncJobSetID (job, gtk_editable_get_chars (GTK_EDITABLE (jw->id_entry),
0, -1));
gncJobSetName (job, gtk_editable_get_chars (GTK_EDITABLE (jw->name_entry),
0, -1));
gncJobSetDesc (job, gtk_editable_get_chars (GTK_EDITABLE (jw->desc_entry),
0, -1));
gncJobSetActive (job, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(jw->active_check)));
{
GncCustomer *old = gncJobGetCustomer (job);
GncCustomer *new = gnc_general_select_get_selected (GNC_GENERAL_SELECT
(jw->cust_edit));
if (old != new)
gncJobSetCustomer (job, new);
}
gncJobCommitEdit (job);
gnc_resume_gui_refresh ();
}
static void
gnc_job_window_ok_cb (GtkWidget *widget, gpointer data)
{
JobWindow *jw = data;
char *res;
GncCustomer *cust;
/* Check for valid id */
res = gtk_entry_get_text (GTK_ENTRY (jw->id_entry));
if (safe_strcmp (res, "") == 0) {
const char *message = _("The Job must be given an ID.");
gnc_error_dialog_parented(GTK_WINDOW(jw->dialog), message);
return;
}
/* Check for valid name */
res = gtk_entry_get_text (GTK_ENTRY (jw->name_entry));
if (safe_strcmp (res, "") == 0) {
const char *message = _("The Job must be given a name.");
gnc_error_dialog_parented(GTK_WINDOW(jw->dialog), message);
return;
}
/* Check for customer */
cust = gnc_general_select_get_selected (GNC_GENERAL_SELECT (jw->cust_edit));
if (!cust) {
const char *message = _("You must choose a customer.");
gnc_error_dialog_parented(GTK_WINDOW(jw->dialog), message);
return;
}
/* Now save it off */
{
GncJob *job = jw_get_job (jw);
if (job) {
gnc_ui_to_job (jw, job);
}
jw->created_job = job;
jw->job_guid = *xaccGUIDNULL ();
}
gnc_close_gui_component (jw->component_id);
}
static void
gnc_job_window_cancel_cb (GtkWidget *widget, gpointer data)
{
JobWindow *jw = data;
gnc_close_gui_component (jw->component_id);
}
static void
gnc_job_window_help_cb (GtkWidget *widget, gpointer data)
{
JobWindow *jw = data;
char *help_file = ""; /* xxx */
/* XXX */
helpWindow(NULL, NULL, help_file);
}
static void
gnc_job_window_destroy_cb (GtkWidget *widget, gpointer data)
{
JobWindow *jw = data;
GncJob *job = jw_get_job (jw);
gnc_suspend_gui_refresh ();
if (jw->dialog_type == NEW_JOB && job != NULL) {
gncJobDestroy (job);
jw->job_guid = *xaccGUIDNULL ();
}
gnc_unregister_gui_component (jw->component_id);
gnc_resume_gui_refresh ();
g_free (jw);
}
static void
gnc_job_name_changed_cb (GtkWidget *widget, gpointer data)
{
JobWindow *jw = data;
char *name, *id, *fullname, *title;
if (!jw)
return;
name = gtk_entry_get_text (GTK_ENTRY (jw->name_entry));
if (!name || *name == '\0')
name = _("<No name>");
id = gtk_entry_get_text (GTK_ENTRY (jw->id_entry));
fullname = g_strconcat (name, " (", id, ")", NULL);
if (jw->dialog_type == EDIT_JOB)
title = g_strconcat (_("Edit Job"), " - ", fullname, NULL);
else
title = g_strconcat (_("New Job"), " - ", fullname, NULL);
gtk_window_set_title (GTK_WINDOW (jw->dialog), title);
g_free (fullname);
g_free (title);
}
static int
gnc_job_on_close_cb (GnomeDialog *dialog, gpointer data)
{
JobWindow *jw;
GncJob **created_job = data;
if (data) {
jw = gtk_object_get_data (GTK_OBJECT (dialog), "dialog_info");
*created_job = jw->created_job;
}
gtk_main_quit ();
return FALSE;
}
static void
gnc_job_window_close_handler (gpointer user_data)
{
JobWindow *jw = user_data;
gnome_dialog_close (GNOME_DIALOG (jw->dialog));
}
static void
gnc_job_window_refresh_handler (GHashTable *changes, gpointer user_data)
{
JobWindow *jw = user_data;
const EventInfo *info;
GncJob *job = jw_get_job (jw);
/* If there isn't a job behind us, close down */
if (!job) {
gnc_close_gui_component (jw->component_id);
return;
}
/* Next, close if this is a destroy event */
if (changes) {
info = gnc_gui_get_entity_events (changes, &jw->job_guid);
if (info && (info->event_mask & GNC_EVENT_DESTROY)) {
gnc_close_gui_component (jw->component_id);
return;
}
}
}
static JobWindow *
gnc_job_new_window (GtkWidget *parent, GncBusiness *bus, GncCustomer *cust,
GncJob *job)
{
JobWindow *jw;
GladeXML *xml;
GtkWidget *cust_box;
GnomeDialog *jwd;
GtkObject *jwo;
jw = g_new0 (JobWindow, 1);
jw->business = bus;
/* Load the XML */
xml = gnc_glade_xml_new ("job.glade", "Job Dialog");
/* Find the dialog */
jw->dialog = glade_xml_get_widget (xml, "Job Dialog");
jwo = GTK_OBJECT (jw->dialog);
jwd = GNOME_DIALOG (jwo);
gtk_object_set_data (jwo, "dialog_info", jw);
/* default to ok XXX */
gnome_dialog_set_default (jwd, 0);
if (parent)
gnome_dialog_set_parent (jwd, GTK_WINDOW (parent));
/* Get entry points */
jw->id_entry = glade_xml_get_widget (xml, "id_entry");
jw->name_entry = glade_xml_get_widget (xml, "name_entry");
jw->desc_entry = glade_xml_get_widget (xml, "desc_entry");
jw->active_check = glade_xml_get_widget (xml, "active_check");
cust_box = glade_xml_get_widget (xml, "customer_hbox");
/* Setup signals (XXX) */
gnome_dialog_button_connect (jwd, 0,
GTK_SIGNAL_FUNC(gnc_job_window_ok_cb), jw);
gnome_dialog_button_connect (jwd, 1,
GTK_SIGNAL_FUNC(gnc_job_window_cancel_cb), jw);
gnome_dialog_button_connect (jwd, 2,
GTK_SIGNAL_FUNC(gnc_job_window_help_cb), jw);
gtk_signal_connect (jwo, "destroy",
GTK_SIGNAL_FUNC(gnc_job_window_destroy_cb), jw);
gtk_signal_connect(GTK_OBJECT (jw->id_entry), "changed",
GTK_SIGNAL_FUNC(gnc_job_name_changed_cb), jw);
gtk_signal_connect(GTK_OBJECT (jw->name_entry), "changed",
GTK_SIGNAL_FUNC(gnc_job_name_changed_cb), jw);
/* grab the printable routine */
{
const GncBusinessObject *obj =
gncBusinessLookup (GNC_CUSTOMER_MODULE_NAME);
if (!obj)
printf ("NO CUSTOMER OBJECT LOADED");
jw->cust_print = obj->printable;
}
/* Attach <Enter> to default button */
gnome_dialog_editable_enters (jwd, GTK_EDITABLE (jw->id_entry));
gnome_dialog_editable_enters (jwd, GTK_EDITABLE (jw->name_entry));
gnome_dialog_editable_enters (jwd, GTK_EDITABLE (jw->desc_entry));
/* Start at the name */
gtk_widget_grab_focus (jw->name_entry);
/* Set initial entries */
if (job != NULL) {
jw->job_guid = *gncJobGetGUID (job);
jw->dialog_type = EDIT_JOB;
jw->cust_edit = gnc_general_select_new (GNC_GENERAL_SELECT_TYPE_EDIT,
jw->cust_print,
gnc_customer_edit_new_edit, bus);
gtk_box_pack_start(GTK_BOX(cust_box), jw->cust_edit, TRUE, TRUE, 0);
gtk_entry_set_text (GTK_ENTRY (jw->id_entry), gncJobGetID (job));
gtk_entry_set_editable (GTK_ENTRY (jw->id_entry), FALSE);
gtk_entry_set_text (GTK_ENTRY (jw->name_entry), gncJobGetName (job));
gtk_entry_set_text (GTK_ENTRY (jw->desc_entry), gncJobGetDesc (job));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (jw->active_check),
gncJobGetActive (job));
gnc_general_select_set_selected (GNC_GENERAL_SELECT(jw->cust_edit),
gncJobGetCustomer(job));
jw->component_id = gnc_register_gui_component (DIALOG_EDIT_JOB_CM_CLASS,
gnc_job_window_refresh_handler,
gnc_job_window_close_handler,
jw);
} else {
job = gncJobCreate (bus);
jw->job_guid = *gncJobGetGUID (job);
jw->dialog_type = NEW_JOB;
jw->cust_edit = gnc_general_select_new (GNC_GENERAL_SELECT_TYPE_SELECT,
jw->cust_print,
gnc_customer_edit_new_select, bus);
gtk_box_pack_start(GTK_BOX(cust_box), jw->cust_edit, TRUE, TRUE, 0);
gtk_entry_set_text (GTK_ENTRY (jw->id_entry),
g_strdup_printf ("%.6d", gncJobNextID(bus)));
gnc_general_select_set_selected (GNC_GENERAL_SELECT(jw->cust_edit),
cust);
jw->component_id = gnc_register_gui_component (DIALOG_NEW_JOB_CM_CLASS,
gnc_job_window_refresh_handler,
gnc_job_window_close_handler,
jw);
}
gnc_job_name_changed_cb (NULL, jw);
gnc_gui_component_watch_entity_type (jw->component_id,
GNC_ID_NONE,
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
gtk_widget_show_all (jw->dialog);
return jw;
}
GncJob *
gnc_job_new (GtkWidget *parent, GncBusiness *bus, GncCustomer *customer)
{
JobWindow *jw;
GncJob *created_job = NULL;
/* Make sure required options exist */
if (!bus) return NULL;
jw = gnc_job_new_window (parent, bus, customer, NULL);
gtk_signal_connect (GTK_OBJECT (jw->dialog), "close",
GTK_SIGNAL_FUNC (gnc_job_on_close_cb), &created_job);
gtk_window_set_modal (GTK_WINDOW (jw->dialog), TRUE);
gtk_main ();
return created_job;
}
void
gnc_job_edit (GtkWidget *parent, GncJob *job)
{
JobWindow *jw;
if (!job) return;
jw = gnc_job_new_window (parent, gncJobGetBusiness(job),
gncJobGetCustomer(job), job);
gtk_signal_connect (GTK_OBJECT (jw->dialog), "close",
GTK_SIGNAL_FUNC (gnc_job_on_close_cb), NULL);
gtk_window_set_modal (GTK_WINDOW (jw->dialog), TRUE);
gtk_main ();
return;
}
/* Functions for widgets for job selection */
static gpointer gnc_job_edit_new_cb (gpointer arg)
{
struct _job_select_window *sw = arg;
return gnc_job_new (sw->toplevel, sw->business, NULL);
}
static void gnc_job_edit_edit_cb (gpointer arg, gpointer obj)
{
GncJob *job = obj;
struct _job_select_window *sw = arg;
g_return_if_fail (arg != NULL);
g_return_if_fail (obj != NULL);
gnc_job_edit (sw->toplevel, job);
}
gpointer gnc_job_edit_new_select (gpointer job, GtkWidget *toplevel,
GncCustomer *cust)
{
GncBusiness *business;
GncJob *j = job;
struct _job_select_window sw;
if (!cust) return NULL;
business = gncCustomerGetBusiness (cust);
sw.toplevel = toplevel;
sw.business = business;
return
gnc_ui_select_job_new (toplevel, business, cust, j);
/*
return
gnc_ui_business_chooser_new (toplevel, job,
gncBusinessLookup (business,
GNC_JOB_MODULE_NAME),
gnc_job_edit_new_cb,
gnc_job_edit_edit_cb, &sw, cust);
*/
}

View File

@ -0,0 +1,22 @@
/*
* dialog-job.h -- Dialog(s) for Job search and entry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_DIALOG_JOB_H_
#define GNC_DIALOG_JOB_H_
/* Functions to create and edit jobs */
GncJob * gnc_job_new (GtkWidget *parent, GncBusiness *bus, GncCustomer *cust);
void gnc_job_edit (GtkWidget *parent, GncJob *job);
/* Callback to choose a job from a customer, for use with the
* general-select widget. Provides both "new" and "edit" buttons.
*/
gpointer gnc_job_edit_new_select (gpointer start_job,
GtkWidget *toplevel,
GncCustomer *cust);
#endif /* GNC_DIALOG_JOB_H_ */

View File

@ -0,0 +1,580 @@
/*
* dialog-vendor.c -- Dialog for Vendor entry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <gnome.h>
#include "dialog-utils.h"
#include "global-options.h"
#include "gnc-amount-edit.h"
#include "gnc-component-manager.h"
#include "gnc-ui.h"
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
#include "gnc-engine-util.h"
#include "window-help.h"
#include "gncBusiness.h"
#include "gncAddress.h"
#include "gncVendor.h"
#include "gncVendorP.h"
#include "dialog-vendor.h"
#include "business-chooser.h"
#define DIALOG_NEW_VENDOR_CM_CLASS "dialog-new-vendor"
#define DIALOG_EDIT_VENDOR_CM_CLASS "dialog-edit-vendor"
typedef enum
{
NEW_VENDOR,
EDIT_VENDOR
} VendorDialogType;
struct _vendor_select_window {
GncBusiness * business;
};
typedef struct _vendor_window {
GtkWidget * dialog;
GtkWidget * id_entry;
GtkWidget * company_entry;
GtkWidget * name_entry;
GtkWidget * addr1_entry;
GtkWidget * addr2_entry;
GtkWidget * addr3_entry;
GtkWidget * addr4_entry;
GtkWidget * phone_entry;
GtkWidget * fax_entry;
GtkWidget * email_entry;
GtkWidget * terms_amount;
GtkWidget * active_check;
GtkWidget * taxincluded_check;
GtkWidget * notes_text;
VendorDialogType dialog_type;
GUID vendor_guid;
gint component_id;
GncBusiness * business;
GncVendor * created_vendor;
} VendorWindow;
static GncVendor *
vw_get_vendor (VendorWindow *vw)
{
if (!vw)
return NULL;
return gncBusinessLookupGUID (vw->business, GNC_VENDOR_MODULE_NAME,
&vw->vendor_guid);
}
static void gnc_ui_to_vendor (VendorWindow *vw, GncVendor *vendor)
{
GncAddress *addr;
gnc_numeric num;
addr = gncVendorGetAddr (vendor);
gnc_suspend_gui_refresh ();
gncVendorSetID (vendor, gtk_editable_get_chars
(GTK_EDITABLE (vw->id_entry), 0, -1));
gncVendorSetName (vendor, gtk_editable_get_chars
(GTK_EDITABLE (vw->company_entry), 0, -1));
gncAddressSetName (addr, gtk_editable_get_chars
(GTK_EDITABLE (vw->name_entry), 0, -1));
gncAddressSetAddr1 (addr, gtk_editable_get_chars
(GTK_EDITABLE (vw->addr1_entry), 0, -1));
gncAddressSetAddr2 (addr, gtk_editable_get_chars
(GTK_EDITABLE (vw->addr2_entry), 0, -1));
gncAddressSetAddr3 (addr, gtk_editable_get_chars
(GTK_EDITABLE (vw->addr3_entry), 0, -1));
gncAddressSetAddr4 (addr, gtk_editable_get_chars
(GTK_EDITABLE (vw->addr4_entry), 0, -1));
gncAddressSetPhone (addr, gtk_editable_get_chars
(GTK_EDITABLE (vw->phone_entry), 0, -1));
gncAddressSetFax (addr, gtk_editable_get_chars
(GTK_EDITABLE (vw->fax_entry), 0, -1));
gncAddressSetEmail (addr, gtk_editable_get_chars
(GTK_EDITABLE (vw->email_entry), 0, -1));
gncVendorSetActive (vendor, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (vw->active_check)));
gncVendorSetTaxIncluded (vendor, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (vw->taxincluded_check)));
gncVendorSetNotes (vendor, gtk_editable_get_chars
(GTK_EDITABLE (vw->notes_text), 0, -1));
/* Parse and set the terms, discount, and credit amounts */
num = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (vw->terms_amount));
gncVendorSetTerms (vendor, gnc_numeric_num (num));
gncVendorCommitEdit (vendor);
gnc_resume_gui_refresh ();
}
static gboolean check_edit_amount (GtkWidget *dialog, GtkWidget *amount,
gnc_numeric *min, gnc_numeric *max,
const char * error_message)
{
if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (amount))) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
/* We've got a valid-looking number; check mix/max */
if (min || max) {
gnc_numeric val = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (amount));
if ((min && gnc_numeric_compare (*min, val) > 0) ||
(max && gnc_numeric_compare (val, *max) > 0)) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
}
return FALSE;
}
static gboolean check_entry_nonempty (GtkWidget *dialog, GtkWidget *entry,
const char * error_message)
{
const char *res = gtk_entry_get_text (GTK_ENTRY (entry));
if (safe_strcmp (res, "") == 0) {
if (error_message)
gnc_error_dialog_parented (GTK_WINDOW (dialog), error_message);
return TRUE;
}
return FALSE;
}
static void
gnc_vendor_window_ok_cb (GtkWidget *widget, gpointer data)
{
VendorWindow *vw = data;
char *res;
GncVendor *vendor;
gnc_numeric min, max;
/* Check for valid id */
if (check_entry_nonempty (vw->dialog, vw->id_entry,
_("The Vendor must be given an ID.")))
return;
/* Check for valid company name */
if (check_entry_nonempty (vw->dialog, vw->company_entry,
_("You must enter a company name.")))
return;
/* Make sure we have an address */
if (check_entry_nonempty (vw->dialog, vw->addr1_entry, NULL) &&
check_entry_nonempty (vw->dialog, vw->addr2_entry, NULL) &&
check_entry_nonempty (vw->dialog, vw->addr3_entry, NULL) &&
check_entry_nonempty (vw->dialog, vw->addr4_entry, NULL)) {
const char *msg = _("You must enter a payment address.");
gnc_error_dialog_parented (GTK_WINDOW (vw->dialog), msg);
return;
}
/* Verify terms are valid (or empty) */
min = gnc_numeric_zero ();
if (check_edit_amount (vw->dialog, vw->terms_amount, &min, NULL,
_("Terms must be a positive integer or "
"you must leave it blank.")))
return;
/* Now save it off */
{
GncVendor *vendor = vw_get_vendor (vw);
if (vendor) {
gnc_ui_to_vendor (vw, vendor);
}
vw->created_vendor = vendor;
vw->vendor_guid = *xaccGUIDNULL ();
}
gnc_close_gui_component (vw->component_id);
}
static void
gnc_vendor_window_cancel_cb (GtkWidget *widget, gpointer data)
{
VendorWindow *vw = data;
gnc_close_gui_component (vw->component_id);
}
static void
gnc_vendor_window_help_cb (GtkWidget *widget, gpointer data)
{
VendorWindow *vw = data;
char *help_file = ""; /* xxx */
helpWindow(NULL, NULL, help_file);
}
static void
gnc_vendor_window_destroy_cb (GtkWidget *widget, gpointer data)
{
VendorWindow *vw = data;
GncVendor *vendor = vw_get_vendor (vw);
gnc_suspend_gui_refresh ();
if (vw->dialog_type == NEW_VENDOR && vendor != NULL) {
gncVendorDestroy (vendor);
vw->vendor_guid = *xaccGUIDNULL ();
}
gnc_unregister_gui_component (vw->component_id);
gnc_resume_gui_refresh ();
g_free (vw);
}
static void
gnc_vendor_name_changed_cb (GtkWidget *widget, gpointer data)
{
VendorWindow *vw = data;
char *name, *id, *fullname, *title;
if (!vw)
return;
name = gtk_entry_get_text (GTK_ENTRY (vw->name_entry));
if (!name || *name == '\0')
name = _("<No name>");
id = gtk_entry_get_text (GTK_ENTRY (vw->id_entry));
fullname = g_strconcat (name, " (", id, ")", NULL);
if (vw->dialog_type == EDIT_VENDOR)
title = g_strconcat (_("Edit Vendor"), " - ", fullname, NULL);
else
title = g_strconcat (_("New Vendor"), " - ", fullname, NULL);
gtk_window_set_title (GTK_WINDOW (vw->dialog), title);
g_free (fullname);
g_free (title);
}
static int
gnc_vendor_on_close_cb (GnomeDialog *dialog, gpointer data)
{
VendorWindow *vw;
GncVendor **created_vendor = data;
if (data) {
vw = gtk_object_get_data (GTK_OBJECT (dialog), "dialog_info");
*created_vendor = vw->created_vendor;
}
gtk_main_quit ();
return FALSE;
}
static void
gnc_vendor_window_close_handler (gpointer user_data)
{
VendorWindow *vw = user_data;
gnome_dialog_close (GNOME_DIALOG (vw->dialog));
}
static void
gnc_vendor_window_refresh_handler (GHashTable *changes, gpointer user_data)
{
VendorWindow *vw = user_data;
const EventInfo *info;
GncVendor *vendor = vw_get_vendor (vw);
/* If there isn't a vendor behind us, close down */
if (!vendor) {
gnc_close_gui_component (vw->component_id);
return;
}
/* Next, close if this is a destroy event */
if (changes) {
info = gnc_gui_get_entity_events (changes, &vw->vendor_guid);
if (info && (info->event_mask & GNC_EVENT_DESTROY)) {
gnc_close_gui_component (vw->component_id);
return;
}
}
}
static VendorWindow *
gnc_vendor_new_window (GtkWidget *parent, GncBusiness *bus,
GncVendor *vendor)
{
VendorWindow *vw;
GladeXML *xml;
GtkWidget *hbox, *edit;
GnomeDialog *vwd;
gnc_commodity *commodity;
GNCPrintAmountInfo print_info;
vw = g_new0 (VendorWindow, 1);
vw->business = bus;
/* Find the dialog */
xml = gnc_glade_xml_new ("vendor.glade", "Vendor Dialog");
vw->dialog = glade_xml_get_widget (xml, "Vendor Dialog");
vwd = GNOME_DIALOG (vw->dialog);
gtk_object_set_data (GTK_OBJECT (vw->dialog), "dialog_info", vw);
/* default to ok */
gnome_dialog_set_default (vwd, 0);
if (parent)
gnome_dialog_set_parent (vwd, GTK_WINDOW (parent));
/* Get entry points */
vw->id_entry = glade_xml_get_widget (xml, "id_entry");
vw->company_entry = glade_xml_get_widget (xml, "company_entry");
vw->name_entry = glade_xml_get_widget (xml, "name_entry");
vw->addr1_entry = glade_xml_get_widget (xml, "addr1_entry");
vw->addr2_entry = glade_xml_get_widget (xml, "addr2_entry");
vw->addr3_entry = glade_xml_get_widget (xml, "addr3_entry");
vw->addr4_entry = glade_xml_get_widget (xml, "addr4_entry");
vw->phone_entry = glade_xml_get_widget (xml, "phone_entry");
vw->fax_entry = glade_xml_get_widget (xml, "fax_entry");
vw->email_entry = glade_xml_get_widget (xml, "email_entry");
vw->active_check = glade_xml_get_widget (xml, "active_check");
vw->taxincluded_check = glade_xml_get_widget (xml, "tax_included_check");
vw->notes_text = glade_xml_get_widget (xml, "notes_text");
/* TERMS: Integer Value */
edit = gnc_amount_edit_new();
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
print_info = gnc_integral_print_info ();
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 1);
vw->terms_amount = edit;
gtk_widget_show (edit);
hbox = glade_xml_get_widget (xml, "terms_box");
gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
/* Setup Dialog for Editing */
gnome_dialog_set_default (vwd, 0);
/* Attach <Enter> to default button */
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->id_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->company_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->name_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->addr1_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->addr2_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->addr3_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->addr4_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->phone_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->fax_entry));
gnome_dialog_editable_enters (vwd, GTK_EDITABLE (vw->email_entry));
/* Set focus to company name */
gtk_widget_grab_focus (vw->company_entry);
/* Setup signals */
gnome_dialog_button_connect
(vwd, 0, GTK_SIGNAL_FUNC(gnc_vendor_window_ok_cb), vw);
gnome_dialog_button_connect
(vwd, 1, GTK_SIGNAL_FUNC(gnc_vendor_window_cancel_cb), vw);
gnome_dialog_button_connect
(vwd, 2, GTK_SIGNAL_FUNC(gnc_vendor_window_help_cb), vw);
gtk_signal_connect (GTK_OBJECT (vw->dialog), "destroy",
GTK_SIGNAL_FUNC(gnc_vendor_window_destroy_cb), vw);
gtk_signal_connect(GTK_OBJECT (vw->id_entry), "changed",
GTK_SIGNAL_FUNC(gnc_vendor_name_changed_cb), vw);
gtk_signal_connect(GTK_OBJECT (vw->company_entry), "changed",
GTK_SIGNAL_FUNC(gnc_vendor_name_changed_cb), vw);
/* Setup initial values */
if (vendor != NULL) {
GncAddress *addr;
const char *string;
gint pos = 0;
vw->dialog_type = EDIT_VENDOR;
vw->vendor_guid = *gncVendorGetGUID (vendor);
addr = gncVendorGetAddr (vendor);
gtk_entry_set_text (GTK_ENTRY (vw->id_entry), gncVendorGetID (vendor));
gtk_entry_set_editable (GTK_ENTRY (vw->id_entry), FALSE);
gtk_entry_set_text (GTK_ENTRY (vw->company_entry), gncVendorGetName (vendor));
/* Setup Address */
gtk_entry_set_text (GTK_ENTRY (vw->name_entry), gncAddressGetName (addr));
gtk_entry_set_text (GTK_ENTRY (vw->addr1_entry), gncAddressGetAddr1 (addr));
gtk_entry_set_text (GTK_ENTRY (vw->addr2_entry), gncAddressGetAddr2 (addr));
gtk_entry_set_text (GTK_ENTRY (vw->addr3_entry), gncAddressGetAddr3 (addr));
gtk_entry_set_text (GTK_ENTRY (vw->addr4_entry), gncAddressGetAddr4 (addr));
gtk_entry_set_text (GTK_ENTRY (vw->phone_entry), gncAddressGetPhone (addr));
gtk_entry_set_text (GTK_ENTRY (vw->fax_entry), gncAddressGetFax (addr));
gtk_entry_set_text (GTK_ENTRY (vw->email_entry), gncAddressGetEmail (addr));
/* Set toggle buttons */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vw->active_check),
gncVendorGetActive (vendor));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vw->taxincluded_check),
gncVendorGetTaxIncluded (vendor));
string = gncVendorGetNotes (vendor);
gtk_editable_delete_text (GTK_EDITABLE (vw->notes_text), 0, -1);
gtk_editable_insert_text (GTK_EDITABLE (vw->notes_text), string,
strlen(string), &pos);
vw->component_id =
gnc_register_gui_component (DIALOG_EDIT_VENDOR_CM_CLASS,
gnc_vendor_window_refresh_handler,
gnc_vendor_window_close_handler,
vw);
} else {
gnc_numeric num;
vendor = gncVendorCreate (bus);
vw->vendor_guid = *gncVendorGetGUID (vendor);
vw->dialog_type = NEW_VENDOR;
gtk_entry_set_text (GTK_ENTRY (vw->id_entry),
g_strdup_printf ("%.6d", gncVendorNextID(bus)));
vw->component_id =
gnc_register_gui_component (DIALOG_NEW_VENDOR_CM_CLASS,
gnc_vendor_window_refresh_handler,
gnc_vendor_window_close_handler,
vw);
}
/* I know that vendor exists here -- either passed in or just created */
{
gnc_numeric terms;
/* Set the Terms amounts */
terms = gnc_numeric_create (gncVendorGetTerms (vendor), 1);
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (vw->terms_amount), terms);
}
gnc_gui_component_watch_entity_type (vw->component_id,
GNC_ID_NONE,
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
gtk_widget_show_all (vw->dialog);
return vw;
}
GncVendor *
gnc_vendor_new (GtkWidget *parent, GncBusiness *bus)
{
VendorWindow *vw;
GncVendor *created_vendor = NULL;
/* Make sure required options exist */
if (!bus) return NULL;
vw = gnc_vendor_new_window (parent, bus, NULL);
gtk_signal_connect (GTK_OBJECT (vw->dialog), "close",
GTK_SIGNAL_FUNC (gnc_vendor_on_close_cb),
&created_vendor);
gtk_window_set_modal (GTK_WINDOW (vw->dialog), TRUE);
gtk_main ();
return created_vendor;
}
void
gnc_vendor_edit (GtkWidget *parent, GncVendor *vendor)
{
VendorWindow *vw;
if (!vendor) return;
vw = gnc_vendor_new_window (parent, gncVendorGetBusiness(vendor), vendor);
gtk_signal_connect (GTK_OBJECT (vw->dialog), "close",
GTK_SIGNAL_FUNC (gnc_vendor_on_close_cb),
NULL);
gtk_window_set_modal (GTK_WINDOW (vw->dialog), TRUE);
gtk_main ();
return;
}
/* Functions for widgets for vendor selection */
static gpointer gnc_vendor_edit_new_cb (gpointer arg, GtkWidget *toplevel)
{
struct _vendor_select_window *sw = arg;
if (!arg) return NULL;
return gnc_vendor_new (toplevel, sw->business);
}
static void gnc_vendor_edit_edit_cb (gpointer arg, gpointer obj, GtkWidget *toplevel)
{
GncVendor *vendor = obj;
struct _vendor_select_window *sw = arg;
if (!arg || !obj) return;
gnc_vendor_edit (toplevel, vendor);
}
gpointer gnc_vendor_edit_new_select (gpointer bus, gpointer vendor,
GtkWidget *toplevel)
{
GncBusiness *business = bus;
struct _vendor_select_window sw;
g_return_val_if_fail (bus != NULL, NULL);
sw.business = business;
return
gnc_ui_business_chooser_new (toplevel, vendor,
business, GNC_VENDOR_MODULE_NAME,
gnc_vendor_edit_new_cb,
gnc_vendor_edit_edit_cb, &sw);
}
gpointer gnc_vendor_edit_new_edit (gpointer bus, gpointer v,
GtkWidget *toplevel)
{
GncBusiness *busiess = bus;
GncVendor *vendor = v;
g_return_val_if_fail (vendor != NULL, NULL);
gnc_vendor_edit (toplevel, vendor);
return vendor;
}

View File

@ -0,0 +1,27 @@
/*
* dialog-vendor.h -- Dialog(s) for Vendor search and entry
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_DIALOG_VENDOR_H_
#define GNC_DIALOG_VENDOR_H_
/* Functions to create and edit vendors */
GncVendor * gnc_vendor_new (GtkWidget *parent, GncBusiness *bus);
void gnc_vendor_edit (GtkWidget *parent, GncVendor *vendor);
/* Callbacks to select a vendor that match the necessary functions
* for use with the gnc_general_select widget.
*
* new_select provides a selection and the ability to create and edit
* vendors.
* new_edit provides only the ability to edit the current selection
*/
gpointer gnc_vendor_edit_new_select (gpointer bus, gpointer c,
GtkWidget *toplevel);
gpointer gnc_vendor_edit_new_edit (gpointer bus, gpointer vendor,
GtkWidget *toplevel);
#endif /* GNC_DIALOG_VENDOR_H_ */

View File

@ -0,0 +1,797 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Employee</name>
<program_name>employee</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<output_main_file>False</output_main_file>
<output_support_files>False</output_support_files>
<output_build_files>False</output_build_files>
<backup_source_files>False</backup_source_files>
</project>
<widget>
<class>GnomeDialog</class>
<name>Employee Dialog</name>
<title>New Employee</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button4</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button5</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button6</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
</widget>
</widget>
<widget>
<class>GtkNotebook</class>
<name>notebook1</name>
<can_focus>True</can_focus>
<show_tabs>True</show_tabs>
<show_border>True</show_border>
<tab_pos>GTK_POS_TOP</tab_pos>
<scrollable>False</scrollable>
<tab_hborder>2</tab_hborder>
<tab_vborder>2</tab_vborder>
<popup_enable>False</popup_enable>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox2</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<border_width>3</border_width>
<label>Indentification</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox2</name>
<border_width>2</border_width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkVBox</class>
<name>vbox11</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label1</name>
<label>Employee Number: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label19</name>
<label>Username: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>active_check</name>
<can_focus>True</can_focus>
<label>Active</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox12</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkEntry</class>
<name>id_entry</name>
<width>50</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>username_entry</name>
<width>158</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label26</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame2</name>
<border_width>3</border_width>
<label>Payment Address</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox3</name>
<width>200</width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkVBox</class>
<name>vbox5</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>3</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label3</name>
<label>Name: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label4</name>
<label>Address: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label23</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label24</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label25</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>Phone: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label6</name>
<label>Fax: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label7</name>
<label>Email: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox6</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkEntry</class>
<name>name_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>addr1_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>addr2_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>addr3_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>addr4_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>phone_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>fax_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>email_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame4</name>
<border_width>3</border_width>
<label>Interface</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox14</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox7</name>
<border_width>2</border_width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label34</name>
<label>Language: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>language_entry</name>
<width>50</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame5</name>
<border_width>3</border_width>
<label>Billing</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox15</name>
<border_width>2</border_width>
<homogeneous>True</homogeneous>
<spacing>2</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox8</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label35</name>
<label>Default Hours per Day: </label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHBox</class>
<name>hours_hbox</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox9</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label36</name>
<label>Default Rate: </label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHBox</class>
<name>rate_hbox</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label9</name>
<label>Employee</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox13</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkFrame</class>
<name>frame3</name>
<border_width>3</border_width>
<label>Access Control List</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox16</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label33</name>
<label>Access Control</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@ -0,0 +1,19 @@
/*
* gnc-business-utils.c -- Utilities for the Business UI
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <gnome.h>
#include "dialog-utils.h"
#include "gnc-ui.h"
#include "gncBusiness.h"
#include "gncCustomer.h"
#include "gncJob.h"
#include "gnc-business-utils.h"

View File

@ -0,0 +1,11 @@
/*
* gnc-business-utils.h -- Utilities for the Business UI
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_BUSINESS_UTILS_H_
#define GNC_BUSINESS_UTILS_H_
#endif /* GNC_BUSINESS_UTILS_H_ */

View File

@ -0,0 +1,183 @@
;;; -*-scheme-*-
(use-modules (g-wrap))
(debug-set! maxdepth 100000)
(debug-set! stack 2000000)
(define-module (g-wrapped gw-business-gnome-spec)
:use-module (g-wrap))
(use-modules (g-wrapped gw-business-core-spec))
(use-modules (g-wrapped gw-gnc-spec))
(let ((mod (gw:new-module "gw-business-gnome")))
(define (standard-c-call-gen result func-call-code)
(list (gw:result-get-c-name result) " = " func-call-code ";\n"))
(define (add-standard-result-handlers! type c->scm-converter)
(define (standard-pre-handler result)
(let* ((ret-type-name (gw:result-get-proper-c-type-name result))
(ret-var-name (gw:result-get-c-name result)))
(list "{\n"
" " ret-type-name " " ret-var-name ";\n")))
(gw:type-set-pre-call-result-ccodegen! type standard-pre-handler)
(gw:type-set-post-call-result-ccodegen!
type
(lambda (result)
(let* ((scm-name (gw:result-get-scm-name result))
(c-name (gw:result-get-c-name result)))
(list
(c->scm-converter scm-name c-name)
" }\n")))))
(gw:module-depends-on mod "gw-runtime")
(gw:module-depends-on mod "gw-business-core")
(gw:module-depends-on mod "gw-gnc")
(gw:module-set-guile-module! mod '(g-wrapped gw-business-gnome))
(gw:module-set-declarations-ccodegen!
mod
(lambda (client-only?)
(list
"#include <dialog-customer.h>\n"
"#include <dialog-employee.h>\n"
"#include <dialog-job.h>\n"
"#include <dialog-job-select.h>\n"
"#include <dialog-vendor.h>\n"
)))
(gw:module-set-init-ccodegen!
mod
(lambda (client-only?)
(if client-only?
'()
(gw:inline-scheme '(use-modules (gnucash business-gnome))))))
;;
;; dialog-customer.h
;;
(gw:wrap-function
mod
'gnc:customer-new
'<gnc:GncCustomer*>
"gnc_customer_new"
'((<gnc:UIWidget> parent) (<gnc:GncBusiness*> business))
"Dialog: create a new GncCustomer. Parent may be NULL.")
(gw:wrap-function
mod
'gnc:customer-edit
'<gw:void>
"gnc_customer_edit"
'((<gnc:UIWidget> parent) (<gnc:GncCustomer*> customer))
"Dialog: Edit a GncCustomer. Parent may be NULL.")
(gw:wrap-function
mod
'gnc:customer-select
'<gnc:GncCustomer*>
"gnc_customer_edit_new_select"
'((<gnc:GncBusiness*> business) (<gnc:GncCustomer*> start_selection)
(<gnc:UIWidget> parent))
"Dialog: Select a GncCustomer. Parent and start_selection may be NULL.")
;;
;; dialog-employee.h
;;
(gw:wrap-function
mod
'gnc:employee-new
'<gnc:GncEmployee*>
"gnc_employee_new"
'((<gnc:UIWidget> parent) (<gnc:GncBusiness*> business))
"Dialog: create a new GncEmployee. Parent may be NULL.")
(gw:wrap-function
mod
'gnc:employee-edit
'<gw:void>
"gnc_employee_edit"
'((<gnc:UIWidget> parent) (<gnc:GncEmployee*> employee))
"Dialog: Edit a GncEmployee. Parent may be NULL.")
(gw:wrap-function
mod
'gnc:employee-select
'<gnc:GncEmployee*>
"gnc_employee_edit_new_select"
'((<gnc:GncBusiness*> business) (<gnc:GncEmployee*> start_selection)
(<gnc:UIWidget> parent))
"Dialog: Select a GncEmployee. Parent and start_selection may be NULL.")
;;
;; dialog-job.h
;;
(gw:wrap-function
mod
'gnc:job-new
'<gnc:GncJob*>
"gnc_job_new"
'((<gnc:UIWidget> parent) (<gnc:GncBusiness*> business_state)
(<gnc:GncCustomer*> default_customer))
"Dialog: create a new GncJob. Parent and Customer may be NULL.")
(gw:wrap-function
mod
'gnc:job-edit
'<gw:void>
"gnc_job_edit"
'((<gnc:UIWidget> parent) (<gnc:GncJob*> job))
"Dialog: Edit a GncJob. Parent may be NULL.")
;;
;; dialog-job-select.h
;;
(gw:wrap-function
mod
'gnc:job-select
'<gnc:GncJob*>
"gnc_ui_select_job_new"
'((<gnc:UIWidget> parent) (<gnc:GncBusiness*> business)
(<gnc:GncCustomer*> cust) (<gnc:GncJob*> job))
"Dialog: Select a new job. Parent and Customer may be NULL.")
;;
;; dialog-vendor.h
;;
(gw:wrap-function
mod
'gnc:vendor-new
'<gnc:GncVendor*>
"gnc_vendor_new"
'((<gnc:UIWidget> parent) (<gnc:GncBusiness*> business))
"Dialog: create a new GncVendor. Parent may be NULL.")
(gw:wrap-function
mod
'gnc:vendor-edit
'<gw:void>
"gnc_vendor_edit"
'((<gnc:UIWidget> parent) (<gnc:GncVendor*> vendor))
"Dialog: Edit a GncVendor. Parent may be NULL.")
(gw:wrap-function
mod
'gnc:vendor-select
'<gnc:GncVendor*>
"gnc_vendor_edit_new_select"
'((<gnc:GncBusiness*> business) (<gnc:GncVendor*> start_selection)
(<gnc:UIWidget> parent))
"Dialog: Select a GncVendor. Parent and start_selection may be NULL.")
)

View File

@ -0,0 +1,715 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Job</name>
<program_name>job</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<output_main_file>False</output_main_file>
<output_support_files>False</output_support_files>
<output_build_files>False</output_build_files>
<backup_source_files>False</backup_source_files>
</project>
<widget>
<class>GnomeDialog</class>
<name>Job Dialog</name>
<title>Job Dialog</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox2</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area2</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button8</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button9</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button10</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<border_width>3</border_width>
<label>Identification</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox4</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label1</name>
<width>75</width>
<label>Job Number: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>id_entry</name>
<width>50</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox2</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label2</name>
<width>75</width>
<label>Customer: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHBox</class>
<name>customer_hbox</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame2</name>
<border_width>3</border_width>
<label>Description</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox5</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox3</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label3</name>
<width>100</width>
<label>Job Name: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>name_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox4</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label4</name>
<width>100</width>
<label>Description: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>desc_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame3</name>
<border_width>3</border_width>
<label>Active</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkCheckButton</class>
<name>active_check</name>
<can_focus>True</can_focus>
<label>Job Active</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GnomeDialog</class>
<name>Job Selector Dialog</name>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox3</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area3</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button14</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>gnc_ui_select_job_ok_cb</handler>
<data>Job_Selector_Dialog</data>
<last_modification_time>Sun, 11 Nov 2001 03:08:59 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button18</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>gnc_ui_select_job_new_cb</handler>
<data>Job_Selector_Dialog</data>
<last_modification_time>Sun, 11 Nov 2001 03:09:14 GMT</last_modification_time>
</signal>
<label>New Job...</label>
</widget>
<widget>
<class>GtkButton</class>
<name>button20</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>gnc_ui_select_job_edit_cb</handler>
<data>Job_Selector_Dialog</data>
<last_modification_time>Tue, 13 Nov 2001 22:24:22 GMT</last_modification_time>
</signal>
<label>Edit Job...</label>
</widget>
<widget>
<class>GtkButton</class>
<name>button21</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>gnc_ui_select_job_cancel_cb</handler>
<data>Job_Selector_Dialog</data>
<last_modification_time>Tue, 13 Nov 2001 22:24:33 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox11</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox7</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkTable</class>
<name>table2</name>
<rows>2</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label6</name>
<label>Job:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>Customer:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCombo</class>
<name>customer_combo</name>
<value_in_list>True</value_in_list>
<ok_if_empty>False</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items></items>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>customer_entry</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>gnc_ui_select_job_customer_changed_cb</handler>
<data>Commodity_Selector_Dialog</data>
<last_modification_time>Tue, 13 Nov 2001 22:25:09 GMT</last_modification_time>
</signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
<widget>
<class>GtkCombo</class>
<name>job_combo</name>
<value_in_list>True</value_in_list>
<ok_if_empty>False</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items></items>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>job_entry</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox10</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox6</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkTable</class>
<name>table1</name>
<rows>2</rows>
<columns>1</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkCheckButton</class>
<name>showcust_check</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>gnc_ui_select_job_showcust_toggled_cb</handler>
<data>Job_Selector_Dialog</data>
<last_modification_time>Sun, 11 Nov 2001 04:48:09 GMT</last_modification_time>
</signal>
<label>Show All Customers</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>showjobs_check</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>gnc_ui_select_job_showjobs_toggled_cb</handler>
<data>Job_Selector_Dialog</data>
<last_modification_time>Sun, 11 Nov 2001 03:19:10 GMT</last_modification_time>
</signal>
<label>Show All Jobs</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@ -0,0 +1,741 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Vendor</name>
<program_name>vendor</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<output_main_file>False</output_main_file>
<output_support_files>False</output_support_files>
<output_build_files>False</output_build_files>
<backup_source_files>False</backup_source_files>
</project>
<widget>
<class>GnomeDialog</class>
<name>Vendor Dialog</name>
<title>New Vendor</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button4</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button5</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button6</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
</widget>
</widget>
<widget>
<class>GtkNotebook</class>
<name>notebook1</name>
<can_focus>True</can_focus>
<show_tabs>True</show_tabs>
<show_border>True</show_border>
<tab_pos>GTK_POS_TOP</tab_pos>
<scrollable>False</scrollable>
<tab_hborder>2</tab_hborder>
<tab_vborder>2</tab_vborder>
<popup_enable>False</popup_enable>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox2</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<border_width>3</border_width>
<label>Indentification</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox2</name>
<border_width>2</border_width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkVBox</class>
<name>vbox11</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label1</name>
<label>Vendor Number: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label19</name>
<label>Vendor Name: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>active_check</name>
<can_focus>True</can_focus>
<label>Active</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox12</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkEntry</class>
<name>id_entry</name>
<width>50</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>company_entry</name>
<width>158</width>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label26</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame2</name>
<border_width>3</border_width>
<label>Payment Address</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox3</name>
<width>200</width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkVBox</class>
<name>vbox5</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>3</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label3</name>
<label>Name: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label4</name>
<label>Address: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label23</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label24</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label25</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>Phone: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label6</name>
<label>Fax: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label7</name>
<label>Email: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox6</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkEntry</class>
<name>name_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>addr1_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>addr2_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>addr3_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>addr4_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>phone_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>fax_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>email_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame4</name>
<border_width>3</border_width>
<label>Notes</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow1</name>
<border_width>3</border_width>
<hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<widget>
<class>GtkText</class>
<name>notes_text</name>
<height>15</height>
<can_focus>True</can_focus>
<editable>True</editable>
<text></text>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label9</name>
<label>Vendor</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox13</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkFrame</class>
<name>frame3</name>
<border_width>3</border_width>
<label>Payment Information</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox6</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkVBox</class>
<name>vbox7</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label8</name>
<label>Terms: </label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>tax_included_check</name>
<border_width>3</border_width>
<can_focus>True</can_focus>
<label>Tax Included</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox13</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>terms_box</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>label32</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label33</name>
<label>Payment Information</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@ -9,16 +9,16 @@ libgncmodule_la_SOURCES = gnc-module.c
libgncmodule_la_LDFLAGS = -module
libgncmodule_la_LIBADD = \
${G_WRAP_LINK_ARGS} \
${GLIB_LIBS} \
${GUILE_LIBS} \
${GLIB_LIBS} \
-lltdl
libgw_gnc_module_la_SOURCES = gw-gnc-module.c
libgw_gnc_module_la_LDFLAGS = -module
libgw_gnc_module_la_LIBADD = libgncmodule.la \
${G_WRAP_LINK_ARGS} \
${GLIB_LIBS} \
${GUILE_LIBS}
${GUILE_LIBS} \
${GLIB_LIBS}
gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
gncmod_DATA = gnc-module.scm

View File

@ -78,6 +78,7 @@ libgncmod_gnome_utils_la_LIBADD = \
${top_srcdir}/src/calculation/libgncmod-calculation.la \
${top_srcdir}/src/network-utils/libgncmod-network-utils.la \
${top_srcdir}/src/app-utils/libgncmod-app-utils.la \
${GUILE_LIBS} \
${GUPPI_LIBS} \
${GNOMEUI_LIBS} \
${GNOME_LIBDIR} \

View File

@ -1458,8 +1458,10 @@ gnc_option_set_ui_widget(GNCOption *option,
g_free(colon_name);
enclosing = gtk_hbox_new(FALSE, 5);
value = gnc_general_select_new(gnc_commodity_edit_get_string,
gnc_commodity_edit_new_select);
value = gnc_general_select_new(GNC_GENERAL_SELECT_TYPE_SELECT,
gnc_commodity_edit_get_string,
gnc_commodity_edit_new_select,
NULL);
gnc_option_set_widget (option, value);
gnc_option_set_ui_value(option, FALSE);

View File

@ -44,9 +44,11 @@ const char * gnc_commodity_edit_get_string (gpointer ptr)
return gnc_commodity_get_printname(comm);
}
gpointer gnc_commodity_edit_new_select (gpointer ptr, GtkWidget *toplevel)
gpointer gnc_commodity_edit_new_select (gpointer arg, gpointer ptr,
GtkWidget *toplevel)
{
gnc_commodity * comm = (gnc_commodity *)ptr;
arg;
return gnc_ui_select_commodity_modal(comm, toplevel);
}

View File

@ -38,8 +38,13 @@
/* Callback function to return the printable string of a commodity */
const char * gnc_commodity_edit_get_string (gpointer ptr);
/* Callback function to popup a new selection (modal) dialog */
gpointer gnc_commodity_edit_new_select (gpointer ptr, GtkWidget *toplevel);
/* Callback function to popup a new selection (modal) dialog.
*
* NOTE: The argument here is ignored, so you can safely set the
* cb_arg to NULL when you create the general_select widget
*/
gpointer gnc_commodity_edit_new_select (gpointer arg, gpointer ptr,
GtkWidget *toplevel);
#endif

View File

@ -163,7 +163,8 @@ select_cb(GtkButton * button, gpointer user_data)
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
new_selection = (gsl->new_select)(gsl->selected_item, toplevel);
new_selection = (gsl->new_select)(gsl->cb_arg, gsl->selected_item,
toplevel);
/* NULL return means cancel; no change */
if (new_selection == NULL)
@ -173,14 +174,18 @@ select_cb(GtkButton * button, gpointer user_data)
}
static void
create_children (GNCGeneralSelect *gsl)
create_children (GNCGeneralSelect *gsl, GNCGeneralSelectType type)
{
gsl->entry = gtk_entry_new ();
gtk_entry_set_editable (GTK_ENTRY (gsl->entry), FALSE);
gtk_box_pack_start (GTK_BOX (gsl), gsl->entry, TRUE, TRUE, 0);
gtk_widget_show (gsl->entry);
gsl->button = gtk_button_new_with_label (_("Select..."));
if (type == GNC_GENERAL_SELECT_TYPE_SELECT)
gsl->button = gtk_button_new_with_label (_("Select..."));
else if (type == GNC_GENERAL_SELECT_TYPE_EDIT)
gsl->button = gtk_button_new_with_label (_("Edit..."));
gtk_box_pack_start (GTK_BOX (gsl), gsl->button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (gsl->button), "clicked",
select_cb, gsl);
@ -196,8 +201,10 @@ create_children (GNCGeneralSelect *gsl)
* Returns a GNCGeneralSelect widget.
*/
GtkWidget *
gnc_general_select_new (GNCGeneralSelectGetStringCB get_string,
GNCGeneralSelectNewSelectCB new_select)
gnc_general_select_new (GNCGeneralSelectType type,
GNCGeneralSelectGetStringCB get_string,
GNCGeneralSelectNewSelectCB new_select,
gpointer cb_arg)
{
GNCGeneralSelect *gsl;
g_return_val_if_fail (get_string != NULL, NULL);
@ -205,9 +212,10 @@ gnc_general_select_new (GNCGeneralSelectGetStringCB get_string,
gsl = gtk_type_new (gnc_general_select_get_type ());
create_children (gsl);
create_children (gsl, type);
gsl->get_string = get_string;
gsl->new_select = new_select;
gsl->cb_arg = cb_arg;
return GTK_WIDGET (gsl);
}

View File

@ -40,6 +40,14 @@ BEGIN_GNOME_DECLS
#define GNC_GENERAL_SELECT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gnc_general_select_get_type(), GNCGeneralSelectClass)
#define GNC_IS_GENERAL_SELECT(obj) GTK_CHECK_TYPE (obj, gnc_general_select_get_type ())
typedef const char * (*GNCGeneralSelectGetStringCB) (gpointer);
typedef gpointer (*GNCGeneralSelectNewSelectCB) (gpointer cbarg, gpointer default_selection, GtkWidget *parent);
typedef enum {
GNC_GENERAL_SELECT_TYPE_SELECT = 1,
GNC_GENERAL_SELECT_TYPE_EDIT = 2
} GNCGeneralSelectType;
typedef struct {
GtkHBox hbox;
@ -48,8 +56,9 @@ typedef struct {
gpointer selected_item;
const char * (*get_string) (gpointer ptr);
gpointer (*new_select) (gpointer ptr, GtkWidget *toplevel);
GNCGeneralSelectGetStringCB get_string;
GNCGeneralSelectNewSelectCB new_select;
gpointer cb_arg;
} GNCGeneralSelect;
typedef struct {
@ -58,11 +67,11 @@ typedef struct {
void (*changed) (GNCGeneralSelect *edit);
} GNCGeneralSelectClass;
typedef const char * (*GNCGeneralSelectGetStringCB) (gpointer);
typedef gpointer (*GNCGeneralSelectNewSelectCB) (gpointer, GtkWidget *);
GtkWidget *gnc_general_select_new (GNCGeneralSelectGetStringCB get_string,
GNCGeneralSelectNewSelectCB new_select);
GtkWidget *gnc_general_select_new (GNCGeneralSelectType type,
GNCGeneralSelectGetStringCB get_string,
GNCGeneralSelectNewSelectCB new_select,
gpointer cb_arg);
void gnc_general_select_set_selected (GNCGeneralSelect *gsl,
gpointer selected);
gpointer gnc_general_select_get_selected (GNCGeneralSelect *gsl);

View File

@ -800,8 +800,10 @@ gnc_price_dialog_create (PricesDialog *pdb_dialog)
box = glade_xml_get_widget (xml, "commodity_box");
w = gnc_general_select_new (gnc_commodity_edit_get_string,
gnc_commodity_edit_new_select);
w = gnc_general_select_new (GNC_GENERAL_SELECT_TYPE_SELECT,
gnc_commodity_edit_get_string,
gnc_commodity_edit_new_select,
NULL);
pdb_dialog->commodity_edit = w;
gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0);
gtk_widget_show (w);

View File

@ -107,8 +107,10 @@ get_commodity_editor(void)
GNCGeneralSelect *cur_editor;
cur_editor =
GNC_GENERAL_SELECT (gnc_general_select_new(gnc_commodity_edit_get_string,
gnc_commodity_edit_new_select));
GNC_GENERAL_SELECT (gnc_general_select_new(GNC_GENERAL_SELECT_TYPE_SELECT,
gnc_commodity_edit_get_string,
gnc_commodity_edit_new_select,
NULL));
gtk_widget_show (GTK_WIDGET(cur_editor));
gnc_general_select_set_selected (cur_editor,
gnc_locale_default_currency());

View File

@ -37,9 +37,9 @@ libgncmod_binary_import_la_LIBADD = \
${top_srcdir}/src/app-utils/libgncmod-app-utils.la \
${top_srcdir}/src/app-file/libgncmod-app-file.la \
${top_srcdir}/src/gnome-utils/libgncmod-gnome-utils.la \
${GUILE_LIBS} \
${GNOMEUI_LIBS} \
${GNOME_LIBDIR} \
${GUILE_LIBS} \
${GLIB_LIBS}
libgw_binary_import_la_SOURCES = gw-binary-import.c

View File

@ -18,10 +18,11 @@ libgncmod_qif_import_la_LIBADD = \
${top_srcdir}/src/app-file/libgncmod-app-file.la \
${top_srcdir}/src/gnc-module/libgncmodule.la \
${top_srcdir}/src/engine/libgncmod-engine.la \
${GUILE_LIBS} \
${GNOME_LIBS} \
${GLADE_LIBS} \
${GLIB_LIBS} \
${GUILE_LIBS}
${GLIB_LIBS}
gncscmmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/import-export
gncscmmod_DATA = qif-import.scm

View File

@ -13,8 +13,8 @@ gncinclude_HEADERS = \
libgncmod_report_system_la_LDFLAGS = -module
libgncmod_report_system_la_LIBADD = \
${top_srcdir}/src/gnc-module/libgncmodule.la \
${GLIB_LIBS} \
${GUILE_LIBS}
${GUILE_LIBS} \
${GLIB_LIBS}
AM_CFLAGS = -I${top_srcdir}/src/gnc-module ${GLIB_CFLAGS} ${GUILE_INCS}

View File

@ -54,11 +54,77 @@
(define (gnc:make-separator path)
(gnc:make-extension 'separator #f #f path #f))
(gnc:module-load "gnucash/business-gnome" 0)
(define gnc:extensions-temp-business #f)
(define (gnc:extensions-get-business)
(if gnc:extensions-temp-business
gnc:extensions-temp-business
(begin
(set! gnc:extensions-temp-business (gnc:business-create
(gnc:get-current-session)))
gnc:extensions-temp-business)))
(define (gnc:extensions-menu-setup)
(define menu (gnc:make-menu "Extensions" (list "_Settings")))
(define new-job-item
(gnc:make-menu-item (N_ "Test New Job Dialog")
(N_ "Test New Job Dialog")
(list "Extensions" "")
(lambda ()
(gnc:job-new #f (gnc:extensions-get-business)
#f))))
(define select-job-item
(gnc:make-menu-item (N_ "Test Job Selection Dialog")
(N_ "Test Job Selection Dialog")
(list "Extensions" "")
(lambda ()
(gnc:job-select #f (gnc:extensions-get-business)
#f #f))))
(define new-vendor-item
(gnc:make-menu-item (N_ "Test New Vendor Dialog")
(N_ "Test New Vendor Dialog")
(list "Extensions" "")
(lambda ()
(gnc:vendor-new #f (gnc:extensions-get-business)))))
(define select-vendor-item
(gnc:make-menu-item (N_ "Test Vendor Selection Dialog")
(N_ "Test Vendor Selection Dialog")
(list "Extensions" "")
(lambda ()
(gnc:vendor-select (gnc:extensions-get-business)
#f #f))))
(define new-employee-item
(gnc:make-menu-item (N_ "Test New Employee Dialog")
(N_ "Test New Employee Dialog")
(list "Extensions" "")
(lambda ()
(gnc:employee-new #f (gnc:extensions-get-business)))))
(define select-employee-item
(gnc:make-menu-item (N_ "Test Employee Selection Dialog")
(N_ "Test Employee Selection Dialog")
(list "Extensions" "")
(lambda ()
(gnc:employee-select (gnc:extensions-get-business)
#f #f))))
(gnc:add-extension menu)
(gnc:add-extension select-employee-item)
(gnc:add-extension new-employee-item)
(gnc:add-extension select-vendor-item)
(gnc:add-extension new-vendor-item)
(gnc:add-extension select-job-item)
(gnc:add-extension new-job-item)
)
(if (gnc:debugging?)

View File

@ -7,8 +7,8 @@ libgncmod_tax_us_la_SOURCES = \
libgncmod_tax_us_la_LDFLAGS = -module
libgncmod_tax_us_la_LIBADD = \
${GLIB_LIBS} \
${GUILE_LIBS}
${GUILE_LIBS} \
${GLIB_LIBS}
AM_CFLAGS = -I${top_srcdir}/src/gnc-module ${GLIB_CFLAGS} ${GUILE_INCS}