From db5f327eedd2541110e7ca27a15cfc1d7c9984c7 Mon Sep 17 00:00:00 2001 From: treectrl Date: Sat, 19 Jul 2003 17:51:05 +0000 Subject: Allow running from 'demos' directory and when installed. --- demos/demo.tcl | 71 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file 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 -- cgit v0.12