1#!/usr/bin/env ruby
2require 'tk'
3require 'tkextlib/iwidgets'
4
5def get_files(file)
6  dir = (file.empty?)? ENV['HOME'] : TkComm._fromUTF8(file)
7  Dir.chdir(dir) rescue return ''
8  Dir['*'].sort.collect{|f|
9    [TkComm._toUTF8(File.join(dir, f)), TkComm._toUTF8(f)]
10  }
11end
12
13Tk::Iwidgets::Hierarchy.new(:querycommand=>proc{|arg| get_files(arg.node)},
14                            :visibleitems=>'30x15',
15                            :labeltext=>ENV['HOME']).pack(:side=>:left,
16                                                          :expand=>true,
17                                                          :fill=>:both)
18
19# Tk::Iwidgets::Hierarchy.new(:querycommand=>[proc{|n| get_files(n)}, '%n'],
20#                           :visibleitems=>'30x15',
21#                           :labeltext=>ENV['HOME']).pack(:side=>:left,
22#                                                         :expand=>true,
23#                                                         :fill=>:both)
24
25Tk.mainloop
26