#!/usr/local/bin/wish8.0 # Start & # This is a tcl/tk clone of the W95 desktop. We create a rather large window, # which is initially empty except for the icon bar across the bottom. The # icon bar has a Start button that behaves somewhat like W95 users expect: It # produces a menu of commands, many of which are submenus, etc. # The commands are kept in a "registry", directory, which has a number of # subdirectories: # registry/Cmd/ # Commands. The main rule for an executable here is that it work # standalone, that is, it must not require any command-line options or # stdin data to run. This excludes most Unix programs, of course, but # that's the nature of GUI programs. The files here are mostly tcl (wish) # wrappers around the actual program, to provide a GUI that the user can # talk to. This directory may include subdirectories, which are turned into # submenus of the Start menu. Recommended setup: registry/Cmd/Foo should be # a tcl wrapper for the registry/bin/foo command. # registry/icon/ # For each program in registry/Cmd/, if there is a graphics file in # registry/icon/ with the same basename (i.e., the names are the same after # stripping off any .suffix), then the graphics file will be used as an # icon for the program. # registry/bin/ # The recommended place to put executables used by the programs in # registry/Cmd/, mostly linked in from some other bin/ directory. We put # our Cmd and bin directory at the start of the search path. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # wm geometry . +0-0 set mi [lindex [set namo [winfo name .]] 0] if [info exists env(B_$mi)] {set B $env(B_$mi)} else {set B 3} if [info exists env(D_$mi)] {set D $env(D_$mi)} else {set D 0} if [info exists env(R_$mi)] {set R $env(R_$mi)} else {set R ridge} if [info exists env(S_$mi)] {set S $env(S_$mi)} else {set S text} foreach d [split $env(PATH) :] {if [file exists $d/Help.w] {source $d/Help.w;break}} foreach d [split $env(PATH) :] {if [file exists $d/Dbg.w] {source $d/Dbg.w;break}} if [info exists env(HOME)] {set home $env(HOME)} else {set home /} set rpath $home/win/registry if ![info exists env(PATH)] {set env(PATH) /bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb/bin:/usr/local/bin:/usr/X11/bin} set path $rpath/Cmd:$rpath/bin:$env(PATH) set BB {-bd $B -relief $R -padx 0 -pady 0 -highlightthickness 0} # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # proc menuStart {X Y} { global B D R home rpath if {$D>1} {puts "menuStart X=$X Y=$Y ..."} if [winfo exists .b.bStart.menu] {destroy .b.bStart.menu} menu .b.bStart.menu .b.bStart.menu add command -label Exit -command exit dirmenu .b.bStart.menu $rpath/Cmd if {$X && $Y} { incr X 5 tk_popup .b.bStart.menu $X $Y .b.bStart.menu post $X $Y bind .b.bStart.menu {} } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # proc dirmenu {m d} { global D errmsg if [catch {open "| ls $d"} fd] { set errmsg "Can't run \"ls $d\" ($fd)" if {$D} {Out $errmsg; Msg $errmsg} return } while {[gets $fd f] >= 0} { if {$D>1} {Out "dirmenu: f=\"$f\""} set p "$d/$f" if [file isdir $p] { if {$D>1} {Out "dirmenu: $p is directory."} $m add cascade -label $f -menu $m.c$f menu $m.c$f dirmenu $m.c$f $p } else { if {$D>1} {Out "dirmenu: $p is file."} $m add command -label $f -command "Start $p" } } close $fd } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # proc Msg {m} { global errmsg set errmsg $m update idletasks } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # proc Out args { if [winfo exists .out] { .out insert end "$args\n" } else { eval puts $args } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # proc Start {cmd} { global D mi home rpath if {$D>1} {Out "Start \"$cmd\""} exec $cmd & } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # frame .b -bd $B -relief $R entry .m -bd $B -relief $R -textvariable errmsg \ -width 0 -highlightthickness 0 -bg black -fg orange pack .b -side bottom -fill x pack .m -side bottom -fill x eval menubutton .b.bStart $BB -text Start -direction above pack .b.bStart -in .b -side left if {$D>0} {puts "$mi: menuStart 0 0"} menuStart 0 0 bind .b.bStart {menuStart %X %Y} Dbg .b -padx 0 -pady 0 -highlightthickness 0 bind all { if {$D>1} {puts "$mi: Enter [winfo containing %X %Y]"} } bind all { if {$D>1} {puts "$mi: Leave [winfo containing %X %Y]"} }