From: Andrew Ruthven Date: Wed, 17 Sep 2008 10:52:41 +0000 (+1200) Subject: Add more functionality and make it more robust. X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a63e303d6f41fa840fac0e60be79efb30b71cb1f;p=picture-display.git Add more functionality and make it more robust. --- diff --git a/lib/Display/Plugins/FSpot.pm b/lib/Display/Plugins/FSpot.pm index 4446846..941c5da 100644 --- a/lib/Display/Plugins/FSpot.pm +++ b/lib/Display/Plugins/FSpot.pm @@ -19,6 +19,20 @@ sub new { sub display { my $self = shift; + my $file; + + # Keep on looking until we find a file that exists. + do { + $file = $self->find_photo(); + } until (-f $file); + + $self->{'picture'}->set_from_file($file); + + return $file; +} + +sub find_photo { + my $self = shift; my $uri; $self->{'sth'}->bind_columns(\$uri); @@ -31,7 +45,6 @@ sub display { || die "Failed to finish statement: $DBI::errstr\n";; $uri =~ s|^file://||; - $self->{'picture'}->set_from_file($uri); return $uri; } @@ -57,8 +70,8 @@ LIMIT 1 $self->{'picture'} = Clutter::Texture->new(); $self->{'picture'}->set_size($self->{'stage'}->get_size()); - $self->{'picture'}->{'keep-aspect-ratio'} = 1; - $self->{'picture'}->{'sync-size'} = 1; + $self->{'picture'}->set('keep-aspect-ratio' => 1); + $self->{'picture'}->set('sync-size' => 1); $self->display(); $self->{'stage'}->add($self->{'picture'}); } diff --git a/picture.pl b/picture.pl index fc8a632..0a135c1 100755 --- a/picture.pl +++ b/picture.pl @@ -36,6 +36,7 @@ sub update_screen { for my $module (@modules) { $module->display(); } + Glib::Timeout->add_seconds(30, \&update_screen); } sub loadModules {