#!/usr/bin/perl -w
###

use strict;

use Gtk;
init Gtk;
init Gtk::Gdk::ImlibImage;

my($w,$h)	= (384,288);
my $basefile	= "p_%04d.jpg";

# create window.
my $win = new Gtk::Gdk::Window( {
	'window_type' => 'toplevel',
	'width' => $w,
	'height' => $h,
	'event_mask' => ['structure_mask']
});

my $p;
my $i=0;
my $im;
while () {
    $i++;
    my $file = sprintf($basefile,$i);
    if (my $pid = fork()) {
	while () { sleep 1; }
    } else {
    print "hrm...\n"	if $im;
    my $im	= load_image Gtk::Gdk::ImlibImage($file);

    $im->render($w, $h);
    $p->imlib_free()	if $p;
    $p = $im->move_image();
    $win->set_back_pixmap($p, 0);
    $win->clear;
    $win->show;
    $im->destroy_image;
    Gtk::Gdk->flush;
    }
    sleep 1;
}
