#!/usr/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
#

sub Xui { $|=1; for (split("\n",@_[0])) {print "%$_\n";} }

&Xui("viewport vp topLevel width 500 height 600 forceBars true allowVert true;"
   ."action vp override {<Key>q : exec(quit)};"
   ."box top vp");

@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; setWMProtocols topLevel WM_DELETE_WINDOW;'
     .'action topLevel override "<Message>WM_PROTOCOLS: exec(quit)"');
while(<STDIN>) {print;}

