#!../tree_wish -f
# -*-Tcl-*-
#
# Below is an example of a simple directory tree using the [incr Tk] Tree class
#
# Usage: dirtree.itk
#
# Author: Allan Brighton (abrighto@eso.org) 

if {[catch {class X {}}]} {
    puts "This demo requires itcl2.0/itk2.0."
    puts "Install itcl2.0 and then rerun configure and make here..."
    exit
}

# the utility classes in ../library use this namespace
namespace ::util {}; import add util

# make sure the ree [incr Tk] library sources are found
lappend auto_path ../library

# create an instance of the [incr Tk] "Tree" widget
set tree [Tree .tree -layout vertical]
pack $tree -fill both -expand 1

# bitmap to use for nodes
set bitmap "../bitmaps/dir.xbm"

# directory for root node
set dir [file dirname [pwd]]

# add the root node
$tree add_node {} $dir -bitmap @$bitmap -text [file tail $dir]

# add the subnodes
foreach i [exec ls $dir] {
    if {[file isdir $dir/$i]} {
        $tree add_node $dir $dir/$i -bitmap @$bitmap -text $i
    }
}

