home *** CD-ROM | disk | FTP | other *** search
Wrap
#!/usr/bin/wish set rdesktop "/usr/local/bin/rdesktop" #BK path... source /usr/lib/combobox-2.3/combobox.tcl package require combobox 2.3 catch {namespace import combobox::*} namespace eval notebook {} proc notebook::create {w args} { variable Notebook set Notebook($w,width) 420 set Notebook($w,height) 300 set Notebook($w,pages) {} set Notebook($w,top) 0 set Notebook($w,pad) 5 set Notebook($w,fg,on) black set Notebook($w,fg,off) grey50 set Notebook($w,command) {} set Notebook($w,ypad) 20 set Notebook($w,fidx) -1 set Notebook($w,frames) {} canvas $w -bd 0 -highlightthickness 0 -takefocus 0 set Notebook($w,bg) [$w cget -bg] bind $w <1> "notebook::click $w %x %y" bind $w <Configure> "notebook::scheduleExpand $w" eval notebook::config $w $args } proc notebook::WidName {w n} { variable Notebook set l [llength $Notebook($w,frames)] if {$n >= $l} { for {set i $l} {$i <= $n} {incr i} { lappend Notebook($w,frames) [incr Notebook($w,fidx)] } } return $w.f[lindex $Notebook($w,frames) $n] } proc notebook::delete {w n} { variable Notebook set l [llength $Notebook($w,frames)] if {$n < $l} { set wn [WidName $w $n] set Notebook($w,frames) [lreplace $Notebook($w,frames) $n $n] set Notebook($w,pages) [lreplace $Notebook($w,pages) $n $n] set Notebook($w,xlate) [lreplace $Notebook($w,xlate) $n $n] destroy $wn } eval notebook::config $w } proc notebook::config {w args} { variable Notebook foreach {tag value} $args { switch -- $tag { -width { set Notebook($w,width) $value } -height { set Notebook($w,height) $value } -pages { set Notebook($w,pages) $value set Notebook($w,xlate) $value } -xlate { set Notebook($w,xlate) $value } -pad { set Notebook($w,pad) $value } -bg { set Notebook($w,bg) $value } -fg { set Notebook($w,fg,on) $value } -command { set Notebook($w,command) $value } -disabledforeground { set Notebook($w,fg,off) $value } } } # # After getting new configuration values, reconstruct the widget # $w delete all set rise 3 set Notebook($w,x1) $Notebook($w,pad) set Notebook($w,x2) [expr $Notebook($w,x1)+2] set Notebook($w,x3) [expr $Notebook($w,x2)+$Notebook($w,width)] set Notebook($w,x4) [expr $Notebook($w,x3)+2] set Notebook($w,y1) [expr $Notebook($w,pad)+2] set Notebook($w,y2) [expr $Notebook($w,y1)+2] set Notebook($w,y5) [expr $Notebook($w,y1)+$Notebook($w,ypad)] set Notebook($w,y6) [expr $Notebook($w,y5)+2] set Notebook($w,y3) [expr $Notebook($w,y6)+$Notebook($w,height)] set Notebook($w,y4) [expr $Notebook($w,y3)+2] set x $Notebook($w,x1) set cnt 0 set y7 [expr $Notebook($w,y1)+$rise] foreach p $Notebook($w,pages) xl $Notebook($w,xlate) { set Notebook($w,p$cnt,x5) $x set id [$w create text 0 0 -text $xl -anchor nw -tags "p$cnt t$cnt"] set bbox [$w bbox $id] set width [lindex $bbox 2] $w move $id [expr $x+10] $y7 $w create line $x $Notebook($w,y5) $x $Notebook($w,y2) [expr $x+2]\ $Notebook($w,y1) [expr $x+$width+16] $Notebook($w,y1) -width 2\ -fill white -tags p$cnt $w create line [expr $x+$width+16] $Notebook($w,y1) [expr $x+$width+18]\ $Notebook($w,y2) [expr $x+$width+18] $Notebook($w,y5) -width 2\ -fill black -tags p$cnt set x [expr $x+$width+20] set Notebook($w,p$cnt,x6) [expr $x-2] set wn [WidName $w $cnt] if {![winfo exists $wn]} { ::frame $wn -bd 0 } $wn config -bg $Notebook($w,bg) place $wn -x $Notebook($w,x2) -y $Notebook($w,y6)\ -width $Notebook($w,width) -height $Notebook($w,height) incr cnt } $w create line $Notebook($w,x1) [expr $Notebook($w,y5)-2] $Notebook($w,x1)\ $Notebook($w,y3) -width 2 -fill white $w create line $Notebook($w,x1) $Notebook($w,y3) $Notebook($w,x2)\ $Notebook($w,y4) $Notebook($w,x3) $Notebook($w,y4) $Notebook($w,x4)\ $Notebook($w,y3) $Notebook($w,x4) $Notebook($w,y6) $Notebook($w,x3)\ $Notebook($w,y5) -width 2 -fill black $w config -width [expr $Notebook($w,x4)+$Notebook($w,pad)] -height\ [expr $Notebook($w,y4)+$Notebook($w,pad)] -bg $Notebook($w,bg) set top $Notebook($w,top) set Notebook($w,top) -1 notebook::raise.page $w $top } # # This routine is called whenever the mouse-button is pressed over # the notebook. It determines if any page should be raised and raises # that page. # proc notebook::click {w x y} { variable Notebook if {$y<$Notebook($w,y1) || $y>$Notebook($w,y6)} return set N [llength $Notebook($w,pages)] for {set i 0} {$i<$N} {incr i} { if {$x>=$Notebook($w,p$i,x5) && $x<=$Notebook($w,p$i,x6)} { notebook::raise.page $w $i break } } } # # For internal use only. This procedure raised the n-th page of # the notebook # proc notebook::raise.page {w n} { variable Notebook if {$n<0 || $n>=[llength $Notebook($w,pages)]} return set top $Notebook($w,top) if {$top>=0 && $top<[llength $Notebook($w,pages)]} { $w move p$top 0 2 } $w move p$n 0 -2 $w delete topline if {$n>0} { $w create line $Notebook($w,x1) $Notebook($w,y6) $Notebook($w,x2)\ $Notebook($w,y5) $Notebook($w,p$n,x5) $Notebook($w,y5)\ $Notebook($w,p$n,x5) [expr $Notebook($w,y5)-2] -width 2 -fill white\ -tags topline } $w create line $Notebook($w,p$n,x6) [expr $Notebook($w,y5)-2]\ $Notebook($w,p$n,x6) $Notebook($w,y5) -width 2 -fill white -tags topline $w create line $Notebook($w,p$n,x6) $Notebook($w,y5) $Notebook($w,x3)\ $Notebook($w,y5) -width 2 -fill white -tags topline set Notebook($w,top) $n if {$Notebook($w,command) != {}} { eval uplevel #0 "$Notebook($w,command) $w $n 1" } ::raise [WidName $w $n] } # # Change the page-specific configuration options for the notebook # proc notebook::pageconfig {w name args} { variable Notebook set i [lsearch $Notebook($w,pages) $name] if {$i<0} return foreach {tag value} $args { switch -- $tag { -state { if {"$value" == "disabled"} { $w itemconfig t$i -fg $Notebook($w,fg,off) } { $w itemconfig t$i -fg $Notebook($w,fg,on) } } -onexit { set Notebook($w,p$i,onexit) $value } } } } # # This procedure raises a notebook page given its name. But first # we check the "onexit" procedure for the current page (if any) and # if it returns false, we don't allow the raise to proceed. # proc notebook::raise {w name} { variable Notebook set i [lsearch $Notebook($w,pages) $name] if {$i<0} return if {[info exists Notebook($w,p$i,onexit)]} { set onexit $Notebook($w,p$i,onexit) if {"$onexit" != "" && [eval uplevel #0 $onexit]!=0} { notebook::raise.page $w $i } } { notebook::raise.page $w $i } } # # Return the frame associated with a given page of the notebook. # proc notebook::frame {w name} { variable Notebook set i [lsearch $Notebook($w,pages) $name] if {$i>=0} { return [WidName $w $i] } { return {} } } # # Try to resize the notebook to the next time we become idle. # proc notebook::scheduleExpand w { variable Notebook if {[info exists Notebook($w,expand)]} return set Notebook($w,expand) 1 after idle "notebook::expand $w" } # # Resize the notebook to fit inside its containing widget. # proc notebook::expand w { variable Notebook set wi [expr [winfo width $w]-($Notebook($w,pad)*2+4)] set hi [expr [winfo height $w]-($Notebook($w,pad)*2+6+$Notebook($w,ypad))] notebook::config $w -width $wi -height $hi catch {unset Notebook($w,expand)} } proc screen {} { wm title . "Remote Desktop Client" #BK path... set myimage [image create photo -file /usr/local/lib/X11/pixmaps/rdp.gif] frame .waytop pack .waytop -fill x label .waytop.imagedisplayer -image $myimage pack .waytop.imagedisplayer -side left -padx 0p -pady 0 -anchor n frame .top -borderwidth 3 pack .top -fill x label .top.lblhostname -text "Hostname " entry .top.hostname -textvariable hostname pack .top.lblhostname .top.hostname -side left -padx 0p -pady 0 -anchor n focus .top.hostname notebook::create .n -pages {General Resources Display Programs Experience About} -pad 20 pack .n -fill both -expand 1 set w [notebook::frame .n General] frame $w.info pack $w.info -fill x label $w.info.infolbl -text "Please type optional information" pack $w.info.infolbl -side left -padx 0 -pady 0 -anchor n frame $w.usernamefrm pack $w.usernamefrm -fill x label $w.usernamefrm.lblusername -text "Username " entry $w.usernamefrm.username -textvariable username pack $w.usernamefrm.lblusername $w.usernamefrm.username -side left -padx 0 -pady 0 -anchor n frame $w.password pack $w.password -fill x label $w.password.lblpassword -text "Password " entry $w.password.password -textvariable password -show * pack $w.password.lblpassword $w.password.password -side left -padx 0 -pady 0 -anchor n frame $w.domain pack $w.domain -fill x label $w.domain.lbldomain -text "Domain " entry $w.domain.domain -textvariable domain pack $w.domain.lbldomain $w.domain.domain -side left -padx 0 -pady 0 -anchor n set w [notebook::frame .n Resources] frame $w.midlbl pack $w.midlbl -fill x label $w.midlbl.lbl -text "Local Resources " pack $w.midlbl.lbl -side left -padx 0p -pady 0 -anchor n checkbutton $w.disk -text "Disk Drives" -variable disk checkbutton $w.com -text "Com Ports" -variable com checkbutton $w.sound -text "Sound" -variable sound pack $w.disk $w.com $w.sound -side left -padx 0p -pady 0 -anchor n set w [notebook::frame .n Display] frame $w.displayslbl pack $w.displayslbl -fill x label $w.displayslbl.lbldisp -text "Choose the size of your remote desktop.\nClick the drop down and select the resoltion." pack $w.displayslbl.lbldisp -side left -padx 0p -pady 0 -anchor n frame $w.displays pack $w.displays -fill x combobox $w.displays.displayList -borderwidth 1 -highlightthickness 1 -maxheight 0 -width 10 -editable false -textvariable mode $w.displays.displayList list insert end "640x480" $w.displays.displayList list insert end "800x600" $w.displays.displayList list insert end "1024x768" $w.displays.displayList list insert end "Full Screen" pack $w.displays.displayList -side left -padx 0 -pady 0 -anchor n frame $w.colorslbl pack $w.colorslbl -fill x label $w.colorslbl.lbldisp -text "\n\n\n\n\n\n\n\nColors" pack $w.colorslbl.lbldisp -side left -padx 0 -pady 0 -anchor n frame $w.colors pack $w.colors -fill x combobox $w.colors.cmb -borderwidth 1 -highlightthickness 1 -maxheight 0 -width 10 -editable false -textvariable col $w.colors.cmb list insert end "256" $w.colors.cmb list insert end "65,000" $w.colors.cmb list insert end "Millions" pack $w.colors.cmb -side left -padx 0p -pady 0 -anchor n set w [notebook::frame .n Programs] frame $w.programlbl pack $w.programlbl -fill x label $w.programlbl.programlbl -text "Please enter the Path\nand the name of the program to use\ni.e. c:\\windows\\notepad.exe" pack $w.programlbl.programlbl -side left -padx 0p -pady 0 -anchor n frame $w.program pack $w.program -fill x entry $w.program.programname -textvariable program -width 40 pack $w.program.programname -side left -padx 0p -pady 0 -anchor n set w [notebook::frame .n Experience] frame $w.experiencelbl pack $w.experiencelbl -fill x label $w.experiencelbl.lbldisp -text "Experience" pack $w.experiencelbl.lbldisp -side left -padx 0p -pady 0 -anchor n frame $w.experience pack $w.experience -fill x radiobutton $w.experience.broadband -text "Broadband" -variable exp -value b -command clickp radiobutton $w.experience.modem -text "Modem" -variable exp -value m -command clickp radiobutton $w.experience.lan -text "Lan" -variable exp -value l -command clickp pack $w.experience.broadband $w.experience.modem $w.experience.lan -side left -padx 0p -pady 0 -anchor n frame $w.mexperience pack $w.mexperience -fill x checkbutton $w.mexperience.caching -text "Bitmap Caching" -variable p pack $w.mexperience.caching -side left -padx 0p -pady 0 -anchor n set w [notebook::frame .n About] frame $w.about pack $w.about -fill x label $w.about.info -text "Thinix Remote Desktop Client\nDesigned and Written By John Hass john@thinix.com\nWritten in pure tcl\nComboboxes were designed by Bryan Douglas Oakley\nhttp://www.purl.org/net/oakley/tcl/combobox/index.html\nmailto:oakley@bardo.clearlight.com" pack $w.about.info -side top -padx 0p -pady 0 -anchor n frame .bottom -borderwidth 10 pack .bottom -fill x button .bottom.submit -text "Connect" -command init pack .bottom.submit -side bottom -fill y } proc init { } { global mode action gloabl p exp col disk com sound hostname global colors username password domain global res persistant experience colors dsk cm snd rdesktop user pass colors dmn if {$hostname != ""} { if {$domain != ""} { set dmn "-d $domain" } else { set dmn "" } if {$username != ""} { set user "-u $username" } else { set user "" } if {$password != ""} { set pass "-p $password" } else { set pass "" } if {$disk == "1"} { set dsk "-r disk:local=/" } else { set dsk "" } if {$com == "1"} { set cm "-r com1:COM1=/dev/ttyS0" } else { set cm "" } if {$sound == "1"} { set snd "-r sound" } else { set snd "" } if {$col == "256"} { set colors "-a 8" } elseif {$col == "65,000"} { set colors "-a 16" } elseif {$col == "Millions"} { set colors "-a 24" } else { set colors "" } if {$exp == "b"} { set experience "-x b" } elseif {$exp == "m"} { set experience "-x m" } elseif {$exp == "l"} { set experience "-x l" } else { set experience "" } if {$p == "1"} { set persistant "-P" } else { set persistant "" } if {$mode == "800x600"} { set res "-g$mode" } elseif {$mode == "640x480"} { set res "-g$mode" } elseif {$mode == "1024x768"} { set res "-g$mode" } elseif {$mode == "Full Screen"} { set res "-f" } else { set res "-g640x480" } #puts "$rdesktop $user $pass $dmn $persistant $res $experience $colors $dsk $cm $snd $hostname" open "| $rdesktop $user $pass $dmn $persistant $res $experience $colors $dsk $cm $snd $hostname" exit } else { tk_messageBox -message "You Must Enter a Hostname" -type ok -icon error } } proc clickp { } { global p set p "1" } proc quit { } { set answer [tk_messageBox -message "Really quit?" -type yesno -icon question] switch -- $answer { yes exit no } } proc colorchange { } { global change puts "Change" } screen