[GNC-dev] Getting book option
Adrian Panella
ianchi74 at outlook.com
Tue May 14 00:19:18 EDT 2019
Hi John,
I've tried to use qof_book_get_option, but it wasn't working (always returned null).
After some more digging, I found a bug in the book's budget property setter/getter implementation: the wrong KVP path was being used, and so it was never found.
I pushed a fix to PR #503.
I've been trying to use the budgets functionality, but found it very annoying to edit, so I added some fixes/enhancements in that PR:
+ add option to use flat average for estimating budget amount (bug 646631)
+ allow editing budget for all periods (bugs 639404, 679800)
+ add multicurrency support in budget page (bug 676810)
+ preselect default budget in "open" dialog. (bug 788157)
Regards,
Adrián
-----Original Message-----
From: John Ralls <jralls at ceridwen.us>
Sent: domingo, 12 de mayo de 2019 10:47 p. m.
To: Adrian Panella <ianchi74 at outlook.com>
Cc: gnucash-devel at gnucash.org
Subject: Re: [GNC-dev] Getting book option
> On May 12, 2019, at 8:08 PM, Adrian Panella <ianchi74 at outlook.com> wrote:
>
> Hi, I need help to find the right API from C code to get the value of a book option (the ones set from the dialog at File -> Properties ).
> I know it is stored as a KVP with the name "options/Budgeting/Default Budget".
> I've read the documentation and the source code, but couldn't find a simple way to do it.
> The only way a found would be to use qof_book_get_option() (as done from SCM code) but I'll have to add boilerplate to convert the string path to a GSList and to unpack the returned value from KvpValue to the stored GUID.
> Is there a better way of doing it?
>
> Another question, that I cannot deduce: which is the relationship (if any), between that option and qof_instance_get (book, "default-budget", &value, NUL)?
> This last one, is always NUL, but I couldn't find a way to set it.
I'm not familiar with the budget code, but I think the two are the same. You probably want to use the property because anything involving KVP is private to libgnucash.
qof_instance_get is a wrapper around g_object_get with some special handling for properties stored in KVP. See https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#g-object-get.
Regards,
John Ralls
More information about the gnucash-devel
mailing list