summaryrefslogtreecommitdiffstats
path: root/library/safetk.tcl
diff options
context:
space:
mode:
authorhobbs <hobbs>2008-03-27 21:02:55 (GMT)
committerhobbs <hobbs>2008-03-27 21:02:55 (GMT)
commit579bd267ae6d51f2362fa303d6389c6bafe9489c (patch)
tree2c43b234c3dac0fd69c81b09ea3f8ac8d1a0b5f6 /library/safetk.tcl
parentef719b7292192473b2043e3594fc0dbe26092cc0 (diff)
downloadtk-579bd267ae6d51f2362fa303d6389c6bafe9489c.zip
tk-579bd267ae6d51f2362fa303d6389c6bafe9489c.tar.gz
tk-579bd267ae6d51f2362fa303d6389c6bafe9489c.tar.bz2
* library/safetk.tcl (::safe::tkInterpInit): make sure tk_library
and its subdirs (eg, ttk) are on the "safe" access path.
Diffstat (limited to 'library/safetk.tcl')
-rw-r--r--library/safetk.tcl56
1 files changed, 25 insertions, 31 deletions
diff --git a/library/safetk.tcl b/library/safetk.tcl
index 4ad1418..c7cf97d 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.10 2006/11/03 15:58:51 patthoyts Exp $
+# RCS: @(#) $Id: safetk.tcl,v 1.11 2008/03/27 21:02:56 hobbs Exp $
#
# Copyright (c) 1997 Sun Microsystems, Inc.
#
@@ -27,34 +27,30 @@ package require opt 0.4.1;
namespace eval ::safe {
# counter for safe toplevels
- variable tkSafeId 0;
-
- #
- # tkInterpInit : prepare the slave interpreter for tk loading
- # most of the real job is done by loadTk
- # returns the slave name (tkInterpInit does)
- #
- proc ::safe::tkInterpInit {slave argv} {
- global env tk_library
-
- # We have to make sure that the tk_library variable uses a file
- # pathname that works better in Tk (of the style returned by
- # [file join], ie C:/path/to/tk/lib, not C:\path\to\tk\lib
- set tk_library [file join $tk_library]
-
- # Clear Tk's access for that interp (path).
- allowTk $slave $argv
-
- # there seems to be an obscure case where the tk_library
- # variable value is changed to point to a sym link destination
- # dir instead of the sym link itself, and thus where the $tk_library
- # would then not be anymore one of the auto_path dir, so we use
- # the addToAccessPath which adds if it's not already in instead
- # of the more conventional findInAccessPath.
- # Might be usefull for masters without Tk really loaded too.
- ::interp eval $slave [list set tk_library [::safe::interpAddToAccessPath $slave $tk_library]]
- return $slave
+ variable tkSafeId 0
+}
+
+#
+# tkInterpInit : prepare the slave interpreter for tk loading
+# most of the real job is done by loadTk
+# returns the slave name (tkInterpInit does)
+#
+proc ::safe::tkInterpInit {slave 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
+
+ # Ensure tk_library and subdirs (eg, ttk) are on the access path
+ ::interp eval $slave [list set tk_library [::safe::interpAddToAccessPath $slave $tk_library]]
+ foreach subdir [::safe::AddSubDirs [list $tk_library]] {
+ ::safe::interpAddToAccessPath $slave $subdir
}
+ return $slave
+}
# tkInterpLoadTk :
@@ -67,7 +63,7 @@ namespace eval ::safe {
# empty definition for auto_mkIndex
proc ::safe::loadTk {} {}
-::tcl::OptProc loadTk {
+::tcl::OptProc ::safe::loadTk {
{slave -interp "name of the slave interpreter"}
{-use -windowId {} "window Id to use (new toplevel otherwise)"}
{-display -displayName {} "display name to use (current one otherwise)"}
@@ -275,5 +271,3 @@ proc ::safe::tkTopLevel {slave display} {
# return both the toplevel window name and the id to use for embedding
list $w [winfo id $w.c]
}
-
-} \ No newline at end of file