mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* business-options: (new files) implement owner/customer/vendor
options to plug into the options dialog. * businessmod-gnome: initialize business options * business-utils: pack into box FALSE, not TRUE * owner-report: put the company into the options dialog instead of hiding it. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7084 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
74388444a2
commit
49809dd904
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2002-07-04 Derek Atkins <derek@ihtfp.com>
|
||||||
|
|
||||||
|
* option-util.c: add gnc_option_get_option_data() function
|
||||||
|
* dialog-options: publish gnc_options_dialog_changed_internal() so
|
||||||
|
pluggible options can set the flag, too.
|
||||||
|
|
||||||
|
* business-options: (new files) implement owner/customer/vendor
|
||||||
|
options to plug into the options dialog.
|
||||||
|
* businessmod-gnome: initialize business options
|
||||||
|
* business-utils: pack into box FALSE, not TRUE
|
||||||
|
* owner-report: put the company into the options dialog instead of
|
||||||
|
hiding it.
|
||||||
|
|
||||||
2002-07-03 Derek Atkins <derek@ihtfp.com>
|
2002-07-03 Derek Atkins <derek@ihtfp.com>
|
||||||
|
|
||||||
* moved receivable and payable aging reports to business-reports;
|
* moved receivable and payable aging reports to business-reports;
|
||||||
|
@ -28,6 +28,7 @@ AM_CFLAGS = \
|
|||||||
|
|
||||||
libgncmod_business_gnome_la_SOURCES = \
|
libgncmod_business_gnome_la_SOURCES = \
|
||||||
businessmod-gnome.c \
|
businessmod-gnome.c \
|
||||||
|
business-options.c \
|
||||||
business-urls.c \
|
business-urls.c \
|
||||||
business-utils.c \
|
business-utils.c \
|
||||||
dialog-billterms.c \
|
dialog-billterms.c \
|
||||||
@ -43,6 +44,7 @@ libgncmod_business_gnome_la_SOURCES = \
|
|||||||
gnc-business-utils.c
|
gnc-business-utils.c
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
|
business-options.h \
|
||||||
business-urls.h \
|
business-urls.h \
|
||||||
business-utils.h \
|
business-utils.h \
|
||||||
dialog-billterms.h \
|
dialog-billterms.h \
|
||||||
|
296
src/business/business-gnome/business-options.c
Normal file
296
src/business/business-gnome/business-options.c
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
/*
|
||||||
|
* business-options.c -- Initialize Business Options
|
||||||
|
*
|
||||||
|
* Written By: Derek Atkins <warlord@MIT.EDU>
|
||||||
|
* Copyright (C) 2002 Derek Atkins
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gnome.h>
|
||||||
|
#include <g-wrap-wct.h>
|
||||||
|
#include <libguile.h>
|
||||||
|
|
||||||
|
#include "gnc-ui-util.h"
|
||||||
|
#include "gnc-engine-util.h"
|
||||||
|
#include "option-util.h"
|
||||||
|
|
||||||
|
#include "dialog-options.h"
|
||||||
|
#include "business-options.h"
|
||||||
|
#include "business-utils.h"
|
||||||
|
|
||||||
|
static int
|
||||||
|
owner_changed_cb (GtkWidget *widget, gpointer data)
|
||||||
|
{
|
||||||
|
GNCOption *option = data;
|
||||||
|
|
||||||
|
gnc_option_set_changed (option, TRUE);
|
||||||
|
gnc_option_call_option_widget_changed_proc (option);
|
||||||
|
gnc_options_dialog_changed_internal (widget);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
create_owner_widget (GNCOption *option, GncOwnerType type, GtkWidget *hbox)
|
||||||
|
{
|
||||||
|
GtkWidget *widget;
|
||||||
|
GncOwner owner;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case GNC_OWNER_CUSTOMER:
|
||||||
|
gncOwnerInitCustomer (&owner, NULL);
|
||||||
|
break;
|
||||||
|
case GNC_OWNER_VENDOR:
|
||||||
|
gncOwnerInitVendor (&owner, NULL);
|
||||||
|
break;
|
||||||
|
case GNC_OWNER_JOB:
|
||||||
|
gncOwnerInitJob (&owner, NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget = gnc_owner_select_create (NULL, hbox,
|
||||||
|
gnc_get_current_book (), &owner);
|
||||||
|
gnc_option_set_widget (option, widget);
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT (widget), "changed",
|
||||||
|
GTK_SIGNAL_FUNC (owner_changed_cb), option);
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
make_name_label (char *name)
|
||||||
|
{
|
||||||
|
GtkWidget *label;
|
||||||
|
gchar *colon_name;
|
||||||
|
|
||||||
|
colon_name = g_strconcat (name, ":", NULL);
|
||||||
|
label = gtk_label_new (colon_name);
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
||||||
|
g_free (colon_name);
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
/* "Owner" Option functions */
|
||||||
|
|
||||||
|
|
||||||
|
static GncOwnerType
|
||||||
|
get_owner_type_from_option (GNCOption *option)
|
||||||
|
{
|
||||||
|
SCM odata = gnc_option_get_option_data (option);
|
||||||
|
SCM conv_func;
|
||||||
|
|
||||||
|
conv_func = gh_eval_str ("gw:enum-<gnc:GncOwnerType>-val->int");
|
||||||
|
odata = gh_call1 (conv_func, odata);
|
||||||
|
|
||||||
|
return gh_scm2long (odata);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to set the UI widget based upon the option */
|
||||||
|
static GtkWidget *
|
||||||
|
owner_set_widget (GNCOption *option, GtkBox *page_box,
|
||||||
|
GtkTooltips *tooltips,
|
||||||
|
char *name, char *documentation,
|
||||||
|
/* Return values */
|
||||||
|
GtkWidget **enclosing, gboolean *packed)
|
||||||
|
{
|
||||||
|
GtkWidget *value;
|
||||||
|
GtkWidget *label;
|
||||||
|
|
||||||
|
*enclosing = gtk_hbox_new (FALSE, 5);
|
||||||
|
label = make_name_label (name);
|
||||||
|
gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
value = create_owner_widget (option, get_owner_type_from_option (option),
|
||||||
|
*enclosing);
|
||||||
|
|
||||||
|
gnc_option_set_ui_value (option, FALSE);
|
||||||
|
|
||||||
|
gtk_widget_show_all (*enclosing);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to set the UI Value for a particular option */
|
||||||
|
static gboolean
|
||||||
|
owner_set_value (GNCOption *option, gboolean use_default,
|
||||||
|
GtkWidget *widget, SCM value)
|
||||||
|
{
|
||||||
|
GncOwner owner_def;
|
||||||
|
GncOwner *owner;
|
||||||
|
|
||||||
|
if (!gw_wcp_p (value))
|
||||||
|
scm_misc_error("business_options:owner_set_value",
|
||||||
|
"Item is not a gw:wcp.", value);
|
||||||
|
|
||||||
|
owner = gw_wcp_get_ptr (value);
|
||||||
|
|
||||||
|
/* XXX: should we verify that the owner type is correct? */
|
||||||
|
if (!owner) {
|
||||||
|
owner_def.type = get_owner_type_from_option (option);
|
||||||
|
owner_def.owner.undefined = NULL;
|
||||||
|
owner = &owner_def;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget = gnc_option_get_widget (option);
|
||||||
|
gnc_owner_set_owner (widget, owner);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to get the UI Value for a particular option */
|
||||||
|
static SCM
|
||||||
|
owner_get_value (GNCOption *option, GtkWidget *widget)
|
||||||
|
{
|
||||||
|
static GncOwner owner; /* XXX: might cause trouble? */
|
||||||
|
GncOwnerType type;
|
||||||
|
|
||||||
|
type = get_owner_type_from_option (option);
|
||||||
|
owner.type = type;
|
||||||
|
gnc_owner_get_owner (widget, &owner);
|
||||||
|
|
||||||
|
return gw_wcp_assimilate_ptr (&owner, gh_eval_str("<gnc:GncOwner*>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
/* "Customer" Option functions */
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to set the UI widget based upon the option */
|
||||||
|
static GtkWidget *
|
||||||
|
customer_set_widget (GNCOption *option, GtkBox *page_box,
|
||||||
|
GtkTooltips *tooltips,
|
||||||
|
char *name, char *documentation,
|
||||||
|
/* Return values */
|
||||||
|
GtkWidget **enclosing, gboolean *packed)
|
||||||
|
{
|
||||||
|
GtkWidget *value;
|
||||||
|
GtkWidget *label;
|
||||||
|
|
||||||
|
*enclosing = gtk_hbox_new (FALSE, 5);
|
||||||
|
label = make_name_label (name);
|
||||||
|
gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
value = create_owner_widget (option, GNC_OWNER_CUSTOMER, *enclosing);
|
||||||
|
|
||||||
|
gnc_option_set_ui_value (option, FALSE);
|
||||||
|
|
||||||
|
gtk_widget_show_all (*enclosing);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to set the UI Value for a particular option */
|
||||||
|
static gboolean
|
||||||
|
customer_set_value (GNCOption *option, gboolean use_default,
|
||||||
|
GtkWidget *widget, SCM value)
|
||||||
|
{
|
||||||
|
GncOwner owner;
|
||||||
|
GncCustomer *customer;
|
||||||
|
|
||||||
|
if (!gw_wcp_p (value))
|
||||||
|
scm_misc_error("business_options:customer_set_value",
|
||||||
|
"Item is not a gw:wcp.", value);
|
||||||
|
|
||||||
|
customer = gw_wcp_get_ptr (value);
|
||||||
|
gncOwnerInitCustomer (&owner, customer);
|
||||||
|
|
||||||
|
widget = gnc_option_get_widget (option);
|
||||||
|
gnc_owner_set_owner (widget, &owner);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to get the UI Value for a particular option */
|
||||||
|
static SCM
|
||||||
|
customer_get_value (GNCOption *option, GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GncOwner owner;
|
||||||
|
|
||||||
|
gnc_owner_get_owner (widget, &owner);
|
||||||
|
|
||||||
|
return gw_wcp_assimilate_ptr (owner.owner.undefined,
|
||||||
|
gh_eval_str("<gnc:GncCustomer*>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
/* "Vendor" Option functions */
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to set the UI widget based upon the option */
|
||||||
|
static GtkWidget *
|
||||||
|
vendor_set_widget (GNCOption *option, GtkBox *page_box,
|
||||||
|
GtkTooltips *tooltips,
|
||||||
|
char *name, char *documentation,
|
||||||
|
/* Return values */
|
||||||
|
GtkWidget **enclosing, gboolean *packed)
|
||||||
|
{
|
||||||
|
GtkWidget *value;
|
||||||
|
GtkWidget *label;
|
||||||
|
|
||||||
|
*enclosing = gtk_hbox_new (FALSE, 5);
|
||||||
|
label = make_name_label (name);
|
||||||
|
gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
value = create_owner_widget (option, GNC_OWNER_VENDOR, *enclosing);
|
||||||
|
|
||||||
|
gnc_option_set_ui_value (option, FALSE);
|
||||||
|
|
||||||
|
gtk_widget_show_all (*enclosing);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to set the UI Value for a particular option */
|
||||||
|
static gboolean
|
||||||
|
vendor_set_value (GNCOption *option, gboolean use_default,
|
||||||
|
GtkWidget *widget, SCM value)
|
||||||
|
{
|
||||||
|
GncOwner owner;
|
||||||
|
GncVendor *vendor;
|
||||||
|
|
||||||
|
if (!gw_wcp_p (value))
|
||||||
|
scm_misc_error("business_options:vendor_set_value",
|
||||||
|
"Item is not a gw:wcp.", value);
|
||||||
|
|
||||||
|
vendor = gw_wcp_get_ptr (value);
|
||||||
|
gncOwnerInitVendor (&owner, vendor);
|
||||||
|
|
||||||
|
widget = gnc_option_get_widget (option);
|
||||||
|
gnc_owner_set_owner (widget, &owner);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to get the UI Value for a particular option */
|
||||||
|
static SCM
|
||||||
|
vendor_get_value (GNCOption *option, GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GncOwner owner;
|
||||||
|
|
||||||
|
gnc_owner_get_owner (widget, &owner);
|
||||||
|
|
||||||
|
return gw_wcp_assimilate_ptr (owner.owner.undefined,
|
||||||
|
gh_eval_str("<gnc:GncVendor*>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
gnc_business_options_initialize (void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
static GNCOptionDef_t options[] = {
|
||||||
|
{ "owner", owner_set_widget, owner_set_value, owner_get_value },
|
||||||
|
{ "customer", customer_set_widget, customer_set_value,
|
||||||
|
customer_get_value },
|
||||||
|
{ "vendor", vendor_set_widget, vendor_set_value, vendor_get_value },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; options[i].option_name; i++)
|
||||||
|
gnc_options_ui_register_option (&(options[i]));
|
||||||
|
}
|
13
src/business/business-gnome/business-options.h
Normal file
13
src/business/business-gnome/business-options.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* business-options.h -- Initialize the Business Options
|
||||||
|
*
|
||||||
|
* Written By: Derek Atkins <warlord@MIT.EDU>
|
||||||
|
* Copyright (C) 2002
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GNC_BUSINESS_OPTIONS_H_
|
||||||
|
#define GNC_BUSINESS_OPTIONS_H_
|
||||||
|
|
||||||
|
void gnc_business_options_initialize (void);
|
||||||
|
|
||||||
|
#endif /* GNC_BUSINESS_OPTIONS_H_ */
|
@ -89,7 +89,7 @@ static GtkWidget * gnc_owner_new (GtkWidget *label, GtkWidget *hbox,
|
|||||||
|
|
||||||
gnc_general_search_set_selected (GNC_GENERAL_SEARCH (edit),
|
gnc_general_search_set_selected (GNC_GENERAL_SEARCH (edit),
|
||||||
owner->owner.undefined);
|
owner->owner.undefined);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), edit, FALSE, FALSE, 0);
|
||||||
if (label)
|
if (label)
|
||||||
gtk_label_set_text (GTK_LABEL (label), gncObjectGetTypeLabel (type_name));
|
gtk_label_set_text (GTK_LABEL (label), gncObjectGetTypeLabel (type_name));
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "search-core-type.h"
|
#include "search-core-type.h"
|
||||||
#include "search-owner.h"
|
#include "search-owner.h"
|
||||||
#include "gncOwner.h"
|
#include "gncOwner.h"
|
||||||
|
#include "business-options.h"
|
||||||
#include "business-urls.h"
|
#include "business-urls.h"
|
||||||
|
|
||||||
/* version of the gnc module system interface we require */
|
/* version of the gnc module system interface we require */
|
||||||
@ -78,6 +79,7 @@ libgncmod_business_gnome_LTX_gnc_module_init(int refcount)
|
|||||||
gnc_search_core_register_type (GNC_OWNER_MODULE_NAME,
|
gnc_search_core_register_type (GNC_OWNER_MODULE_NAME,
|
||||||
(GNCSearchCoreNew) gnc_search_owner_new);
|
(GNCSearchCoreNew) gnc_search_owner_new);
|
||||||
gnc_business_urls_initialize ();
|
gnc_business_urls_initialize ();
|
||||||
|
gnc_business_options_initialize ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
(define acct-string (N_ "Account"))
|
(define acct-string (N_ "Account"))
|
||||||
(define owner-string (N_ "Company"))
|
(define owner-string (N_ "Company"))
|
||||||
|
(define owner-page gnc:pagename-general)
|
||||||
|
|
||||||
(define-macro (addto! alist element)
|
(define-macro (addto! alist element)
|
||||||
`(set! ,alist (cons ,element ,alist)))
|
`(set! ,alist (cons ,element ,alist)))
|
||||||
@ -257,7 +258,8 @@
|
|||||||
(gnc:register-option gnc:*report-options* new-option))
|
(gnc:register-option gnc:*report-options* new-option))
|
||||||
|
|
||||||
(gnc:register-inv-option
|
(gnc:register-inv-option
|
||||||
(gnc:make-owner-option "__reg" owner-string "" ""
|
(gnc:make-owner-option owner-page owner-string "v"
|
||||||
|
(N_ "The company for this report")
|
||||||
(lambda () #f) #f owner-type))
|
(lambda () #f) #f owner-type))
|
||||||
|
|
||||||
(gnc:register-inv-option
|
(gnc:register-inv-option
|
||||||
@ -295,8 +297,8 @@
|
|||||||
|
|
||||||
(gnc:register-inv-option
|
(gnc:register-inv-option
|
||||||
(gnc:make-string-option
|
(gnc:make-string-option
|
||||||
(N_ "Display") (N_ "Today Date Format")
|
gnc:pagename-general (N_ "Today Date Format")
|
||||||
"v" (N_ "The format for the date->string conversion for today's date.")
|
"p" (N_ "The format for the date->string conversion for today's date.")
|
||||||
"~B ~e, ~Y"))
|
"~B ~e, ~Y"))
|
||||||
|
|
||||||
(gnc:options-set-default-section gnc:*report-options* "General")
|
(gnc:options-set-default-section gnc:*report-options* "General")
|
||||||
@ -429,7 +431,7 @@
|
|||||||
(query (gnc:malloc-query))
|
(query (gnc:malloc-query))
|
||||||
(account-list (opt-val acct-string acct-string))
|
(account-list (opt-val acct-string acct-string))
|
||||||
(account #f)
|
(account #f)
|
||||||
(owner (opt-val "__reg" owner-string))
|
(owner (opt-val owner-page owner-string))
|
||||||
(report-date (gnc:timepair-end-day-time
|
(report-date (gnc:timepair-end-day-time
|
||||||
(gnc:date-option-absolute-time
|
(gnc:date-option-absolute-time
|
||||||
(opt-val gnc:pagename-general (N_ "To")))))
|
(opt-val gnc:pagename-general (N_ "To")))))
|
||||||
@ -477,7 +479,7 @@
|
|||||||
|
|
||||||
(gnc:html-document-add-object!
|
(gnc:html-document-add-object!
|
||||||
document
|
document
|
||||||
(make-myname-table (opt-val "Display" "Today Date Format")))
|
(make-myname-table (opt-val gnc:pagename-general (N_ "Today Date Format"))))
|
||||||
|
|
||||||
(gnc:html-document-add-object!
|
(gnc:html-document-add-object!
|
||||||
document
|
document
|
||||||
@ -534,20 +536,22 @@
|
|||||||
(gnc:define-report
|
(gnc:define-report
|
||||||
'version 1
|
'version 1
|
||||||
'name (N_ "Customer Report")
|
'name (N_ "Customer Report")
|
||||||
|
'menu-path (list gnc:menuname-business-reports)
|
||||||
'options-generator customer-options-generator
|
'options-generator customer-options-generator
|
||||||
'renderer reg-renderer
|
'renderer reg-renderer
|
||||||
'in-menu? #f)
|
'in-menu? #t)
|
||||||
|
|
||||||
(gnc:define-report
|
(gnc:define-report
|
||||||
'version 1
|
'version 1
|
||||||
'name (N_ "Vendor Report")
|
'name (N_ "Vendor Report")
|
||||||
|
'menu-path (list gnc:menuname-business-reports)
|
||||||
'options-generator vendor-options-generator
|
'options-generator vendor-options-generator
|
||||||
'renderer reg-renderer
|
'renderer reg-renderer
|
||||||
'in-menu? #f)
|
'in-menu? #t)
|
||||||
|
|
||||||
(define (owner-report-create-internal report-name owner account)
|
(define (owner-report-create-internal report-name owner account)
|
||||||
(let* ((options (gnc:make-report-options report-name))
|
(let* ((options (gnc:make-report-options report-name))
|
||||||
(owner-op (gnc:lookup-option options "__reg" owner-string))
|
(owner-op (gnc:lookup-option options owner-page owner-string))
|
||||||
(account-op (gnc:lookup-option options acct-string acct-string)))
|
(account-op (gnc:lookup-option options acct-string acct-string)))
|
||||||
|
|
||||||
(gnc:option-set-value owner-op owner)
|
(gnc:option-set-value owner-op owner)
|
||||||
|
Loading…
Reference in New Issue
Block a user