my ($class,$stage) = @_;
my $self = {
- 'stage' => $stage
+ 'stage' => $stage,
+ 'last_file' => '',
};
bless ($self, $class);
# Keep on looking until we find a file that exists.
do {
$file = $self->find_photo();
- } until (-f $file);
+ } until (-f $file && $file ne $self->{'last_file'});
- $self->{'picture'}->set_from_file($file);
+ $self->{'new'}->set_from_file($file);
+
+ if ($self->{'last_file'} eq '') {
+ fade_in($self->{'new'});
+# } else {
+#warn "Fade out old\n";
+# my $old_effect = Clutter::EffectTemplate->new_for_duration(1000, 'smoothstep_dec' );
+# my $old = Clutter::Effect->fade($old_effect, $self->{'old'}, 0, $self->can('fade_in'), $self->{'new'});
+# $old->start();
+ }
+
+# my $temp = $self->{'old'};
+# $self->{'old'} = $self->{'new'};
+# $self->{'new'} = $temp;
+ $self->{'last_file'} = $file;
+}
+
+sub fade_in {
+ my $new_pic = shift;
- return $file;
+ my $new_effect = Clutter::EffectTemplate->new_for_duration(1000, 'smoothstep_inc');
+ my $new = Clutter::Effect->fade($new_effect, $new_pic, 255);
+ $new->start();
}
sub find_photo {
$self->{'sth'} = $self->{'dbh'}->prepare($sql)
|| die "Failed to prepare statement: $DBI::errstr\n";
- $self->{'picture'} = Clutter::Texture->new();
- $self->{'picture'}->set_size($self->{'stage'}->get_size());
- $self->{'picture'}->set('keep-aspect-ratio' => 1);
- $self->{'picture'}->set('sync-size' => 1);
+ for my $age ('new', 'old') {
+ $self->{$age} = Clutter::Texture->new();
+ $self->{$age}->set_size($self->{'stage'}->get_size());
+ $self->{$age}->set('keep-aspect-ratio' => 1);
+ $self->{$age}->set('sync-size' => 1);
+ $self->{$age}->set_opacity(0);
+ }
+
$self->display();
- $self->{'stage'}->add($self->{'picture'});
+
+ for my $age ('new', 'old') {
+ $self->{'stage'}->add($self->{$age});
+ }
Glib::Timeout->add_seconds(30, $self->can('display'), $self);
}