Commit Graph

831 Commits

Author SHA1 Message Date
John Ralls
1a186b953e [C++options] Correct handling of multichoice scheme option types.
Includes tests for save-to-scheme for each type.
2022-05-02 11:28:28 -07:00
John Ralls
a8e6a59bf8 [C++options] Fix Guile crash when restoring some reports.
In particular those with commodity options or those using a stylesheet
whose name has spaces like "Head or Tail".
2022-04-29 11:16:25 -07:00
Christopher Lam
dc620d4b24 Merge branch 'maint' 2022-04-22 13:43:47 +08:00
Christopher Lam
394e0a4b71 [gnc-sx-instance-model.c] leak: don't strdup char* for xaccTransSetNotes
For a while now, xaccTransSetNotes would strdup the notes. Don't need
to strdup it beforehand.
2022-04-19 22:59:51 +08:00
John Ralls
95487eb4a0 Merge branch 'maint'
# Conflicts:
#	gnucash/gnome/window-reconcile2.c
#	libgnucash/app-utils/options.scm
#	libgnucash/engine/gnc-numeric.cpp
2022-04-14 18:02:17 -07:00
luz paz
8adedc2248 Fix various typos
Found via `codespell -q 3 -S *.po,./po,*.min.js,./ChangeLog*,./NEWS,./borrowed,./doc/README*,./AUTHORS,./libgnucash/tax/us/txf-de*,./data/accounts -L ans,ba,cas,dragable,gae,iff,iif,mut,nd,numer,parm,parms,startd,stoll`
2022-04-08 14:12:50 -04:00
Robert Fewell
ae220b86a4 [C++options] Fix Ubuntu test failure. 2022-04-07 14:28:02 +01:00
Robert Fewell
83373563c3 Counter formats stored in wrong place.
The Book Options, counter formats were being stored under the 'options'
tree but need to be stored in the 'counter_format' tree similar to the
'counters' tree.
2022-04-07 10:33:11 +01:00
John Ralls
29bdd9b526 [C++options] Fix Ubuntu test failure. 2022-03-31 13:12:45 -07:00
John Ralls
1fddf70e21 [C++options] Fix previous month and previous quarter at the end of March
.

Because March has more days than February the previous month offset was
getting normalized back to the current month--th 29 February this
year is really 1 March, so normalizing before setting the day caused
begin/end previous month to return the begin/end of the current month.
That probably happened on the 31st of May, July, October, and December
as well, I just hadn't managed to test on those days. Switching the
normalization to after calculating the day of the month broke the
previous quarter calculation because now the month was out of range, so
normalize month & year first.
2022-03-31 12:27:58 -07:00
John Ralls
abd1a0b3f1 Merge branch 'c++options' 2022-03-29 15:58:22 -07:00
John Ralls
109efe62b8 Rework default non-currency commodity namespace.
Separate the "All noncurrency" convenience category in the commodity
selector and the default non-commodity namespace proposed by the QIF
importer because they have different functions.

Also remove the namespace guessing code from qif-dialog because with
only one default non-currency namespace there's nothing to guess.
2022-03-24 18:10:32 -07:00
John Ralls
4fe83c3b32 [C++options] Remove GncOptionValue<SCM>.
No longer needed.
2022-03-21 14:08:06 -07:00
John Ralls
278aa484d7 [C++options] Implement new GncOptionValue type GncOptionReportPlacement.
For multicolumn reports so that we don't have to pass Scheme values.
2022-03-21 13:58:50 -07:00
Christopher Lam
cf1282501e Use original guile variable names changed in #1073
The changes 09296dfb96, 1373233cd0 and 189db58e6 had caused
inconsistencies. Best restore original guile variable names using
underscore, bound to strings instead of functions returning strings.
2022-03-20 12:38:09 +08:00
Christopher Lam
5993ebf4d4 Merge branch 'maint' 2022-03-18 20:37:07 +08:00
John Ralls
30e6c8ab11 [gnc-optiondb.i]Explicitly include array.
Xcode-13.3 errors without it.
2022-03-15 16:16:50 -07:00
John Ralls
572cb6b1d1 Banish gnc_get_optiondb_from_dispatcher to gnc-report.cpp.
Puts it closer to its points of use and removes it with its Scheme
dependency from libgnucash.
2022-03-14 10:32:08 -07:00
John Ralls
e63baa6270 Merge Bob Fewell's 'rtl' into maint. 2022-03-14 09:25:42 -07:00
Robert Fewell
f8fc796c95 Bug797501 - Currency symbols in Hebrew (RTL) language
When Gnucash is run in Hebrew which is a RTL language, on the accounts
page the tree view is displaying the required number as the following...

TreeView entry is   '1,500.00 ₪' or '-1,500.00 ₪'
TreeModel string is '₪ 1,500.00‬' or '₪ 1,500.00-‬'

This seems to be down to the GTK 'Unicode Bidirectional Text Algorithm'
which is changing the representation of the model string based on the
first strongly typed character, in this case the Israeli shekel sign.

To fix this, when creating the displayed monetary amount insert a BiDi
ltr isolate uni-character at the start of the string.
2022-03-14 10:05:46 +00:00
John Ralls
d4c3c30b1a Use GUIDs to represent QofInstances instead of pointers.
Converting them to pointers for Scheme to use. Prevents
dangling pointers when the user deletes a QofInstance as long as the
Scheme report code re-fetches its pointers from the options when it's
regenerated.
2022-03-12 17:58:23 -08:00
Christopher Lam
193a7aae5d Merge branch 'maint' 2022-03-12 15:18:43 +08:00
Frank H. Ellenberger
09296dfb96 Drop commodity-table.scm, no longer required after adjusting qif-dialog-utils 2022-03-01 19:58:11 -08:00
John Ralls
c1c75e8f81 Revert "Revert "Merge Stefan Bayer's 'SepaInternalTransfer' into maint.""
The original merge was of a PR based on master into maint, bringing
along all of the development changes in master along with it. We don't
want that so the merge was reverted and the PR's two changes
cherry-picked in. That fixed maint, but then the next regular merge of
maint into master naturally included that revert commit undoing the
changes in master. Not so good. Reverting the revert, this commit,
restores the changes, albeit with messed up history.
2022-01-08 15:10:53 -08:00
Christopher Lam
5603acba31 Merge branch 'maint' 2022-01-06 21:32:41 +08:00
John Ralls
a7a643f7f2 Store option commodities and namespace and mnemonic instead of pointer.
Protects against crashes caused by the user deleting the commodity and
allows the option to work if a deleted commodity is recreated.
2022-01-03 14:47:18 -08:00
John Ralls
65bd860249 Fix relative_date_to_time64 calculations.
Where the date requested extends beyond the start or end of the year.
2022-01-01 16:05:06 -08:00
John Ralls
6841e5b5c8 Replace GncOptionValue<const QofInstance*> with GncOptionQofInstanceValue.
That stores its values as a pair of <QofIdType, gncGUID> so that it
won't have dangling ptrs if the instance gets deleted.
2021-12-30 12:21:56 -08:00
John Ralls
11225d9741 c++options: Remove gnc:options-data 2021-12-15 14:54:41 -08:00
John Ralls
16dc15964c c++options: Remove the callback registration functions. 2021-12-15 14:32:39 -08:00
John Ralls
759376eb13 c++options: Fix multicolumn report 2021-12-15 14:13:47 -08:00
John Ralls
18edc17541 c++options remove stray debugging comment. 2021-12-14 14:20:20 -08:00
John Ralls
b5d0c42505 c++options: Put copyright and FSF header comment on gnc-optiondb.i. 2021-12-14 12:06:39 -08:00
John Ralls
a700701cd3 c++options: Remove three unused test functions.
Scheme serialization is now tested in test-option-gnc-scheme-output.scm.
2021-12-14 11:52:15 -08:00
John Ralls
eb0bd4f998 c++options: Remove unneeded C++20 header and resolve ambiguous call. 2021-12-14 11:51:37 -08:00
John Ralls
a3f50586df c++options: More thorough testing of scheme serialization. 2021-12-14 11:03:37 -08:00
John Ralls
6cd88c230c c++options: Create bool or string internal options when possible.
There's no need to save internal options as SCM when we support the
underlying type in C++.
2021-12-14 11:03:01 -08:00
John Ralls
e9b850cca5 c++options: Correct Scheme serialization of type bool. 2021-12-14 10:58:48 -08:00
John Ralls
66f9fc81c7 c++options: Implement serialization for GncOwner. 2021-12-14 10:57:41 -08:00
John Ralls
0ce841d4ce c++options Fix Scheme bindings for QofQuery options. 2021-12-14 10:55:59 -08:00
John Ralls
216b483e26 c++options SCM bindings Rewrite save_scm_value to branch on type.
Instead of GncOptionUIType, mostly. We still need to do that to tell apart
commodities and currencies from other QofInstances.
Allows compile-time dispatch for most types.
2021-12-13 11:05:15 -08:00
Kevin M. Buckley
1e22632687 Bug 798382 - Typo corrections in comments 2021-12-12 09:50:48 -08:00
John Ralls
947c061989 C++options: Create QofQueryValue trait. 2021-12-11 15:12:22 -08:00
John Ralls
f26014a04e c++options: QofInstanceValue: Protect against crashes when m_value is nullptr. 2021-12-11 15:11:26 -08:00
John Ralls
95b973f792 Bug 798352 - Decimal Precision when Entering Mutual Fund Transaction
Let xaccParseAmount parse up to 12 decimal places instead of 8.
2021-12-09 15:55:37 -08:00
Christopher Lam
33b6dfc6ce [options.scm] addendum ca6604c93 gnc:make-budget-option
selection-budget changed from budget object to guid, handle other uses
as appropriate.
2021-12-04 20:35:04 +08:00
Christopher Lam
ca6604c93c [options.scm] Addon previous commit... need to initialize with guid 2021-12-04 08:59:14 +08:00
Christopher Lam
5a812ca1eb [options.scm] gnc:make-budget-option stores guid instead of object
because object may become stale if UI is used to delete it, leading to
stale pointer and segfault. storing guid is safer, and will return
null if budget is deleted.
2021-12-04 01:37:08 +08:00
Christopher Lam
91b1d291a5 [3/3][gnc-ui-util.c] Remove unused functions
These functions were used to (optionally) reverse amounts according to
whether the feature GNC_FEATURE_BUDGET_UNREVERSED was set. They are
now obsolete because code will now assume feature is set for all
loaded datafiles.
2021-12-03 17:40:21 +08:00
John Ralls
269249378f c++options fix setting account-selection widget from option. 2021-12-02 16:05:14 -08:00
John Ralls
6f93a68bad c++options: Serialize and deserialize to strings instead of streams.
And use serialize to create values for gnc:generate-restore-forms and both
of them for the meat of the stream functions.

This fixes in particular QofInstance serialization where passing the
option value directly to scheme format resulted in a notation about
a swig pointer instead of the desired GUID string or commodity namespace
and mnemonic strings.
2021-12-02 15:04:49 -08:00
John Ralls
dd7feb9988 options.scm: Remove second license comment. 2021-11-19 11:45:54 -08:00
John Ralls
74fd716afb Clarify gnc_relative_date_to_time64 helper functions. 2021-11-19 11:43:04 -08:00
John Ralls
f6c9e63e3d Fix PR comments so far.
Except for gnc-option-date's normalize_tm and set_day_and_time.
2021-11-14 15:28:22 -08:00
John Ralls
cf5da9fffd Resolve merge conflicts. 2021-11-12 19:56:29 -08:00
John Ralls
96b09ded9f Doxygen documentation for new options classes. 2021-11-12 15:27:36 -08:00
John Ralls
00a982d97d Use Scheme to generate and parse saved option files.
The saved option files being Scheme executables.
2021-11-12 15:27:36 -08:00
Christopher Lam
984d816a58 Merge branch 'maint' 2021-11-06 21:41:17 +08:00
Christopher Lam
f813f7cd14 [gnc-autoclear] Move autoclear algorithm into gnome-utils 2021-10-28 21:41:46 +08:00
Geert Janssens
bdb06479e8 GSettings - fix GObject warning when old prefs-version is unset
This will happen when current master (future 5.0) has been run
at least once.
2021-10-27 10:35:11 +02:00
Geert Janssens
09b3ce2382 Revert "Add structure to map migrated preferences to old ones"
This reverts commit c6103a5c17.
2021-10-16 19:02:17 +02:00
Geert Janssens
806d0b3157 Revert "GSettings - make most of the api private"
This reverts commit 26b2d7ca78.
2021-10-16 19:02:10 +02:00
Geert Janssens
1d4673ed2a Revert "GSettings - rework internal helper functions to use more C++"
This reverts commit 24fa289952.
2021-10-16 19:02:04 +02:00
Geert Janssens
24fa289952 GSettings - rework internal helper functions to use more C++ 2021-10-16 10:49:05 +02:00
Geert Janssens
26b2d7ca78 GSettings - make most of the api private
All preference calls should happen via the gnc_prefs_... apis.
The gnc_gsettings_... apis are an internal implementation of this.
2021-10-16 10:49:04 +02:00
Geert Janssens
c6103a5c17 Add structure to map migrated preferences to old ones
This can be used to keep both in sync in the period between
initial migration and eventual obsolence.
Note only non-obsoleted, migrated preferences are tracked.
We don't want to resync preferences that have been
obsoleted (reset). That would nullify the whole idea
of making them obsolete for future removal.

This commit only adds the mapping, synching will follow in a future
commit.
2021-10-16 10:49:04 +02:00
Geert Janssens
e64bcfe620 Merge branch 'maint' 2021-10-01 14:51:04 +02:00
Geert Janssens
9a465fc359 GSettings - add 'deprecate' and 'obsolete' conversions for user preferences
'deprecate' is technically a noop. It serves to remind maintainers
the 'deprecated' preference is to be obsoleted in the next major
release.
'obsolete' goes one step further in that it will cause gnucash to reset
the preference, effectively clearing the value stored in the preferences
backend. This is the final phase of a preference. Following this it
will be completely removed from the GSettings schema in the next
major release.

Notes
* 'deprecate' and 'migrate' are related. Both are a reminder the
preference is to be obsoleted in the next major release. 'deprecate'
does only that though while 'migrate' will also trigger a copy of
the old value to a new location in the databse.

* This commit readds a couple of preferences that had been removed
in the past to be able to properly obsolete them (and to test
the obsoleting code)
2021-10-01 14:46:55 +02:00
Geert Janssens
64576f7d27 GSettings - widen scope from 'migration' to 'transformation'
This commit mostly changes descriptions and variable names to
use the more generic terms 'transformations' or 'conversions'.
'migration' is only one possible transform, future commits will
add others.
There are no functional changes in this commit other than
a logic inversion in parse_one_release_node. It now checks
for nodes named 'migrate' rather than for nodes not named
'migrate' (the code is adapted accordingly to match this
logic change).
2021-10-01 13:59:55 +02:00
John Ralls
29e7b07ed3 Remove superflous schema_source left over from pasting. 2021-09-28 17:17:23 -07:00
John Ralls
8bfa5a63f2 [gsettings] Avoid crash from settings schema not being registered. 2021-09-28 11:00:05 -07:00
Geert Janssens
2a7566cc40 Win32 - drop conditional code never reached
We had hardcoded HAVE_HTMLHELPW to always be true so the fallback
code that's only reached when it is false was never reached.
Time to drop this dead code.
2021-09-26 22:58:08 +02:00
John Ralls
67191203ae Merge branch 'maint' 2021-09-26 10:46:06 -07:00
Geert Janssens
8ea52ae212 GSettings - run data model transations while setting up
This makes sure all schema changes are in effect before
the first consumer can query them. For example this will
prevent a one-time re-occurrence of the tip of the day dialog
the first time the new migrations are run.
2021-09-22 15:44:30 +02:00
Geert Janssens
f1802b6fdf GSettings Upgrade - add code to migrate settings
The rules for migration are read from an xml file. This file was
prepared in a previous commit. Future settings 'data model' changes can
reuse this code by simply adding migration rules in the xml file.

This replaces the hardcoded rules that were currently in place to
migrate a few settings from 2.6 and older to 3.0. These rules are no
longer meaningful as we require users to migrate from one major release
series to the immediate next one. So by the time the new migration rules
in this commit are applied by users they should already have run gnucash
3.x at least once. That run should have taken care of the pre-3.0
migration actions.
2021-09-21 17:10:56 +02:00
Geert Janssens
f21c7b6e90 GSettings - define old prefix and check settings for the presence of both prefixes while normalizing 2021-09-21 17:10:56 +02:00
Geert Janssens
a203c5b2d5 GSettings - drop logic to relocate our settings
This was ported from GConf, but GSettings doesn't work that way.
Settings locations are defined at compile time and can't be
relocated at run time (unless you make all of the settings
explicitly relocatable. That however is not how GSettings is meant to be
used.)
2021-09-21 17:10:56 +02:00
Geert Janssens
d1113a4534 GSettings - build as cpp 2021-09-21 17:10:56 +02:00
Geert Janssens
02fbf217f6 GSettings Upgrade - change schema prefix from org.gnucash to org.gnucash.GnuCash
The latter is the prefix format prescribed by gsettings itself. The former never
was an issue until flatpak decided to not accept the shorter prefix when
requesting a settings migration from host system to flatpak sandbox.

In order to allow for migration, keep the old schema around in
org.gnucash.GnuCash.deprecated.gschema.in

While we're at it, make the new prefix an internal implementation detail.
There's no need for it to be visible to the rest of the gnucash code.
2021-09-21 17:10:55 +02:00
Geert Janssens
6674b1bb6b Cleanup - minimal glib=2.56.1 - drop all conditionals on older versions 2021-09-21 17:10:55 +02:00
John Ralls
74d0630867 Bug 798237 - Logging during XML file loading degrades performance...
significantly

Modify the DEBUG and PINFO macros to return unless qof_log_check is
true. Replace almost all direct calls to g_debug and g_message with
DEBUG and PINFO respectively.

Track the highest logging level sent to qof_log_set_level to provide a
short-circuit return in qof_log_check. Remove setting GNC_MOD_TESTS to
QOF_LOG_DEBUG so that the short-circuit threshold isn't defeated by
always being DEBUG.

Net result: 33% improvement in xml load times.
2021-09-14 15:15:11 -07:00
Christopher Lam
017ab06939 Merge branch 'maint' 2021-09-12 22:44:34 +08:00
John Ralls
cd0d50aac1 Deprecate date options with a time of day setting.
Removing the only use, an example in hello-world.scm. GnuCash doesn't
use this value in any of its own report options and the feature will
be removed in GnuCash 5.

Related to bug 798297 Pref "Use 24-hour clock" obsolete?.
2021-09-10 12:21:46 -07:00
John Ralls
00c2e99d2e Convert the Scheme RelativeDatePeriod lookup table to a std::vector.
From a Scheme alist. The vector can be used to find the scheme symbol
as a direct lookup, which isn't possible with an alist, and can be
searched for the Scheme symbol match more quickly than an alist can.
2021-09-02 14:33:35 -07:00
John Ralls
bed44f404f Remove the always questionable Scheme generation and parsing code.
It's more reasonable to do that in Scheme than in C++.
2021-08-30 11:47:04 -07:00
John Ralls
a487ca3f98 Improve template conditional readability with custom traits values. 2021-08-28 16:45:31 -07:00
John Ralls
62ab148a3e Output a pair when writing relative date values to scheme file.
So that the can be properly recognized on input.
2021-08-19 09:48:44 -07:00
John Ralls
b3f96701a0 GncOptionAccountListValue: Make setter param cv match template. 2021-08-18 16:14:21 -07:00
John Ralls
b361582cf2 Ensure option UI is sorted: Tabs by names, items by keys. 2021-08-18 15:42:29 -07:00
John Ralls
10381d42e0 Fix color option handling.
Read and write color options the way legacy code does. Pass only values
with no alpha to gdk_rgba_parse because it fails if a hex-string has
alpha.
2021-08-18 13:38:06 -07:00
John Ralls
97a317b50c Ensure that alpha values in colors aren't passed to html.
html color tags don't like them.
2021-08-17 15:47:11 -07:00
John Ralls
3d1812aacd Explicitly cast a value to the decltype of get_value().
Can't always rely on implicit conversion working.
2021-08-17 15:41:26 -07:00
John Ralls
474bc360f4 Improve converting vectors to SCM lists. 2021-08-15 14:25:52 -07:00
John Ralls
1cd2cf211c Specialize QofInstance* options set_value, catch validation exceptions.
GncOptionValue<const QofInstance*>.get_value() returns a QofInstance* but
reports store them as strings, either commodity mnemonics or GUIDs.
Specialize set_value/set_default_value from scheme to handle those
possibilities.

GncOptionValidatedValue throws an invalid_argument exception if it's
fed an invalid argument. Catch that so that it doesn't crash the program.
2021-08-13 14:06:47 -07:00
John Ralls
852b2ffc2e Handle bare currency mnemonics, catch invalid GUID string exceptions. 2021-08-13 14:06:47 -07:00
John Ralls
e43ff93279 Fix some overly-long lines. 2021-08-13 14:06:47 -07:00
John Ralls
1af97ebb9a Implement registering/unregistering/calling change callbacks.
Drives reloading the report when the Apply or OK button is pressed.
2021-08-13 14:06:47 -07:00
John Ralls
86da12d844 Use RGB instead of RGBA for color set for color 2021-08-12 14:28:44 -07:00
Christopher Lam
eafc290034 Merge branch 'maint' 2021-08-12 22:28:58 +08:00
John Ralls
86d7637160 Handle GncOptionMultichoiceValue::set_value parameters
that don't match the get_value return type.
2021-08-08 15:22:53 -07:00
John Ralls
b6622a386b Pick up option aliases recently added in maint. 2021-08-05 15:52:13 -07:00
John Ralls
a97b3e0c6d Don't let C code destroy the ODB, it's owned by Guile. 2021-08-05 15:52:13 -07:00
John Ralls
a2e1a3e1b8 Extract the GncOptionDB* from the Scheme dispatch function closure.
Scheme code keeps the GncOptionDB in a closure. Extract it for C/C++
use. Ownership remains with the closure, don't free the GncOptionDB*.
2021-08-05 15:46:56 -07:00
John Ralls
99eaa81a28 Fix parse of commodity namespace from scheme istream.
Just ignore 2 instead of ignoring 1 twice. No ifdef required.
2021-08-04 10:04:47 -07:00
Christopher Lam
a5edacf0fc [options.scm] Rename option name to "Levels of Subaccounts"
Original name "Show Accounts until level". Add backward compatibility
missed in 08f490ee98
2021-08-04 19:02:30 +08:00
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
0f02236ebe Fix gcc warnings. 2021-08-01 10:27:50 -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
dd8e8b4efa Evaluate the getter for making invoice options. 2021-07-31 18:22:45 -07:00
John Ralls
05ac056449 Make separate option type for GncOwner.
GncOwner is not a QofInstance subclass.
2021-07-31 18:22:45 -07:00
John Ralls
9d150b1ae7 Always set budget option to default budget. 2021-07-31 18:18:05 -07:00
John Ralls
f5d8d508ee Create the GncOptionVariant's GncOptionValue in place.
Saves a temporary, prevents premature unprotecting of Scheme objects.
2021-07-31 18:18:05 -07:00
John Ralls
c034a26ae7 Protect stored scheme option values from the garbage collector. 2021-07-31 18:18:05 -07:00
John Ralls
67dab6b320 Remove business-options.scm and business-prefs.scm.
Their functions have been reimplemented elsewhere.
2021-07-31 18:18:04 -07:00
John Ralls
a1af86ed40 Implement gnc:generate-restore-forms, gnc-optiondb-save-to-scheme. 2021-07-31 17:54:30 -07:00
John Ralls
c34986dad4 Change gnc:new-options to return a fake dispatch function.
To placate test-report.scm
2021-07-31 17:54:30 -07:00
John Ralls
3f89d063eb Evaluate default function in gnc:make-account-sel-limited-option. 2021-07-31 17:54:30 -07:00
John Ralls
6eb5dfed51 make-internal fail if there is a ui_item, not if there isn't. 2021-07-31 17:54:30 -07:00
John Ralls
29a2365fdf Avoid infinite recursion when the alias changes only the section name. 2021-07-31 17:54:30 -07:00
John Ralls
7885353fe3 Bring option aliases up to date. 2021-07-31 17:54:30 -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
7c6ecafd61 Rewrite options.scm to wrap options.hpp functions where needed. 2021-07-31 17:54:30 -07:00
John Ralls
52ef53a405 Implement multichoice selection options. 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
be322a0d7c Group GncOptionMultChoiceValue::set_multiple with set_default_multiple.
Better readability.
2021-07-31 17:54:30 -07:00
John Ralls
27670a6e98 Make the 'pixel and 'percent SCM symbols C++ constants.
Improves efficiency and conciseness.
2021-07-31 17:54:30 -07:00
John Ralls
a94f69d6e0 Pretty up some SFINAE formatting for easier reading. 2021-07-31 17:54:30 -07:00
John Ralls
0f8446a1bb Remove some no longer needed diagnostics. 2021-07-31 17:54:30 -07:00
John Ralls
f66a918be4 Implement GncOptionValue<const QofQuery*>
QofQuery isn't a QofInstance and doesn't have a GUID.
2021-07-31 17:54:30 -07:00
John Ralls
0a8f66ee90 Fold GncOptionGncOwnerValue into GncOptionValue<const QofQuery*>.
Reflecting the way Scheme options handles it.
2021-07-31 17:54:30 -07:00
John Ralls
418eb06620 Remove GncOptionDateValue::set_default_value(size_t)
Because it's ambiguous with set_default_value(time64).
2021-07-31 17:54:30 -07:00
John Ralls
7d0cdf7c94 Handle #f input to option typemap(in)s. 2021-07-31 17:54:30 -07:00
John Ralls
86a2f1551f Implement gnc-make-date-option. 2021-07-31 17:54:30 -07:00
John Ralls
693e966bf9 Extract Scheme date handling functions and apply them.
Including in RelativeDatePeriodVec typemap, making it work correctly.
2021-07-31 17:54:30 -07:00
John Ralls
63502900f3 Permit GncOptionAccountValue to have a nil default value. 2021-07-31 17:54:30 -07:00
John Ralls
42185c0ec8 typemap for std::size_t
Unaccountably missing from swig_guile.
2021-07-31 17:54:30 -07:00
John Ralls
5c74337810 Add function GncOption::set_default_value.
Allows reports to derive from other reports and then change the option
default values to suit. If they change only the values and not the defaults
then it's possible to create saved report configs that don't include the
options whose values are changed to the base report's default value. See
https://bugs.gnucash.org/show_bug.cgi?id=642292.
2021-07-31 17:54:30 -07:00
John Ralls
c04f4a00e0 Replace gnc_make_option<SCM> with gnc_make_scm_option
To finesse SWIG_Guile's typedef unsigned long SCM, which causes SFINAE
issues when trying to resolve the template.
2021-07-31 17:54:30 -07:00
John Ralls
e7309f077b Replace gnc_make_option<gnc_commodity*> with gnc_make_commodity_option.
To handle cases where we try to create commodity options with a symbol as
the default instead of a gnc_commodity*.
2021-07-31 17:54:29 -07:00
John Ralls
3aa86ca992 QofInstance* needs a typemap to match the from/to SCM logic. 2021-07-31 17:54:29 -07:00
John Ralls
4a305998e4 GncOptionDateValue set_value_from_scm: 'else' required. 2021-07-31 17:54:29 -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
43cd81ba78 Fix a couple of RangeValue retrieval issues. 2021-07-31 17:54:29 -07:00
John Ralls
9bd3baff63 Change the reldate_values alist from a static to a singleton.
A static has to be initialized at library load and Guile
isn't necessarily running then. The singleton gets evaluated at
runtime only if the getter is called from Guile.
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
c62b526ba0 Implement scm_to_value<bool>. 2021-07-31 17:54:29 -07:00
John Ralls
efc7346490 Implement scm_to_value<GncOptionAccountList>. 2021-07-31 17:54:29 -07:00
John Ralls
f20c358ce1 Return a pair in scheme for GncOptionRangeValue<int>.
This is a bit of a hack to handle PlotSize options. They're the only
RangeValues that use ints; the rest use doubles because the control is a
GtkSpinButton and that uses doubles. The chart code expects a pair with
either 'pixel or 'percent saying what to put in front of the number. We
hack that too: if value <= 100 then it's percent because 100px is about
3cm on modern monitors and 15mm on HiDPI ones. Bigger numbers are pixels.
2021-07-31 17:54:29 -07:00
John Ralls
b5c0477143 Use the SWIGGED pointer for the SCM value of QofInstance* Values.
This effectively reverts b7dd7f.

Note that two cases aren't handled because the types aren't GObjects and
so don't have type macros to decipher them: GncOwner and QofQuery. Since
they're not GObjects they're obviously not QofInstances either and we
need to rethink this value type a bit.
2021-07-31 17:54:29 -07:00
John Ralls
f7f2d22909 Implement gnc-optiondb-foreach. 2021-07-31 17:54:29 -07:00
John Ralls
81d261897e scm_to_value<QofInstance*>() handle Swigged ptrs as well as GUIDs.
Some swigged engine functions used to set options return Swigged ptrs.
2021-07-31 17:54:29 -07:00
John Ralls
16a36d9104 Correctly set value of a GncOptionMultichoiceValue.
Accounting for the 3 types of SCM object that we might be handed.
2021-07-31 17:54:29 -07:00
John Ralls
7c1b4b794a Convert from Scheme date-period symbols to C++ RelativeDatePeriod enum.
Create an alist mapping the Scheme symbols to the corresponding Swig
functions that alias the enumerations. When a symbol is received look
up the corresponding function and evaluate it, retrieving the enumeration.
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
a21f329b1e Use 100% instead of 20000 px for default Pixmap size. 2021-07-31 17:54:29 -07:00
John Ralls
8c2a8edbed Implement gnc_option_db_set_string_value and gnc_optiondb_lookup_string_value. 2021-07-31 17:54:29 -07:00
John Ralls
86102e1be7 Return SCM_BOOL_F instead of nullptr to Scheme optiondb-lookup.
Because unlike C, Scheme thinks (if 0) should return true. Besides, Swig
hides pointers so a null check doesn't even work.
2021-07-31 17:54:29 -07:00
John Ralls
53ad0ba440 Prevent SWIG from trying to call delete on a std::unique_ptr. 2021-07-31 17:54:29 -07:00
John Ralls
08d1eebba2 Use GUID strings instead of QofInstance* for scheme value of QofInstance.
Because that's what gets used everywhere else.
2021-07-31 17:54:29 -07:00
John Ralls
fba0248548 Support different GncOptionMultichoiceValue key types.
Scheme can use strings, symbols, or ints as keys in multichoice options,
but C++ can handle only strings. Add conversion and tracking so that the
right key type gets sent back to Scheme.
2021-07-31 17:54:29 -07:00
John Ralls
55a2ed1df8 gnc-optiondb.i uses functions declared in gnc-optiondb.h.
So it needs it declared in the swig file.
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
0b7ccfbd5b Create gnc-make-foo-option functions.
For compatibility with current Scheme code.
2021-07-31 17:54:29 -07:00
John Ralls
a602f64b17 SFINAE-constrain the GncOption constructor templates.
So that one can't instantiate an invalid constructor.

Unfortunately Swig doesn't understand SFINAE and will try to create the
invalid constructors anyway but at least this generates a compile-time
error when it tries to.
2021-07-31 17:54:29 -07:00
John Ralls
43f4bcb610 Make GncOptionUIType an enum class.
So that Swig will create properly constrained identifiers for its values.
2021-07-31 17:54:29 -07:00
John Ralls
7fa6778b4b Add a register_option overload to GncOptionDB
For compatibility with existing scheme code.
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
76b0001cbe Remove option-util. 2021-07-31 17:54:29 -07:00
John Ralls
e2c87f23c3 Convert optiondb users in gnome and gnome-utils to C++.
To enable using std::unique_ptr<GncObjectDB> and avoid memory management
problems.
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
472814d315 Change the normal internal option ValueType to SCM.
Internal options are used as a Scheme hack and don't need to be interpreted
on the C side so there's no point in converting them to C types.
2021-07-31 17:54:29 -07:00
John Ralls
e48416010d Remove redundant GncOptionDB decl. 2021-07-31 17:54:29 -07:00
John Ralls
7022f5222d Revert gnc_option_db_lookup|set_glist_value to ...scm_value.
GLists and SCM lists are not interchangeable.
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
4f3fd665cf Fix counter and counter_format storage in KVP.
So that they go to their own slots instead of to the options slot.
2021-07-31 17:54:29 -07:00
John Ralls
b19f3d383c Protect some exceptions from being passed to Swig. 2021-07-31 17:54:29 -07:00
John Ralls
52600bbd1f Instantiate gnc_register_number_range_option templates in SWIG. 2021-07-31 17:54:28 -07:00
John Ralls
31a0153fec Another GncOptionDBPtr fix. 2021-07-31 17:54:28 -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
d1cfd62f31 Fix loading text fields from KVP into options. 2021-07-31 17:54:28 -07:00
John Ralls
276d33975a Remove dialog-options.c, replaced by dialog-options.cpp.
Adds new function reset_default_value to GncOption; doing it outside
of the class requires knowing the Type of m_value.
2021-07-31 17:54:28 -07:00
John Ralls
5f9c66aa61 Save all options to KVP if clear_options is true. 2021-07-31 17:54:28 -07:00
John Ralls
6491c98563 Clean up some omitted type-forcing in set_option_from_ui_type() instances. 2021-07-31 17:54:28 -07:00
John Ralls
245a8fccc7 Correctly select UI types for GUID output. 2021-07-31 17:54:28 -07:00
John Ralls
c751e56184 Fix fail to load or save number-range values in KVP. 2021-07-31 17:54:28 -07:00
John Ralls
010ab1a965 Fix free of unallocated ptr crash. 2021-07-31 17:54:28 -07:00
John Ralls
4a4e5d36f8 Enable gnc_register_owner_option to handle the three types that GncOwner aliases. 2021-07-31 17:54:28 -07:00
John Ralls
d8f83d6ee6 Boolean simple won't work if its UI type is INTERNAL. 2021-07-31 17:54:28 -07:00
John Ralls
3514725a97 Make gnc_register_number_range_option a template on ValueType.
GtkSpinButton works with doubles, but we want to preserve the
ability to use other types.
It really should have enable_if<is_arithmetic(ValueType)>.
2021-07-31 17:54:28 -07:00
John Ralls
e78c012699 Fill in the book options. 2021-07-31 17:54:28 -07:00
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
9111f118e0 Business option create_option_widget specializations.
Required creating a registration class for create_option_widget
overload functions because without it the dispatch function
complained of missing symbols at link time.
2021-07-31 17:54:28 -07:00
John Ralls
01c0fe2364 Include what we use. 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
4451f58bd6 Rename RelativeDatePeriods missed earlier. 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
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
67508ea039 Reimplement dialog-options for 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
0106176436 Provide GncOption::is_alternate() for GncOptionRangeValue<>.
Needed for GncOptionUIType::PLOT_SIZE to indicate whether the option
value represents pixels or percent.
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
16da3208fc Make GncOptionDateValue::get_period_index return value size_t.
Instead of int8_t to match the built-in vector index type.
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
fce33799af Change GncOptionUIItem to be a pure virtual class instead of a templated one.
Simplifies the design because derived classes can have whatever save UI class
they need and implement the void(void) set_ui_item_from option and
set_option_from_ui_item with whatever functions are appropriate for
the UI class. No need for callbacks or std::function members.
2021-07-31 17:54:27 -07:00
John Ralls
00aa0f603d Add a PLOTSIZE option UI type.
I'd missed this one earlier.
2021-07-31 17:54:27 -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
08bf3ec5b0 Merge branch 'maint' 2021-07-30 10:28:57 -07:00
Christopher Lam
f1e35daab3 Rename option name from "Extra notes" to "Extra Notes" 2021-07-23 06:25:01 +08:00
Christopher Lam
251db8c37b Rename option name from "Report title" to "Report Title" 2021-07-23 06:25:01 +08:00
Christopher Lam
2606ddf905 Rename option name from "Invoice number" to "Invoice Number"
This ensures it matches all other invoice reports.
2021-07-23 06:24:55 +08:00
John Ralls
3b78b6e894 Change the GncOptionMultichoiceValue permissible value return types to const char*.
From std::string. The consumer is a GtkWidget so we might as well do the conversion
inside the class and this will simplify adding these functions to GncOptionDateValue
in the next commit.
2021-07-10 17:29:16 -07:00
John Ralls
d5f6a2539b Replace GncOption::_get_option() with a friend function swig_get_option.
Implemented in gnc-optiondb.i it more clearly indicates the intended
use and restricts the access. Unfortunately further limiting the
friend declaration with #ifdef SWIG prevented the declaration from
working, raising the error "m_option is a private member of GncOption".
2021-07-10 17:29:15 -07:00
John Ralls
93a3716c00 Enable retrieval of a GncOptionDateValue's relative period.
So that it can be displayed by dialog-option.
2021-07-10 17:29:15 -07:00
John Ralls
dc876d4041 Provide an accessor to GncOptionAccountValue::m_allowed
To enable its use by gnc_account_sel_filter
2021-07-10 17:29:15 -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
5a82aac639 Hide constexpr constants from SWIG.
Swig bindings don't need them and SWIG can't digest constexpr.
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
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
51a1430c24 Remove stray diagnostic. 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
d7a2a0ffff Make a constant for std::numeric_limits<std::size_t>max().
Improves readability.
2021-07-10 17:24:57 -07:00
John Ralls
826d75af16 Use istream::getline instead of std::getline for date option type parsing. 2021-07-10 17:24:57 -07:00
John Ralls
c5294ed6b3 Fix missing-declaration errors in swig-gnc-optiondb-guile.cpp. 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