'From Cuis 2.4 of 17 June 2010 [latest update: #509] on 2 August 2010 at 10:22:36 am'!

!Preference methodsFor: 'initialization' stamp: 'jmv 7/28/2010 11:44'!
name: aName defaultValue: aValue helpString: aString categoryList: aList changeInformee: informee changeSelector:  aChangeSelector
	"Initialize the preference from the given values.  There is an extra tolerence here for the symbols #true, #false, and #nil, which are interpreted, when appropriate, as meaning true, false, and nil"

	name _ aName asSymbol.
	defaultValue _ aValue.
	defaultValue = #true ifTrue: [ defaultValue _ true ].
	defaultValue = #false ifTrue: [ defaultValue _ false ].
	value _ defaultValue.
	helpString _ aString.
	categoryList _ (aList ifNil: [OrderedCollection with: #unclassified]) collect:
		[:elem | elem asSymbol].

	changeInformee _ (informee == nil or: [informee == #nil])
						ifTrue: [nil]
						ifFalse:	[(informee isKindOf: Symbol)
							ifTrue:
								[Smalltalk at: informee]
							ifFalse:
								[informee]].
	changeSelector  _ aChangeSelector! !


!Preferences class methodsFor: 'get/set' stamp: 'jmv 7/28/2010 11:30'!
setPreference: prefSymbol toValue: aValue 
	"Set the given preference to the given value, and answer that value"
	(self
		preferenceAt: prefSymbol
		ifAbsent: [ 
			^ self
				addPreference: prefSymbol
				category: #misc
				default: aValue
				balloonHelp: '' ])
		preferenceValue: aValue! !

!Preferences class methodsFor: 'get/set' stamp: 'jmv 7/28/2010 11:40'!
valueOfFlag: aFlagName ifAbsent: aBlock
	"Answer the value of the given flag
	Not limited to booleans..."

	^ (self preferenceAt: aFlagName ifAbsent: [^ aBlock value]) preferenceValue! !

