home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / remotedesktopclient < prev    next >
Encoding:
Tcl/Tk script  |  2005-04-16  |  14.6 KB  |  505 lines

  1. #!/usr/bin/wish
  2. set rdesktop "/usr/local/bin/rdesktop"
  3.  
  4. #BK path...
  5. source /usr/lib/combobox-2.3/combobox.tcl
  6. package require combobox 2.3
  7. catch {namespace import combobox::*}
  8.  
  9. namespace eval notebook {}
  10.  
  11. proc notebook::create {w args} {
  12.   variable Notebook
  13.   set Notebook($w,width) 420
  14.   set Notebook($w,height) 300
  15.   set Notebook($w,pages) {}
  16.   set Notebook($w,top) 0
  17.   set Notebook($w,pad) 5
  18.   set Notebook($w,fg,on) black
  19.   set Notebook($w,fg,off) grey50
  20.   set Notebook($w,command) {}
  21.   set Notebook($w,ypad) 20   
  22.   set Notebook($w,fidx) -1
  23.   set Notebook($w,frames) {}
  24.   canvas $w -bd 0 -highlightthickness 0 -takefocus 0
  25.   set Notebook($w,bg) [$w cget -bg]
  26.   bind $w <1> "notebook::click $w %x %y"
  27.   bind $w <Configure> "notebook::scheduleExpand $w"
  28.   eval notebook::config $w $args
  29. }
  30.  
  31. proc notebook::WidName {w n} {
  32.   variable Notebook
  33.   set l [llength $Notebook($w,frames)]
  34.   if {$n >= $l} {
  35.     for {set i $l} {$i <= $n} {incr i} {
  36.       lappend Notebook($w,frames) [incr Notebook($w,fidx)]
  37.     }
  38.   }
  39.   return $w.f[lindex $Notebook($w,frames) $n]
  40. }
  41.  
  42. proc notebook::delete {w n} {
  43.   variable Notebook
  44.   set l [llength $Notebook($w,frames)]
  45.   if {$n < $l} {
  46.     set wn [WidName $w $n]
  47.     set Notebook($w,frames) [lreplace $Notebook($w,frames) $n $n]
  48.     set Notebook($w,pages) [lreplace $Notebook($w,pages) $n $n]
  49.     set Notebook($w,xlate) [lreplace $Notebook($w,xlate) $n $n]
  50.     destroy $wn
  51.   }
  52.   eval notebook::config $w
  53. }
  54.  
  55.  
  56.  
  57. proc notebook::config {w args} {
  58.   variable Notebook
  59.   foreach {tag value} $args {
  60.     switch -- $tag {
  61.     -width {
  62.         set Notebook($w,width) $value
  63.       }
  64.     -height {
  65.         set Notebook($w,height) $value
  66.       }
  67.     -pages {
  68.         set Notebook($w,pages) $value
  69.         set Notebook($w,xlate) $value
  70.       }
  71.     -xlate {
  72.         set Notebook($w,xlate) $value
  73.       }
  74.     -pad {
  75.         set Notebook($w,pad) $value
  76.       }
  77.     -bg {
  78.         set Notebook($w,bg) $value
  79.       }
  80.     -fg {
  81.         set Notebook($w,fg,on) $value
  82.       }
  83.     -command {
  84.         set Notebook($w,command) $value
  85.       }
  86.     -disabledforeground {
  87.         set Notebook($w,fg,off) $value
  88.       }
  89.     }
  90.   }
  91.   #
  92.   # After getting new configuration values, reconstruct the widget
  93.   #
  94.   $w delete all
  95.   set rise 3
  96.   set Notebook($w,x1) $Notebook($w,pad)
  97.   set Notebook($w,x2) [expr $Notebook($w,x1)+2]
  98.   set Notebook($w,x3) [expr $Notebook($w,x2)+$Notebook($w,width)]
  99.   set Notebook($w,x4) [expr $Notebook($w,x3)+2]
  100.   set Notebook($w,y1) [expr $Notebook($w,pad)+2]
  101.   set Notebook($w,y2) [expr $Notebook($w,y1)+2]
  102.   set Notebook($w,y5) [expr $Notebook($w,y1)+$Notebook($w,ypad)]
  103.   set Notebook($w,y6) [expr $Notebook($w,y5)+2]
  104.   set Notebook($w,y3) [expr $Notebook($w,y6)+$Notebook($w,height)]
  105.   set Notebook($w,y4) [expr $Notebook($w,y3)+2]
  106.   set x $Notebook($w,x1)
  107.   set cnt 0   
  108.   set y7 [expr $Notebook($w,y1)+$rise] 
  109.   foreach p $Notebook($w,pages) xl $Notebook($w,xlate) {
  110.     set Notebook($w,p$cnt,x5) $x
  111.     set id [$w create text 0 0 -text $xl -anchor nw -tags "p$cnt t$cnt"]
  112.     set bbox [$w bbox $id]
  113.     set width [lindex $bbox 2]
  114.     $w move $id [expr $x+10] $y7
  115.     $w create line $x $Notebook($w,y5) $x $Notebook($w,y2) [expr $x+2]\
  116.       $Notebook($w,y1) [expr $x+$width+16] $Notebook($w,y1) -width 2\
  117.       -fill white -tags p$cnt
  118.     $w create line [expr $x+$width+16] $Notebook($w,y1) [expr $x+$width+18]\
  119.       $Notebook($w,y2) [expr $x+$width+18] $Notebook($w,y5) -width 2\
  120.       -fill black -tags p$cnt
  121.     set x [expr $x+$width+20]
  122.     set Notebook($w,p$cnt,x6) [expr $x-2]
  123.     set wn [WidName $w $cnt]
  124.     if {![winfo exists $wn]} {
  125.       ::frame $wn -bd 0
  126.     }
  127.     $wn config -bg $Notebook($w,bg)
  128.     place $wn -x $Notebook($w,x2) -y $Notebook($w,y6)\
  129.       -width $Notebook($w,width) -height $Notebook($w,height)
  130.     incr cnt
  131.   }
  132.   $w create line $Notebook($w,x1) [expr $Notebook($w,y5)-2] $Notebook($w,x1)\
  133.     $Notebook($w,y3) -width 2 -fill white
  134.   $w create line $Notebook($w,x1) $Notebook($w,y3) $Notebook($w,x2)\
  135.     $Notebook($w,y4) $Notebook($w,x3) $Notebook($w,y4) $Notebook($w,x4)\
  136.     $Notebook($w,y3) $Notebook($w,x4) $Notebook($w,y6) $Notebook($w,x3)\
  137.     $Notebook($w,y5) -width 2 -fill black
  138.   $w config -width [expr $Notebook($w,x4)+$Notebook($w,pad)] -height\
  139.     [expr $Notebook($w,y4)+$Notebook($w,pad)] -bg $Notebook($w,bg)
  140.   set top $Notebook($w,top)
  141.   set Notebook($w,top) -1
  142.   notebook::raise.page $w $top
  143. }
  144.  
  145. #
  146. # This routine is called whenever the mouse-button is pressed over
  147. # the notebook.  It determines if any page should be raised and raises
  148. # that page.
  149. #
  150. proc notebook::click {w x y} {
  151.   variable Notebook
  152.   if {$y<$Notebook($w,y1) || $y>$Notebook($w,y6)} return
  153.   set N [llength $Notebook($w,pages)]
  154.   for {set i 0} {$i<$N} {incr i} {
  155.     if {$x>=$Notebook($w,p$i,x5) && $x<=$Notebook($w,p$i,x6)} {
  156.       notebook::raise.page $w $i
  157.       break
  158.     }
  159.   }
  160. }
  161.  
  162. #
  163. # For internal use only.  This procedure raised the n-th page of
  164. # the notebook
  165. #
  166. proc notebook::raise.page {w n} {
  167.   variable Notebook
  168.   if {$n<0 || $n>=[llength $Notebook($w,pages)]} return
  169.   set top $Notebook($w,top)
  170.   if {$top>=0 && $top<[llength $Notebook($w,pages)]} {
  171.     $w move p$top 0 2
  172.   }
  173.   $w move p$n 0 -2
  174.   $w delete topline
  175.   if {$n>0} {
  176.     $w create line $Notebook($w,x1) $Notebook($w,y6) $Notebook($w,x2)\
  177.       $Notebook($w,y5) $Notebook($w,p$n,x5) $Notebook($w,y5)\
  178.       $Notebook($w,p$n,x5) [expr $Notebook($w,y5)-2] -width 2 -fill white\
  179.       -tags topline
  180.   }
  181.   $w create line $Notebook($w,p$n,x6) [expr $Notebook($w,y5)-2]\
  182.     $Notebook($w,p$n,x6) $Notebook($w,y5) -width 2 -fill white -tags topline
  183.   $w create line $Notebook($w,p$n,x6) $Notebook($w,y5) $Notebook($w,x3)\
  184.     $Notebook($w,y5) -width 2 -fill white -tags topline
  185.   set Notebook($w,top) $n
  186.   if {$Notebook($w,command) != {}} {
  187.     eval uplevel #0 "$Notebook($w,command) $w $n 1"
  188.   }
  189.   ::raise [WidName $w $n]
  190. }
  191.  
  192. #
  193. # Change the page-specific configuration options for the notebook
  194. #
  195. proc notebook::pageconfig {w name args} {
  196.   variable Notebook  
  197.   set i [lsearch $Notebook($w,pages) $name]
  198.   if {$i<0} return
  199.   foreach {tag value} $args {
  200.     switch -- $tag {
  201.     -state {
  202.         if {"$value" == "disabled"} {
  203.           $w itemconfig t$i -fg $Notebook($w,fg,off)
  204.         } {
  205.           $w itemconfig t$i -fg $Notebook($w,fg,on)
  206.         }
  207.       }
  208.     -onexit {
  209.         set Notebook($w,p$i,onexit) $value
  210.       }
  211.     }
  212.   }
  213.  
  214. #
  215. # This procedure raises a notebook page given its name.  But first
  216. # we check the "onexit" procedure for the current page (if any) and
  217. # if it returns false, we don't allow the raise to proceed.
  218. #
  219. proc notebook::raise {w name} {
  220.   variable Notebook  
  221.   set i [lsearch $Notebook($w,pages) $name]
  222.   if {$i<0} return
  223.   if {[info exists Notebook($w,p$i,onexit)]} {
  224.     set onexit $Notebook($w,p$i,onexit)
  225.     if {"$onexit" != "" && [eval uplevel #0 $onexit]!=0} {
  226.       notebook::raise.page $w $i
  227.     }
  228.   } {
  229.     notebook::raise.page $w $i
  230.   }
  231. }
  232.     
  233. #
  234. # Return the frame associated with a given page of the notebook.
  235. #
  236. proc notebook::frame {w name} {
  237.   variable Notebook
  238.   set i [lsearch $Notebook($w,pages) $name]
  239.   if {$i>=0} {
  240.     return [WidName $w $i]
  241.   } {
  242.     return {}
  243.   }
  244. }
  245.  
  246. #
  247. # Try to resize the notebook to the next time we become idle.
  248. #
  249. proc notebook::scheduleExpand w {
  250.   variable Notebook
  251.   if {[info exists Notebook($w,expand)]} return
  252.   set Notebook($w,expand) 1
  253.   after idle "notebook::expand $w"
  254. }
  255.    
  256. #
  257. # Resize the notebook to fit inside its containing widget.
  258. #
  259. proc notebook::expand w {
  260.   variable Notebook
  261.   set wi [expr [winfo width $w]-($Notebook($w,pad)*2+4)]
  262.   set hi [expr [winfo height $w]-($Notebook($w,pad)*2+6+$Notebook($w,ypad))]
  263.   notebook::config $w -width $wi -height $hi
  264.   catch {unset Notebook($w,expand)}
  265. }
  266.  
  267.  
  268.  
  269. proc screen {} {
  270.   wm title . "Remote Desktop Client"
  271. #BK path...
  272.   set myimage [image create photo -file /usr/local/lib/X11/pixmaps/rdp.gif]
  273.   frame .waytop
  274.   pack .waytop -fill x
  275.   label .waytop.imagedisplayer -image $myimage
  276.   pack .waytop.imagedisplayer -side left -padx 0p -pady 0 -anchor n
  277.  
  278.   frame .top -borderwidth 3
  279.   pack  .top -fill x
  280.   label .top.lblhostname -text "Hostname "
  281.   entry .top.hostname  -textvariable hostname
  282.   pack  .top.lblhostname .top.hostname -side left -padx 0p -pady 0 -anchor n
  283.   focus .top.hostname
  284.  
  285.  
  286. notebook::create .n -pages {General Resources Display Programs Experience About} -pad 20
  287. pack .n -fill both -expand 1
  288.  
  289.  set w [notebook::frame .n General]
  290.     frame $w.info
  291.     pack $w.info -fill x
  292.     label  $w.info.infolbl -text "Please type optional information"   
  293.     pack $w.info.infolbl -side left -padx 0 -pady 0 -anchor n
  294.  
  295.  
  296.     frame $w.usernamefrm
  297.     pack $w.usernamefrm -fill x
  298.     label  $w.usernamefrm.lblusername -text "Username "     
  299.     entry  $w.usernamefrm.username  -textvariable username
  300.     pack $w.usernamefrm.lblusername $w.usernamefrm.username -side left -padx 0 -pady 0 -anchor n
  301.  
  302.     frame $w.password
  303.     pack $w.password -fill x
  304.     label $w.password.lblpassword -text "Password "
  305.     entry  $w.password.password  -textvariable password -show *
  306.     pack $w.password.lblpassword  $w.password.password -side left -padx 0 -pady 0 -anchor n
  307.     
  308.     frame $w.domain
  309.     pack $w.domain -fill x  
  310.     label $w.domain.lbldomain -text "Domain "
  311.     entry  $w.domain.domain  -textvariable domain
  312.     pack $w.domain.lbldomain $w.domain.domain -side left -padx 0 -pady 0 -anchor n
  313.  
  314.  
  315.  set w [notebook::frame .n Resources]
  316.   frame $w.midlbl
  317.   pack $w.midlbl -fill x
  318.   label $w.midlbl.lbl -text "Local Resources "
  319.   pack $w.midlbl.lbl -side left -padx 0p -pady 0 -anchor n
  320.   checkbutton $w.disk -text "Disk Drives" -variable disk
  321.   checkbutton $w.com -text "Com Ports" -variable com
  322.   checkbutton $w.sound -text "Sound" -variable sound
  323.   pack $w.disk $w.com $w.sound -side left -padx 0p -pady 0 -anchor n
  324.  
  325.  set w [notebook::frame .n Display]
  326.   frame $w.displayslbl
  327.   pack $w.displayslbl -fill x  
  328.   label $w.displayslbl.lbldisp -text "Choose the size of your remote desktop.\nClick the drop down and select the resoltion." 
  329.   pack $w.displayslbl.lbldisp  -side left -padx 0p -pady 0 -anchor n
  330.  
  331.   frame $w.displays
  332.   pack $w.displays -fill x
  333.   combobox $w.displays.displayList -borderwidth 1 -highlightthickness 1 -maxheight 0 -width 10 -editable false -textvariable mode
  334.   $w.displays.displayList list insert end "640x480"
  335.   $w.displays.displayList list insert end "800x600"
  336.   $w.displays.displayList list insert end "1024x768"
  337.   $w.displays.displayList list insert end "Full Screen"
  338.   pack $w.displays.displayList -side left -padx 0 -pady 0 -anchor n
  339.  
  340.   frame $w.colorslbl
  341.   pack $w.colorslbl -fill x
  342.   label $w.colorslbl.lbldisp -text "\n\n\n\n\n\n\n\nColors"
  343.   pack $w.colorslbl.lbldisp  -side left -padx 0 -pady 0 -anchor n
  344.  
  345.   frame $w.colors
  346.   pack $w.colors -fill x
  347.   combobox $w.colors.cmb -borderwidth 1 -highlightthickness 1 -maxheight 0 -width 10 -editable false -textvariable col
  348.   $w.colors.cmb list insert end "256"
  349.   $w.colors.cmb list insert end "65,000"
  350.   $w.colors.cmb list insert end "Millions"
  351.   pack $w.colors.cmb -side left -padx 0p -pady 0 -anchor n
  352.  
  353. set w [notebook::frame .n Programs]
  354.   frame $w.programlbl
  355.   pack $w.programlbl -fill x
  356.   label $w.programlbl.programlbl -text "Please enter the Path\nand the name of the program to use\ni.e. c:\\windows\\notepad.exe"
  357.   pack $w.programlbl.programlbl -side left -padx 0p -pady 0 -anchor n
  358.  
  359.  
  360.   frame $w.program
  361.   pack $w.program -fill x
  362.   entry $w.program.programname -textvariable program -width 40
  363.   pack $w.program.programname -side left -padx 0p -pady 0 -anchor n
  364.  
  365.  
  366. set w [notebook::frame .n Experience]
  367.  
  368.   frame $w.experiencelbl
  369.   pack $w.experiencelbl -fill x
  370.   label $w.experiencelbl.lbldisp -text "Experience"
  371.   pack $w.experiencelbl.lbldisp  -side left -padx 0p -pady 0 -anchor n
  372.  
  373.  
  374.   frame $w.experience
  375.   pack $w.experience -fill x
  376.   radiobutton $w.experience.broadband -text "Broadband" -variable exp -value b -command clickp
  377.   radiobutton $w.experience.modem -text "Modem" -variable exp -value m -command clickp
  378.   radiobutton $w.experience.lan -text "Lan" -variable exp -value l -command clickp
  379.   pack $w.experience.broadband $w.experience.modem $w.experience.lan -side left -padx 0p -pady 0 -anchor n 
  380.   
  381.   frame $w.mexperience
  382.   pack $w.mexperience -fill x
  383.   checkbutton $w.mexperience.caching -text "Bitmap Caching" -variable p
  384.   pack $w.mexperience.caching -side left -padx 0p -pady 0 -anchor n
  385.  
  386. set w [notebook::frame .n About]
  387.   frame $w.about
  388.   pack $w.about -fill x
  389.   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"
  390.   pack $w.about.info -side top -padx 0p -pady 0 -anchor n
  391.  
  392.   frame .bottom -borderwidth 10
  393.   pack .bottom -fill x
  394.   button .bottom.submit -text "Connect" -command init
  395.   pack .bottom.submit -side bottom -fill y
  396. }
  397.  
  398. proc init { } {
  399. global mode action gloabl p exp col disk com sound hostname global colors username password domain
  400. global res persistant experience colors dsk cm snd rdesktop user pass colors dmn
  401.  
  402. if {$hostname != ""} {
  403.     if {$domain != ""} {
  404.         set dmn  "-d $domain"
  405.     } else {
  406.         set dmn ""
  407.     }
  408.  
  409.  
  410.     if {$username != ""} {
  411.      set user  "-u $username"
  412.     } else {
  413.      set user ""
  414.     }
  415.     if {$password != ""} {
  416.         set pass  "-p $password"
  417.     } else {
  418.         set pass ""
  419.     }
  420.  
  421.     if {$disk == "1"} {
  422.     set dsk "-r disk:local=/"
  423.     } else {
  424.     set dsk ""
  425.     }
  426.     if {$com == "1"} {
  427.     set cm "-r com1:COM1=/dev/ttyS0"
  428.     } else {
  429.     set cm ""
  430.     }
  431.     if {$sound == "1"} {
  432.     set snd "-r sound"
  433.     } else {
  434.     set snd ""
  435.     }
  436.  
  437.     if {$col == "256"} {
  438.     set colors "-a 8"
  439.     } elseif {$col == "65,000"} {
  440.     set colors "-a 16"
  441.     } elseif {$col == "Millions"} {
  442.     set colors "-a 24"
  443.     } else {
  444.     set colors ""
  445.     }
  446.     
  447.     if {$exp == "b"} {
  448.     set experience "-x b"
  449.     } elseif {$exp == "m"} {
  450.     set experience "-x m"
  451.     } elseif {$exp == "l"} {
  452.     set experience "-x l"
  453.     } else {
  454.     set experience ""
  455.     }
  456.     
  457.     if {$p == "1"} {
  458.         set persistant "-P"
  459.     } else {
  460.     set persistant ""
  461.     }
  462.  
  463.     if {$mode == "800x600"} {
  464.     set res "-g$mode"
  465.     } elseif {$mode == "640x480"} {
  466.     set res "-g$mode"
  467.     } elseif {$mode == "1024x768"} {
  468.         set res "-g$mode"
  469.     } elseif {$mode == "Full Screen"} {
  470.         set res "-f"
  471.     } else {
  472.     set res "-g640x480"
  473.     }
  474. #puts  "$rdesktop $user $pass $dmn $persistant $res $experience $colors $dsk $cm $snd $hostname"
  475. open "| $rdesktop $user $pass $dmn $persistant $res $experience $colors $dsk $cm $snd $hostname"
  476. exit
  477. } else {
  478. tk_messageBox -message "You Must Enter a Hostname" -type ok -icon error
  479. }
  480.  
  481. }
  482.  
  483.  
  484. proc clickp { } {
  485. global p
  486. set p "1"
  487. }
  488.  
  489. proc quit { } {
  490. set answer [tk_messageBox -message "Really quit?" -type yesno -icon question]
  491. switch -- $answer {
  492.     yes exit
  493.     no
  494. }
  495. }
  496. proc colorchange { } {
  497. global change
  498. puts "Change"
  499. }
  500.  
  501.  
  502. screen
  503.  
  504.