--- a/SettingsDialog.st Fri Feb 28 20:31:53 2014 +0100
+++ b/SettingsDialog.st Fri Feb 28 22:29:12 2014 +0100
@@ -35,7 +35,7 @@
!
AbstractSettingsApplication subclass:#SettingsFilenameAppl
- instanceVariableNames:''
+ instanceVariableNames:'settingsFilenameHolder'
classVariableNames:''
poolDictionaries:''
privateIn:SettingsDialog
@@ -1524,7 +1524,11 @@
"a temporary kludge - we need a central systemSettings object for this,
which can be saved/restored with a single store/read."
- |fileName transcript launcher|
+ |oldFile dir fileName transcript launcher|
+
+ (oldFile := UserPreferences current at:#settingsFilename) notNil ifTrue:[
+ dir := oldFile asFilename directory.
+ ].
fileName := Dialog
requestFileName:(resources string:'Load Settings from File')
@@ -1532,7 +1536,7 @@
ok:(resources string:'Load')
abort:(resources string:'Cancel')
pattern:'*.stx'
- fromDirectory:nil.
+ fromDirectory:dir.
(fileName size == 0) ifTrue:[
"/ canceled
@@ -1672,70 +1676,75 @@
<resource: #canvas>
^
- #(FullSpec
- name: windowSpec
- window:
- (WindowSpec
- label: 'Settings File'
- name: 'Settings File'
- min: (Point 10 10)
- bounds: (Rectangle 0 0 300 300)
- )
- component:
- (SpecCollection
- collection: (
- (LabelSpec
- label: 'Preferences are stored in file:'
- name: 'Label1'
- layout: (LayoutFrame 0 0 -30 0.5 0 1 0 0.5)
- translateLabel: true
- )
- (LinkButtonSpec
- label: 'LinkButton'
- name: 'EditPreferences'
- layout: (LayoutFrame 0 0 0 0.5 0 1 30 0.5)
- foregroundColor: (Color 0.0 0.0 100.0)
- translateLabel: true
- labelChannel: settingsFilenameAspect
- model: openSettingsFile
- )
- (ActionButtonSpec
- label: 'Edit'
- name: 'Button1'
- layout: (LayoutFrame -120 1 60 0.5 -20 1 85 0.5)
- translateLabel: true
- model: openSettingsFile
- )
- (ActionButtonSpec
- label: 'Reload'
- name: 'Button2'
- layout: (LayoutFrame -230 1 60 0.5 -130 1 85 0.5)
- translateLabel: true
- model: reloadSettingsFile
- )
+ #(FullSpec
+ name: windowSpec
+ window:
+ (WindowSpec
+ label: 'Settings File'
+ name: 'Settings File'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 411 358)
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: 'Preferences are stored in file:'
+ name: 'Label1'
+ layout: (LayoutFrame 0 0 -30 0.5 0 1 0 0.5)
+ translateLabel: true
+ )
+ (LinkButtonSpec
+ label: 'LinkButton'
+ name: 'EditPreferences'
+ layout: (LayoutFrame 0 0 0 0.5 0 1 30 0.5)
+ foregroundColor: (Color 0.0 0.0 100.0)
+ translateLabel: true
+ labelChannel: settingsFilenameHolder
+ model: openSettingsFile
)
-
- )
- )
+ (HorizontalPanelViewSpec
+ name: 'HorizontalPanel1'
+ layout: (LayoutFrame 0 0 53 0.5 0 1 101 0.5)
+ horizontalLayout: rightMax
+ verticalLayout: center
+ horizontalSpace: 3
+ verticalSpace: 3
+ component:
+ (SpecCollection
+ collection: (
+ (ActionButtonSpec
+ label: 'Reload'
+ name: 'Button2'
+ translateLabel: true
+ model: reloadSettingsFile
+ useDefaultExtent: true
+ )
+ (ActionButtonSpec
+ label: 'Save as Private'
+ name: 'Button3'
+ translateLabel: true
+ model: saveAsPrivateSettingsFile
+ useDefaultExtent: true
+ )
+ (ActionButtonSpec
+ label: 'File Browser'
+ name: 'Button1'
+ translateLabel: true
+ model: openSettingsFile
+ useDefaultExtent: true
+ )
+ )
+
+ )
+ )
+ )
+
+ )
+ )
! !
-!SettingsDialog::SettingsFilenameAppl methodsFor:'aspects'!
-
-settingsFilenameAspect
-
- | filename |
-
- filename := UserPreferences current
- at:#settingsFilename
- ifAbsent:[UserPreferences defaultUserSettingsFile pathName].
- ^filename asText
-"/ colorizeAllWith: Color blue;
-"/ actionForAll:[ self openSettingsFile: filename ].
-
- "Created: / 07-02-2012 / 01:08:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-!SettingsDialog::SettingsFilenameAppl methodsFor:'private'!
+!SettingsDialog::SettingsFilenameAppl methodsFor:'actions'!
openSettingsFile
| filename |
@@ -1748,14 +1757,6 @@
"Created: / 07-02-2012 / 11:15:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-openSettingsFile: filename
-
- UserPreferences current fileBrowserClass
- openOnFileNamed:filename editing:true
-
- "Created: / 07-02-2012 / 01:08:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
reloadSettingsFile
| filename |
@@ -1767,6 +1768,37 @@
"Created: / 17-02-2012 / 10:26:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+saveAsPrivateSettingsFile
+ |fn|
+
+ fn := UserPreferences defaultUserSettingsFile pathName.
+ SettingsDialog saveSettingsTo:fn.
+ UserPreferences current at:#settingsFilename put:fn.
+ settingsFilenameHolder value:fn.
+! !
+
+!SettingsDialog::SettingsFilenameAppl methodsFor:'aspects'!
+
+settingsFilenameHolder
+ settingsFilenameHolder isNil ifTrue:[
+ settingsFilenameHolder := nil asValue.
+ self basicReadSettings.
+ ].
+ ^ settingsFilenameHolder
+
+ "Created: / 07-02-2012 / 01:08:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!SettingsDialog::SettingsFilenameAppl methodsFor:'private'!
+
+openSettingsFile: filename
+
+ UserPreferences current fileBrowserClass
+ openOnFileNamed:filename editing:true
+
+ "Created: / 07-02-2012 / 01:08:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
reloadSettingsFile: filename
filename asFilename fileIn.
@@ -1778,9 +1810,15 @@
!SettingsDialog::SettingsFilenameAppl methodsFor:'protocol'!
basicReadSettings
- ^self
+ |filename|
- "Modified: / 07-02-2012 / 01:02:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ filename := UserPreferences current
+ at:#settingsFilename
+ ifAbsent:[UserPreferences defaultUserSettingsFile pathName].
+"/ filename := filename asText
+"/ colorizeAllWith: Color blue;
+"/ actionForAll:[ self openSettingsFile: filename ].
+ self settingsFilenameHolder value:filename.
!
basicSaveSettings
@@ -1800,11 +1838,11 @@
!SettingsDialog class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.110 2014-02-05 18:55:57 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.111 2014-02-28 21:29:12 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.110 2014-02-05 18:55:57 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.111 2014-02-28 21:29:12 cg Exp $'
! !