Etoys: System-kfr.64.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Etoys: System-kfr.64.mcz

commits-2
Karl Ramberg uploaded a new version of System to project Etoys:
http://source.squeak.org/etoys/System-kfr.64.mcz

==================== Summary ====================

Name: System-kfr.64
Author: kfr
Time: 24 October 2012, 11:24:27 pm
UUID: 6ee1e9a6-b91d-da44-a775-eec897e30213
Ancestors: System-bf.63

Register preferences as a file service and make storing and loading preferences a little more flexible.

=============== Diff against System-bf.63 ===============

Item was added:
+ ----- Method: Preferences class>>fileReaderServicesForFile:suffix: (in category 'services') -----
+ fileReaderServicesForFile: fullName suffix: suffix  
+
+ ^(self registeredPreferencesFileSuffixes includes: suffix )
+ ifTrue: [ self services ]
+ ifFalse: [ #() ] !

Item was changed:
  ----- Method: Preferences class>>loadPreferencesFrom: (in category 'personalization') -----
+ loadPreferencesFrom: aFileName
- loadPreferencesFrom: aFileName
  | stream params dict desktopColor |
+ stream := ReferenceStream oldFileNamed: aFileName.
+ params := stream next.
+ self
+ assert: (params isKindOf: IdentityDictionary).
- stream _ ReferenceStream fileNamed: aFileName.
- params _ stream next.
- self assert: (params isKindOf: IdentityDictionary).
  params removeKey: #PersonalDictionaryOfPreferences.
+ dict := stream next.
+ self
+ assert: (dict isKindOf: IdentityDictionary).
+ desktopColor := stream next.
- dict _ stream next.
- self assert: (dict isKindOf: IdentityDictionary).
- desktopColor _ stream next.
  stream close.
+ dict
+ keysAndValuesDo: [:key :value | (self
+ preferenceAt: key
+ ifAbsent: [])
+ ifNotNilDo: [:pref | pref preferenceValue: value preferenceValue]].
+ params
+ keysAndValuesDo: [:key :value | self setParameter: key to: value].
- dict keysAndValuesDo:
- [:key :value | (self preferenceAt: key ifAbsent: [nil]) ifNotNilDo:
- [:pref | pref preferenceValue: value preferenceValue]].
-
- params keysAndValuesDo: [ :key :value | self setParameter: key to: value ].
-
  Smalltalk isMorphic
+ ifTrue: [World fillStyle: desktopColor]
+ ifFalse: [self desktopColor: desktopColor.
+ ScheduledControllers updateGray]!
- ifTrue: [ World fillStyle: desktopColor ]
- ifFalse: [ self desktopColor: desktopColor. ScheduledControllers updateGray ].
- !

Item was added:
+ ----- Method: Preferences class>>registeredPreferencesFileSuffixes (in category 'services') -----
+ registeredPreferencesFileSuffixes
+ ^{'prefs'}!

Item was changed:
  ----- Method: Preferences class>>restorePreferencesFromDisk (in category 'personalization') -----
  restorePreferencesFromDisk
+ | result |
+ result := (FileList2 modalFileSelectorForSuffixes: #('prefs')) .
+ result ifNil: [^ self].
+ self restorePreferencesFromDisk: result fullName
+
- (FileDirectory default fileExists: 'my.prefs')
- ifTrue: [ Cursor wait showWhile: [
- [ self loadPreferencesFrom: 'my.prefs' ] on: Error do: [ :ex | self inform: 'there was an error restoring the preferences' translated]
- ] ]
- ifFalse: [ self inform: 'you haven''t saved your preferences yet!!' translated].
  !

Item was added:
+ ----- Method: Preferences class>>restorePreferencesFromDisk: (in category 'personalization') -----
+ restorePreferencesFromDisk: aFile
+ Cursor wait
+ showWhile: [[self loadPreferencesFrom: aFile]
+ on: Error
+ do: [:ex | self inform: 'there was an error restoring the preferences' translated]]!

Item was added:
+ ----- Method: Preferences class>>serviceLoadPreferences (in category 'services') -----
+ serviceLoadPreferences
+ "Answer a service for loading preferences from disk"
+
+ ^ SimpleServiceEntry
+ provider: self
+ label: 'load preferences' translatedNoop
+ selector: #restorePreferencesFromDisk:
+ description: 'load preferences file from disk' translatedNoop
+ buttonLabel: 'load preferences' translatedNoop!

Item was added:
+ ----- Method: Preferences class>>services (in category 'services') -----
+ services  
+ "Answer the receiver's services"
+
+      ^ Array with: self serviceLoadPreferences !

Item was changed:
  ----- Method: Preferences class>>storePreferencesIn: (in category 'personalization') -----
  storePreferencesIn: aFileName
  | stream |
  #(Prevailing PersonalPreferences) do: [ :ea | Parameters removeKey: ea ifAbsent: []].  
  stream _ ReferenceStream fileNamed: aFileName.
  stream nextPut: Parameters.
  stream nextPut: DictionaryOfPreferences.
  Smalltalk isMorphic
  ifTrue: [ stream nextPut: World fillStyle ]
  ifFalse: [ stream nextPut: DesktopColor ].
  stream close.!

Item was changed:
  ----- Method: Preferences class>>storePreferencesToDisk (in category 'personalization') -----
  storePreferencesToDisk
+ | newName |
+ newName := UIManager default request: 'Please confirm name for save...' initialAnswer: 'myPreferences'.
+ newName isEmpty
+ ifTrue: [^ self].
+ Cursor wait
+ showWhile: [[self storePreferencesIn: newName , '.prefs']
+ on: Error
+ do: [:ex | self inform: 'there was an error storing your preferences to disk. you probably already have stored your preferences' translated]]!
- Cursor wait showWhile: [
- [ self storePreferencesIn: 'my.prefs' ] on: Error do: [ :ex | self inform: 'there was an error storing your preferences to disk' translated]]!

_______________________________________________
etoys-dev mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/etoys-dev