Change Job to use GncOwner instead of GncCustomer -- this lets

you create Jobs for Vendors as well as Jobs for Customers.
Still needs more Vendor support to maintain a Job list.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6635 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2002-01-22 15:51:14 +00:00
parent fb0ae8b224
commit 7e2891f0d8
13 changed files with 293 additions and 263 deletions

View File

@@ -1,6 +1,6 @@
/*
* gncJob.c -- the Core Job Interface
* Copyright (C) 2001 Derek Atkins
* Copyright (C) 2001, 2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
@@ -19,7 +19,6 @@
#include "gncBusiness.h"
#include "gncJob.h"
#include "gncJobP.h"
#include "gncCustomer.h"
struct _gncJob {
GNCBook * book;
@@ -27,7 +26,7 @@ struct _gncJob {
char * id;
char * name;
char * desc;
GncCustomer * cust;
GncOwner owner;
gboolean active;
gboolean dirty;
};
@@ -55,7 +54,6 @@ GncJob *gncJobCreate (GNCBook *book)
job->id = CACHE_INSERT ("");
job->name = CACHE_INSERT ("");
job->desc = CACHE_INSERT ("");
job->cust = NULL;
job->active = TRUE;
xaccGUIDNew (&job->guid, book);
@@ -72,8 +70,15 @@ void gncJobDestroy (GncJob *job)
CACHE_REMOVE (job->name);
CACHE_REMOVE (job->desc);
if (job->cust)
gncCustomerRemoveJob (job->cust, job);
switch (gncOwnerGetType (&(job->owner))) {
case GNC_OWNER_CUSTOMER:
gncCustomerRemoveJob (gncOwnerGetCustomer(&job->owner), job);
break;
case GNC_OWNER_VENDOR:
/* XXX */
break;
default:
}
remObj (job);
@@ -124,17 +129,34 @@ void gncJobSetGUID (GncJob *job, const GUID *guid)
addObj (job);
}
void gncJobSetCustomer (GncJob *job, GncCustomer *cust)
void gncJobSetOwner (GncJob *job, GncOwner *owner)
{
if (!job) return;
if (!cust) return;
if (cust == job->cust) return;
if (!owner) return;
if (gncOwnerEqual (owner, &(job->owner))) return;
/* XXX: Fail if we have ANY orders or invoices */
if (cust)
gncCustomerRemoveJob (job->cust, job);
job->cust = cust;
gncCustomerAddJob (cust, job);
switch (gncOwnerGetType (&(job->owner))) {
case GNC_OWNER_CUSTOMER:
gncCustomerRemoveJob (gncOwnerGetCustomer(&job->owner), job);
break;
case GNC_OWNER_VENDOR:
/* XXX */
break;
default:
}
gncOwnerCopy (owner, &(job->owner));
switch (gncOwnerGetType (&(job->owner))) {
case GNC_OWNER_CUSTOMER:
gncCustomerAddJob (gncOwnerGetCustomer(&job->owner), job);
break;
case GNC_OWNER_VENDOR:
/* XXX */
break;
default:
}
job->dirty = TRUE;
}
@@ -179,10 +201,10 @@ const char * gncJobGetDesc (GncJob *job)
return job->desc;
}
GncCustomer * gncJobGetCustomer (GncJob *job)
GncOwner * gncJobGetOwner (GncJob *job)
{
if (!job) return NULL;
return job->cust;
return &(job->owner);
}
const GUID * gncJobGetGUID (GncJob *job)

View File

@@ -1,6 +1,6 @@
/*
* gncJob.h -- the Core Job Interface
* Copyright (C) 2001 Derek Atkins
* Copyright (C) 2001, 2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
@@ -10,7 +10,7 @@
typedef struct _gncJob GncJob;
#include "gncAddress.h"
#include "gncCustomer.h"
#include "gncOwner.h"
#define GNC_JOB_MODULE_NAME "gncJob"
@@ -24,7 +24,7 @@ void gncJobDestroy (GncJob *job);
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 gncJobSetOwner (GncJob *job, GncOwner *owner);
void gncJobSetActive (GncJob *job, gboolean active);
void gncJobCommitEdit (GncJob *job);
@@ -36,7 +36,7 @@ const GUID * gncJobGetGUID (GncJob *job);
const char * gncJobGetID (GncJob *job);
const char * gncJobGetName (GncJob *job);
const char * gncJobGetDesc (GncJob *job);
GncCustomer * gncJobGetCustomer (GncJob *job);
GncOwner * gncJobGetOwner (GncJob *job);
gboolean gncJobGetActive (GncJob *job);
GncJob * gncJobLookup (GNCBook *book, const GUID *guid);

View File

@@ -1,6 +1,6 @@
/*
* gncOwner.c -- Business Interface: Object OWNERs
* Copyright (C) 2001 Derek Atkins
* Copyright (C) 2001, 2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
@@ -39,34 +39,34 @@ void gncOwnerInitVendor (GncOwner *owner, GncVendor *vendor)
owner->owner.vendor = vendor;
}
GncOwnerType gncOwnerGetType (GncOwner *owner)
GncOwnerType gncOwnerGetType (const GncOwner *owner)
{
if (!owner) return GNC_OWNER_NONE;
return owner->type;
}
gpointer gncOwnerGetUndefined (GncOwner *owner)
gpointer gncOwnerGetUndefined (const GncOwner *owner)
{
if (!owner) return NULL;
if (owner->type != GNC_OWNER_UNDEFINED) return NULL;
return owner->owner.undefined;
}
GncCustomer * gncOwnerGetCustomer (GncOwner *owner)
GncCustomer * gncOwnerGetCustomer (const GncOwner *owner)
{
if (!owner) return NULL;
if (owner->type != GNC_OWNER_CUSTOMER) return NULL;
return owner->owner.customer;
}
GncJob * gncOwnerGetJob (GncOwner *owner)
GncJob * gncOwnerGetJob (const GncOwner *owner)
{
if (!owner) return NULL;
if (owner->type != GNC_OWNER_JOB) return NULL;
return owner->owner.job;
}
GncVendor * gncOwnerGetVendor (GncOwner *owner)
GncVendor * gncOwnerGetVendor (const GncOwner *owner)
{
if (!owner) return NULL;
if (owner->type != GNC_OWNER_VENDOR) return NULL;
@@ -80,6 +80,13 @@ void gncOwnerCopy (const GncOwner *src, GncOwner *dest)
memcpy (dest, src, sizeof (*dest));
}
gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b)
{
if (!a || !b) return FALSE;
if (gncOwnerGetType (a) != gncOwnerGetType (b)) return FALSE;
return (a->owner.undefined == b->owner.undefined);
}
const char * gncOwnerGetName (GncOwner *owner)
{
if (!owner) return NULL;

View File

@@ -1,12 +1,14 @@
/*
* gncOwner.h -- Business Interface: Object OWNERs
* Copyright (C) 2001 Derek Atkins
* Copyright (C) 2001, 2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_OWNER_H_
#define GNC_OWNER_H_
typedef struct gnc_owner_s GncOwner;
#include "gncCustomer.h"
#include "gncJob.h"
#include "gncVendor.h"
@@ -19,7 +21,7 @@ typedef enum {
GNC_OWNER_VENDOR
} GncOwnerType;
typedef struct gnc_owner_s {
struct gnc_owner_s {
GncOwnerType type;
union {
gpointer undefined;
@@ -27,20 +29,21 @@ typedef struct gnc_owner_s {
GncJob * job;
GncVendor * vendor;
} owner;
} GncOwner;
};
void gncOwnerInitUndefined (GncOwner *owner, gpointer obj);
void gncOwnerInitCustomer (GncOwner *owner, GncCustomer *customer);
void gncOwnerInitJob (GncOwner *owner, GncJob *job);
void gncOwnerInitVendor (GncOwner *owner, GncVendor *vendor);
GncOwnerType gncOwnerGetType (GncOwner *owner);
gpointer gncOwnerGetUndefined (GncOwner *owner);
GncCustomer * gncOwnerGetCustomer (GncOwner *owner);
GncJob * gncOwnerGetJob (GncOwner *owner);
GncVendor * gncOwnerGetVendor (GncOwner *owner);
GncOwnerType gncOwnerGetType (const GncOwner *owner);
gpointer gncOwnerGetUndefined (const GncOwner *owner);
GncCustomer * gncOwnerGetCustomer (const GncOwner *owner);
GncJob * gncOwnerGetJob (const GncOwner *owner);
GncVendor * gncOwnerGetVendor (const GncOwner *owner);
void gncOwnerCopy (const GncOwner *src, GncOwner *dest);
gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b);
const char * gncOwnerGetName (GncOwner *owner);

View File

@@ -98,10 +98,13 @@ test_job (void)
}
{
GList *list;
GncOwner owner;
GncCustomer *cust = gncCustomerCreate (book);
gncOwnerInitCustomer (&owner, cust);
do_test (gncCustomerGetJoblist (cust, TRUE) == NULL, "empty list at start");
gncJobSetCustomer (job, cust);
gncJobSetOwner (job, &owner);
list = gncCustomerGetJoblist (cust, FALSE);
do_test (list != NULL, "added to cust");
do_test (g_list_length (list) == 1, "correct joblist length");

View File

@@ -25,8 +25,7 @@
(N_ "Test New Job Dialog")
(list "Extensions" "")
(lambda ()
(gnc:job-new #f (gnc:extensions-get-book)
#f))))
(gnc:job-new #f (gnc:extensions-get-book) #f))))
(define select-job-item
(gnc:make-menu-item (N_ "Test Job Selection Dialog")

View File

@@ -2,7 +2,7 @@
* dialog-job-select.c -- Job Selection Dialog for GNC Business Objects
*
* Written By: Derek Atkins <warlord@MIT.EDU>
* Copyright (C) 2001
* Copyright (C) 2001, 2002 Derek Atkins
*/
#include "config.h"
@@ -14,7 +14,6 @@
#include "gnc-gui-query.h"
#include "gncBusiness.h"
#include "gncCustomer.h"
#include "gncJob.h"
#include "dialog-job-select.h"
#include "dialog-job.h"
@@ -29,10 +28,10 @@ struct select_job_window {
GtkWidget * showjobs_check;
GNCBook * book;
GncCustomer * customer;
GncJob * job;
GncOwner owner;
const GncBusinessObject *job_type, *cust_type;
const GncBusinessObject *job_type, *owner_type;
};
@@ -49,13 +48,22 @@ update_job_select_picker (struct select_job_window *w)
gtk_list_clear_items (GTK_LIST (GTK_COMBO (w->job_combo)->list), 0, -1);
/* Get the list of objects */
if (w->customer == NULL) {
if (w->owner.owner.undefined == NULL) {
w->job = NULL;
} else {
/* Save the current job */
saved_job = w->job;
objs = gncCustomerGetJoblist (w->customer, show_all);
switch (gncOwnerGetType (&(w->owner))) {
case GNC_OWNER_CUSTOMER:
objs = gncCustomerGetJoblist (gncOwnerGetCustomer (&(w->owner)),
show_all);
break;
case GNC_OWNER_VENDOR:
/* XXX */
break;
default:
}
/* Build a list of strings (objs is pre-sorted, so keep the order!) */
for (iterator = objs; iterator; iterator = iterator->next) {
@@ -99,7 +107,7 @@ update_customer_select_picker (struct select_job_window *w)
{
GList *custs, *iterator;
GtkWidget *li;
GncCustomer * saved_cust;
GncOwner saved_owner;
gboolean show_all = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(w->showcust_check));
@@ -107,14 +115,14 @@ update_customer_select_picker (struct select_job_window *w)
gtk_list_clear_items (GTK_LIST (GTK_COMBO (w->customer_combo)->list), 0, -1);
/* Save the existing selection */
saved_cust = w->customer;
gncOwnerCopy (&(w->owner), &saved_owner);
/* Get the list of objects */
custs = (*(w->cust_type->get_list))(w->book, show_all);
custs = (*(w->owner_type->get_list))(w->book, 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);
const gchar *label = (*(w->owner_type->printable))(iterator->data);
li = gtk_list_item_new_with_label (label);
gtk_object_set_data (GTK_OBJECT (li), "item-list-pointer", iterator->data);
@@ -123,18 +131,18 @@ update_customer_select_picker (struct select_job_window *w)
}
/* Revert the saved customer */
w->customer = saved_cust;
gncOwnerCopy (&saved_owner, &(w->owner));
if (! custs) {
/* no customers -- update the job picker (it will clear itself) */
w->customer = NULL;
w->owner.owner.undefined = NULL;
update_job_select_picker (w);
} else if (g_list_index (custs, w->customer) == -1) {
} else if (g_list_index (custs, w->owner.owner.undefined) == -1) {
/* customer doesn't exist anymore!?! Clear out the job, too */
w->customer = custs->data;
w->owner.owner.undefined = custs->data;
update_job_select_picker (w);
}
@@ -142,8 +150,8 @@ update_customer_select_picker (struct select_job_window *w)
{
const char * label;
if (w->customer)
label = (*(w->cust_type->printable))(w->customer);
if (w->owner.owner.undefined)
label = (*(w->owner_type->printable))(w->owner.owner.undefined);
else
label = "";
@@ -162,7 +170,8 @@ select_job_customer_changed_cb(GtkList *list, GtkWidget *li,
if (!li)
return;
w->customer = gtk_object_get_data (GTK_OBJECT (li), "item-list-pointer");
w->owner.owner.undefined =
gtk_object_get_data (GTK_OBJECT (li), "item-list-pointer");
w->job = NULL;
update_job_select_picker (w);
}
@@ -195,10 +204,10 @@ 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->book, w->customer);
GncJob * new_selection = gnc_job_new (w->dialog, w->book, &(w->owner));
if (new_selection) {
w->customer = gncJobGetCustomer (new_selection);
gncOwnerCopy (gncJobGetOwner (new_selection), &(w->owner));
update_customer_select_picker (w);
w->job = new_selection;
update_job_select_picker (w);
@@ -214,7 +223,7 @@ gnc_ui_select_job_edit_cb(GtkButton * button, gpointer user_data)
return;
gnc_job_edit (w->dialog, w->job);
w->customer = gncJobGetCustomer (w->job);
gncOwnerCopy (gncJobGetOwner (w->job), &(w->owner));
update_customer_select_picker (w);
update_job_select_picker (w);
}
@@ -255,22 +264,48 @@ select_job_close (GnomeDialog *dialog, gpointer data)
GncJob *
gnc_ui_select_job_new (GtkWidget * parent, GNCBook *book,
GncCustomer *cust, GncJob *job)
GncOwner *ownerp, GncJob *job)
{
struct select_job_window * win =
g_new0(struct select_job_window, 1);
struct select_job_window * win;
GladeXML *xml;
GncJob *retval;
GtkWidget *owner_label;
const char * type_name;
g_return_val_if_fail (book != NULL, NULL);
win = g_new0(struct select_job_window, 1);
win->book = book;
win->cust_type = gncBusinessLookup (GNC_CUSTOMER_MODULE_NAME);
if (ownerp) {
g_return_val_if_fail ((gncOwnerGetType (ownerp) == GNC_OWNER_CUSTOMER) ||
(gncOwnerGetType (ownerp) == GNC_OWNER_VENDOR),
NULL);
gncOwnerCopy (ownerp, &(win->owner));
} else
gncOwnerInitCustomer (&(win->owner), NULL); /* XXX */
switch (gncOwnerGetType (&(win->owner))) {
case GNC_OWNER_CUSTOMER:
type_name = GNC_CUSTOMER_MODULE_NAME;
break;
case GNC_OWNER_VENDOR:
type_name = GNC_VENDOR_MODULE_NAME;
break;
default:
g_warning ("Cannot handle this owner type");
return NULL;
}
win->owner_type = gncBusinessLookup (type_name);
win->job_type = gncBusinessLookup (GNC_JOB_MODULE_NAME);
xml = gnc_glade_xml_new ("job.glade",
"Job Selector Dialog");
owner_label = glade_xml_get_widget (xml, "owner_label");
gtk_label_set_text (GTK_LABEL (owner_label),
gncBusinessGetTypeLabel (type_name));
/* Grab the widgets */
win->dialog = glade_xml_get_widget (xml, "Job Selector Dialog");
@@ -322,7 +357,6 @@ gnc_ui_select_job_new (GtkWidget * parent, GNCBook *book,
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);

View File

@@ -13,6 +13,6 @@
*/
GncJob *
gnc_ui_select_job_new (GtkWidget * parent, GNCBook *book,
GncCustomer *cust, GncJob *job);
GncOwner *owner, GncJob *job);
#endif /* GNC_DIALOG_JOB_SELECT_H_ */

View File

@@ -16,13 +16,11 @@
#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 "business-utils.h"
#include "dialog-job-select.h"
#include "dialog-job.h"
@@ -35,11 +33,6 @@ typedef enum
EDIT_JOB
} JobDialogType;
struct _job_select_window {
GtkWidget * toplevel;
GNCBook * book;
};
typedef struct _job_window {
GtkWidget * dialog;
GtkWidget * id_entry;
@@ -54,7 +47,7 @@ typedef struct _job_window {
GNCBook * book;
GncJob * created_job;
GNCGeneralSelectGetStringCB cust_print;
GncOwner owner;
} JobWindow;
@@ -79,11 +72,10 @@ static void gnc_ui_to_job (JobWindow *jw, GncJob *job)
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);
GncOwner * old = gncJobGetOwner (job);
gnc_owner_get_owner (jw->cust_edit, &(jw->owner));
if (! gncOwnerEqual (old, &(jw->owner)))
gncJobSetOwner (job, &(jw->owner));
}
gncJobCommitEdit (job);
@@ -94,8 +86,7 @@ static void
gnc_job_window_ok_cb (GtkWidget *widget, gpointer data)
{
JobWindow *jw = data;
char *res;
GncCustomer *cust;
const char *res;
/* Check for valid id */
res = gtk_entry_get_text (GTK_ENTRY (jw->id_entry));
@@ -113,10 +104,11 @@ gnc_job_window_ok_cb (GtkWidget *widget, gpointer data)
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.");
/* Check for owner */
gnc_owner_get_owner (jw->cust_edit, &(jw->owner));
res = gncOwnerGetName (&(jw->owner));
if (res == NULL || safe_strcmp (res, "") == 0) {
const char *message = _("You must choose an owner for this job.");
gnc_error_dialog_parented(GTK_WINDOW(jw->dialog), message);
return;
}
@@ -247,17 +239,18 @@ gnc_job_window_refresh_handler (GHashTable *changes, gpointer user_data)
}
static JobWindow *
gnc_job_new_window (GtkWidget *parent, GNCBook *bookp, GncCustomer *cust,
gnc_job_new_window (GtkWidget *parent, GNCBook *bookp, GncOwner *owner,
GncJob *job)
{
JobWindow *jw;
GladeXML *xml;
GtkWidget *cust_box;
GtkWidget *owner_box, *owner_label;
GnomeDialog *jwd;
GtkObject *jwo;
jw = g_new0 (JobWindow, 1);
jw->book = bookp;
gncOwnerCopy (owner, &(jw->owner)); /* save it off now, we know it's valid */
/* Load the XML */
xml = gnc_glade_xml_new ("job.glade", "Job Dialog");
@@ -281,7 +274,8 @@ gnc_job_new_window (GtkWidget *parent, GNCBook *bookp, GncCustomer *cust,
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");
owner_box = glade_xml_get_widget (xml, "customer_hbox");
owner_label = glade_xml_get_widget (xml, "owner_label");
/* Setup signals (XXX) */
gnome_dialog_button_connect (jwd, 0,
@@ -300,13 +294,6 @@ gnc_job_new_window (GtkWidget *parent, GNCBook *bookp, GncCustomer *cust,
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));
@@ -321,10 +308,8 @@ gnc_job_new_window (GtkWidget *parent, GNCBook *bookp, GncCustomer *cust,
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, bookp);
gtk_box_pack_start(GTK_BOX(cust_box), jw->cust_edit, TRUE, TRUE, 0);
jw->cust_edit = gnc_owner_edit_create (owner_label, owner_box,
bookp, owner);
gtk_entry_set_text (GTK_ENTRY (jw->id_entry), gncJobGetID (job));
gtk_entry_set_editable (GTK_ENTRY (jw->id_entry), FALSE);
@@ -332,8 +317,6 @@ gnc_job_new_window (GtkWidget *parent, GNCBook *bookp, GncCustomer *cust,
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,
@@ -341,19 +324,16 @@ gnc_job_new_window (GtkWidget *parent, GNCBook *bookp, GncCustomer *cust,
jw);
} else {
job = gncJobCreate (bookp);
gncJobSetOwner (job, owner);
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, bookp);
gtk_box_pack_start(GTK_BOX(cust_box), jw->cust_edit, TRUE, TRUE, 0);
jw->cust_edit = gnc_owner_select_create (owner_label, owner_box,
bookp, owner);
gtk_entry_set_text (GTK_ENTRY (jw->id_entry),
g_strdup_printf ("%.6d", gncJobNextID(bookp)));
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,
@@ -371,15 +351,24 @@ gnc_job_new_window (GtkWidget *parent, GNCBook *bookp, GncCustomer *cust,
}
GncJob *
gnc_job_new (GtkWidget *parent, GNCBook *bookp, GncCustomer *customer)
gnc_job_new (GtkWidget *parent, GNCBook *bookp, GncOwner *ownerp)
{
JobWindow *jw;
GncJob *created_job = NULL;
GncOwner owner;
/* Make sure required options exist */
if (!bookp) return NULL;
jw = gnc_job_new_window (parent, bookp, customer, NULL);
if (ownerp) {
g_return_val_if_fail ((gncOwnerGetType (ownerp) == GNC_OWNER_CUSTOMER) ||
(gncOwnerGetType (ownerp) == GNC_OWNER_VENDOR),
NULL);
gncOwnerCopy (ownerp, &owner);
} else
gncOwnerInitCustomer (&owner, NULL); /* XXX */
jw = gnc_job_new_window (parent, bookp, &owner, NULL);
gtk_signal_connect (GTK_OBJECT (jw->dialog), "close",
GTK_SIGNAL_FUNC (gnc_job_on_close_cb), &created_job);
@@ -399,7 +388,7 @@ gnc_job_edit (GtkWidget *parent, GncJob *job)
if (!job) return;
jw = gnc_job_new_window (parent, gncJobGetBook(job),
gncJobGetCustomer(job), job);
gncJobGetOwner(job), job);
gtk_signal_connect (GTK_OBJECT (jw->dialog), "close",
GTK_SIGNAL_FUNC (gnc_job_on_close_cb), NULL);
@@ -413,40 +402,6 @@ gnc_job_edit (GtkWidget *parent, GncJob *job)
/* Functions for widgets for job selection */
#if 0
static gpointer gnc_job_edit_new_cb (gpointer arg)
{
struct _job_select_window *sw = arg;
return gnc_job_new (sw->toplevel, sw->book, 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);
}
#endif
gpointer gnc_job_edit_new_select (gpointer job, GtkWidget *toplevel,
GncCustomer *cust)
{
GNCBook *book;
GncJob *j = job;
if (!cust) return NULL;
book = gncCustomerGetBook (cust);
return
gnc_ui_select_job_new (toplevel, book, cust, j);
}
gpointer
gnc_job_edit_new_edit (gpointer book, gpointer jobp, GtkWidget *toplevel)
{
@@ -464,12 +419,15 @@ gnc_job_select_new_select (gpointer bookp, gpointer jobp, GtkWidget *parent)
{
GncJob *j = jobp;
GNCBook *book = bookp;
GncCustomer *cust = NULL;
GncOwner owner, *ownerp;
if (!book) return NULL;
if (j)
cust = gncJobGetCustomer (j);
if (j) {
ownerp = gncJobGetOwner (j);
gncOwnerCopy (ownerp, &owner);
} else
gncOwnerInitCustomer (&owner, NULL); /* XXX */
return gnc_ui_select_job_new (parent, book, cust, j);
return gnc_ui_select_job_new (parent, book, &owner, j);
}

View File

@@ -9,7 +9,7 @@
#define GNC_DIALOG_JOB_H_
/* Functions to create and edit jobs */
GncJob * gnc_job_new (GtkWidget *parent, GNCBook *book, GncCustomer *cust);
GncJob * gnc_job_new (GtkWidget *parent, GNCBook *book, GncOwner *owner);
void gnc_job_edit (GtkWidget *parent, GncJob *job);
/* Callback to choose a job from a customer, for use with the

View File

@@ -382,8 +382,7 @@ gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
if (type == NEW_ORDER) {
order = gncOrderCreate (bookp);
gncOrderSetOwner (order, owner);
} else
owner = gncOrderGetOwner (order); /* Overwrite what was passed in */
}
/* Save this for later */
gncOwnerCopy (owner, &(ow->owner));
@@ -617,7 +616,7 @@ gnc_order_edit (GtkWidget *parent, GncOrder *order)
}
ow = gnc_order_new_window (parent, gncOrderGetBook(order), type, order,
NULL);
gncOrderGetOwner (order));
gtk_signal_connect (GTK_OBJECT (ow->dialog), "close",
GTK_SIGNAL_FUNC (gnc_order_on_close_cb),

View File

@@ -113,8 +113,8 @@
'<gnc:GncJob*>
"gnc_job_new"
'((<gnc:UIWidget> parent) (<gnc:Book*> book)
(<gnc:GncCustomer*> default_customer))
"Dialog: create a new GncJob. Parent and Customer may be NULL.")
(<gnc:GncOwner*> default_owner))
"Dialog: create a new GncJob. Parent and Owner may be NULL.")
(gw:wrap-function
ws
@@ -134,8 +134,8 @@
'<gnc:GncJob*>
"gnc_ui_select_job_new"
'((<gnc:UIWidget> parent) (<gnc:Book*> book)
(<gnc:GncCustomer*> cust) (<gnc:GncJob*> job))
"Dialog: Select a new job. Parent and Customer may be NULL.")
(<gnc:GncOwner*> owner) (<gnc:GncJob*> job))
"Dialog: Select a new job. Parent and Owner may be NULL.")
;;
;; dialog-order.h

View File

@@ -98,13 +98,13 @@
<class>GtkFrame</class>
<name>frame1</name>
<border_width>3</border_width>
<label>Identification</label>
<label>Job Information</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
@@ -129,7 +129,7 @@
<widget>
<class>GtkLabel</class>
<name>label1</name>
<label>Job Number: </label>
<label>Job Number</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
@@ -145,8 +145,9 @@
<widget>
<class>GtkLabel</class>
<name>label2</name>
<label>Customer: </label>
<name>label3</name>
<width>100</width>
<label>Job Name</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
@@ -164,7 +165,8 @@
<widget>
<class>GtkVBox</class>
<name>vbox12</name>
<homogeneous>False</homogeneous>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
@@ -188,6 +190,104 @@
</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>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame2</name>
<border_width>3</border_width>
<label>Owner 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>hbox9</name>
<border_width>3</border_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>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>owner_label</name>
<label>(owner)</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>
<width>100</width>
<label>Reference</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>True</expand>
<fill>True</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>customer_hbox</name>
@@ -203,103 +303,6 @@
<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>
@@ -311,8 +314,8 @@
<text></text>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
@@ -457,6 +460,7 @@
<widget>
<class>GtkHBox</class>
<name>hbox7</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
@@ -468,6 +472,7 @@
<widget>
<class>GtkTable</class>
<name>table2</name>
<border_width>3</border_width>
<rows>2</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
@@ -482,7 +487,7 @@
<widget>
<class>GtkLabel</class>
<name>label6</name>
<label>Job:</label>
<label>Job Name</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
@@ -507,8 +512,8 @@
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>Customer:</label>
<name>owner_label</name>
<label>(owner)</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
@@ -658,7 +663,7 @@
<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>
<label>Show All Owners</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>