Switch to use correct method for checking if we're connected. poe-component-client-mpd
authorAndrew Ruthven <puck@catalyst.net.nz>
Mon, 22 Sep 2008 23:11:57 +0000 (11:11 +1200)
committerAndrew Ruthven <puck@dirk.wgtn.cat-it.co.nz>
Mon, 22 Sep 2008 23:11:57 +0000 (11:11 +1200)
lib/Display/Plugins/MPD.pm
picture.pl

index be47da1..6015a54 100644 (file)
@@ -79,12 +79,13 @@ sub error {
 sub init {
   my $self = shift;
 
+  $self->{'kernel'}->state('mpd_connected', $self, 'connected');
   $self->{'kernel'}->state('mpd_result', $self, 'display');
   $self->{'kernel'}->state('mpd_error', $self, 'error');
   $self->{'kernel'}->state('mpd_hide_display', $self, 'hide_display');
   POE::Component::Client::MPD->new( {
     alias => 'mpd',
-    status_msgs_to => 'mpd_status_msgs',
+    status_msgs_to => 'display',
   } );
 
   $self->{'status'} = Clutter::Label->new('Sans 20', "Song\nAlbum");
@@ -95,14 +96,10 @@ sub init {
   $self->{'bg'}->set_opacity(100);
 }
 
-sub mpd_status_msgs {
-  my ($kernel, $arg) = @_[KERNEL, ARG0];
+sub connected {
+  my ($self, $kernel) = @_[OBJECT, KERNEL];
 
-  if ($arg eq 'mpd_connected') {
-    $self->{'kernel'}->post( 'mpd', 'current' );
-  } else {
-    warn "Failed to connected to MPD.  What now?\n";
-  }
+  $kernel->post( 'mpd', 'current' );
 }
 
 1;
index a51ba80..abd397a 100755 (executable)
@@ -33,6 +33,8 @@ sub start {
   $stage->set_color(Clutter::Color->parse('Black'));
   $stage->signal_connect('key-press-event' => sub { Clutter->main_quit() });
 
+  $kernel->alias_set('display');
+
   if ($full_screen) {
     $stage->fullscreen;
   } else {