Commit Graph

140 Commits

Author SHA1 Message Date
John Ralls
0bd9033bb3 Move includes of glib and gtk out or extern C in new cpp files. 2021-08-01 11:11:20 -07:00
John Ralls
18997db720 Separate GncOptionAccountValue into GncOptionAccountListValue and GncOptionAccountSelValue.
They have different get_value() return types so can't cohabit comfortably.
2021-07-31 18:22:46 -07:00
John Ralls
bbe74aa086 Remove tooltips from multichoice option values.
This is the c++options equivalent to 02a6a0ae and e1525721.
2021-07-31 17:54:30 -07:00
John Ralls
7239eb809a Test more natural way of designating relative dates. 2021-07-31 17:54:30 -07:00
John Ralls
23461f1d6c The value of a list-option is a list. Duh. 2021-07-31 17:54:30 -07:00
John Ralls
12f8df1eab Fix test failure: Clear the stream before reusing it. 2021-07-31 17:54:30 -07:00
John Ralls
d9984f75ab Update test-gnc-optiondb.scm for not renaming the RelativeDatePeriod enums. 2021-07-31 17:54:29 -07:00
John Ralls
534a7c2893 GncOptionMultichoiceValue allow setting a default selection.
Instead of arbitrarily using the first allowed value.
Also update tests for the Scheme type addition to
GncMultichoiceOptionChoices, intercept more cases where the value
needs to be transformed, and go back to emitting a string instead of
throwing in GncOptionMultichoiceValue::get_value when m_values has more
than one value.
2021-07-31 17:54:29 -07:00
John Ralls
d41292fddd Make set_selectable a GncOptionsGtkUIItem member function.
Callable from the option object with set_ui_item_selectable and from
Scheme as gnc-option-db-set-option-selectable-by-name.
2021-07-31 17:54:29 -07:00
John Ralls
18b83874fd Another bit of Remove test-option-utils 2021-07-31 17:54:29 -07:00
John Ralls
cb7270cafe Fix myriad gcc10 complaints. 2021-07-31 17:54:29 -07:00
John Ralls
ea835b31b7 Provide GncOptionPtr& overloads for register-option functions.
Simplifies and makes safer calls from Scheme and C++ by not requiring
a raw pointer.
2021-07-31 17:54:29 -07:00
John Ralls
8c77ce967b Implement and test obsolete option name aliasing. 2021-07-31 17:54:29 -07:00
John Ralls
90b8fce59f Fix build after merge. 2021-07-31 17:54:29 -07:00
John Ralls
85db341afe Remove test-option-utils
It no longer works. Since that's all that test-app-utils called,
delete it too.
2021-07-31 17:54:28 -07:00
John Ralls
21398dfda1 Testing fixups for using GncOptionDB* in register_option functions. 2021-07-31 17:54:28 -07:00
John Ralls
6feb92d4e8 Provide scheme function new-gnc-optiondb.
Wraps creating a GncOptionDBPtr, freeing up gnc_option_db_new() to
return a GncOptionDB* for use in C code. Convert gnc_option_db_new()
calls in gtest-gnc-optiondb to call std::make_unique() as well.
2021-07-31 17:54:28 -07:00
John Ralls
f9e136dbac Get the spelling of GncMultichoiceOptionEntry consistent. 2021-07-31 17:54:28 -07:00
John Ralls
3b4785e744 Convert GncOptionSection from a std::pair to a class.
Provides find_option(const char*) and foreach_option(func) for easy
iteration. find_option and find_section now return plain const ptrs
instead of std::optionals. Much less cumbersome though the compiler
won't nag if you forget the nullptr check.
2021-07-31 17:54:28 -07:00
John Ralls
5fd53c94de Provide GncOption::GetLimits for setting a NUMBER_RANGE spin button. 2021-07-31 17:54:28 -07:00
John Ralls
a995343a8b Provide for multiple selections in GncOptionMultichoiceValue
To support the GncOptionUIType::LIST. This UI type is unused in GnuCash
code but might be used in user custom reports.
2021-07-31 17:54:28 -07:00
John Ralls
ac0e7063c7 Move the GncOptionUIType and dirty members to GncOptionUIUtem.
Even though it makes the class not pure virtual any more it is necessary
behavior common to all possible subclasses.
2021-07-31 17:54:28 -07:00
John Ralls
3200bd4966 Add a multiselect boolean member to GncOptionAccountValue.
To support a variation available in dialog-options. Even though it's not
used in any GnuCash code nor documented anywhere it might be in some
custom reports.
2021-07-31 17:54:28 -07:00
John Ralls
6c8e0e23f7 Redesign GncOptionDateValue.
After getting a better understanding of how it interacts with dialog-options and
finding some additional scheme API needing implementation (exposed only in
hello-world.scm, but possibly used in user-written reports).

Creates a new file-pair, gnc-options-date.[ch]pp to separate the creation of
the static structs with the type info and strings for the various
RelativeDatePeriod values from the already too large gnc-option-impl.
Although the result is a rather C-ish design the alternative with classes
or template specializations would be more complicated and offer no
benefit.

Implements the permissible_values functions of GncOptionMultichoiceValue
for GncDateValue and provides for absolute, relative, and both
UI values for the three widget configs afforded by dialog-options.
2021-07-31 17:54:27 -07:00
John Ralls
102f36c3be Provide more than one Date UI type to match options available in dialog-option.c
Also differentiates begin-period and end-period controls.
2021-07-10 17:29:15 -07:00
John Ralls
99c2c5e439 GncOptionUIItem from the GncOptionVariant classes to GncOption.
Separating the UI from the data model. Note that the GncOptionVariant
classes still have a GncOptionUIType member to ensure that a
GncOptionUIItem of the right type is attached.
2021-07-10 17:29:15 -07:00
John Ralls
1bea809cec Remove the UI interface from GncOptionDB.
UI operations occur only in dialog-option so there's no need to expose
them from GncOptionDB.
2021-07-10 17:29:15 -07:00
John Ralls
cbf7d70ecd Integrate gnc-option into app-utils.
Includes converting swig-app-utils-guile to c++.
2021-07-10 17:29:15 -07:00
John Ralls
81c5ac6689 Remove the incomplete book-currency code.
Not everything from the 6 Book-Currency commits is removed: Switching
the Num and split-action fields and restricting edits of transactions
older than n days were included and those changes are left in place.

Some other partly-implemented features were also part of these commits
and were removed: Options for setting a default capital gains account
and currency, completion of the LIFO cap-gains policy, and creation of
a list of cap-gains policies.

If any of these are to be revived they should each be done in a separate
feature branch and submitted via Github pull request for a code review
before merging; a design discussion on gnucash-devel before restarting
work is also advisable.
2021-07-10 17:29:11 -07:00
John Ralls
aa246d3096 Make implementation classes and template code visible only in app-utils.
So only GncOption and the GncOptionDB free-function interface are public.
We don't want to expose template headers widely, it would blow up compilation
times and might lead to one definition rule violations.
2021-07-10 17:24:58 -07:00
John Ralls
20b3ef8a89 Handle some minor differences between libc++ (clang) and libstdc++ (gcc). 2021-07-10 17:24:58 -07:00
John Ralls
cd6ccbe331 Fix account-tree double-free in scheme test when built with gcc.
Oddly when built with clang it doesn't exhibit the crash.
2021-07-10 17:24:58 -07:00
John Ralls
691cb0992e Follow change in loading method for engine's guile bindings. 2021-07-10 17:24:58 -07:00
John Ralls
cbd0607e80 Implement load and store options from/to book options. 2021-07-10 17:24:58 -07:00
John Ralls
ffc6866406 Changes to accommodate moving guile engine bindings to bindings/guile.
Plus for changing targets gncmod-engine and gncmod-app-utils to
gnc-engine and gnc-app-utils.
2021-07-10 17:24:58 -07:00
John Ralls
76172af239 Implement saving and loading OptionDB items to/from scheme and
key-value string representations.
2021-07-10 17:24:57 -07:00
John Ralls
7ccba53739 Add stream functions to_scheme and from_scheme to GncOption.
These add or parse the textual noise needed to replicate the Scheme options'
serialization technique of saving scheme forms for saving report options
and then evaluating those forms to restore the option values. Required for
backward saved-reports compatibility.
2021-07-10 17:24:57 -07:00
John Ralls
1ea3822665 More operator <</>> Fixups. 2021-07-10 17:24:57 -07:00
John Ralls
98ca190700 Fix commodity in/out to use namespace & mnemonic instead of GUID. 2021-07-10 17:24:57 -07:00
John Ralls
4b997cd025 Fixups for GncOptionDateValue better design. 2021-07-10 17:24:57 -07:00
John Ralls
b2fb57d39e Fix GncOption::set_value() to work with GncOptionDateValue::set_value(RelativeDatePeriod).
Adjusting tests as necessary.
2021-07-10 17:24:57 -07:00
John Ralls
4dcf4a0e6a Test GncOptionRangeValue as a GncOption.
Better representation of how it will be used.
2021-07-10 17:24:57 -07:00
John Ralls
4cabd6c052 Change the GncOptionMultichoiceValue test to use a GncOption.
Requires exposing the permissible values functions to GncOption.
2021-07-10 17:24:57 -07:00
John Ralls
e2a36a8be3 Expose function validate to GncOption and test it on GncOptionValidatedValue. 2021-07-10 17:24:57 -07:00
John Ralls
6df516dfcd Clean up the commodity/currency tests with a better fixture class. 2021-07-10 17:24:57 -07:00
John Ralls
52d0ec5290 Change GncOptionDateValue design to better match usage.
Added advantage that it handles (not correctly, but in the same way as
the old code) the ambiguity between a period starting or ending with
the stored value "relative . today".
2021-07-10 17:24:57 -07:00
John Ralls
883127a59d Implement operators >> and << on GncOption. 2021-07-10 17:24:57 -07:00
John Ralls
b95ea2c4aa Add Account-list options. 2021-07-10 17:24:57 -07:00
John Ralls
399573a89d Fix multichoice test construction. 2021-07-10 17:24:57 -07:00
John Ralls
12c5b94430 New scheme function gnc_option_default_value. 2021-07-10 17:24:57 -07:00