summaryrefslogtreecommitdiffstats
path: root/demos/demo.tcl
diff options
context:
space:
mode:
authortreectrl <treectrl>2003-07-19 17:51:05 (GMT)
committertreectrl <treectrl>2003-07-19 17:51:05 (GMT)
commitdb5f327eedd2541110e7ca27a15cfc1d7c9984c7 (patch)
treed6e1843734c57e217db8509f141ad94bd2bd7ad2 /demos/demo.tcl
parent33278d3d463b2ebded2bff9a07e871fba3b4a67d (diff)
downloadtktreectrl-db5f327eedd2541110e7ca27a15cfc1d7c9984c7.zip
tktreectrl-db5f327eedd2541110e7ca27a15cfc1d7c9984c7.tar.gz
tktreectrl-db5f327eedd2541110e7ca27a15cfc1d7c9984c7.tar.bz2
Allow running from 'demos' directory and when installed.
Diffstat (limited to 'demos/demo.tcl')
-rw-r--r--demos/demo.tcl71
1 files changed, 47 insertions, 24 deletions
diff --git a/demos/demo.tcl b/demos/demo.tcl
index 1534558..d30da91 100644
--- a/demos/demo.tcl
+++ b/demos/demo.tcl
@@ -17,7 +17,7 @@ cd $ScriptDir
# Command to create a full pathname in this file's directory
proc Path {args} {
- return [eval file join [list $::ScriptDir] $args]
+ return [file normalize [eval file join [list $::ScriptDir] $args]]
}
# Create some photo images on demand
@@ -49,35 +49,58 @@ if {[catch {
proc dbwin s {puts -nonewline $s}
}
-switch -- $::thisPlatform {
- macintosh {
- load treectrl.shlb
- }
- macosx {
- load build/treectrl.dylib
- }
- unix {
+# Return TRUE if we are running from the development directory
+proc IsDevelopment {} {
+ return [file exists [Path .. generic]]
+}
- # Try to load libtreectrl*.so on Unix
- set lib [glob -nocomplain libtreectrl*[info sharedlibextension]]
- load $lib
- }
- default {
+if {[IsDevelopment]} {
+
+ switch -- $::thisPlatform {
+ macintosh {
+ load [Path .. treectrl.shlb]
+ }
+ macosx {
+ load [Path .. build treectrl.dylib]
+ }
+ unix {
+
+ # Try to load libtreectrl*.so on Unix
+ load [glob -directory [Path ..] libtreectrl*[info sharedlibextension]]
+ }
+ default {
- # Windows build
- load Build/treectrl[info sharedlibextension]
+ # Windows build
+ load [Path .. Build treectrl[info sharedlibextension]]
+ }
}
-}
-# Default TreeCtrl bindings
-source [Path library treectrl.tcl]
+ # Default TreeCtrl bindings
+ source [Path .. library treectrl.tcl]
+
+ # Other useful bindings
+ source [Path .. library filelist-bindings.tcl]
-# Other useful bindings
-source [Path library filelist-bindings.tcl]
+} else {
+
+ lappend ::auto_path [Path ..]
+ package require treectrl
+}
# Demo sources
-foreach file [glob -directory [Path demos] *.tcl] {
- source $file
+foreach file {
+ bitmaps
+ explorer
+ help
+ imovie
+ layout
+ mailwasher
+ outlook-folders
+ outlook-newgroup
+ random
+ www-options
+ } {
+ source [Path $file.tcl]
}
# Get default colors
@@ -141,7 +164,7 @@ proc MakeSourceWindow {} {
}
proc ShowSource {file} {
wm title .source "Demo Source: $file"
- set path [Path demos $file]
+ set path [Path $file]
set t .source.f.t
set chan [open $path]
$t delete 1.0 end