diff options
Diffstat (limited to 'library')
-rw-r--r-- | library/console.tcl | 4 | ||||
-rw-r--r-- | library/demos/dialog1.tcl | 14 | ||||
-rw-r--r-- | library/demos/fontchoose.tcl | 6 | ||||
-rw-r--r-- | library/safetk.tcl | 80 |
4 files changed, 51 insertions, 53 deletions
diff --git a/library/console.tcl b/library/console.tcl index eb8990a..b98689f 100644 --- a/library/console.tcl +++ b/library/console.tcl @@ -740,9 +740,9 @@ proc ::tk::console::FontchooserToggle {} { } proc ::tk::console::FontchooserVisibility {index} { if {[tk fontchooser configure -visible]} { - .menubar.edit entryconfigure $index -label [msgcat::mc "Hide Fonts"] + .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Hide Fonts"] } else { - .menubar.edit entryconfigure $index -label [msgcat::mc "Show Fonts"] + .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Show Fonts"] } } proc ::tk::console::FontchooserFocus {w isFocusIn} { diff --git a/library/demos/dialog1.tcl b/library/demos/dialog1.tcl index 976e955..66d8c9a 100644 --- a/library/demos/dialog1.tcl +++ b/library/demos/dialog1.tcl @@ -2,16 +2,16 @@ # # This demonstration script creates a dialog box with a local grab. -interp create slave -load {} Tk slave -slave eval { - wm title . slave +interp create child +load {} Tk child +child eval { + wm title . child wm geometry . +700+30 pack [text .t -width 30 -height 10] } after idle {.dialog1.msg configure -wraplength 4i} -set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "slave" which was created by a slave interpreter.} \ +set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "child" which was created by a child interpreter.} \ info 0 OK Cancel {Show Code}] switch $i { @@ -20,6 +20,6 @@ switch $i { 2 {showCode .dialog1} } -if {[interp exists slave]} { - interp delete slave +if {[interp exists child]} { + interp delete child } diff --git a/library/demos/fontchoose.tcl b/library/demos/fontchoose.tcl index 8b34377..446ed34 100644 --- a/library/demos/fontchoose.tcl +++ b/library/demos/fontchoose.tcl @@ -55,10 +55,6 @@ grid $f.msg $f.vs -sticky news grid $f.font - -sticky e grid columnconfigure $f 0 -weight 1 grid rowconfigure $f 0 -weight 1 -bind $w <Visibility> { - bind %W <Visibility> {} - grid propagate %W.f 0 -} ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] @@ -67,3 +63,5 @@ grid $f -sticky news grid $btns -sticky ew grid columnconfigure $w 0 -weight 1 grid rowconfigure $w 0 -weight 1 +update idletasks +grid propagate $f 0 diff --git a/library/safetk.tcl b/library/safetk.tcl index 9f8e25d..841a0b6 100644 --- a/library/safetk.tcl +++ b/library/safetk.tcl @@ -14,9 +14,9 @@ # Note: It is now ok to let untrusted code being executed # between the creation of the interp and the actual loading # of Tk in that interp because the C side Tk_Init will -# now look up the master interp and ask its safe::TkInit +# now look up the parent interp and ask its safe::TkInit # for the actual parameters to use for it's initialization (if allowed), -# not relying on the slave state. +# not relying on the child state. # # We use opt (optional arguments parsing) @@ -29,31 +29,31 @@ namespace eval ::safe { } # -# tkInterpInit : prepare the slave interpreter for tk loading +# tkInterpInit : prepare the child interpreter for tk loading # most of the real job is done by loadTk -# returns the slave name (tkInterpInit does) +# returns the child name (tkInterpInit does) # -proc ::safe::tkInterpInit {slave argv} { +proc ::safe::tkInterpInit {child argv} { global env tk_library # We have to make sure that the tk_library variable is normalized. set tk_library [file normalize $tk_library] # Clear Tk's access for that interp (path). - allowTk $slave $argv + allowTk $child $argv # Ensure tk_library and subdirs (eg, ttk) are on the access path - ::interp eval $slave [list set tk_library [::safe::interpAddToAccessPath $slave $tk_library]] + ::interp eval $child [list set tk_library [::safe::interpAddToAccessPath $child $tk_library]] foreach subdir [::safe::AddSubDirs [list $tk_library]] { - ::safe::interpAddToAccessPath $slave $subdir + ::safe::interpAddToAccessPath $child $subdir } - return $slave + return $child } # tkInterpLoadTk: # Do additional configuration as needed (calling tkInterpInit) -# and actually load Tk into the slave. +# and actually load Tk into the child. # # Either contained in the specified windowId (-use) or # creating a decorated toplevel for it. @@ -62,37 +62,37 @@ proc ::safe::tkInterpInit {slave argv} { proc ::safe::loadTk {} {} ::tcl::OptProc ::safe::loadTk { - {slave -interp "name of the slave interpreter"} + {child -interp "name of the child interpreter"} {-use -windowId {} "window Id to use (new toplevel otherwise)"} {-display -displayName {} "display name to use (current one otherwise)"} } { set displayGiven [::tcl::OptProcArgGiven "-display"] if {!$displayGiven} { # Try to get the current display from "." - # (which might not exist if the master is tk-less) + # (which might not exist if the parent is tk-less) if {[catch {set display [winfo screen .]}]} { if {[info exists ::env(DISPLAY)]} { set display $::env(DISPLAY) } else { - Log $slave "no winfo screen . nor env(DISPLAY)" WARNING + Log $child "no winfo screen . nor env(DISPLAY)" WARNING set display ":0.0" } } } # Get state for access to the cleanupHook. - namespace upvar ::safe S$slave state + namespace upvar ::safe S$child state if {![::tcl::OptProcArgGiven "-use"]} { # create a decorated toplevel - lassign [tkTopLevel $slave $display] w use + lassign [tkTopLevel $child $display] w use - # set our delete hook (slave arg is added by interpDelete) - # to clean up both window related code and tkInit(slave) + # set our delete hook (child arg is added by interpDelete) + # to clean up both window related code and tkInit(child) set state(cleanupHook) [list tkDelete {} $w] } else { - # set our delete hook (slave arg is added by interpDelete) - # to clean up tkInit(slave) + # set our delete hook (child arg is added by interpDelete) + # to clean up tkInit(child) set state(cleanupHook) [list disallowTk] # Let's be nice and also accept tk window names instead of ids @@ -122,12 +122,12 @@ proc ::safe::loadTk {} {} } } - # Prepares the slave for tk with those parameters - tkInterpInit $slave [list "-use" $use "-display" $display] + # Prepares the child for tk with those parameters + tkInterpInit $child [list "-use" $use "-display" $display] - load {} Tk $slave + load {} Tk $child - return $slave + return $child } proc ::safe::TkInit {interpPath} { @@ -149,7 +149,7 @@ proc ::safe::TkInit {interpPath} { # safe::TkInit. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # argv arguments passed to safe::TkInterpInit # # Results: @@ -168,7 +168,7 @@ proc ::safe::allowTk {interpPath argv} { # in safe::TkInit. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # # Results: # none. @@ -188,43 +188,43 @@ proc ::safe::disallowTk {interpPath} { # Clean up the window associated with the interp being deleted. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # # Results: # none. -proc ::safe::tkDelete {W window slave} { +proc ::safe::tkDelete {W window child} { # we are going to be called for each widget... skip untill it's # top level - Log $slave "Called tkDelete $W $window" NOTICE - if {[::interp exists $slave]} { - if {[catch {::safe::interpDelete $slave} msg]} { - Log $slave "Deletion error : $msg" + Log $child "Called tkDelete $W $window" NOTICE + if {[::interp exists $child]} { + if {[catch {::safe::interpDelete $child} msg]} { + Log $child "Deletion error : $msg" } } if {[winfo exists $window]} { - Log $slave "Destroy toplevel $window" NOTICE + Log $child "Destroy toplevel $window" NOTICE destroy $window } - # clean up tkInit(slave) - disallowTk $slave + # clean up tkInit(child) + disallowTk $child return } -proc ::safe::tkTopLevel {slave display} { +proc ::safe::tkTopLevel {child display} { variable tkSafeId incr tkSafeId set w ".safe$tkSafeId" if {[catch {toplevel $w -screen $display -class SafeTk} msg]} { return -code error -errorcode {TK TOPLEVEL SAFE} \ - "Unable to create toplevel for safe slave \"$slave\" ($msg)" + "Unable to create toplevel for safe child \"$child\" ($msg)" } - Log $slave "New toplevel $w" NOTICE + Log $child "New toplevel $w" NOTICE - set msg "Untrusted Tcl applet ($slave)" + set msg "Untrusted Tcl applet ($child)" wm title $w $msg # Control frame (we must create a style for it) @@ -236,7 +236,7 @@ proc ::safe::tkTopLevel {slave display} { # We will destroy the interp when the window is destroyed bindtags $wc [concat Safe$wc [bindtags $wc]] - bind Safe$wc <Destroy> [list ::safe::tkDelete %W $w $slave] + bind Safe$wc <Destroy> [list ::safe::tkDelete %W $w $child] ttk::label $wc.l -text $msg -anchor w @@ -247,7 +247,7 @@ proc ::safe::tkTopLevel {slave display} { # but still have the default background instead of red one from the parent ttk::frame $wc.fb -borderwidth 0 ttk::button $wc.fb.b -text "Delete" \ - -command [list ::safe::tkDelete $w $w $slave] + -command [list ::safe::tkDelete $w $w $child] pack $wc.fb.b -side right -fill both pack $wc.fb -side right -fill both -expand 1 pack $wc.l -side left -fill both -expand 1 -ipady 2 |