dialog-options vs. glade

Chris Shoemaker c.shoemaker at cox.net
Tue Jan 4 11:04:03 EST 2005



I just want to report some recent experiences and possibly get some
feedback.

Background:
	I'm working on budget functionality in the g2 branch.  I
almost had full budget persistence, when I decided I wanted to make
some design simplifications to the budget's engine API.  (I'll report
more on that later.)  The simpler budget needed a simpler budget gui,
so I used the gnc_plugin, gnc_plugin_page, and gncmod APIs to give a
budget a page of its own.  This seems to work pretty well.
Furthermore, I used the engine's event notification api
(component_manager) with success.  E.g. budget pages close themselves
if their budget is destroyed.

Current Issues:
	Budget's have editable properties, and I wanted to provide a
gui for editing them.  I wanted to use the "Option" paradigm used in
editing properties of reports.  Thus, I discovered dialog-options.c
and option-util.c and the option definitions in options.scm.  So, in
my view options callback, I call gnc_build_options_dialog_contents()
and register my apply callback.
	That creates nice option dialogs, but with no actual set/get
of values.  So I started pairing getters like
gnc_option_db_lookup_{string}_option() in my apply callback with
setters like gnc_option_db_set_{string}_option() in the page init
function to push the budget's property values into the optionsDB.
	This worked well, _at_first_.  I was able to set and show a
few budget properties right off the bat, but I ran into a few
problems.  For one, I can't figure out how to set a date option.  I
can _get_ the date option values, and I can set the other option types
I'm using so far (string and number range.)  ISTM, this must be
possible because, e.g. the hello world report has a date option that
works.
	But when I try to see how this is done elsewhere, I see that
1) no one else is using the gnc_option_db_set_{type}_option API, 2)
the report options work in some other way that I haven't figured out
yet, and, frankly, seems rather mysterious.
	

Planned Direction:
	Specifying my options dialog in scheme was nifty. (I could
even control layout with the sort order field.)  But I can't seem to
get it to work for even a date type option, and I eventually visioned
having a FreqSpec option, too, which isn't already supported by the
options.scm.  Therefore, this seems like it might be a dead-end.
	Here's another approach that might work: Specify my options
dialog using glade; handle property push/pull myself.


Reflection:
	I guess I was led down this road by
gnc-plugin-page-account-tree.c, which does use
gnc_build_options_dialog_contents(), but if I look more closely, I see
that this page's options don't work anyway. :(
	I knew that there would be a learning curve for gnucash
hacking when I started -- and it is _large_.  On the bright side,
design "mistakes" (if that what it turns out to be) like mine, aren't
really as much a waste of time as they feel like (several days),
because I think I'm climbing the learning curve as fast as I would
have been if I'd made a "better" decision.

-chris


More information about the gnucash-devel mailing list