(FILECREATED "24-Mar-86 16:35:53" {ERIS}<LISPUSERS>KOTO>SETDEFAULTPRINTER.;2 5304   

      changes to:  (VARS SETDEFAULTPRINTERCOMS)
		   (FNS \sdp.get.printer \sdp.menu.subitems)

      previous date: "31-Jan-86 16:42:52" {QV}<BRIGGS>LISP>SETDEFAULTPRINTER.;8)


(* Copyright (c) 1985, 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT SETDEFAULTPRINTERCOMS)

(RPAQQ SETDEFAULTPRINTERCOMS ((* * the regular DEFAULTSUBITEMFN modified to recognize EVAL as a key 
				   to EVAL the CADR of the list to get the subitems)
				(FILES DEFAULTSUBITEMFN)
				(* * the setdefaultprinter functions)
				(FNS \sdp.get.printer \sdp.menu.subitems \sdp.set.printer)
				(* * SDP.PRINTERINFO is the place to look up things like printer 
				   location, it also looks on the name of the printer for a LOCATION 
				   property)
				[INITVARS (SDP.PRINTERINFO NIL)
					  (\\sdp.read.table (COPYREADTABLE (QUOTE ORIG]
				(* * the variables that signal recreating the menu subitems)
				(VARS (\\sdp.known.printers)
				      (\\sdp.menu.subitems))
				(* * insinuate self into background menu)
				[ADDVARS (BackgroundMenuCommands ("Set Default Printer"
								   (\sdp.set.printer (\sdp.get.printer
										       ))
								   
		"Asks for (new) default printer name.  <cr> without entering name aborts change."
								   (EVAL (\sdp.menu.subitems]
				(* * reset the background menu so our change takes effect, and remove 
				   space from the separators when reading printer names)
				(P (SETQ BackgroundMenu)
				   (SETSYNTAX 32 (QUOTE OTHER)
					      \\sdp.read.table))))
(* * the regular DEFAULTSUBITEMFN modified to recognize EVAL as a key to EVAL the CADR of the 
list to get the subitems)

(FILESLOAD DEFAULTSUBITEMFN)
(* * the setdefaultprinter functions)

(DEFINEQ

(\sdp.get.printer
  [LAMBDA NIL                                                (* N.H.Briggs "24-Mar-86 16:24")
                                                             (* TBigham " 2-Dec-85 07:48")
    (DECLARE (GLOBALVARS LASTMOUSEX LASTMOUSEY \\sdp.read.table))
    (LET* ((font (DEFAULTFONT (QUOTE DISPLAY)))
	   (prompt "Enter printer name: ")
	   (window (CREATEW [MAKEWITHINREGION (CREATEREGION
						    LASTMOUSEX LASTMOUSEY
						    [WIDTHIFWINDOW
						      (IPLUS (STRINGWIDTH prompt font)
							       (ITIMES 40 (CHARWIDTH
									   (CHARCODE M)
									   font]
						    (HEIGHTIFWINDOW (FONTPROP font (QUOTE
										    HEIGHT]
			      NIL NIL T)))
          (RESETLST (RESETSAVE (OPENW window)
				   (BQUOTE (CLOSEW , window)))
		      (SETQ input (PROMPTFORWORD prompt NIL NIL window NIL NIL (CHARCODE EOL)))
		      (AND input (CAR (NLSETQ (READ (OPENSTRINGSTREAM input (QUOTE INPUT))
							    \\sdp.read.table])

(\sdp.menu.subitems
  [LAMBDA NIL                                                (* N.H.Briggs "24-Mar-86 16:09")
    (if (AND \\sdp.menu.subitems (EQUAL \\sdp.known.printers DEFAULTPRINTINGHOST))
	then \\sdp.menu.subitems
      else (SETQ \\sdp.known.printers (COPY DEFAULTPRINTINGHOST))
	     (SETQ \\sdp.menu.subitems (NCONC1 [for printer inside \\sdp.known.printers
						      collect
						       (LIST printer (LIST (QUOTE 
										 \sdp.set.printer)
									       (KWOTE printer))
							       (OR (GETPROP (U-CASE printer)
										(QUOTE LOCATION))
								     (CDR (ASSOC (U-CASE 
											  printer)
										     SDP.PRINTERINFO]
						   (LIST "Other..." (QUOTE (\sdp.set.printer
										 (\sdp.get.printer))
									       )
							   
		"Asks for (new) default printer name.  <cr> without entering name aborts change."])

(\sdp.set.printer
  [LAMBDA (printer)                                          (* edited: "31-Dec-85 16:28")
    (if [AND printer (NEQ printer (CAR (SETQ DEFAULTPRINTINGHOST (MKLIST 
									      DEFAULTPRINTINGHOST]
	then (SETQ DEFAULTPRINTINGHOST (CONS printer (REMOVE printer DEFAULTPRINTINGHOST)))
	       (PROMPTPRINT "default printer set to " printer)
      else (PROMPTPRINT "default printer not changed"))
    NIL])
)
(* * SDP.PRINTERINFO is the place to look up things like printer location, it also looks on 
the name of the printer for a LOCATION property)


(RPAQ? SDP.PRINTERINFO NIL)

(RPAQ? \\sdp.read.table (COPYREADTABLE (QUOTE ORIG)))
(* * the variables that signal recreating the menu subitems)


(RPAQQ \\sdp.known.printers NIL)

(RPAQQ \\sdp.menu.subitems NIL)
(* * insinuate self into background menu)


(ADDTOVAR BackgroundMenuCommands ("Set Default Printer" (\sdp.set.printer (\sdp.get.printer))
							  
		"Asks for (new) default printer name.  <cr> without entering name aborts change."
							  (EVAL (\sdp.menu.subitems))))
(* * reset the background menu so our change takes effect, and remove space from the 
separators when reading printer names)

(SETQ BackgroundMenu)
(SETSYNTAX 32 (QUOTE OTHER)
	   \\sdp.read.table)
(PUTPROPS SETDEFAULTPRINTER COPYRIGHT ("Xerox Corporation" 1985 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1800 4346 (\sdp.get.printer 1810 . 2890) (\sdp.menu.subitems 2892 . 3857) (
\sdp.set.printer 3859 . 4344)))))
STOP