Nicolas Cellier uploaded a new version of Services-Base to project The Trunk:
http://source.squeak.org/trunk/Services-Base-nice.38.mcz ==================== Summary ==================== Name: Services-Base-nice.38 Author: nice Time: 7 December 2009, 9:11:52 am UUID: a207ee3e-cec3-464c-9111-481371e8609a Ancestors: Services-Base-ul.37 Merge some of Pharo changes: - no fixTemps - no underscore assignments - ifNotNilDo: -> ifNotNil: =============== Diff against Services-Base-ul.37 =============== Item was changed: ----- Method: PasteUpMorph>>worldMenu (in category '*services-base') ----- worldMenu - | | ^ TheWorldMenu new adaptToWorld: self! Item was changed: ----- Method: ServiceShortcuts class>>arrowShortcut:event: (in category 'as yet unclassified') ----- arrowShortcut: str event: event | key s | + key := event keyCharacter caseOf: { - key _ event keyCharacter caseOf: { [Character arrowDown] -> ['down']. [Character arrowUp] -> ['up']. [Character arrowLeft] -> ['left']. [Character arrowRight] -> ['right']}. + s := self map - s _ self map at: str , key ifAbsent: [^ self]. s serviceOrNil + ifNotNil: [:sv | sv execute. - ifNotNilDo: [:sv | sv execute. event wasHandled: true]! Item was changed: ----- Method: PreferenceBrowser class>>openForServices (in category '*services-base') ----- openForServices "PreferenceBrowser openForServices" | browser | + browser := self new. - browser _ self new. browser initializeForServices. (ServiceBrowserMorph withModel: browser) openInWorld. ^browser. ! Item was changed: ----- Method: ServiceAction>>action: (in category 'accessing') ----- action: aBlock + action := aBlock! - action := aBlock fixTemps! Item was changed: ----- Method: ServiceAction>>updateEnable (in category 'preferences') ----- updateEnable + enabled := ServicePreferences - enabled _ ServicePreferences valueOfPreference: self id ifAbsent: [true]! Item was changed: ----- Method: ServiceGui class>>browserButtonRow:inlinedIn: (in category 'hooks') ----- browserButtonRow: aBrowser inlinedIn: row | bar | self buttonBarServices + ifTrue: [bar := (self new for: aBrowser id: #browserButtonBar) buildButtonBar. - ifTrue: [bar _ (self new for: aBrowser id: #browserButtonBar) buildButtonBar. row addMorphBack: bar]. ^ row! Item was changed: + ----- Method: ServiceGui>>for:id: (in category 'initialization') ----- - ----- Method: ServiceGui>>for:id: (in category 'initialize-release') ----- for: caller id: id + service := id service. - service _ id service. caller ifNotNil: [service requestor: caller requestor]! Item was changed: ----- Method: ServiceAction>>condition: (in category 'accessing') ----- condition: aBlock + condition := aBlock! - condition := aBlock fixTemps! Item was changed: + ----- Method: ServiceGui>>initialize (in category 'initialization') ----- - ----- Method: ServiceGui>>initialize (in category 'initialize-release') ----- initialize + super initialize. + menu := OrderedCollection new. + bar := AlignmentMorph newRow. - menu _ OrderedCollection new. - bar _ AlignmentMorph newRow. n := OrderedCollection with: 0! Item was changed: ----- Method: ServiceGui>>menuItemForCategory: (in category 'servicecategory') ----- menuItemForCategory: aServiceCategory "Returns a menuItem triggering self" | submenu | + submenu := self subMenuFor: aServiceCategory. - submenu _ self subMenuFor: aServiceCategory. self menu add: (aServiceCategory menuLabelNumbered: self n) subMenu: submenu! Item was changed: ----- Method: ServiceGui>>buttonForCategory: (in category 'servicecategory') ----- buttonForCategory: aService "see getstate for availability?" | aButton | aButton := PluggableButtonMorph on: [:button | aService requestor: button requestor. + self class openMenuFor: aService] - self class openMenuFor: aService] fixTemps getState: nil action: #value:. aButton arguments: (Array with: aButton). self styleButton: aButton. aButton label: aService buttonLabel. ^aButton! Item was changed: ----- Method: ServiceRegistry class>>rebuild (in category 'as yet unclassified') ----- rebuild | old | old := Current. + [Current := self new. - [Current _ self new. Current build] on: Error do: [:err | (self confirm: 'An error occured during build. Debug it?') ifTrue: [err signal]. Current := old]! Item was changed: ----- Method: ServiceShortcuts class>>setPreferences (in category 'as yet unclassified') ----- setPreferences | mm | + mm := self map copy. - mm _ self map copy. (0 to: 9) do: [:i | #('ctrl-' 'cmd-' 'ctrl-cmd-' ) do: [:str | | short | + short := (str , i asString) asSymbol. - short _ (str , i asString) asSymbol. self insertPrefShortcut: short]]. #(#up #down #left #right ) do: [:s | self insertPrefShortcut: ('ctrl-cmd-' , s) asSymbol.]. mm keysAndValuesDo: [:k :v | ServicePreferences setPreference: k toValue: v]. ((Array new: 3) at: 1 put: ((Array new: 3) at: 1 put: #inlineServicesInMenu; at: 2 put: true; at: 3 put: 'Inline the services the squeak menus'; yourself); at: 2 put: ((Array new: 3) at: 1 put: #useOnlyServicesInMenu; at: 2 put: false; at: 3 put: 'Use only services and not regular menu items'; yourself); at: 3 put: ((Array new: 3) at: 1 put: #useServicesInBrowserButtonBar; at: 2 put: true; at: 3 put: 'Use a service-based button bar'; yourself); yourself) do: [:tr | ServicePreferences addPreference: tr first categories: #('-- settings --' ) default: tr second balloonHelp: tr third]! Item was changed: ----- Method: ServiceGui>>menuFor: (in category 'servicecategory') ----- menuFor: aServiceCategory | submenu | + submenu := self subMenuFor: aServiceCategory. - submenu _ self subMenuFor: aServiceCategory. ^ submenu addTitle: (aServiceCategory menuLabel)! Item was changed: ----- Method: ServiceGui class>>initialize (in category 'registering button bars') ----- initialize + bars := OrderedCollection new. - bars _ OrderedCollection new. (TheWorldMenu respondsTo: #registerOpenCommand:) ifTrue: [TheWorldMenu unregisterOpenCommand: 'Services Browser'. TheWorldMenu registerOpenCommand: {'Services Browser'. {PreferenceBrowser. #openForServices}}]! Item was changed: ----- Method: ServiceAction>>text (in category 'accessing') ----- text + ^label isBlock ifTrue: [label value: requestor] ifFalse: [label]! - ^label isBlock ifTrue: [label fixTemps value: requestor] ifFalse: [label]! Item was changed: ----- Method: ServiceProvider>>savePreferencesFor: (in category 'persistence') ----- savePreferencesFor: aService | strm | + "pref := ServicePreferences preferenceAt: aService shortcutPreference. + strm := WriteStream with: ''. - "pref _ ServicePreferences preferenceAt: aService shortcutPreference. - strm _ WriteStream with: ''. strm nextPutAll: aService id; nextPutAll: 'shortcut'; cr; tab; nextPutAll: '^ '; nextPutAll: {pref name. pref preferenceValue. 1000} storeString. self class compileSilently: strm contents classified: 'saved preferences'." aService isCategory ifTrue: [aService externalPreferences doWithIndex: [:e :i | + strm := WriteStream with: aService id asString. - strm _ WriteStream with: aService id asString. strm nextPutAll: e id asString; cr; tab; nextPutAll: '^ '; nextPutAll: {aService childrenPreferences. e id. i} storeString. e provider class compileSilently: strm contents classified: 'saved preferences']]! Item was changed: ----- Method: BasicRequestor>>newCaption (in category 'generic requests') ----- newCaption + caption := 'Enter text'. + answer := String new writeStream.! - caption _ 'Enter text'. - answer _ WriteStream on:''! Item was changed: ----- Method: ServicePreferences class>>replayPreferences: (in category 'replaying') ----- replayPreferences: preferences | s v | + s := SortedCollection new - s _ SortedCollection new sortBlock: [:a :b | a last < b last]. s addAll: preferences; reSort. s do: [:e | + v := self valueOfPreference: e first ifAbsent: ''. - v _ self valueOfPreference: e first ifAbsent: ''. self setPreference: e first toValue: (v ifEmpty: [''] ifNotEmpty: [v , ' ']) , e second]! Item was changed: ----- Method: ServiceCategory>>replaceChildren (in category 'preferences') ----- replaceChildren ServiceRegistry ifInteractiveDo: [services do: [:s | s provider + ifNotNil: [:p | p class removeSelector: (self id , s id) asSymbol]]]. + services := self newChildren. - ifNotNilDo: [:p | p class removeSelector: (self id , s id) asSymbol]]]. - services _ self newChildren. services do: [:e | (ServicePreferences preferenceAt: e shortcutPreference) + ifNotNil: [:p | p categoryList: {'-- keyboard shortcuts --'. self id asString}]. - ifNotNilDo: [:p | p categoryList: {'-- keyboard shortcuts --'. self id asString}]. ServiceRegistry ifInteractiveDo: [self provider savePreferencesFor: self]]! Item was changed: ----- Method: BrowserRequestor>>getNewVariableName (in category 'requests') ----- getNewVariableName + ^ UIManager default request: 'Enter the new variable name' translated initialAnswer: 'foo'! - ^ UIManager default request: 'Enter the new variable name' - initialAnswer: 'foo'! |
Free forum by Nabble | Edit this page |