[GNC-dev] Getting book option
John Ralls
jralls at ceridwen.us
Sun May 12 23:47:20 EDT 2019
> 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