]> git.etc.gen.nz Git - picture-display.git/blobdiff - lib/Display/Plugins/FSpot.pm
Convert to using POE for the event management.
[picture-display.git] / lib / Display / Plugins / FSpot.pm
index 50357e87a353f71e5d4878732c44e0c0207a9ac9..766a9d6d1b7409055a28534e3af10fdd1644dd60 100644 (file)
@@ -1,17 +1,17 @@
 package Display::Plugins::FSpot;
 
-use DBI;
 use Clutter;
+use base ('Display::Plugin');
 
 my $f_spot_db = "/home/andrew/.gnome2/f-spot/photos.db";
 
 sub new {
-  my ($class,$stage) = @_;
+  my $proto = shift;
+  my $class = ref($proto) || $proto;
 
-  my $self = {
-    'stage' => $stage,
-    'last_file' => '',
-  };
+  my $self = $class->SUPER::new(@_);
+
+  $self->{'last_file'} = '';
 
   bless ($self, $class);
   $self->init();
@@ -33,7 +33,7 @@ sub display {
     fade_in($self->{'new'});
 #  } else {
 #warn "Fade out old\n";
-#    my $old_effect = Clutter::EffectTemplate->new_for_duration(1000, 'smoothstep_dec' );
+#    my $old_effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_dec' );
 #    my $old = Clutter::Effect->fade($old_effect, $self->{'old'}, 0, $self->can('fade_in'), $self->{'new'});
 #    $old->start();
   }
@@ -43,13 +43,14 @@ sub display {
 #  $self->{'new'} = $temp;
   $self->{'last_file'} = $file;
 
+  $self->{'kernel'}->delay_set(fspot_display => 30);
   return 1;
 }
 
 sub fade_in {
   my $new_pic = shift;
 
-  my $new_effect = Clutter::EffectTemplate->new_for_duration(1000, 'smoothstep_inc');
+  my $new_effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc');
   my $new = Clutter::Effect->fade($new_effect, $new_pic, 255);
   $new->start();
 }
@@ -75,6 +76,8 @@ sub find_photo {
 sub init {
   my $self = shift;
 
+  $self->{'kernel'}->state('fspot_display', $self, 'display');
+
   $self->{'dbh'} = DBI->connect("dbi:SQLite:dbname=$f_spot_db","","")
     || die "Failed to connect to $f_spot_db: $DBI::errstr\n";
 
@@ -105,7 +108,7 @@ LIMIT 1
     $self->{'stage'}->add($self->{$age});
   }
 
-  Glib::Timeout->add_seconds(30, $self->can('display'), $self);
+  $self->{'kernel'}->delay_set(fspot_display => 30);
 }
 
 1;