#!/usr/local/bin/perl 
#
# Copyright (C) 1994 by Gustaf Neumann
#
#      Wirtschaftsuniversitaet Wien,
#      Abteilung fuer Wirtschaftsinformatik
#      Augasse 2-6,
#      A-1090 Vienna, Austria
#      neumann@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: Thu, Jul 7, 1994
# Author: Gustaf Neumann
# Version: 1.0
#

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

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

@files = ($#ARGV>=0) ? @ARGV : </usr/local/lib/sounds/*>;

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

$i = 0;
for (sort @nfiles) {
    next if ! -f $_;
    @_ = split('/'); $name = $_[$#_];
    &Xui("Command c$i top label $name  callback {exec play $_}");
    $i++;
}
&Xui("Label error top label {No audio files found!}") unless $i>0;
&Xui("realize; deleteWindowProtocol quit");
while($_=&wafe'read) {print;}


