SettingsDialog.st
branchjv
changeset 12147 5f1d0885c1bc
parent 12128 a7ff7d66ee85
child 12148 c675c7212c87
--- a/SettingsDialog.st	Mon Feb 06 23:27:23 2012 +0000
+++ b/SettingsDialog.st	Tue Feb 07 01:13:19 2012 +0000
@@ -34,6 +34,13 @@
 	privateIn:SettingsDialog::HierarchicalApplicationList
 !
 
+AbstractSettingsApplication subclass:#SettingsFilenameAppl
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:SettingsDialog
+!
+
 !SettingsDialog class methodsFor:'documentation'!
 
 copyright
@@ -448,8 +455,17 @@
 saveSettingsAsDefaultSettings
     | file |
 
-    file := (Filename currentDirectory construct:UserPreferences defaultSettingsFilename) asAbsoluteFilename.
+    "JV@2012-02-07: Changed to save preferences back to file from which
+     they have been loaded (if known). If no such file is known,
+     save to DEFAULT USER SETTINGS file (default ~/.smalltalk/settings.rc)"
+
+    file := UserPreferences current at: #settingsFilename ifAbsent:[nil].
+    file isNil ifTrue:[
+        file := UserPreferences defaultUserSettingsFile.
+    ].
     self saveSettingsTo:file.
+
+    "Modified: / 07-02-2012 / 00:45:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 saveSettingsTo:file
@@ -1397,9 +1413,11 @@
     rootItem label:lbl "allBold".
     rootItem nameString:lbl.
     rootItem icon:self class settingsIcon.
+    rootItem applicationClass: SettingsFilenameAppl.
     ^ rootItem
 
     "Created: / 03-11-2007 / 14:22:01 / cg"
+    "Modified: / 07-02-2012 / 01:03:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 initialize
@@ -1566,10 +1584,107 @@
     ^ self applicationClass isNil
 ! !
 
+!SettingsDialog::SettingsFilenameAppl class methodsFor:'interface specs'!
+
+windowSpec
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the UIPainter may not be able to read the specification."
+
+    "
+     UIPainter new openOnClass:SettingsDialog::SettingsFilenameAppl andSelector:#windowSpec
+     SettingsDialog::SettingsFilenameAppl new openInterface:#windowSpec
+     SettingsDialog::SettingsFilenameAppl open
+    "
+
+    <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)
+              translateLabel: true
+              labelChannel: settingsFilenameAspect
+            )
+           )
+         
+        )
+      )
+! !
+
+!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'!
+
+openSettingsFile: filename 
+
+    UserPreferences current fileBrowserClass
+        openOnFileNamed:filename editing:true
+
+    "Created: / 07-02-2012 / 01:08:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!SettingsDialog::SettingsFilenameAppl methodsFor:'protocol'!
+
+basicReadSettings
+    ^self
+
+    "Modified: / 07-02-2012 / 01:02:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+basicSaveSettings
+    ^self
+
+    "Modified: / 07-02-2012 / 01:03:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!SettingsDialog::SettingsFilenameAppl methodsFor:'queries'!
+
+hasUnsavedChanges
+    ^false
+
+    "Modified: / 07-02-2012 / 01:03:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !SettingsDialog class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.97 2011/11/25 14:44:20 cg Exp $'
+    ^ '$Id: SettingsDialog.st 7874 2012-02-07 01:13:19Z vranyj1 $'
 !
 
 version_CVS
@@ -1577,7 +1692,7 @@
 !
 
 version_SVN
-    ^ '$Id: SettingsDialog.st 7854 2012-01-30 17:49:41Z vranyj1 $'
+    ^ '$Id: SettingsDialog.st 7874 2012-02-07 01:13:19Z vranyj1 $'
 ! !
 
 SettingsDialog initialize!