--- a/SettingsDialog.st Sun Mar 01 15:38:23 2015 +0100
+++ b/SettingsDialog.st Sun Mar 01 15:49:30 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2002 by eXept Software AG
All Rights Reserved
@@ -499,7 +501,7 @@
"Modified: / 27-10-2010 / 11:24:54 / cg"
!
-saveSettingsAsDefaultSettings
+currentSettingsFilename
| file |
"JV@2012-02-07: Changed to save preferences back to file from which
@@ -510,7 +512,11 @@
file isNil ifTrue:[
file := UserPreferences defaultUserSettingsFile.
].
- self saveSettingsTo:file.
+ ^ file.
+!
+
+saveSettingsAsDefaultSettings
+ self saveSettingsTo:(self currentSettingsFilename).
"Modified: / 07-02-2012 / 00:45:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
@@ -704,15 +710,7 @@
!
destroyAll
- self applicationList do:[:applItem |
- |application|
-
- applItem isCategory ifFalse:[
- (application := applItem application) notNil ifTrue:[
- application close.
- ].
- ].
- ].
+ self realApplicationsDo:[:app | app close ].
!
doIndicatorClick:index
@@ -758,7 +756,12 @@
item application help.
!
-reopenLauncher
+reopenLauncher
+ "force the launcher to reopen an instance of itself.
+ Done whenever relevant look&feel settings are changed
+ (actually a workaround - a much better solution would be to teach
+ all smalltalk applications/views to dynamically update their style)."
+
|app|
(app := self requestor) notNil ifTrue:[
@@ -769,33 +772,46 @@
!
sendLoadRequestToAll
- self applicationList do:[:applItem |
- (applItem isCategory not and:[applItem application notNil]) ifTrue:[
- applItem application readSettings.
- ]
+ "ask all subApps to reload their idea of the current settings.
+ Do this, after userPrefs have been loaded from a file,
+ while a settingsDialog is open"
+
+ self realApplicationsDo:[:app |
+ app readSettings.
+ app clearDidModifySettings.
].
"Modified: / 24-08-2010 / 18:41:36 / sr"
!
sendSaveRequestToAll
- self applicationList do:[ : applItem |
- (applItem isCategory not and:[applItem application notNil]) ifTrue:[
- applItem application saveRequest ifFalse:[
- ^ false
- ].
+ "give all subapps a chance to apply any changes.
+ No longer needed, as we do this at the time the subApp
+ is changed; so only the current app needs this chance again,
+ when about to close (seesendSaveRequestToCurrent) "
+
+ self realApplicationsDo:[ :app |
+ app saveRequest ifFalse:[
+ ^ false
].
].
^ true
!
sendSaveRequestToCurrent
- | item |
+ "when about to close the dialog, give the current
+ subapp a chance to apply any changes"
+
+ | item currentApp |
item := self selectedItem value.
- (item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ ^ true].
+ (item isNil
+ or:[item isCategory
+ or:[(currentApp := item application) isNil]]
+ ) ifTrue:[ ^ true].
+
self withWaitCursorDo:[
- ^ item application saveRequest.
+ ^ currentApp saveRequest.
].
^ true
! !
@@ -1273,6 +1289,22 @@
"Modified: / 03-11-2007 / 14:23:28 / cg"
!
+realApplications
+ "return a collection of all real (non-folder) applications.
+ A helper to avoid code duplication"
+
+ ^ self applicationList
+ select:[:appItem | appItem isCategory not and:[ appItem application notNil]]
+ thenCollect:[:appItem | appItem application].
+!
+
+realApplicationsDo:aBlock
+ "evaluate aBlock for all real (non-folder) applications.
+ A helper to avoid code duplication"
+
+ self realApplications do:aBlock.
+!
+
removeItem:anItem
"remove an application from the settingsTree"
@@ -1498,6 +1530,19 @@
| req |
(self sendSaveRequestToCurrent == false) ifTrue:[^ self].
+
+ "/ if any of my subApps has made a change, ask user if he wants
+ "/ to write the settings file
+ (self realApplications contains:[:app | app didModifySettings]) ifTrue:[
+ (Dialog
+ confirm:(resources
+ stringWithCRs:'Save your changed settings in the settings file?\(which is: "%1"\\If not saved, these changes only apply to your current session.'
+ with:self class currentSettingsFilename allBold))
+ ifTrue:[
+ self saveSettingsWithoutAskingForFile.
+ ].
+ ].
+
self destroyAll.
req := self requestor.
@@ -1555,6 +1600,7 @@
askForFileAndSaveSettings
self class askForFileAndSaveSettings.
+ self realApplicationsDo:[:app | app clearDidModifySettings].
!
loadSettingsFromFile
@@ -1610,6 +1656,7 @@
saveSettingsWithoutAskingForFile
self class saveSettingsWithoutAskingForFile.
+ self realApplicationsDo:[:app | app clearDidModifySettings].
! !
!SettingsDialog methodsFor:'selection'!
@@ -1870,7 +1917,7 @@
saveAsPrivateSettingsFile
|fn|
- fn := self defaultSettingsFile.
+ fn := UserPreferences defaultUserSettingsFile pathName.
SettingsDialog saveSettingsTo:fn.
UserPreferences current at:#settingsFilename put:fn.
settingsFilenameHolder value:fn.
@@ -1953,10 +2000,6 @@
!SettingsDialog::SettingsFilenameAppl methodsFor:'queries'!
-defaultSettingsFile
- ^ UserPreferences defaultUserSettingsFile pathName
-!
-
hasUnsavedChanges
^false
@@ -1964,19 +2007,17 @@
!
settingsFile
- ^ UserPreferences current
- at:#settingsFilename
- ifAbsent:[self defaultSettingsFile].
+ ^ SettingsDialog currentSettingsFilename
! !
!SettingsDialog class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.126 2015-02-21 14:16:53 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.127 2015-03-01 14:49:30 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.126 2015-02-21 14:16:53 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.127 2015-03-01 14:49:30 cg Exp $'
! !