| 1 |
#!/usr/local/bin/perl -w |
| 2 |
use Tk; |
| 3 |
use Tk::Xlib; |
| 4 |
use Tk::HList; |
| 5 |
|
| 6 |
my $win_image; |
| 7 |
|
| 8 |
sub AddChildren |
| 9 |
{ |
| 10 |
my ($hl,$path,$id) = @_; |
| 11 |
my $w; |
| 12 |
# foreach $w ($hl->property(list => $$id)) |
| 13 |
# { |
| 14 |
# $hl->add("$path.$w", -itemtype => 'text', -text => $w, -data => $w); |
| 15 |
# } |
| 16 |
foreach $w ($hl->Display->XQueryTree($id)) |
| 17 |
{ |
| 18 |
my $name = sprintf("#%X",$$w); |
| 19 |
my $text = ($hl->property('exists' => 'WM_NAME',$$w)) |
| 20 |
? $hl->property(get => 'WM_NAME',$$w) |
| 21 |
: $name; |
| 22 |
|
| 23 |
$hl->add("$path.$name", -itemtype => 'imagetext', -image => $win_image, -text => $text, -data => $w); |
| 24 |
AddChildren($hl,"$path.$name",$w); |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
sub More |
| 29 |
{ |
| 30 |
my ($w,$item) = @_; |
| 31 |
my $data = $w->entrycget($item,'-data'); |
| 32 |
if (ref($data)) |
| 33 |
{ |
| 34 |
AddChildren($w,$item,$data); |
| 35 |
} |
| 36 |
else |
| 37 |
{ |
| 38 |
my $prop = $data; |
| 39 |
my $parent = $w->info('parent',$item); |
| 40 |
$data = $w->entrycget($parent,'-data'); |
| 41 |
my @info = $w->property('get',$prop,$$data); |
| 42 |
print join(' ',$prop,@info),"\n"; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
my $mw = MainWindow->new; |
| 48 |
$mw->MakeWindowExist; |
| 49 |
my $root; |
| 50 |
$mw->Display->XQueryTree($mw->WindowId,$root); |
| 51 |
|
| 52 |
if (defined $root) |
| 53 |
{ |
| 54 |
$win_image = $mw->Bitmap(-file => Tk->findINC('win.xbm')); |
| 55 |
my $hl = $mw->Scrolled('HList',-separator => '.',-drawbranch => 1); |
| 56 |
$hl->configure(-command => [\&More,$hl]); |
| 57 |
my $name = sprintf("%X",$$root); |
| 58 |
$hl->add($name, -itemtype => 'imagetext', -image => $win_image, -text => $name, -data => $root); |
| 59 |
AddChildren($hl,$name,$root); |
| 60 |
$hl->pack(-expand=> 1, -fill => 'both'); |
| 61 |
} |
| 62 |
|
| 63 |
MainLoop; |