allow for a nil-printer
authorfm
Mon, 07 Aug 2006 15:26:10 +0200
changeset 6853 daa2e7da1c7e
parent 6852 39c9b68020eb
child 6854 7934fb88c60b
allow for a nil-printer
AbstractSettingsApplication.st
--- a/AbstractSettingsApplication.st	Mon Aug 07 13:09:57 2006 +0200
+++ b/AbstractSettingsApplication.st	Mon Aug 07 15:26:10 2006 +0200
@@ -6953,23 +6953,27 @@
 !AbstractSettingsApplication::PrinterSettingsAppl methodsFor:'actions'!
 
 basicReadSettings
-    self 
-        readAspects:
-            #( 
-                topMargin
-                bottomMargin
-                leftMargin
-                rightMargin
-                landscape
-                printCommand
-                printFilename
-                supportsColor
-            )
-        from:Printer.
+    Printer notNil ifTrue:[
+        self 
+            readAspects:
+                #( 
+                    topMargin
+                    bottomMargin
+                    leftMargin
+                    rightMargin
+                    landscape
+                    printCommand
+                    printFilename
+                    supportsColor
+                )
+            from:Printer.
+    ].
 
     self printerTypeSelection value:(self possiblePrinters identityIndexOf:Printer).
     self pageFormatList notEmpty ifTrue:[ self pageFormat value:Printer pageFormat ].
     self printerTypeSelectionOrUnitListChanged.
+
+    "Modified: / 07-08-2006 / 15:22:27 / fm"
 !
 
 basicSaveSettings
@@ -7050,10 +7054,12 @@
 landscape
 
     landscape isNil ifTrue:[
-        landscape := Printer landscape asValue.
+        landscape := (Printer isNil ifTrue:[ false ] ifFalse:[ Printer landscape])  asValue.
         landscape onChangeSend:#updateModifiedChannel to:self
     ].
     ^ landscape.
+
+    "Modified: / 07-08-2006 / 15:22:44 / fm"
 !
 
 leftMargin
@@ -7084,9 +7090,11 @@
 pageFormatList
 
     pageFormatList isNil ifTrue:[
-        pageFormatList := Printer defaultPageFormats asList.
+        pageFormatList := (Printer isNil ifTrue:[ #() ] ifFalse: [Printer defaultPageFormats]) asList.
     ].
     ^ pageFormatList.
+
+    "Modified: / 07-08-2006 / 15:23:19 / fm"
 !
 
 printCommand
@@ -7114,10 +7122,12 @@
 
 printFilename
     printFilename isNil ifTrue:[
-        printFilename := (Printer printFilename ? '') asValue.
+        printFilename := (Printer isNil ifTrue:[''] ifFalse:[Printer printFilename ? '']) asValue.
         printFilename onChangeSend:#updateModifiedChannel to:self
     ].
     ^ printFilename.
+
+    "Modified: / 07-08-2006 / 15:24:45 / fm"
 !
 
 printerType
@@ -7164,19 +7174,23 @@
 supportsColor
 
     supportsColor isNil ifTrue:[
-        supportsColor := Printer supportsColor asValue.
+        supportsColor := (Printer notNil and:[Printer supportsColor]) asValue.
         supportsColor onChangeSend:#updateModifiedChannel to:self
     ].
     ^ supportsColor.
+
+    "Modified: / 07-08-2006 / 15:24:22 / fm"
 !
 
 topMargin
 
     topMargin isNil ifTrue:[
-        topMargin := Printer topMargin asValue.
+        topMargin := (Printer isNil ifTrue:[ 0 ] ifFalse:[ Printer topMargin ]) asValue.
         topMargin onChangeSend:#updateModifiedChannel to:self
     ].
     ^ topMargin.
+
+    "Modified: / 07-08-2006 / 15:21:50 / fm"
 !
 
 unitList
@@ -7203,7 +7217,7 @@
 !
 
 printerTypeSelectionOrUnitListChanged
-    | p hasPageSize hasMargins unit|
+    | p hasPageSize hasMargins unit printerSupportsPostscript|
 
     self printerTypeSelection value ~~ 0 ifTrue:[
         p := self possiblePrinters at:(self printerTypeSelection value).
@@ -7247,12 +7261,15 @@
         self printCommand value:(p printCommand).
         self printFilename value:(p printFilename ? '').
     ].
-    self enableColorBox value:p supportsPostscript.
-    p supportsPostscript ifFalse:[
+    printerSupportsPostscript := p notNil and:[p supportsPostscript].
+    self enableColorBox value:printerSupportsPostscript.
+    printerSupportsPostscript ifFalse:[
         self supportsColor value:false
     ] ifTrue:[
         self supportsColor value:(Printer supportsColor).
     ]
+
+    "Modified: / 07-08-2006 / 15:24:06 / fm"
 !
 
 unitListChanged
@@ -7288,6 +7305,8 @@
 hasUnsavedChanges
     | printer unit|
 
+    Printer isNil ifTrue:[^ false].
+
     self selectedUnit value == 2 ifTrue:[
         unit := #mm
     ] ifFalse:[
@@ -7314,6 +7333,8 @@
         Printer supportsColor ~= self supportsColor value ifTrue:[^ true].
     ].
     ^ false
+
+    "Modified: / 07-08-2006 / 15:25:47 / fm"
 !
 
 possiblePrinters
@@ -12217,5 +12238,5 @@
 !AbstractSettingsApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractSettingsApplication.st,v 1.233 2006-07-03 14:55:10 cg Exp $'
-! !
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractSettingsApplication.st,v 1.234 2006-08-07 13:26:10 fm Exp $'
+! !