gnucash/libgnucash/app-utils/option-util.h

286 lines
11 KiB
C
Raw Normal View History

/********************************************************************\
* option-util.h -- GNOME<->guile option interface *
* Copyright (C) 1998,1999 Linas Vepstas *
* Copyright (C) 2000 Dave Peticolas *
2017-11-13 14:10:39 -06:00
* Copyright (C) 2017 Aaron Laws *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
\********************************************************************/
#ifndef OPTION_UTIL_H
#define OPTION_UTIL_H
#include <glib.h>
#include <libguile.h>
#include "guile-mappings.h"
#include "gnc-commodity.h"
#include "gnc-engine-guile.h"
#include "qof.h"
typedef struct gnc_option GNCOption;
typedef struct gnc_option_section GNCOptionSection;
/* typedef struct gnc_option_db GNCOptionDB is in qof-book.h */
typedef int GNCOptionDBHandle;
typedef SCM (*GNCOptionGetUIValue) (GNCOption *option);
typedef void (*GNCOptionSetUIValue) (GNCOption *option,
gboolean use_default);
typedef void (*GNCOptionSetSelectable) (GNCOption *option,
gboolean selectable);
typedef void (*GNCOptionChangeCallback) (gpointer user_data);
/***** Prototypes ********************************************************/
void gnc_option_set_changed (GNCOption *option, gboolean changed);
/** Returns an opaque pointer to the widget of this option. The actual
* GUI implementation in dialog-options.c will store a GtkWidget* in
* here. */
gpointer gnc_option_get_widget (GNCOption *option);
/** Store an opaque pointer to the widget of this option. The actual
* GUI implementation in dialog-options.c will store a GtkWidget* in
* here. */
void gnc_option_set_widget (GNCOption *option, gpointer widget);
SCM gnc_option_get_ui_value(GNCOption *option);
void gnc_option_set_ui_value(GNCOption *option, gboolean use_default);
void gnc_option_set_selectable (GNCOption *option, gboolean selectable);
GNCOptionDB * gnc_option_db_new(SCM guile_options);
void gnc_option_db_destroy(GNCOptionDB *odb);
/* Create an option DB for a particular type, and save/load from a kvp.
* This assumes the gnc:*kvp-option-path* location for the options
* in the kvp.
*/
GNCOptionDB * gnc_option_db_new_for_type(QofIdType id_type);
void gnc_option_db_load(GNCOptionDB* odb, QofBook *book);
void gnc_option_db_save(GNCOptionDB* odb, QofBook *book, gboolean clear_all);
void gnc_register_kvp_option_generator(QofIdType id_type, SCM generator);
void gnc_option_db_set_ui_callbacks (GNCOptionDB *odb,
GNCOptionGetUIValue get_ui_value,
GNCOptionSetUIValue set_ui_value,
GNCOptionSetSelectable set_selectable);
SCM gnc_option_db_register_change_callback(GNCOptionDB *odb,
GNCOptionChangeCallback callback,
gpointer data,
const char *section,
const char *name);
void gnc_option_db_unregister_change_callback_id(GNCOptionDB *odb,
SCM callback_id);
char * gnc_option_section(GNCOption *option);
char * gnc_option_name(GNCOption *option);
char * gnc_option_type(GNCOption *option);
char * gnc_option_sort_tag(GNCOption *option);
char * gnc_option_documentation(GNCOption *option);
SCM gnc_option_getter(GNCOption *option);
SCM gnc_option_setter(GNCOption *option);
SCM gnc_option_default_getter(GNCOption *option);
SCM gnc_option_value_validator(GNCOption *option);
SCM gnc_option_widget_changed_proc_getter(GNCOption *option);
SCM gnc_option_get_option_data(GNCOption *option);
int gnc_option_num_permissible_values(GNCOption *option);
int gnc_option_permissible_value_index(GNCOption *option, SCM value);
SCM gnc_option_permissible_value(GNCOption *option, int index);
char * gnc_option_permissible_value_name(GNCOption *option, int index);
char * gnc_option_permissible_value_description(GNCOption *option, int index);
gboolean gnc_option_show_time(GNCOption *option);
gboolean gnc_option_multiple_selection(GNCOption *option);
GList * gnc_option_get_account_type_list(GNCOption *option);
gboolean gnc_option_get_range_info(GNCOption *option,
double *lower_bound,
double *upper_bound,
int *num_decimals,
double *step_size);
gdouble gnc_option_color_range(GNCOption *option);
gdouble gnc_option_use_alpha(GNCOption *option);
guint32 gnc_option_get_color_argb(GNCOption *option);
gboolean gnc_option_get_color_info(GNCOption *option,
gboolean use_default,
gdouble *red,
gdouble *green,
gdouble *blue,
gdouble *alpha);
void gnc_option_call_option_widget_changed_proc (GNCOption *option);
void gnc_option_set_default(GNCOption *option);
guint gnc_option_db_num_sections(GNCOptionDB *odb);
const char * gnc_option_section_name(GNCOptionSection *section);
guint gnc_option_section_num_options(GNCOptionSection *section);
GNCOptionSection * gnc_option_db_get_section(GNCOptionDB *odb, gint i);
GNCOption * gnc_get_option_section_option(GNCOptionSection *section, int i);
GNCOption * gnc_option_db_get_option_by_name(GNCOptionDB *odb,
const char *section_name,
const char *name);
GNCOption * gnc_option_db_get_option_by_SCM(GNCOptionDB *odb,
SCM guile_option);
gboolean gnc_option_db_dirty(GNCOptionDB *odb);
void gnc_option_db_clean(GNCOptionDB *odb);
gboolean gnc_option_db_get_changed(GNCOptionDB *odb);
GList* gnc_option_db_commit(GNCOptionDB *odb);
char * gnc_option_db_get_default_section(GNCOptionDB *odb);
SCM gnc_option_db_lookup_option(GNCOptionDB *odb,
const char *section,
const char *name,
SCM default_value);
gboolean gnc_option_db_lookup_boolean_option(GNCOptionDB *odb,
const char *section,
const char *name,
gboolean default_value);
char * gnc_option_db_lookup_string_option(GNCOptionDB *odb,
const char *section,
const char *name,
const char *default_value);
char * gnc_option_db_lookup_font_option(GNCOptionDB *odb,
const char *section,
const char *name,
const char *default_value);
char * gnc_option_db_lookup_multichoice_option(GNCOptionDB *odb,
const char *section,
const char *name,
const char *default_value);
gdouble gnc_option_db_lookup_number_option(GNCOptionDB *odb,
const char *section,
const char *name,
gdouble default_value);
gboolean gnc_option_db_lookup_color_option(GNCOptionDB *odb,
const char *section,
const char *name,
gdouble *red,
gdouble *green,
gdouble *blue,
gdouble *alpha);
guint32 gnc_option_db_lookup_color_option_argb(GNCOptionDB *odb,
const char *section,
const char *name,
guint32 default_value);
GSList * gnc_option_db_lookup_list_option(GNCOptionDB *odb,
const char *section,
const char *name,
GSList *default_value);
void gnc_free_list_option_value(GSList *list);
gnc_commodity *
gnc_option_db_lookup_currency_option(GNCOptionDB *odb,
const char *section,
const char *name,
gnc_commodity *default_value);
void gnc_option_db_set_option_default(GNCOptionDB *odb,
const char *section,
const char *name);
gboolean gnc_option_db_set_option(GNCOptionDB *odb,
const char *section,
const char *name,
SCM value);
gboolean gnc_option_db_set_number_option(GNCOptionDB *odb,
const char *section,
const char *name,
gdouble value);
gboolean gnc_option_db_set_boolean_option(GNCOptionDB *odb,
const char *section,
const char *name,
gboolean value);
gboolean gnc_option_db_set_string_option(GNCOptionDB *odb,
const char *section,
const char *name,
const char *value);
char * gnc_option_date_option_get_subtype(GNCOption *option);
char * gnc_date_option_value_get_type (SCM option_value);
2017-11-13 14:10:39 -06:00
time64 gnc_date_option_value_get_absolute (SCM option_value);
SCM gnc_date_option_value_get_relative (SCM option_value);
char * gnc_plot_size_option_value_get_type (SCM option_value);
gdouble gnc_plot_size_option_value_get_value (SCM option_value);
Book-Currency Feature Step 3 Add an option to the File->Properties dialog to select a Currency Accounting Method, and to specify the book-currency and a default gains/loss policy if the 'book-currency' method is selected. Revert some changes made in prior commits. Other than storing and retrieving the book-currency and policy in book KVPs, the behavior of gnucash has not been affected by these changes. The changes made are: engine/policy.c & .h - define valid policies and their descriptions and hints; define functions gnc_get_valid_policy_list and gnc_valid_policy engine/engine.i - include policy.h; define 'CURRENCY-ACCOUNTING', 'BOOK-CURRENCY', and 'DEFAULT-GAINS-POLICY' as option names engine/test/utest-Split.cpp - revert prior commit that modified test function for trading accounts engine/test/utest-Transaction.c - revert prior commit that modified test function for trading accounts libqof/qof/qofbookslots.h - revert prior commit that defined Currency Accounting Method; modify definitions of Currency Accounting and Book Currency; add definition of default gains policy; keep the previous Trading Accounts definition libqof/qof/qofbook.cpp & .h - reverted function to determine currency accounting method; add function to get book-currency, revert previously committed changes to function to determine if book uses trading accounts; add function to get gains policy; modify gobject properties accordingly libqof/qof/test/test-qofbook.c - revert prior modification to test function for trading accounts; define tests for book-currency and default gains policies app-utils/options.scm - define make-currency-accounting-option and required support functions app-utils/options-util.c & .h - make support functions of make-currency-accounting-option available in c code app-utils/test/test-options-util.c - include tests for using book-currency app-utils/gnc-ui-util.c & .h - define gnc_book_use_book_currency, gnc_book_get_book_currency and gnc_book_get_default_gains_policy functions app-utils/test/test-gnc-ui-util.c - set up tests for new gnc-ui-util functions app-utils/test/test-app-utils.c - include test-gnc-ui-util.c app-utils/test/Makefile.am - include test-gnc-ui-util.c app-utils/app-utils.scm - define and export book options for Currency Accounting, Book-Currency and Default Gains Policy; export required currency-accounting-option support functions app-utils/business-prefs.scm - replace the Trading Accounts boolean option with a currency-accounting-option and rearrange the order of the options gnome-utils/dialog-options.c - define functions for set-ui-widget, set-ui-value, and get-ui-value for 'currency-accounting' option and various other support functions
2015-06-27 18:06:56 -05:00
char * gnc_currency_accounting_option_currency_documentation(GNCOption *option);
SCM gnc_currency_accounting_option_get_default_currency(GNCOption *option);
char * gnc_currency_accounting_option_policy_documentation(GNCOption *option);
SCM gnc_currency_accounting_option_get_default_policy(GNCOption *option);
Book-Currency Feature step 6 Modify File->Properties dialog to maintain a default gain/loss account in a book KVP. The changes made are: app-utils/app-utils.scm - define items related to book default gain/loss acct app-utils/business-prefs.scm - define items related to book default gain/loss acct;re-arrange sequence of options to make default (neither) first app-utils/gnc-ui-util.c - refine gnc_book_get_default_gains_policy to check for hidden and/or placeholder status app-utils/option-util.c & h - define items related to book default gain/loss acct app-utils/options.scm - add functionality related to book default gain/loss acct app-utils/test/test-gnc-ui-util.c - for gnc_book_get_default_gains_policy, add tests to check for hidden and/or placeholder status app-utils/test/test-option-util.cpp - add tests related to book default gain/loss acct engine/engine.i - define item related to book default gain/loss acct gnome-utils/dialog-options.c & h - add functionality related to book default gain/loss acct and rearrange dialog layout; make gain/loss acct widget refresh on account maintenance gnome-utils/gnc-main-window.c - only allow one book-option dialog if called from file->properties gnome-utils/gtkbuilder/dialog-options.glade - increase dialog height to accomodate book default gain/loss acct widget; add tooltip text for dialog buttons gnome/assistant-hierarchy.c - change sequence of pages: book options before currency selection; if book currency selected, currency also selected gnome/gtkbuilder/assistant-hierarchy.glade - increase dialog height to accomodate book default gain/loss acct widget
2017-07-09 14:19:36 -05:00
char * gnc_currency_accounting_option_gain_loss_account_documentation(GNCOption *option);
Book-Currency Feature Step 3 Add an option to the File->Properties dialog to select a Currency Accounting Method, and to specify the book-currency and a default gains/loss policy if the 'book-currency' method is selected. Revert some changes made in prior commits. Other than storing and retrieving the book-currency and policy in book KVPs, the behavior of gnucash has not been affected by these changes. The changes made are: engine/policy.c & .h - define valid policies and their descriptions and hints; define functions gnc_get_valid_policy_list and gnc_valid_policy engine/engine.i - include policy.h; define 'CURRENCY-ACCOUNTING', 'BOOK-CURRENCY', and 'DEFAULT-GAINS-POLICY' as option names engine/test/utest-Split.cpp - revert prior commit that modified test function for trading accounts engine/test/utest-Transaction.c - revert prior commit that modified test function for trading accounts libqof/qof/qofbookslots.h - revert prior commit that defined Currency Accounting Method; modify definitions of Currency Accounting and Book Currency; add definition of default gains policy; keep the previous Trading Accounts definition libqof/qof/qofbook.cpp & .h - reverted function to determine currency accounting method; add function to get book-currency, revert previously committed changes to function to determine if book uses trading accounts; add function to get gains policy; modify gobject properties accordingly libqof/qof/test/test-qofbook.c - revert prior modification to test function for trading accounts; define tests for book-currency and default gains policies app-utils/options.scm - define make-currency-accounting-option and required support functions app-utils/options-util.c & .h - make support functions of make-currency-accounting-option available in c code app-utils/test/test-options-util.c - include tests for using book-currency app-utils/gnc-ui-util.c & .h - define gnc_book_use_book_currency, gnc_book_get_book_currency and gnc_book_get_default_gains_policy functions app-utils/test/test-gnc-ui-util.c - set up tests for new gnc-ui-util functions app-utils/test/test-app-utils.c - include test-gnc-ui-util.c app-utils/test/Makefile.am - include test-gnc-ui-util.c app-utils/app-utils.scm - define and export book options for Currency Accounting, Book-Currency and Default Gains Policy; export required currency-accounting-option support functions app-utils/business-prefs.scm - replace the Trading Accounts boolean option with a currency-accounting-option and rearrange the order of the options gnome-utils/dialog-options.c - define functions for set-ui-widget, set-ui-value, and get-ui-value for 'currency-accounting' option and various other support functions
2015-06-27 18:06:56 -05:00
SCM gnc_currency_accounting_option_value_get_method (SCM option_value);
SCM gnc_currency_accounting_option_value_get_book_currency (SCM option_value);
SCM gnc_currency_accounting_option_value_get_default_policy (SCM option_value);
Book-Currency Feature step 6 Modify File->Properties dialog to maintain a default gain/loss account in a book KVP. The changes made are: app-utils/app-utils.scm - define items related to book default gain/loss acct app-utils/business-prefs.scm - define items related to book default gain/loss acct;re-arrange sequence of options to make default (neither) first app-utils/gnc-ui-util.c - refine gnc_book_get_default_gains_policy to check for hidden and/or placeholder status app-utils/option-util.c & h - define items related to book default gain/loss acct app-utils/options.scm - add functionality related to book default gain/loss acct app-utils/test/test-gnc-ui-util.c - for gnc_book_get_default_gains_policy, add tests to check for hidden and/or placeholder status app-utils/test/test-option-util.cpp - add tests related to book default gain/loss acct engine/engine.i - define item related to book default gain/loss acct gnome-utils/dialog-options.c & h - add functionality related to book default gain/loss acct and rearrange dialog layout; make gain/loss acct widget refresh on account maintenance gnome-utils/gnc-main-window.c - only allow one book-option dialog if called from file->properties gnome-utils/gtkbuilder/dialog-options.glade - increase dialog height to accomodate book default gain/loss acct widget; add tooltip text for dialog buttons gnome/assistant-hierarchy.c - change sequence of pages: book options before currency selection; if book currency selected, currency also selected gnome/gtkbuilder/assistant-hierarchy.glade - increase dialog height to accomodate book default gain/loss acct widget
2017-07-09 14:19:36 -05:00
SCM gnc_currency_accounting_option_value_get_default_account (SCM option_value);
Book-Currency Feature Step 3 Add an option to the File->Properties dialog to select a Currency Accounting Method, and to specify the book-currency and a default gains/loss policy if the 'book-currency' method is selected. Revert some changes made in prior commits. Other than storing and retrieving the book-currency and policy in book KVPs, the behavior of gnucash has not been affected by these changes. The changes made are: engine/policy.c & .h - define valid policies and their descriptions and hints; define functions gnc_get_valid_policy_list and gnc_valid_policy engine/engine.i - include policy.h; define 'CURRENCY-ACCOUNTING', 'BOOK-CURRENCY', and 'DEFAULT-GAINS-POLICY' as option names engine/test/utest-Split.cpp - revert prior commit that modified test function for trading accounts engine/test/utest-Transaction.c - revert prior commit that modified test function for trading accounts libqof/qof/qofbookslots.h - revert prior commit that defined Currency Accounting Method; modify definitions of Currency Accounting and Book Currency; add definition of default gains policy; keep the previous Trading Accounts definition libqof/qof/qofbook.cpp & .h - reverted function to determine currency accounting method; add function to get book-currency, revert previously committed changes to function to determine if book uses trading accounts; add function to get gains policy; modify gobject properties accordingly libqof/qof/test/test-qofbook.c - revert prior modification to test function for trading accounts; define tests for book-currency and default gains policies app-utils/options.scm - define make-currency-accounting-option and required support functions app-utils/options-util.c & .h - make support functions of make-currency-accounting-option available in c code app-utils/test/test-options-util.c - include tests for using book-currency app-utils/gnc-ui-util.c & .h - define gnc_book_use_book_currency, gnc_book_get_book_currency and gnc_book_get_default_gains_policy functions app-utils/test/test-gnc-ui-util.c - set up tests for new gnc-ui-util functions app-utils/test/test-app-utils.c - include test-gnc-ui-util.c app-utils/test/Makefile.am - include test-gnc-ui-util.c app-utils/app-utils.scm - define and export book options for Currency Accounting, Book-Currency and Default Gains Policy; export required currency-accounting-option support functions app-utils/business-prefs.scm - replace the Trading Accounts boolean option with a currency-accounting-option and rearrange the order of the options gnome-utils/dialog-options.c - define functions for set-ui-widget, set-ui-value, and get-ui-value for 'currency-accounting' option and various other support functions
2015-06-27 18:06:56 -05:00
void gnc_option_db_set_option_selectable_by_name(SCM guile_options,
const char *section,
const char *name,
gboolean selectable);
gboolean gnc_dateformat_option_value_parse(SCM value, QofDateFormat *format,
GNCDateMonthFormat *months,
gboolean *years, char **custom);
SCM gnc_dateformat_option_set_value(QofDateFormat format, GNCDateMonthFormat months,
gboolean years, const char *custom);
void gnc_option_db_register_option(GNCOptionDBHandle handle,
SCM guile_option);
/* private */
void gncp_option_invoke_callback(GNCOptionChangeCallback callback,
gpointer data);
/* Reset all the widgets in one section to their default values */
void gnc_option_db_section_reset_widgets (GNCOptionSection *section);
/* Reset all the widgets to their default values */
void gnc_option_db_reset_widgets (GNCOptionDB *odb);
#endif /* OPTION_UTIL_H */