#UI_ENHANCEMENT
authorClaus Gittinger <cg@exept.de>
Tue, 06 Oct 2015 22:32:31 +0200
changeset 15887 933c82d405ca
parent 15886 478b3120e2ae
child 15888 1d7798d909c8
#UI_ENHANCEMENT class: Tools::FontSettingsApplication class definition added: #useXftFontsOnly #useXftFontsOnlyVisible comment/format in: #labelsFontLabelHolder #linuxFontWorkaround #linuxFontWorkaroundVisible changed: #basicReadFontSettings #basicSaveSettings #hasUnsavedChanges #windowSpec xft fixes
Tools__FontSettingsApplication.st
--- a/Tools__FontSettingsApplication.st	Tue Oct 06 18:15:01 2015 +0200
+++ b/Tools__FontSettingsApplication.st	Tue Oct 06 22:32:31 2015 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "{ Package: 'stx:libtool' }"
 
 "{ NameSpace: Tools }"
@@ -10,7 +12,7 @@
 		textLabel labelLabel listsLabel menuLabel inputFieldLabel
 		inputFieldDef inputFieldFontLabelHolder otherLabel
 		linuxFontWorkaround otherDef tooltipDef tooltipFontLabelHolder
-		tooltipLabel'
+		tooltipLabel useXftFontsOnly'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Smalltalk'
@@ -169,8 +171,12 @@
                    isReadOnly: true
                    hasKeyboardFocusInitially: false
                    extent: (Point 637 132)
+                   postBuildCallback: postBuildHelpLabel:
                    viewClassName: 'ListView'
-                   postBuildCallback: postBuildHelpLabel:
+                 )
+                (DividerSpec
+                   name: 'Separator14'
+                   extent: (Point 637 4)
                  )
                 (ViewSpec
                    name: 'CodeBox'
@@ -184,27 +190,27 @@
                          translateLabel: true
                          adjust: left
                        )
+                      (ActionButtonSpec
+                         label: 'Change...'
+                         name: 'Button1'
+                         layout: (LayoutFrame 100 0.0 7 0 205 0 29 0)
+                         translateLabel: true
+                         tabable: true
+                         model: changeTextFont
+                       )
                       (LabelSpec
                          label: 'Text Font'
                          name: 'Label2'
-                         layout: (LayoutFrame 110 0 22 0 -2 1 44 0)
+                         layout: (LayoutFrame 210 0 7 0 -2 1 29 0)
                          translateLabel: true
                          labelChannel: textFontLabelHolder
                          adjust: left
                          postBuildCallback: postBuildTextFontLabel:
                        )
-                      (ActionButtonSpec
-                         label: 'Change...'
-                         name: 'Button1'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
-                         translateLabel: true
-                         tabable: true
-                         model: changeTextFont
-                       )
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (ViewSpec
                    name: 'InputFieldsBox'
@@ -218,27 +224,27 @@
                          translateLabel: true
                          adjust: left
                        )
+                      (ActionButtonSpec
+                         label: 'Change...'
+                         name: 'ChangeText'
+                         layout: (LayoutFrame 100 0.0 7 0 205 0 29 0)
+                         translateLabel: true
+                         tabable: true
+                         model: changeInputFieldFont
+                       )
                       (LabelSpec
                          label: 'InputFields Font'
                          name: 'InputFieldsFont'
-                         layout: (LayoutFrame 110 0 22 0 -2 1 44 0)
+                         layout: (LayoutFrame 210 0 7 0 -2 1 29 0)
                          translateLabel: true
                          labelChannel: inputFieldFontLabelHolder
                          adjust: left
                          postBuildCallback: postBuildInputFieldFontLabel:
                        )
-                      (ActionButtonSpec
-                         label: 'Change...'
-                         name: 'ChangeText'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
-                         translateLabel: true
-                         tabable: true
-                         model: changeInputFieldFont
-                       )
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (ViewSpec
                    name: 'ListsBox'
@@ -252,27 +258,27 @@
                          translateLabel: true
                          adjust: left
                        )
+                      (ActionButtonSpec
+                         label: 'Change...'
+                         name: 'ChangeLists'
+                         layout: (LayoutFrame 100 0.0 7 0 205 0 29 0)
+                         translateLabel: true
+                         tabable: true
+                         model: changeListsFont
+                       )
                       (LabelSpec
                          label: 'Lists Font'
                          name: 'ListsFont'
-                         layout: (LayoutFrame 110 0 22 0 -2 1 44 0)
+                         layout: (LayoutFrame 210 0 7 0 -2 1 29 0)
                          translateLabel: true
                          labelChannel: listsFontLabelHolder
                          adjust: left
                          postBuildCallback: postBuildListsFontLabel:
                        )
-                      (ActionButtonSpec
-                         label: 'Change...'
-                         name: 'ChangeLists'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
-                         translateLabel: true
-                         tabable: true
-                         model: changeListsFont
-                       )
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (ViewSpec
                    name: 'MenusBox'
@@ -286,27 +292,27 @@
                          translateLabel: true
                          adjust: left
                        )
+                      (ActionButtonSpec
+                         label: 'Change...'
+                         name: 'ChangeMenus'
+                         layout: (LayoutFrame 100 0.0 7 0 205 0 29 0)
+                         translateLabel: true
+                         tabable: true
+                         model: changeMenusFont
+                       )
                       (LabelSpec
                          label: 'Menus Font'
                          name: 'MenusFont'
-                         layout: (LayoutFrame 110 0 22 0 -2 1 44 0)
+                         layout: (LayoutFrame 210 0 7 0 -2 1 29 0)
                          translateLabel: true
                          labelChannel: menusFontLabelHolder
                          adjust: left
                          postBuildCallback: postBuildMenuesFontLabel:
                        )
-                      (ActionButtonSpec
-                         label: 'Change...'
-                         name: 'ChangeMenus'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
-                         translateLabel: true
-                         tabable: true
-                         model: changeMenusFont
-                       )
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (ViewSpec
                    name: 'LabelsBox'
@@ -320,27 +326,27 @@
                          translateLabel: true
                          adjust: left
                        )
+                      (ActionButtonSpec
+                         label: 'Change...'
+                         name: 'ChangeLabels'
+                         layout: (LayoutFrame 100 0.0 7 0 205 0 29 0)
+                         translateLabel: true
+                         tabable: true
+                         model: changeLabelsFont
+                       )
                       (LabelSpec
                          label: 'Labels'
                          name: 'LabelsFont'
-                         layout: (LayoutFrame 110 0 22 0 -2 1 44 0)
+                         layout: (LayoutFrame 210 0 7 0 -2 1 29 0)
                          translateLabel: true
                          labelChannel: labelsFontLabelHolder
                          adjust: left
                          postBuildCallback: postBuildLabelsFontLabel:
                        )
-                      (ActionButtonSpec
-                         label: 'Change...'
-                         name: 'ChangeLabels'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
-                         translateLabel: true
-                         tabable: true
-                         model: changeLabelsFont
-                       )
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (ViewSpec
                    name: 'ButtonsBox'
@@ -354,27 +360,27 @@
                          translateLabel: true
                          adjust: left
                        )
+                      (ActionButtonSpec
+                         label: 'Change...'
+                         name: 'Change Buttons'
+                         layout: (LayoutFrame 100 0.0 7 0 205 0 29 0)
+                         translateLabel: true
+                         tabable: true
+                         model: changeButtonsFont
+                       )
                       (LabelSpec
                          label: 'Buttons Font'
                          name: 'ButtonsFont'
-                         layout: (LayoutFrame 110 0 22 0 -2 1 44 0)
+                         layout: (LayoutFrame 210 0 7 0 -2 1 29 0)
                          translateLabel: true
                          labelChannel: buttonsFontLabelHolder
                          adjust: left
                          postBuildCallback: postBuildButtonsFontLabel:
                        )
-                      (ActionButtonSpec
-                         label: 'Change...'
-                         name: 'Change Buttons'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
-                         translateLabel: true
-                         tabable: true
-                         model: changeButtonsFont
-                       )
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (ViewSpec
                    name: 'ToolTipsBox'
@@ -388,27 +394,27 @@
                          translateLabel: true
                          adjust: left
                        )
+                      (ActionButtonSpec
+                         label: 'Change...'
+                         name: 'Button11'
+                         layout: (LayoutFrame 100 0.0 7 0 205 0 29 0)
+                         translateLabel: true
+                         tabable: true
+                         model: changeTooltipFont
+                       )
                       (LabelSpec
                          label: 'Label'
                          name: 'Label8'
-                         layout: (LayoutFrame 110 0 22 0 -2 1 44 0)
+                         layout: (LayoutFrame 210 0 7 0 -2 1 29 0)
                          translateLabel: true
                          labelChannel: tooltipFontLabelHolder
                          adjust: left
                          postBuildCallback: postBuildTooltipFontLabel:
                        )
-                      (ActionButtonSpec
-                         label: 'Change...'
-                         name: 'Button11'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
-                         translateLabel: true
-                         tabable: true
-                         model: changeTooltipFont
-                       )
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (ViewSpec
                    name: 'OtherBox'
@@ -422,23 +428,23 @@
                          translateLabel: true
                          adjust: left
                        )
+                      (ActionButtonSpec
+                         label: 'Change...'
+                         name: 'Button9'
+                         layout: (LayoutFrame 100 0.0 7 0 205 0 29 0)
+                         translateLabel: true
+                         tabable: true
+                         model: changeOtherFont
+                       )
                       (LabelSpec
                          label: 'Label'
                          name: 'Label6'
-                         layout: (LayoutFrame 110 0 22 0 -2 1 44 0)
+                         layout: (LayoutFrame 210 0 7 0 -2 1 29 0)
                          translateLabel: true
                          labelChannel: otherFontLabelHolder
                          adjust: left
                          postBuildCallback: postBuildOtherFontLabel:
                        )
-                      (ActionButtonSpec
-                         label: 'Change...'
-                         name: 'Button9'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
-                         translateLabel: true
-                         tabable: true
-                         model: changeOtherFont
-                       )
                       (DividerSpec
                          name: 'Separator13'
                          layout: (LayoutFrame 0 0.0 -3 1 0 1.0 0 1)
@@ -446,7 +452,7 @@
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (ViewSpec
                    name: 'AllBox'
@@ -456,14 +462,14 @@
                       (LabelSpec
                          label: 'All'
                          name: 'All'
-                         layout: (LayoutFrame 0 0.0 0 0 0 1.0 20 0)
+                         layout: (LayoutFrame 0 0.0 4 0 0 1.0 24 0)
                          translateLabel: true
                          adjust: left
                        )
                       (ActionButtonSpec
                          label: 'Change...'
                          name: 'ChangeAll'
-                         layout: (LayoutFrame 0 0.0 22 0 105 0 44 0)
+                         layout: (LayoutFrame 100 0.0 11 0 205 0 33 0)
                          translateLabel: true
                          tabable: true
                          model: changeAllFont
@@ -475,7 +481,7 @@
                       )
                     
                    )
-                   extent: (Point 637 50)
+                   extent: (Point 637 45)
                  )
                 (CheckBoxSpec
                    label: 'Linux font workaround: do not reset fonts on snapshot restart'
@@ -485,6 +491,15 @@
                    translateLabel: true
                    extent: (Point 637 30)
                  )
+                (CheckBoxSpec
+                   label: 'Only Use Xft Fonts (Unix Only)'
+                   name: 'CheckBox1'
+                   visibilityChannel: useXftFontsOnlyVisible
+                   model: useXftFontsOnly
+                   activeHelpKey: useXftFontsOnly
+                   translateLabel: true
+                   extent: (Point 637 30)
+                 )
                 (DividerSpec
                    name: 'Separator12'
                    visibilityChannel: linuxFontWorkaroundVisible
@@ -495,17 +510,10 @@
                    component: 
                   (SpecCollection
                      collection: (
-                      (LabelSpec
-                         label: 'Common Settings:'
-                         name: 'Label4'
-                         layout: (LayoutFrame 0 0.0 11 0 0 1.0 33 0)
-                         translateLabel: true
-                         adjust: left
-                       )
                       (ActionButtonSpec
                          label: 'Default'
                          name: 'Button2'
-                         layout: (LayoutFrame 0 0.0 35 0 130 0 57 0)
+                         layout: (LayoutFrame 0 0.0 13 0 130 0 35 0)
                          activeHelpKey: resetToDefault
                          translateLabel: true
                          tabable: true
@@ -514,7 +522,7 @@
                       (ActionButtonSpec
                          label: 'High Contrast'
                          name: 'Button3'
-                         layout: (LayoutFrame 148 0.0 35 0 298 0 57 0)
+                         layout: (LayoutFrame 148 0.0 13 0 298 0 35 0)
                          activeHelpKey: changeToHighContrast
                          translateLabel: true
                          tabable: true
@@ -523,7 +531,7 @@
                       (ActionButtonSpec
                          label: 'Big Fonts'
                          name: 'Button4'
-                         layout: (LayoutFrame 309 0.0 35 0 459 0 57 0)
+                         layout: (LayoutFrame 309 0.0 13 0 459 0 35 0)
                          activeHelpKey: changeToBigFonts
                          translateLabel: true
                          tabable: true
@@ -532,7 +540,7 @@
                       (ActionButtonSpec
                          label: 'Huge Fonts'
                          name: 'Button5'
-                         layout: (LayoutFrame 470 0.0 35 0 620 0 57 0)
+                         layout: (LayoutFrame 470 0.0 13 0 620 0 35 0)
                          activeHelpKey: changeToHugeFonts
                          translateLabel: true
                          tabable: true
@@ -541,7 +549,7 @@
                       (ActionButtonSpec
                          label: 'ST/X Look'
                          name: 'Button8'
-                         layout: (LayoutFrame 148 0.0 67 0 298 0 89 0)
+                         layout: (LayoutFrame 148 0.0 45 0 298 0 67 0)
                          activeHelpKey: changeToSTXLook
                          translateLabel: true
                          tabable: true
@@ -550,7 +558,7 @@
                       (ActionButtonSpec
                          label: 'Squeak Look'
                          name: 'Button6'
-                         layout: (LayoutFrame 309 0.0 67 0 459 0 89 0)
+                         layout: (LayoutFrame 309 0.0 45 0 459 0 67 0)
                          activeHelpKey: changeToSqueakLook
                          translateLabel: true
                          tabable: true
@@ -559,7 +567,7 @@
                       (ActionButtonSpec
                          label: 'V''Age Look'
                          name: 'Button7'
-                         layout: (LayoutFrame 470 0.0 67 0 620 0 89 0)
+                         layout: (LayoutFrame 470 0.0 45 0 620 0 67 0)
                          activeHelpKey: changeToVisualAgeLook
                          translateLabel: true
                          tabable: true
@@ -568,7 +576,7 @@
                       (ActionButtonSpec
                          label: 'ST/X Look (Xft)'
                          name: 'Button10'
-                         layout: (LayoutFrame 148 0.0 99 0 298 0 121 0)
+                         layout: (LayoutFrame 148 0.0 77 0 298 0 99 0)
                          activeHelpKey: changeToSTXLookXft
                          translateLabel: true
                          tabable: true
@@ -603,16 +611,41 @@
 !FontSettingsApplication methodsFor:'actions'!
 
 basicReadFontSettings
-"/    View readStyleSheetAndUpdateAllStyleCaches.
+    |prefs readFont|
+  
+    self useXftFontsOnly value:(UserPreferences current useXftFontsOnly).
+    
+    prefs := UserPreferences current fontPreferences.
+    prefs isNil ifTrue:[
+        prefs := Dictionary new.
+    ].
+    
+    readFont := 
+        [:key :default |
+            |s fn|
+            
+            s := prefs at:key ifAbsent:nil.
+            s notNil ifTrue:[
+                fn := Font readFrom:s.
+                self useXftFontsOnly value ifTrue:[
+                    fn := XftFontDescription for:fn
+                ].
+            ].
+            fn isNil ifTrue:[
+                fn := default.
+            ].
+            fn
+        ].
+        
     self allOfThem value:SimpleView defaultFont.
-    self otherDef value:SimpleView defaultFont.
-    self labelDef value:Label defaultFont.
-    self buttonDef value:Button defaultFont.
-    self listDef value:SelectionInListView defaultFont.
-    self menuDef value:MenuView defaultFont.
-    self textDef value:TextView defaultFont.
-    self inputFieldDef value:EditField defaultFont.
-    self tooltipDef value:ActiveHelpView defaultFont.
+    self otherDef value:(readFont value:#Other value:SimpleView defaultFont).
+    self labelDef value:(readFont value:#Label value:Label defaultFont).
+    self buttonDef value:(readFont value:#Button value:Button defaultFont).
+    self listDef value:(readFont value:#List value:SelectionInListView defaultFont).
+    self menuDef value:(readFont value:#Menu value:MenuView defaultFont).
+    self textDef value:(readFont value:#Text value:TextView defaultFont).
+    self inputFieldDef value:(readFont value:#InputField value:EditField defaultFont).
+    self tooltipDef value:(readFont value:#Tooltip value:ActiveHelpView defaultFont).
 
     "Modified: / 10-10-2011 / 12:15:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Created: / 06-02-2012 / 12:22:39 / cg"
@@ -630,37 +663,51 @@
 basicSaveSettings
     |fn|
 
-    fn := self otherDef value.
-    SimpleView withAllSubclasses do:[:cls | cls defaultFont:fn].
-
-    fn := self labelDef value.
-    Label defaultFont:fn.
-    CheckBox defaultFont:fn.
-
-    fn := self buttonDef value.
-    Button defaultFont:fn.
-    Toggle defaultFont:fn.
-
-    fn := self textDef value.
-    TextView withAllSubclasses do:[:cls | cls defaultFont:fn].
+    self writeAspects: #(linuxFontWorkaround useXftFontsOnly) to: currentUserPrefs.
 
-    fn := self inputFieldDef value.
-    EditField withAllSubclasses do:[:cls | cls defaultFont:fn].
-
-    fn := self listDef value.
-    SelectionInListView withAllSubclasses do:[:cls | cls defaultFont:fn].
-
-    fn := self tooltipDef value.
-    ActiveHelpView withAllSubclasses do:[:cls | cls defaultFont:fn].
-
-    fn := self menuDef value.
-    ListView defaultFont:fn.
-    MenuView defaultFont:fn.
-    MenuPanel defaultFont:fn.
-    NoteBookView defaultFont:fn.
-    PullDownMenu defaultFont:fn.
-
-    self writeAspects: #(linuxFontWorkaround) to: currentUserPrefs.
+    UserPreferences current fontPreferences:
+        (
+            Dictionary new
+                at:#Other put:(self otherDef value storeString);
+                at:#Label put:(self labelDef value storeString);
+                at:#Button put:(self buttonDef value storeString);
+                at:#Text put:(self textDef value storeString);
+                at:#InputField put:(self inputFieldDef value storeString);
+                at:#List put:(self listDef value storeString);
+                at:#Tooltip put:(self tooltipDef value storeString);
+                at:#Menu put:(self menuDef value storeString);
+                yourself
+        ).
+        
+"/    fn := self otherDef value.
+"/    SimpleView withAllSubclasses do:[:cls | cls defaultFont:fn].
+"/
+"/    fn := self labelDef value.
+"/    Label defaultFont:fn.
+"/    CheckBox defaultFont:fn.
+"/
+"/    fn := self buttonDef value.
+"/    Button defaultFont:fn.
+"/    Toggle defaultFont:fn.
+"/
+"/    fn := self textDef value.
+"/    TextView withAllSubclasses do:[:cls | cls defaultFont:fn].
+"/
+"/    fn := self inputFieldDef value.
+"/    EditField withAllSubclasses do:[:cls | cls defaultFont:fn].
+"/
+"/    fn := self listDef value.
+"/    SelectionInListView withAllSubclasses do:[:cls | cls defaultFont:fn].
+"/
+"/    fn := self tooltipDef value.
+"/    ActiveHelpView withAllSubclasses do:[:cls | cls defaultFont:fn].
+"/
+"/    fn := self menuDef value.
+"/    ListView defaultFont:fn.
+"/    MenuView defaultFont:fn.
+"/    MenuPanel defaultFont:fn.
+"/    NoteBookView defaultFont:fn.
+"/    PullDownMenu defaultFont:fn.
 
     DebugView newDebugger.
 
@@ -918,7 +965,6 @@
 !
 
 labelsFontLabelHolder
-
     labelsFontLabelHolder isNil ifTrue:[
         labelsFontLabelHolder := '' asValue.
     ].
@@ -926,11 +972,9 @@
 !
 
 linuxFontWorkaround
-
     linuxFontWorkaround isNil ifTrue:[
         linuxFontWorkaround := false asValue.
         linuxFontWorkaround onChangeSend:#updateModifiedChannel to:self
-
     ].
     ^ linuxFontWorkaround.
 
@@ -938,7 +982,6 @@
 !
 
 linuxFontWorkaroundVisible
-
     ^OperatingSystem getOSType == #linux
 
     "Created: / 10-10-2011 / 12:57:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -1027,6 +1070,19 @@
         tooltipFontLabelHolder := '' asValue.
     ].
     ^ tooltipFontLabelHolder.
+!
+
+useXftFontsOnly
+    useXftFontsOnly isNil ifTrue:[
+        useXftFontsOnly := false asValue.
+        useXftFontsOnly onChangeSend:#updateModifiedChannel to:self
+    ].
+    ^ useXftFontsOnly.
+!
+
+useXftFontsOnlyVisible
+
+    ^ Screen platformName = 'X11'
 ! !
 
 !FontSettingsApplication methodsFor:'change & update'!
@@ -1181,7 +1237,7 @@
     self inputFieldDef value ~= EditField defaultFont ifTrue:[^ true].
     self tooltipDef value ~= ActiveHelpView defaultFont ifTrue:[^ true].
 
-    (self hasChangedAspectIn: #(linuxFontWorkaround) asComparedTo:currentUserPrefs) ifTrue:[^ true].
+    (self hasChangedAspectIn: #(linuxFontWorkaround useXftFontsOnly) asComparedTo:currentUserPrefs) ifTrue:[^ true].
 
     ^ false
 
@@ -1195,10 +1251,10 @@
 !FontSettingsApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__FontSettingsApplication.st,v 1.12 2014-11-26 16:04:17 stefan Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__FontSettingsApplication.st,v 1.12 2014-11-26 16:04:17 stefan Exp $'
+    ^ '$Header$'
 ! !