Changeset 380
- Timestamp:
- 10/02/08 12:33:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Postscript/printps.pro
r371 r380 44 44 ; 45 45 ;- 46 PRO printps_event, event 46 PRO printps_event, event, uval = uval 47 47 ; 48 48 compile_opt idl2, strictarrsubs … … 54 54 ;------------------------------------------------------------ 55 55 ; What kind of event do we have ? 56 widget_control, event.id, get_uvalue = uval56 IF NOT keyword_set(uval) THEN widget_control, event.id, get_uvalue = uval 57 57 ; case on the event 58 58 CASE uval.name OF … … 135 135 ENDCASE 136 136 ; we destroy the widget 137 widget_control, event.top, /destroy137 IF n_tags(event) GT 1 THEN widget_control, event.top, /destroy 138 138 ; if the file was originally gzipped, then we re-gzip it and exit 139 139 IF uval.gzip THEN BEGIN … … 196 196 ; be completed by .ps and/or .gz. 197 197 ; 198 ; @keyword ARCHIVE {default=0} {type=integer 0 or 1} 199 ; activate to bypass the widget and directly archive the postcript 200 ; (useful to use printps in batch mode) 201 ; 202 ; @keyword DIRECTPRINT {default=not defined} {type=string} 203 ; bypass the widget and directly define the printer that must be used 204 ; to print the postcript file. DIRECTPRINT must correspond to one of 205 ; the names defined in the comoon variables printer_machine_names or 206 ; printer_human_names. useful to use printps in batch mode 207 ; 198 208 ; @uses 199 209 ; <pro>cm_4ps</pro> … … 214 224 ; 215 225 ;- 216 PRO printps, psfilename 226 PRO printps, psfilename, ARCHIVE = archive, DIRECTPRINT = directprint 217 227 ; 218 228 ; this is working only with unix/linux/osX machines … … 263 273 gzipped = strpos(nameps, '.gz') 264 274 ; if the file is gzipped we call gunzip and change its name 265 IF gzipped NE -1 THEN BEGIN275 IF gzipped NE -1 AND NOT keyword_set(archive) THEN BEGIN 266 276 spawn, '\gunzip ' + nameps 267 277 nameps = strmid(nameps, 0, gzipped) 268 endif 278 ENDIF 279 ;------------------------------------------------------------ 280 ; what should we do? 281 ;------------------------------------------------------------ 282 CASE 1 OF 283 ;------------------------------------------------------------ 284 ; direct archiving... 285 ;------------------------------------------------------------ 286 keyword_set(archive):IF gzipped EQ -1 THEN printps_event, uval = {name:'archive', nameps:nameps, gzip:gzipped NE -1} 269 287 ;------------------------------------------------------------ 270 288 ; build the widget 271 289 ;------------------------------------------------------------ 272 base = widget_base(/row, title = 'Postscript file: ' $ 273 + file_basename(nameps)) 290 keyword_set(directprint): BEGIN 291 ; check if directprint is well defined 292 printnumb = (where(strlowcase(printer_machine_names) EQ strlowcase(directprint)))[0] 293 IF printnumb EQ -1 THEN BEGIN 294 printnumb = (where(strlowcase(printer_human_names) EQ strlowcase(directprint)))[0] 295 IF printnumb EQ -1 THEN BEGIN 296 dummy = report('directprint does not correspond to any printer defined in printer_machine_names or printer_human_names common variable') 297 return 298 ENDIF 299 ENDIF 300 ; call printps_event with predefined event and uvalue 301 printps_event, {value:printnumb}, uval = {name:'print', nameps:nameps, gzip:gzipped NE -1} 302 END 303 ;------------------------------------------------------------ 304 ; build the widget 305 ;------------------------------------------------------------ 306 ELSE:BEGIN 307 base = widget_base(/row, title = 'Postscript file: ' $ 308 + file_basename(nameps)) 274 309 ; ps viewers grouped button 275 psviewers = ['no psviewers found']276 IF file_which(getenv('PATH'), 'gv') NE '' THEN $277 psviewers = [psviewers, 'GNU Ghostview']278 IF file_which(getenv('PATH'), 'ggv') NE '' THEN $279 psviewers = [psviewers, 'Gnome Ghostview']280 IF file_which(getenv('PATH'), 'ghostview') NE '' THEN $281 psviewers = [psviewers, 'Ghostview']282 IF file_which(getenv('PATH'), 'gs') NE '' THEN $283 psviewers = [psviewers, 'Ghostscript']284 IF file_which(getenv('PATH'), 'kghostview') NE '' THEN $285 psviewers = [psviewers, 'Kghostview']310 psviewers = ['no psviewers found'] 311 IF file_which(getenv('PATH'), 'gv') NE '' THEN $ 312 psviewers = [psviewers, 'GNU Ghostview'] 313 IF file_which(getenv('PATH'), 'ggv') NE '' THEN $ 314 psviewers = [psviewers, 'Gnome Ghostview'] 315 IF file_which(getenv('PATH'), 'ghostview') NE '' THEN $ 316 psviewers = [psviewers, 'Ghostview'] 317 IF file_which(getenv('PATH'), 'gs') NE '' THEN $ 318 psviewers = [psviewers, 'Ghostscript'] 319 IF file_which(getenv('PATH'), 'kghostview') NE '' THEN $ 320 psviewers = [psviewers, 'Kghostview'] 286 321 ; if at least one of viewer was found we define these buttons 287 IF n_elements(psviewers) GT 1 THEN BEGIN288 psviewers = psviewers[1:*]289 notused = cw_bgroup(base, psviewers, /frame, label_top = 'Visualize' $290 , uvalue = {name:'visualize', nameps:nameps} $291 , /column, /return_name)292 ENDIF322 IF n_elements(psviewers) GT 1 THEN BEGIN 323 psviewers = psviewers[1:*] 324 notused = cw_bgroup(base, psviewers, /frame, label_top = 'Visualize' $ 325 , uvalue = {name:'visualize', nameps:nameps} $ 326 , /column, /return_name) 327 ENDIF 293 328 ; printers list grouped buttons 294 329 ; are the common variables printer_human_names and printer_human_names 295 330 ; defined in a proper way? 296 CASE 1 OF 297 n_elements(printer_human_names) eq 0: $ 298 noting = report('the cm_4ps variable printer_human_names is not defined... !CWe could not propose any printer', /simple) 299 n_elements(printer_human_names) NE n_elements(printer_machine_names): $ 300 noting = report('the cm_4ps variables printer_human_names and !Cprinter_machine_names do not have the same number of arguments... !CWe could not propose any printer', /simple) 301 printer_human_names[0] EQ '': 302 ELSE:notused = $ 303 cw_bgroup(base, printer_human_names, /frame, /column $ 304 , label_top = 'Select printer' $ 305 , uvalue = {name:'print', nameps:nameps, gzip:gzipped NE -1}) 331 CASE 1 OF 332 n_elements(printer_human_names) eq 0: $ 333 noting = report('the cm_4ps variable printer_human_names is not defined... !CWe could not propose any printer', /simple) 334 n_elements(printer_human_names) NE n_elements(printer_machine_names): $ 335 noting = report('the cm_4ps variables printer_human_names and !Cprinter_machine_names do not have the same number of arguments... !CWe could not propose any printer', /simple) 336 printer_human_names[0] EQ '': 337 ELSE:notused = $ 338 cw_bgroup(base, printer_human_names, /frame, /column $ 339 , label_top = 'Select printer' $ 340 , uvalue = {name:'print', nameps:nameps, gzip:gzipped NE -1}) 341 ENDCASE 342 ; 'archive ps' button, can be created only if archive_ps ne 0 343 IF keyword_set(archive_ps) THEN $ 344 notused = widget_button(base, value = 'archive ps' $ 345 , uvalue = {name:'archive', nameps:nameps $ 346 , gzip:gzipped NE -1}) 347 ; quit button 348 notused = widget_button(base, value = 'quit' $ 349 , uvalue = {name:'quit', nameps:nameps $ 350 , gzip:gzipped NE -1}) 351 ;------------------------------------------------------------ 352 widget_control, base, /realize 353 ;------------------------------------------------------------ 354 xmanager, 'printps', base, /no_block 355 ;------------------------------------------------------------ 356 END 306 357 ENDCASE 307 ; 'archive ps' button, can be created only if archive_ps ne 0 308 IF keyword_set(archive_ps) THEN $ 309 notused = widget_button(base, value = 'archive ps' $ 310 , uvalue = {name:'archive', nameps:nameps $ 311 , gzip:gzipped NE -1}) 312 ; quit button 313 notused = widget_button(base, value = 'quit' $ 314 , uvalue = {name:'quit', nameps:nameps $ 315 , gzip:gzipped NE -1}) 316 ;------------------------------------------------------------ 317 widget_control, base, /realize 318 ;------------------------------------------------------------ 319 xmanager, 'printps', base, /no_block 320 ;------------------------------------------------------------ 358 359 321 360 return 322 361 end
Note: See TracChangeset
for help on using the changeset viewer.