As some of us are unregistered, I thought it could be of interest ;)
---------- Forwarded message ---------- From: Andreas Raab <[email protected]> Date: 2009/3/4 Subject: [squeak-dev] [ANN] Preference pragmas To: The general-purpose Squeak developers list <[email protected]> Folks - I wanted to make the property whether to show individual processes in MessageTally a preference and couldn't recall any of the three gazillion methods to create one ;-) So I decided enough is enough and added the ability to register a preference via Pragma. In other words, you specify two class side accessors (using MessageTally as example): showProcesses "Indicates whether to show each process separately or cumulatively." <preference: 'Show Processes in MessageTally' category: 'debug' balloonHelp: 'If enabled, each profiled process is shown individually in MessageTally' type: #Boolean> ^ShowProcesses showProcesses: aBool "Indicates whether to show each process separately or cumulatively." ShowProcesses := aBool. and then register the preference in the class initialization method via: initialize "MessageTally initialize" "By default, show each process separately" ShowProcesses := true. "Register preferences" Preferences addPreferencesFor: self. The nice thing about this scheme is that the preference is local to the code where it's used and that there are no more generated accessors which mess up Monticello packages etc. What could probably be improved is the self-registration; I left it that way for now since I don't know how expensive it would be to scan all classes for new preferences when one opens a preference browser. There is also an example class PreferenceExample that illustrates the different types of preferences (textual, numeric, color, boolean) you can use. To install, just execute the following from Squeak 3.10.2: Installer mantis fixBug: 7306. Enjoy! - Andreas -- Cédrick _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
