Preferences

Phil Longstaff plongstaff at rogers.com
Wed Apr 29 15:28:05 EDT 2009


A number of bugs in bugzilla reference the idea of splitting global preferences from per-file preferences, so I thought I would take a stab at this.  Here's my design idea, and I'm looking for any response/feedback:

1) Preferences are currently stored in gconf.  Global preferences will continue to be stored there, but local preferences will be stored as kvp entries of the QofBook.  This is per-file, uses existing mechanisms (I'll need to check that the xml/dbi backends load/save book kvp entries) and fits with the gconf/preferences hierarchical nature.

2) Over the past few years, I've grown to really like the interface idea when two pieces of code need to interact.  It allows one module to use another module's services while only having a dependence on the interface, not the implementation behind it.  Therefore, I'll create a GncPrefs GObject-based interface (GInterface - is that the right term?) with get_string/boolean/double/int and set_string/boolean/double/int methods.

3) A GncPrefsFromGconf GObject will be created and will implement GncPrefs.  This object will interact with gconf (will replace the gnc_gconf_xxx() functions).

4) A GncPrefsFromQofBook GObject will be created and will implement GncPrefs.  For a set operation, this will store the value into the QofBook kvp frames.  For a get operation, this will look for the value in the QofBook kvp frames.  If found, it will be returned.  If not found, it will relay the request to the global prefs to get the value from gconf and then will set the value in the QofBook kvp frames.  This will handle transfering values which are currently global and make them local.  If the key is not found globally, a default value will be returned.

5) New routines GncPrefs* qof_session_get_local_prefs() and GncPrefs* qof_session_get_global_prefs() will return the local and global prefs, respectively.

6) I don't think anything needs to be done for a newly created book.  For current installations, #4 will copy global values from gconf to the book and then they will be used from the book from that time forward.  For new installations with no current gconf values, the defaults will be used until they are changed.

Of course, then there is the decision about which current prefs stay global and which become local.  I haven't looked into that yet, but when I do, I'll make a proposal.

Phil


More information about the gnucash-devel mailing list