'From Squeak3.1alpha of 6 February 2001 [latest update: #3541] on 7 February 2001 at 5:17:49 pm'! "Change Set: personalPrefs-sw Date: 7 February 2001 Author: Scott Wallace Allows the user to save a snapshot of all currenly Preferences settings as her 'personal preferences', and allows the user to restore such settings at any time. Also adds a mechanism allowing latter-day overrides concerning the categories of various preferences -- see #postHocCategoryAdjustments. Strips project-related preferences out from their old categories and places them in a new 'projects' category. The Preferences Panel opens up showing the ? (Help) page now. And there is a 'help!!' button on that page which, when hit, provides some help. A do-it in the postscript saves all the prevailing settings as of the moment of loading this update as the inital seed for 'personal preferences'. Thus, any user wishing to explore our latest take on what the out-of-box preferences will be can ask for the system defaults to be installed, play with the system for as long as desried in that state, and then revert to the former settings by hitting 'Restore my Personal Preferences', and be none the worse for it."! !Preferences class methodsFor: 'initialization' stamp: 'sw 2/7/2001 15:20'! defaultOverridesForCertainPreferences "Answer a list of overrides to the default settings of certain preferences. The default state of preferences -- i.e. the one you get back to if you hit the 'Restore all System Defaults' button -- is defined by the initializer methods of preferences (look in category 'initial values' in Preferences class), as then subsequently amended and overridden by this table, which will continue to evolve right up to each release, and which users may wish to hand-edit as well for their own private configurations" ^ #((capitalizedReferences true) (clickOnLabelToEdit false) (decorateBrowserButtons false) (fastDragWindowForMorphic true) (infiniteUndo false) (menuColorFromWorld true) (mvcProjectsAllowed true) (optionalButtons false) (preserveTrash false) (roundedWindowCorners true) (scrollBarsNarrow false) (soundsEnabled true) (useGlobalFlaps true)) ! ! !Preferences class methodsFor: 'initialization' stamp: 'sw 2/7/2001 15:42'! postHocCategoryAdjustments | aDictionary | "Provides a table governing post-hoc changes to default categories for certain preferences. In the table below, each element gives the name a preference and a list of categories it belongs in; the method returns a dictionary whose keys are the pref names and whose values are the ultimate desired list." aDictionary _ IdentityDictionary new. #( (checkForUnsavedProjects (projects)) (mvcProjectsAllowed (projects)) (projectViewsInWindows (projects)) (projectZoom (projects)) (projectsSendToDisk (projects)) (signProjectFiles (projects))) do: [:pair | aDictionary at: pair first put: pair second]. ^ aDictionary! ! !Preferences class methodsFor: 'initialization' stamp: 'sw 2/7/2001 14:34'! restorePersonalPreferences | savedPrefs | "Restore all the user's saved personal preferences" savedPrefs _ self parameterAt: #PersonalPreferences ifAbsent: [^ self inform: 'There are no personal preferences saved in this image yet']. savedPrefs associationsDo: [:assoc | self setPreference: assoc key toValue: assoc value]! ! !Preferences class methodsFor: 'initialization' stamp: 'sw 2/7/2001 14:30'! savePersonalPreferences "Save the current list of Preference settings as the user's personal choices" self setParameter: #PersonalPreferences to: FlagDictionary deepCopy! ! !Preferences class methodsFor: 'parameters' stamp: 'sw 2/7/2001 14:37'! parameterAt: aKey ifAbsent: aBlock "Answer the parameter saved at the given key; if there is no such key in the Parameters dictionary, evaluate aBlock" ^ Parameters at: aKey ifAbsent: [aBlock value]! ! !Preferences class methodsFor: 'misc' stamp: 'sw 2/7/2001 16:09'! giveHelpWithPreferences "Open up a workspace with explanatory info in it about Prefernces" | aString | aString _ 'Many aspects of the system are governed by the settings of various "Preferences". Click on any of brown tabs at the top of the panel to see all the preferences in that category. Or type in to the box above the Search button, then hit Search, and all Preferences matching whatever you typed in will appear in the "search results" category. To find out more about any particular Preference, hold the mouse over it for a moment and balloon help will appear. If you like all your current Preferences settings, you may wish to hit the "Save Current Settings as my Personal Preferences" button. Once you have done that, you can at any point in the future hit "Restore my Personal Preferences" and all your saved settings will get restored immediately.'. (Workspace new contents: aString) openLabel: 'About Preferences'! ! !Preferences class methodsFor: 'factored pref panel' stamp: 'sw 2/7/2001 15:48'! initialCategoryInfo "Answer an alphabetized array of pairs, each of which consists of: the name of a category a list of preferences belonging to that category This is done by scanning all the initializer methods found in category 'initial values' in Preferences class." | categories catList adjustments itsCategories | categories _ IdentityDictionary new. adjustments _ self postHocCategoryAdjustments. self allPreferenceInitializationSpecs do: [:spec | itsCategories _ adjustments at: spec first ifAbsent: [spec size > 2 ifTrue: [spec third] ifFalse: [#()]]. itsCategories do: [:sym | (categories includesKey: sym) ifFalse: [categories at: sym put: OrderedCollection new]. ((catList _ categories at: sym) includes: spec first) ifFalse: [catList add: spec first]]]. ^ categories keys asSortedArray collect: [:aKey | Array with: aKey with: (categories at: aKey) asSortedArray]! ! !Preferences class methodsFor: 'factored pref panel' stamp: 'sw 2/7/2001 16:13'! openFactoredPanelWithWidth: aWidth "Open up a preferences panel of the given width" "Preferences openFactoredPanelWithWidth: 325" | tabbedPalette controlPage window playfield aColor aFont maxEntriesPerCategory tabsMorph anExtent aPanel | aFont _ StrikeFont familyName: 'NewYork' size: 19. aPanel _ PreferencesPanel new. aColor _ aPanel defaultBackgroundColor. tabbedPalette _ TabbedPalette newSticky. (tabsMorph _ tabbedPalette tabsMorph) color: aColor darker; highlightColor: Color red regularColor: Color brown darker darker. tabbedPalette on: #mouseDown send: #yourself to: #(). maxEntriesPerCategory _ 0. self factoredCategories do: [:aCat | controlPage _ AlignmentMorph newColumn beSticky color: aColor. controlPage on: #mouseDown send: #yourself to: #(). controlPage borderColor: aColor; layoutInset: 4. aCat second do: [:aPrefSymbol | controlPage addMorphBack: (Preferences buttonRepresenting: aPrefSymbol wording: aPrefSymbol color: nil)]. controlPage setNameTo: aCat first asString. aCat first = #? ifTrue: [aPanel addHelpItemsTo: controlPage]. aCat first == #halos ifTrue: [aPanel addHaloControlsTo: controlPage]. tabbedPalette addTabFor: controlPage font: aFont. aCat first = 'search results' ifTrue: [(tabbedPalette tabNamed: aCat first) setBalloonText: 'Use the ? category to find preferences by keyword; the results of your search will show up here']. maxEntriesPerCategory _ maxEntriesPerCategory max: aCat second size]. tabbedPalette selectTabNamed: '?'. tabsMorph rowsNoWiderThan: aWidth. playfield _ Morph newSticky. playfield on: #mouseDown send: #yourself to: #(). anExtent _ aWidth @ (25 + tabsMorph height + (20 * maxEntriesPerCategory)). playfield extent: anExtent. playfield color: aColor. playfield addMorphBack: tabbedPalette. self couldOpenInMorphic ifTrue: [window _ (SystemWindow labelled: 'Preferences') model: aPanel. window on: #keyStroke send: #keyStroke: to: aPanel. window bounds: (100 @ 100 - (0 @ window labelHeight + window borderWidth) extent: playfield extent + (2 * window borderWidth)). window addMorph: playfield frame: (0 @ 0 extent: 1 @ 1). window updatePaneColors. window setProperty: #minimumExtent toValue: anExtent + (2 @ 2). self currentWorld addMorphFront: window. window center: self currentWorld center. window activateAndForceLabelToShow] ifFalse: [(window _ MVCWiWPasteUpMorph newWorldForProject: nil) addMorph: playfield. MorphWorldView openOn: window label: 'Preferences' extent: playfield extent]! ! !PreferencesPanel methodsFor: 'find' stamp: 'sw 2/7/2001 16:05'! addHelpItemsTo: panelPage "Add special items to the page" | aButton aTextMorph aMorph | aTextMorph _ TextMorph new contents: 'Search Preferences for:'. aTextMorph beAllFont: ((TextStyle default fontOfSize: 21) emphasized: 1). panelPage addMorphBack: aTextMorph lock. panelPage addTransparentSpacerOfSize: 0@10. aMorph _ RectangleMorph new clipSubmorphs: true; beTransparent; borderWidth: 2; borderColor: Color black; extent: 250 @ 36. aMorph vResizing: #rigid; hResizing: #rigid. aTextMorph _ PluggableTextMorph new on: self text: #searchString accept: #setSearchStringTo: readSelection: nil menu: nil. " aTextMorph hResizing: #rigid." aTextMorph borderWidth: 0. aTextMorph font: ((TextStyle default fontOfSize: 21) emphasized: 1); setTextColor: Color red. aMorph addMorphBack: aTextMorph. aTextMorph acceptOnCR: true. aMorph clipLayoutCells: true. aTextMorph width: 250. panelPage addMorphBack: aMorph. aTextMorph setBalloonText: 'Type what you want to search for here, then hit the "Search" button'. panelPage addTransparentSpacerOfSize: 0@10. aButton _ SimpleButtonMorph new target: self; color: Color transparent; actionSelector: #initiateSearch:; arguments: {aTextMorph}; label: 'Search'. panelPage addMorphBack: aButton. aButton setBalloonText: 'Type what you want to search for in the box above, then click here (or hit RETURN or ENTER) to start the search; results will appear in the "search results" category.'. panelPage addTransparentSpacerOfSize: 0@40. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Restore all Default Preference Settings'; target: Preferences; actionSelector: #chooseInitialSettings; setBalloonText: 'Click here to reset all the preferences to their standard default values.'; yourself). panelPage addTransparentSpacerOfSize: 0@14. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Save Current Settings as my Personal Preferences'; target: Preferences; actionSelector: #savePersonalPreferences; setBalloonText: 'Click here to save the current constellation of Preferences settings as your personal defaults; you can get them all reinstalled with a single gesture by clicking the "Restore my Personal Preferences".'; yourself). panelPage addTransparentSpacerOfSize: 0@14. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Restore my Personal Preferences'; target: Preferences; actionSelector: #restorePersonalPreferences; setBalloonText: 'Click here to reset all the preferences to their values in your Personal Preferences.'; yourself). panelPage addTransparentSpacerOfSize: 0@30. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Inspect Parameters'; target: Preferences; actionSelector: #inspectParameters; setBalloonText: 'Click here to view all the values stored in the system Parameters dictionary'; yourself). panelPage addTransparentSpacerOfSize: 0@10. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Help!!'; target: Preferences; actionSelector: #giveHelpWithPreferences; setBalloonText: 'Click here to get some hints on use of this Preferences Panel'; yourself).! ! "Postscript:" Preferences savePersonalPreferences.!