Using the Option (UI) framework for KVP manipulation

Derek Atkins warlord@MIT.EDU
07 Jul 2002 11:53:03 -0400


KVP frames are a convenient way to store a tree of data in an object.
The Option Framework allows the programmer to define a set of data
objects (currently called "options") in a hierachy (currently only a
two-level hierachy) and dynamically generates a UI to present the
option-set to the user.  Unfortunately, these two systems are not tied
together.

This proposal defines a way to use the option infrastructure to define
the layout and manipulation of a subset of a KVP tree.  This proposal
does not change the current restriction of a two-level hierarchy, and
it specifically ties the graphical layout to the KVP layout.

CHANGES TO OPTIONS

The first task is to add KVP support into the option framework.  Each
option-type needs two new methods:
        scm->kvp
        kvp->scm

Both of these methods take two arguments, a <gnc:kvp-frame*> and a
key-path list.  The option is stored at the "key-path" slot in the
frame.  If the option needs to store multiple objects, it may create a
subtree at the key-path.  For example, a commodity option needs to
store two strings, so it would store two kvp-entries _under_ the
key-path, whereas a text option would just store the text _at_ the
key-path.

ADDITIONAL INFRASTRUCTURE

Once the option framework supports KVPs, all that is needed is a
general function that will "save" and "restore" an option-db to/from a
KVP-frame at a given base-key.  I see this as:

  (gnc:option-db-save-kvp optiondb kvp-frame base-path)

So, for example:

  (gnc:option-db-save-kvp (gnc:book-get-options book)
                          (gnc:book-get-slots book)
                          '("options"))

The other issue is that instead of defining your options as a one-time
thing, you would need to define a function to define your options on a
per-object basis.  This is just because there is no way, currently, to
define an option-db template and duplicate that template.  Consider
this a potential future-work extension.

CONCLUSIONS

Am I missing a necessary piece, or is this really as fairly
straightforward as I think it is?  Anyone have any comments on this
proposal?

Thanks,

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord@MIT.EDU                        PGP key available