'From Squeak3.1alpha [latest update: #''Squeak3.1alpha'' of 28 February 2001 update 3928] on 14 April 2001 at 11:30 pm'! "Change Set: prefJuntaPhaseThree-sw.cs Date: 15 April 2001 Author: Scott Wallace The third and final part of the Preference junta which establshes Preference objects as the holders of all Preference data. CAUTION: extensively hand-jimmied"! Project removeSelector: #projectPreferenceAt:put:! Project removeSelector: #toggleProjectPreference:! PreferencesPanel removeSelector: #copyNameOf:! PreferencesPanel removeSelector: #prefMenu:event:rcvr:! PreferencesPanel removeSelector: #prefMenu:rcvr:pref:! PreferencesPanel removeSelector: #tearOfButtonFor:! Preferences class removeSelector: #absorbAdditions! Preferences class removeSelector: #allHelpStrings! Preferences class removeSelector: #buttonRepresenting:wording:color:inPanel:! Preferences class removeSelector: #callHelpMessageInitializers! Preferences class removeSelector: #compileAccessMethodFor:! Preferences class removeSelector: #compileAccessMethodFor:defaultValue:! Preferences class removeSelector: #constructMonolithicPreferencesInitializer! Preferences class removeSelector: #deletePreference:! Preferences class removeSelector: #deletePreferenceIfFalse:! Preferences class removeSelector: #dictionaryOfPreferences! Preferences class removeSelector: #fromOldPreference:! Preferences class removeSelector: #globalOrDefaultValueOfFlag:! Preferences class removeSelector: #initializeAddedPreferences! Preferences class removeSelector: #isProjectLocalString:! Preferences class removeSelector: #makeIntoAProjectPreference:defaultValue:! Preferences class removeSelector: #mouseOverHaloseEnabled! Preferences class removeSelector: #orphanedHelpEntries! Preferences class removeSelector: #preferencesLackingHelp! Preferences class removeSelector: #rawSetPreference:toValue:! Preferences class removeSelector: #resetCategoryInfo! Preferences class removeSelector: #setHelpFor:toString:! Preferences class removeSelector: #toggleProjectLocalnessOf:! Preferences class removeSelector: #valueOfPreference:! !FreeTranslation class methodsFor: 'as yet unclassified' stamp: 'sw 4/13/2001 15:21'! openScamperOn: currentSelection "Submit the string to the translation server at www.freetranslation.com. Ask it to translate from (Preferences parameterAt: #languageTranslateFrom) to (Preferences parameterAt: #languageTranslateTo). Display the results in a Scamper window, reusing the previous one if possible." | inputs scamperWindow from to | currentSelection size >= 10000 ifTrue: [^ self inform: 'Text selection is too long.']. from _ Preferences parameterAt: #languageTranslateFrom default: 'English'. to _ Preferences parameterAt: #languageTranslateTo default: 'German'. from = to ifTrue: [^ self inform: 'You asked to translate from ', from, ' to ', to, '.\' withCRs, 'Use "choose language" to set these.']. inputs _ Dictionary new. inputs at: 'SrcText' put: (Array with: currentSelection). inputs at: 'Sequence' put: #('core'). inputs at: 'Mode' put: #('html'). inputs at: 'template' put: #('TextResult2.htm'). inputs at: 'Language' put: (Array with: from, '/', to). scamperWindow _ Scamper newOrExistingOn: 'http://ets.freetranslation.com'. scamperWindow model submitFormWithInputs: inputs url: 'http://ets.freetranslation.com:5081' asUrl method: 'post'. scamperWindow activate. ! ! !Preferences class methodsFor: 'reacting to change' stamp: 'sw 4/13/2001 11:22'! universalTilesSettingToggled "The current value of the universalTiles flag has changed; now react" (self preferenceAt: #universalTiles ifAbsent: [^ self]) localToProject ifFalse: [^ self inform: 'This is troubling -- you may regret having done that, because the change will apply to *all projects*, including pre-existing ones. Unfortunately this check is done after the damage is done, so you may be hosed. Fortunately, however, you can simply reverse your choice right now and perhaps no deep damage will have been done.']. self universalTiles "User just switched project to classic tiles" ifFalse: [self inform: 'CAUTION -- if you had any scripted objects in this project that already used universal tiles, there is no reasonable way to go back to classic tiles. Recommended course of action in that case: just toggle this preference right back to true.'] ifTrue: [Preferences capitalizedReferences ifFalse: [Preferences enable: #capitalizedReferences. self inform: 'Note that the "capitalizedReferences" flag has now been automatically set to true for you, since this is required for the use of universal tiles.']. World isMorph ifTrue: [World recreateScripts]]! ! !Preferences class methodsFor: 'get/set' stamp: 'sw 4/13/2001 01:07'! valueOfFlag: aFlagName "Answer the value of the given flag" ^ (self preferenceAt: aFlagName ifAbsent: [^ false]) preferenceValue! ! !Preferences class methodsFor: 'get/set' stamp: 'sw 4/13/2001 01:07'! valueOfFlag: aFlagName ifAbsent: booleanValuedBlock "Answer the value of the given flag" ^ (self preferenceAt: aFlagName ifAbsent: [^ booleanValuedBlock value]) preferenceValue! ! !Preferences class methodsFor: 'preference-object access' stamp: 'sw 4/13/2001 01:06'! preferenceAt: aSymbol "Answer the Preference object at the given symbol, or nil if not there" ^ DictionaryOfPreferences at: aSymbol ifAbsent: [nil]! ! !Preferences class methodsFor: 'preference-object access' stamp: 'sw 4/13/2001 01:06'! preferenceAt: aSymbol ifAbsent: aBlock "Answer the Preference object at the given symbol, or the value of aBlock if not present" ^ DictionaryOfPreferences at: aSymbol ifAbsent: [aBlock value]! ! !PreferencesPanel methodsFor: 'initialization' stamp: 'sw 4/13/2001 11:26'! adjustProjectLocalEmphasisFor: aSymbol "Somewhere, the preference represented by aSymbol got changed from being one that is truly global to one that varies by project, or vice-versa. Get my panel right -- this involves changing the emphasis on the item" | aWindow toFixUp allMorphs emphasis | (aWindow _ self containingWindow) ifNil: [^ self]. emphasis _ (Preferences preferenceAt: aSymbol ifAbsent: [^ self]) localToProject ifTrue: [1 "bold for local-to-project"] ifFalse: [0 "plain for global"]. allMorphs _ IdentitySet new. aWindow allMorphsAndBookPagesInto: allMorphs. toFixUp _ allMorphs select: [:m | (m isKindOf: StringMorph) and: [m contents = aSymbol]]. toFixUp do: [:aStringMorph | aStringMorph emphasis: emphasis] ! ! !WordNet class methodsFor: 'as yet unclassified' stamp: 'sw 4/13/2001 15:20'! languagePrefs "Set preference of which natural language is primary. Look up definitions in it, and correct speaLanguageing in it. Also, let user set languages to translate from and to." | ch aLanguage | self canTranslateFrom. "sets defaults" ch _ PopUpMenu withCaption: 'Choose the natural language to use for:' chooseFrom: 'word definition and speaLanguageing verification (', (Preferences parameterAt: #myLanguage default: #English) asString ,')...\', 'language to translate from (', (Preferences parameterAt: #languageTranslateFrom default: #English) asString ,')...\', 'language to translate to (', (Preferences parameterAt: #languageTranslateTo default: #German) asString ,')...\'. ch = 1 ifTrue: [ aLanguage _ PopUpMenu withCaption: 'The language for word definitions and speaLanguageing verification:' chooseFrom: Languages. aLanguage > 0 ifTrue: [^ Preferences setParameter: #myLanguage to: (Languages at: aLanguage) asSymbol]]. ch = 2 ifTrue: [aLanguage _ PopUpMenu withCaption: 'The language to translate from:' chooseFrom: CanTranslateFrom. aLanguage > 0 ifTrue: [^ Preferences setParameter: #languageTranslateFrom to: (CanTranslateFrom at: aLanguage) asSymbol]]. ch = 3 ifTrue: [aLanguage _ PopUpMenu withCaption: 'The language to translate to' chooseFrom: CanTranslateFrom. aLanguage > 0 ifTrue: [^ Preferences setParameter: #languageTranslateTo to: (CanTranslateFrom at: aLanguage) asSymbol]]. "Maybe let the user add another language when he knows ther server can take it." " ch _ (PopUpMenu labelArray: Languages, {'other...'. 'Choose language to translate from...'}) startUpWithCaption: 'Choose the language of dictionary for word definitions.'. ch = 0 ifTrue: [^ Preferences setParameter: #myLanguage to: #English]. (ch <= Languages size) ifTrue: [aLanguage _ Languages at: ch]. ch = (Languages size + 1) ifTrue: [ aLanguage _ FiaLanguageInTheBlank request: 'Name of the primary language']. aLanguage ifNotNil: [^ Preferences setParameter: #myLanguage to: aLanguage asSymbol]. "! ! !WordNet class methodsFor: 'as yet unclassified' stamp: 'sw 4/13/2001 15:05'! lexiconServer "Look in Preferences to see what language the user wants, and what class knows about it." | nl | nl _ Preferences parameterAt: #myLanguage ifAbsent: [self]. nl == #English ifTrue: [^ self]. "English, WordNet server" nl == #Portuguese ifTrue: [^ PortugueseLexiconServer]. "www.priberam.pt" " nl == #Deutsch ifTrue: [^ DeutschServerClass]. " "class that knows about a server" self inform: 'Sorry, no known online dictionary in that language.'. ^ self languagePrefs! ! !WordNet class methodsFor: 'as yet unclassified' stamp: 'sw 4/13/2001 15:05'! verify: aWord "See if this spelling is in the WordNet lexicon. Return a string of success, no-such-word, or can't reach the server." | aDef nl | aDef _ self new. (aDef definition: aWord) ifNil: [^ 'Sorry, cannot reach that web site. Task abandoned. (Make sure you have an internet connection.)']. nl _ Preferences parameterAt: #myLanguage default: #English. (aDef parts) size = 0 ifTrue: [^ 'Sorry, ', aWord, ' not found. (', nl, ' lexicon)'] ifFalse: [^ aWord, ' is spelled correctly.']! ! !Preferences class methodsFor: 'factored pref panel' stamp: 'sw 4/10/2001 14:29'! categoriesContainingPreference: prefSymbol "Return a list of all categories in which the preference occurs" ^ (self preferenceAt: prefSymbol ifAbsent: [^ #(unclassified)]) categoryList! ! Preferences class removeSelector: #addPreferenceObjectFor:! Preferences class removeSelector: #allGlobalPreferenceFlagKeys! Preferences class removeSelector: #allPreferenceFlagKeys! Preferences class removeSelector: #allPreferenceInitializationSpecs! Preferences class removeSelector: #bootstrapNewPreferenceScheme! Preferences class removeSelector: #defaultOverridesForCertainPreferences! Preferences class removeSelector: #factoredCategories! Preferences class removeSelector: #flagsHeldByProjects! Preferences class removeSelector: #helpMessageForPreference:! Preferences class removeSelector: #helpMessageOrNilForPreference:! Preferences class removeSelector: #initialCategoryInfo! Preferences class removeSelector: #initialize! Preferences class removeSelector: #initializeHelpMessages! Preferences class removeSelector: #isProjectPreference:! Preferences class removeSelector: #oldValueOfFlag:! Preferences class removeSelector: #postHocCategoryAdjustments! Preferences class removeSelector: #preferencesLackingInitializers! Preferences class removeSelector: #recompileAllPreferenceGetters! Preferences class removeSelector: #scriptPerformer! Preferences class removeSelector: #setScottsPreferences! Preferences class removeSelector: #stashPrevailingFlagDictionary! Preferences class removeSelector: #useAnnotationPanes! Preferences class removeCategory: 'initial values'.! !Preferences class reorganize! ('initialization' addPreferenceForCelesteShowingAttachmentsFlag addPreferenceForOptionalCelesteStatusPane chooseInitialSettings compileAccessMethodForPreference: expungePreferenceNamed: initializeDictionaryOfPreferences initializeSyntaxColorsAndStyles) ('add preferences' addPreference:categories:default:balloonHelp: addPreference:categories:default:balloonHelp:projectLocal:changeInformee:changeSelector: addPreference:category:default:balloonHelp:) ('reacting to change' annotationPanesChanged eToyFriendlyChanged globalFlapsSettingChanged infiniteUndoChanged largeTilesSettingToggled noteThatFlag:justChangedTo: optionalButtonsChanged roundedWindowCornersChanged setNotificationParametersForStandardPreferences showProjectNavigatorChanged smartUpdatingChanged universalTilesSettingToggled) ('get/set' disable: disableGently: doesNotUnderstand: enable: enableGently: enableOrDisable:asPer: setPreference:toValue: togglePreference: valueOfFlag: valueOfFlag:ifAbsent:) ('preference-object access' allPreferenceObjects preferenceAt: preferenceAt:ifAbsent:) ('preferences panel' initialExtent initializePreferencePanel:in: inspectPreferences listOfCategories openFactoredPanel openFactoredPanelWithWidth: openNewPreferencesPanel openPreferencesControlPanel openPreferencesInspector preferenceObjectsInCategory:) ('parameters' acceptAnnotationsFrom: annotationInfo borderColorWhenRunning borderColorWhenStopped defaultAnnotationRequests defaultAnnotationRequests: defaultAuthorName defaultPaintingExtent desktopColor desktopColor: editAnnotations initializeParameters inspectParameters maxBalloonHelpLineLength parameterAt: parameterAt:default: parameterAt:ifAbsent: scrollBarColor scrollBarWidth setDefaultAnnotationInfo setParameter:to: viewerEditingPaneHeight viewerEditingPaneWidth) ('menu parameters' menuBorderColor menuBorderWidth menuColor menuLineLowerColor menuLineUpperColor menuTitleBorderColor menuTitleBorderWidth menuTitleColor restoreDefaultMenuParameters setAltMenuChoices) ('hard-coded prefs' browseToolClass cmdGesturesEnabled cmdKeysInText colorTilesEnabled debugMenuItemsInvokableFromScripts desktopMenuTitle isFlagship macOptionKeyAllowed metaMenuDisabled preserveCommandExcursions useCategoryListsInViewers useScrollingInPartsLists) ('misc' addModelItemsToWindowMenu: giveHelpWithPreferences menuColorString okayToChangeProjectLocalnessOf: roundedCornersString setFlag:toValue:during: soundEnablingString staggerPolicyString toggleMenuColorPolicy toggleRoundedCorners toggleSoundEnabling toggleWindowPolicy wantsChangeSetLogging) ('personalization' compileHardCodedPref:enable: disableProgrammerFacilities enableProgrammerFacilities letUserPersonalizeMenu personalizeUserMenu: restorePersonalPreferences savePersonalPreferences) ('window colors' darkerWindows installBrightWindowColors installPastelWindowColors installUniformWindowColors lighterWindows setWindowColorFor:to: windowColorClasses windowColorFor: windowColorHelp windowSpecificationPanel) ('text highlighting' chooseInsertionPointColor chooseTextHighlightColor initializeTextHighlightingParameters insertionPointColor insertionPointColor: textHighlightColor textHighlightColor:) ('fonts' chooseCodeFont chooseFlapsFont chooseFontWithPrompt:andSendTo:withSelector: chooseListFont chooseMenuFont chooseSystemFont chooseWindowTitleFont fontConfigurationMenu presentMvcFontConfigurationMenu restoreDefaultFonts setButtonFontTo: setCodeFontTo: setFlapsFontTo: setListFontTo: setMenuFontTo: setSystemFontTo: setWindowTitleFontTo: standardButtonFont standardCodeFont standardFlapFont standardListFont standardMenuFont windowTitleFont windowTitleStyle) ('halos' classicHaloSpecs classicHalosInForce customHaloSpecs customHalosInForce editCustomHalos haloSpecifications haloSpecificationsForWorld haloTheme iconicHaloSpecifications iconicHalosInForce installClassicHaloSpecs installCustomHaloSpecs installHaloSpecsFromArray: installHaloTheme: installIconicHaloSpecs installSimpleHaloSpecs resetHaloSpecifications showChooseGraphicHaloHandle simpleFullHaloSpecifications simpleHalosInForce) ('standard queries' abbreviatedBrowserButtons alternativeBrowseIt annotationPanes autoAccessors automaticKeyGeneration automaticPlatformSettings automaticViewerPlacement balloonHelpEnabled batchPenTrails browseWithDragNDrop browseWithPrettyPrint browserShowsPackagePane canRecordWhilePlaying capitalizedReferences caseSensitiveFinds cautionBeforeClosing celesteHasStatusPane celesteShowsAttachmentsFlag changeSetVersionNumbers checkForSlips checkForUnsavedProjects clickOnLabelToEdit cmdDotEnabled colorWhenPrettyPrinting compactViewerFlaps compressFlashImages confirmFirstUseOfStyle conversionMethodsAtFileOut debugHaloHandle debugPrintSpaceLog debugShowDamage decorateBrowserButtons deployDiffToggles diffsInChangeList diffsWithPrettyPrint dismissAllOnOptionClose dragNDropWithAnimation eToyFriendly extractFlashInHighQuality extractFlashInHighestQuality fastDragWindowForMorphic fenceEnabled fullScreenLeavesDeskMargins hiddenScrollBars higherPerformance honorDesktopCmdKeys ignoreStyleIfOnlyBold inboardScrollbars infiniteUndo largeTiles logDebuggerStackToFile menuButtonInToolPane menuColorFromWorld modalColorPickers mvcProjectsAllowed noviceMode okToReinitializeFlaps oneViewerFlapAtATime optionalButtons personalizedWorldMenu postscriptStoredAsEPS preserveTrash printAlternateSyntax projectViewsInWindows projectZoom projectsSentToDisk promptForUpdateServer reverseWindowStagger roundedMenuCorners roundedWindowCorners scrollBarsNarrow scrollBarsOnRight scrollBarsWithoutMenuButton securityChecksEnabled showBoundsInHalo showDirectionForSketches showDirectionHandles showFlapsWhenPublishing showProjectNavigator showSecurityStatus signProjectFiles simpleMenus smartUpdating soundQuickStart soundStopWhenDone soundsEnabled sourceCommentToggleInBrowsers startInUntrustedDirectory systemWindowEmbedOK thoroughSenders tileTranslucentDrag tilesToggleInBrowsers timeStampsInMenuTitles turnOffPowerManager twentyFourHourFileStamps typeCheckingInTileScripting uniqueNamesInHalos universalTiles unlimitedPaintArea updateSavesFile useButtonProprtiesToFire useGlobalFlaps useUndo viewersInFlaps warnAboutInsecureContent warnIfNoChangesFile warnIfNoSourcesFile)! Object subclass: #Preferences instanceVariableNames: '' classVariableNames: 'DesktopColor DictionaryOfPreferences Parameters SyntaxColorsAndStyles ' poolDictionaries: '' category: 'System-Support'! "Postscript:" Preferences organization removeEmptyCategories. Preferences class organization removeEmptyCategories.!