home *** CD-ROM | disk | FTP | other *** search
/ Chip: Linux Special / CorelLinux_CHIP.iso / VMware / bin / vmware-wizard / lib / shell.tcl < prev    next >
Encoding:
Text File  |  1999-07-21  |  2.8 KB  |  102 lines

  1. # Determine whether a file name is in the PATH
  2. # Return value is:
  3. #  1: no
  4. #  0: yes
  5. proc Shell_DoesBinaryExist {progname} {
  6.   return [catch {exec {which} $progname}]
  7. }
  8.  
  9. # Prompts the user if a binary is not found
  10. # Return value is:
  11. #  "": the binary has not been found
  12. #  the binary name if it has been found
  13. proc Shell_DoesBinaryExist_Prompt {progname} {
  14.   while {[Shell_DoesBinaryExist $progname]} {
  15.     global db
  16.  
  17.     toplevel .shell
  18.     wm title .shell "Program Finder"
  19.  
  20.     frame .shell.even
  21.     pack .shell.even -fill both -expand 1 -padx 4 -pady 4
  22.  
  23.     message .shell.even.msg -width 15c -text "The wizard is unable to find the \"$progname\" program on your machine. Please specify the full path to this program."
  24.     pack .shell.even.msg -fill y -expand 1 -padx 4 -pady 4
  25.  
  26.     frame .shell.even.even
  27.     pack .shell.even.even -fill both
  28.  
  29.     frame .shell.even.even2
  30.     pack .shell.even.even2
  31.  
  32.     label .shell.even.even.lbl -text "Location:" -underline 0
  33.     bind .shell <Alt-KeyPress-l> _Shell_Location
  34.     pack .shell.even.even.lbl -anchor e -side left -padx 4 -pady 4
  35.  
  36.     entry .shell.even.even.entry -textvariable db(.shell._entry)
  37.     pack .shell.even.even.entry -side left -padx 4 -pady 4 -fill x -expand 1
  38.     set db(.shell._entry) $progname
  39.  
  40.     button .shell.even.even.browse -text "Browse ..." -underline 0 -command _Shell_Browse
  41.     bind .shell <Alt-KeyPress-b> _Shell_Browse
  42.  
  43.     pack .shell.even.even.browse -side left -padx 4 -pady 4
  44.  
  45.     button .shell.even.even2.cancel -text "Cancel" -underline 0 -command _Shell_Cancel
  46.     bind .shell <Alt-KeyPress-c> _Shell_Cancel
  47.     pack .shell.even.even2.cancel -side right -padx 4 -pady 4
  48.  
  49.     button .shell.even.even2.ok -text "Ok" -underline 0 -default active -command _Shell_Ok
  50.     bind .shell <Alt-KeyPress-o> _Shell_Ok
  51.     bind .shell <KeyPress-Return> _Shell_Ok
  52.     pack .shell.even.even2.ok -side right -padx 4 -pady 4
  53.  
  54.     _Shell_Location
  55.     set db(.shell.progname) ""
  56.     tkwait window .shell
  57.     if {$db(.shell.progname) == ""} {
  58.         # Cancel
  59.     return ""
  60.     }
  61.  
  62.     # Ok
  63.     set progname $db(.shell.progname)
  64.   }
  65.  
  66.   return $progname;
  67. }
  68.  
  69. # Callback for the location accelerator
  70. proc _Shell_Location {} {
  71.   focus .shell.even.even.entry
  72. }
  73.  
  74. # Callback for the browse button
  75. proc _Shell_Browse {} {
  76.     global db
  77.  
  78.     # Pop-up a file chooser
  79.     set res [tk_getOpenFile -parent .shell.even.even.browse -title {Program Chooser}]
  80.     if {$res != ""} {
  81.         # Patch the entry box
  82.     set db(.shell._entry) $res
  83.         # Position its cursor at the end
  84.         .shell.even.even.entry icursor [string length $res]
  85.     }
  86. }
  87.  
  88. # Callback for the cancel button
  89. proc _Shell_Cancel {} {
  90.     # Dismiss the window
  91.     destroy .shell
  92. }
  93.  
  94. # Callback for the ok button
  95. proc _Shell_Ok {} {
  96.     global db
  97.  
  98.     set db(.shell.progname) $db(.shell._entry)
  99.     # Dismiss the window
  100.     destroy .shell
  101. }
  102.