summaryrefslogtreecommitdiffstats
path: root/library/safetk.tcl
diff options
context:
space:
mode:
authorhobbs <hobbs>2008-03-27 21:05:09 (GMT)
committerhobbs <hobbs>2008-03-27 21:05:09 (GMT)
commitb9f3f27899d257217522d0adbb7cd63a7ea7c15d (patch)
tree527dfde6efe432a2571b79a8e45b7b0a250d9bfb /library/safetk.tcl
parent0a9ab8614642f5e827de4edc85c71917069eebe2 (diff)
downloadtk-b9f3f27899d257217522d0adbb7cd63a7ea7c15d.zip
tk-b9f3f27899d257217522d0adbb7cd63a7ea7c15d.tar.gz
tk-b9f3f27899d257217522d0adbb7cd63a7ea7c15d.tar.bz2
whitespace fixes
Diffstat (limited to 'library/safetk.tcl')
-rw-r--r--library/safetk.tcl27
1 files changed, 8 insertions, 19 deletions
diff --git a/library/safetk.tcl b/library/safetk.tcl
index c7cf97d..58cb954 100644
--- a/library/safetk.tcl
+++ b/library/safetk.tcl
@@ -2,7 +2,7 @@
#
# Support procs to use Tk in safe interpreters.
#
-# RCS: @(#) $Id: safetk.tcl,v 1.11 2008/03/27 21:02:56 hobbs Exp $
+# RCS: @(#) $Id: safetk.tcl,v 1.12 2008/03/27 21:05:09 hobbs Exp $
#
# Copyright (c) 1997 Sun Microsystems, Inc.
#
@@ -53,16 +53,16 @@ proc ::safe::tkInterpInit {slave argv} {
}
-# tkInterpLoadTk :
-# Do additional configuration as needed (calling tkInterpInit)
+# tkInterpLoadTk:
+# Do additional configuration as needed (calling tkInterpInit)
# and actually load Tk into the slave.
-#
+#
# Either contained in the specified windowId (-use) or
# creating a decorated toplevel for it.
# empty definition for auto_mkIndex
proc ::safe::loadTk {} {}
-
+
::tcl::OptProc ::safe::loadTk {
{slave -interp "name of the slave interpreter"}
{-use -windowId {} "window Id to use (new toplevel otherwise)"}
@@ -70,10 +70,8 @@ proc ::safe::loadTk {} {}
} {
set displayGiven [::tcl::OptProcArgGiven "-display"]
if {!$displayGiven} {
-
# Try to get the current display from "."
# (which might not exist if the master is tk-less)
-
if {[catch {set display [winfo screen .]}]} {
if {[info exists ::env(DISPLAY)]} {
set display $::env(DISPLAY)
@@ -84,9 +82,7 @@ proc ::safe::loadTk {} {}
}
}
if {![::tcl::OptProcArgGiven "-use"]} {
-
# create a decorated toplevel
-
::tcl::Lassign [tkTopLevel $slave $display] w use
# set our delete hook (slave arg is added by interpDelete)
@@ -97,28 +93,22 @@ proc ::safe::loadTk {} {}
# set our delete hook (slave arg is added by interpDelete)
# to clean up tkInit(slave)
-
Set [DeleteHookName $slave] [list disallowTk]
# Let's be nice and also accept tk window names instead of ids
-
if {[string match ".*" $use]} {
set windowName $use
set use [winfo id $windowName]
set nDisplay [winfo screen $windowName]
} else {
-
# Check for a better -display value
# (works only for multi screens on single host, but not
# cross hosts, for that a tk window name would be better
# but embeding is also usefull for non tk names)
-
if {![catch {winfo pathname $use} name]} {
set nDisplay [winfo screen $name]
} else {
-
# Can't have a better one
-
set nDisplay $display
}
}
@@ -133,9 +123,8 @@ proc ::safe::loadTk {} {}
}
# Prepares the slave for tk with those parameters
-
tkInterpInit $slave [list "-use" $use "-display" $display]
-
+
load {} Tk $slave
return $slave
@@ -219,7 +208,7 @@ proc ::safe::tkDelete {W window slave} {
Log $slave "Destroy toplevel $window" NOTICE
destroy $window
}
-
+
# clean up tkInit(slave)
disallowTk $slave
return
@@ -267,7 +256,7 @@ proc ::safe::tkTopLevel {slave display} {
# Container frame
frame $w.c -container 1
pack $w.c -fill both -expand 1
-
+
# return both the toplevel window name and the id to use for embedding
list $w [winfo id $w.c]
}