#!/afs/athena.mit.edu/contrib/perl5/bin/perl

use Tk;
use Tk qw(exit); 

$toplevel=MainWindow->new(width=>44,height=>44);
$toplevel->resizable(FALSE,FALSE);

# Setup the spinning fish
$pixmaps="/afs/sipb.mit.edu/user/xiphmont/vol/pixmaps";
$fish=$toplevel->Pixmap(-file => "$pixmaps/fishframe.xpm");

$mute=$toplevel->Canvas(borderwidth=>0,
			highlightthickness=>0,
			width=>40,height=>40,-bg=>$toplevel->cget('-bg'))->
    place(-relx=>1.0,-rely=>0.5,-x=>-2,-anchor=>'e');

$mute->createImage(0,0,-image=>$fish,-anchor=>nw,-tags=>["fish"]);

$mute->bind('fish','<Enter>',[sub{$mutelight=1;&twirlupdate}]);
$mute->bind('fish','<Leave>',[sub{$mutelight=0;&twirlupdate}]);
$mute->bind('fish','<Button>',[sub{$muted=1;&twirlupdate;}]);
$mute->bind('fish','<ButtonRelease>',[sub{Tk::exit;&twirlupdate;}]);		  
&twirlupdate();

$muted=0;
$mutelight=0;
$mute->repeat(80,\&twirlback);

MainLoop();

sub twirlback{
    $fishcounter++;
    if($fishcounter>=12){$fishcounter=0;}
    &twirlupdate();
}

sub twirlupdate{
    $math=$fishcounter*-40;
    if($muted){
	$mute->coords('fish',$math,-80);
    }else{
	if($mutelight){
	    $mute->coords('fish',$math,-40);
	}else{
	    $mute->coords('fish',$math,0);
	}
    }
}
