#!/usr/local/bin/perl 
#
# Copyright (C) 1992 by Gustaf Neumann, Stefan Nusser
#
#      Wirtschaftsuniversitaet Wien,
#      Abteilung fuer Wirtschaftsinformatik
#      Augasse 2-6,
#      A-1090 Vienna, Austria
#      neumann@wu-wien.ac.at, nusser@wu-wien.ac.at
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appears in all copies and that both that
# copyright notice and this permission notice appear in all supporting
# documentation.  This software is provided "as is" without expressed or
# implied warranty.
#
# Date: Mon, Apr 13 1992
# Author: Gustaf Neumann
# Version: 0.9
#

$WafeLib = $ENV{'WAFELIB'} || "/usr/lib/X11/wafe";
require "$WafeLib/perl/wafe.pl";

&Xui(<<"__");
   Viewport vp topLevel {
       width 500 height 600 
       forceBars true allowVert true }
   sV vp.vertical $sbColors
   action vp override {<Key>q: exec(quit)}
   Box top vp $backGround
__

@files = ($#ARGV>=0) ? @ARGV : </usr/include/X11/bitmaps/*>;

foreach $f (@files) {
	opendir(D,$f) && (push(@nfiles,grep($_="$f/$_",readdir(D)))) 
	    && closedir D, next  if -d $f;
	push(@nfiles,$f);
}

sub bysize { $keys[$a] <=> $keys[$b]; }
for (@nfiles) { push (@keys, (-s $_)); }

$i = 0;
for (@nfiles[sort bysize $[.. $#nfiles]) {
	next if ! -f $_;
        split('/'); $name = $_[$#_];
	&Xui("Box line$i top orientation vertical;"
	    ."Label lab$i line$i label $name borderWidth 0;"
	    ."Toggle tog$i line$i bitmap $_ borderWidth 0");
	$i++;
}

&Xui("realize; deleteWindowProtocol quit");

while($_=&wafe'read) {print;}

