#!/usr/bin/wish ;# "pdfchoice.tk" ;# ;# version 0.90 ;# ;# simple script for use with Web browsers to chose between ;# different PDF viewers. Use this as your helper application for ;# the Web browser, and just verify the applications listed in the ;# Viewers list. The first valid application will be the default, ;# shown first, and executed if the user presses the return key ;# ;# GNU GPL 1999 Peter Watkins, etc., etc. set Viewers { {{Acrobat Reader} {/usr/local/acrobat/bin/acroread}} {{XPDF} {/usr/X11R6/bin/xpdf}} {{Ghostview} {/usr/X11R6/bin/gv}} } if { $argc < 1 } { puts stderr "Need a filename" exit 1 } set fileName [lindex $argv 0] proc runApp {appName} { global fileName exec $appName $fileName {&} # exit 0 } frame .t -width 150 message .t.msg -text "Choose a PDF viewer" -width 280 label .t.bmap -bitmap questhead catch { .t.bmap configure -fg darkgreen } button .t.quit -text "Quit" -command "exit 0" set numV 0 # parse the viewer list before setting geometry so we know how long the window should be foreach vChoiceList [set Viewers] { set cName [lindex $vChoiceList 0] set cApp [lindex $vChoiceList 1] if { [file executable $cApp] } { button .b$numV -text $cName -command "runApp $cApp" if { $numV == 0} { # first button, should be default bind . "runApp $cApp" } incr numV } } wm title . "Choose a PDF viewer" catch {wm geometry . "270x[expr 100 + ( 30 * $numV ) ]+270+170" } pack .t.bmap .t.msg .t.quit -side left # Now add the buttons for {set loop [expr $numV - 1]} {$loop >= 1} {incr loop -1} { pack .b$loop -side bottom -pady 2 -fill x } # Add the default button last, in its own frame, to look different frame .default -relief sunken -bd 1 raise .b0 pack .default -side bottom -pady 4 -fill x pack .b0 -in .default -fill x pack .t -expand true