Commit Graph

39 Commits

Author SHA1 Message Date
John Ralls
ae79fd016d More skeletons 2021-07-31 17:54:28 -07:00
John Ralls
28438e3126 Rewire gnome and gnome-utils to use GncOptionDB. 2021-07-31 17:54:28 -07:00
John Ralls
41e59df71f Remove unused and un-needed function. 2021-07-31 17:54:28 -07:00
John Ralls
1eef796f09 Add some skeleton functions to make the option-using code in gnucash/gnome-utils and gnucash/gnome happy. 2021-07-31 17:54:28 -07:00
John Ralls
99103ffd10 Change gnc-register-option functions to take GncOptionDB*.
Instead of std::unique_ptr<GncOptionDB> because there's no way
to get a unique_ptr through a C call.
2021-07-31 17:54:28 -07:00
John Ralls
25b717d47a Add a rudimentary C API for GncOptionDB.
So that most of the gnome-util and gnome consumers don't need to
be converted to C++.

Hide the corresponding functions in options-utils to stop the
compiler whining.

Note that this commit breaks the build but is necessary at
least temporarily to compartmentalize the changes.
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
eb6e31f803 dialog-options: Change signature of gnc_option_get_gtk_widget()
So that it can be called from C.
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
c63db36a60 Rename string_equal_charptr to operator==(const std::string&, const char*)
Much prettier and more idiomatic as well as being a lot less typing.
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
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
cbd0607e80 Implement load and store options from/to book options. 2021-07-10 17:24:58 -07:00
John Ralls
009219c63d Much less ugly and fragile.
Finding the right form now relies on the form name instead of its
position in the parse tree.
2021-07-10 17:24:58 -07:00
John Ralls
276641ef15 Change parse of option input to generate a parse tree.
This is I hope less brittle than the previous character-counting, though
it's still brittle because it relies instead on counting form-depth.
2021-07-10 17:24:57 -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
6ab5618b76 Set a 50-character limit on the saved size of option section and name.
Allows use of istream::getline() to retrieve the values, simplifying
delimiter detection.
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
3f576671aa Adapt GncOptionMultiChoiceValue to support list options.
Main change adds a value field to the constructor to set the value and
default value.
2021-07-10 17:24:57 -07:00
John Ralls
3dc4bc2377 Implement GncOptionDateValue. 2021-07-10 17:24:57 -07:00
John Ralls
435667e8fe Implement GncOptionMultichoiceValue
Replaces GncOptionValue<GncMultiChoiceOptionChoices> because having the
vector as the value obviously wouldn't work and besides it needs
additional functions.
2021-07-10 17:24:57 -07:00
John Ralls
d544f85256 Replace boost::variant and boost::optional with the C++17 std equivs. 2021-07-10 17:24:57 -07:00
John Ralls
694a15ed21 Extract SCM GncOptionDB::lookup_option to gnc-optiondb.i. 2021-07-10 17:24:57 -07:00
John Ralls
9cdcaf0da8 Remove GncOptionDB::set_selectable and convert set_option to a template. 2021-07-10 17:24:57 -07:00
John Ralls
c5fac51a8b Change the type of OptionUIItem's m_ui_item from void* to GncOptionUIItem.
A locally-opaque class wrapping whatever sort of widget ptr one needs.
Thanks, warlord!
2021-07-10 17:24:56 -07:00
John Ralls
3296212aef Sketch out the rest of the option types.
Minimal implentation to get it to compile and pass tests, not functional yet.
2021-07-10 17:24:56 -07:00
John Ralls
4146251cc7 Add GncOptionUIItem manipulation to GncOptionDB. 2021-07-10 17:24:56 -07:00
John Ralls
94628097e4 Use GncOptionUIType parameters in gnc_register_option functions. 2021-07-10 17:24:56 -07:00
John Ralls
3769a356d5 Extract functions find_section and find_option using boost::optional
to handle not-found condition.
2021-07-10 17:24:56 -07:00
John Ralls
cf0b1da4fa Remove GncOptionWrapper.
Move the GncOptions into the GncOptionDB. This works with tests but
might not with real reports.
2021-07-10 17:24:56 -07:00
John Ralls
d2655d3fb0 Remove gnc-option-db business convenience functions.
gnc_option_db_lookup_invoice_option used only once, so moved its
guts there. The others weren't used at all.
2021-07-10 17:24:56 -07:00
John Ralls
f3eee511e8 Add free functions to create a new GncOptionDB and to register options.
The objective of the free functions is to hide the GncOption from language
bindings so that the GncOptions can be moved into the GncOptionDB instead
of having shared ptrs splattered around the heap. Nearly all access to
the options can then be mediated through the GncOptionDB container.

Note that gnc_option_db_new creates the GncOptionDB on the heap and
returns a raw ptr, so it's up to the creator of the GncOptionDB to
call delete on it when it's no longer needed.
2021-07-10 17:24:56 -07:00
John Ralls
455d3c2d60 Add GncOptionDB class. 2021-07-10 17:24:56 -07:00