Commit Graph

696 Commits

Author SHA1 Message Date
Christopher Lam
0b5a4cd298 Merge branch 'maint' 2022-08-03 20:38:08 +08:00
Christopher Lam
67a1b7a873 [gnc-sx-instance-model] free GHashTable keys when destroying 2022-07-30 13:43:06 +08:00
Christopher Lam
ebf3439558 [gnc-sx-instance-model] free some GHashTable keys & Values 2022-07-29 12:56:02 +08:00
Christopher Lam
7c2a249511 [gnc-sx-instance-model.c] refactor Scrub function
This scrubbing function calls xaccTransRollbackEdit which is
leaky. Instead of trying to fix xaccTransRollbackEdit which requires
superhuman skills, it's easiest to track the changes separately in a
GList, and use xaccTransBeginEdit/xaccTransCommitEdit only if
necessary.
2022-07-29 12:47:10 +08:00
Christopher Lam
c16840b840 more leaks because qof_instance_get returns a new char* 2022-07-21 07:46:40 +08:00
John Ralls
f4c27d4494 Move gnc_ui_account_get_tax_info_string to gnc-locale-tax.c
To prevent a circular dependency between libgnc-app-utils and
libgnucash-guile.
2022-07-17 10:00:23 -07:00
John Ralls
3e2f7bc66a Create separate shared library for expression parser and SX instance model.
These functions depend on both libgnc-app-utils and libgnucash-guile,
creating a circular dependency when the app-utils bindings are added to
libgnucash-guile.
2022-07-16 18:20:17 -07:00
John Ralls
47904a858e Fix distcheck in master.
Several gnc-optiondb dependencies left out of tarball.
2022-07-16 18:15:57 -07:00
John Ralls
1e6c679e71 Merge branch 'maint' 2022-06-14 12:53:16 -07:00
John Ralls
564d73a553 Bug 798531 - Selecting "Print" from the file menu on a report...
crashes gnucash

Ensure that every call to gnc_prefs_get_string correctly handles both
a NULL or empty string return value without crashing or leaking.
2022-05-20 14:33:29 -07:00
Christopher Lam
a5cae6c5eb Don't export undefined functions 2022-05-05 09:46:49 +08:00
Robert Fewell
ee7ed89b68 This partly fixes the currency and commodity combos
With these changes the currency works but the commodity allows you to
set the commodity but will crash if you save config or leave report
open, this was tested on the 'Price scatter plot' report. Fixed with
John's commit a8e6a59
2022-05-03 16:55:55 +01:00
Robert Fewell
db6a8f809b Tax Tables combo does not set the active one
Fixed by correcting spelling of tax table qof type, should
'gncTaxTable'. Also fixed setting tax table combo to 'none' when page
reset button used.
2022-05-03 16:55:55 +01:00
Robert Fewell
0b67a91217 Fix the option GncOptionRangeValue
The GncOptionRangeValue can be used with integers or doubles, the
default being doubles. When used for setting the plot width/height,
integers are used so all ValueTypes need to be integers other wise
the when create_range_spinner is used you end up with the upper_bound
value being G_MAXDOUBLE, a 309 character wide spin button. To
differentiate the two, use 'set_alternate(true)' for integers.
2022-05-03 16:55:48 +01:00
Robert Fewell
506eb38493 Update Chart Width/Height Plot setting
The new plot setting does both settings, values above 100 are treated
as pixels and ones below are treated as a percentage. This means the
maximum valid setting must be higher and also the tooltip needs to be
changed.
2022-05-03 15:44:24 +01:00
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