www.gibmonks.com




  Previous section   Next section

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 42.  Managing User Preferences


Improving the Package

One small improvement can be made to Pref_Add. If a user specifies a boolean resource manually, he or she might use "true" instead of one and "false" instead of zero. Pref_Add should check for those cases and set the boolean variable to one or zero to avoid errors when the variables are used in expressions.

The interface lets you dismiss it without saving your preference settings. This is either a feature that lets users try out settings without committing to them, or it is a bug. Fixing this requires introducing a parallel set of variables to shadow the real variables until the user hits Save, which is tedious to implement. You can also use a grab as described in Chapter 36 to prevent the user from doing anything but setting preferences.

This preference package is a slightly simplified version of one I developed for exmh, which has so many preference items that a two-level scheme is necessary. The first level is a menu of preference sections, and each section is created with a single call to Pref_Add. This requires additional arguments to Pref_Add to provide a title for the section and some overall information about the preference section. The display code changes a small amount. The code for the exmh is on the CD-ROM.


      Previous section   Next section
    Top