package Display::Notifications;
use Clutter;
+use POE::Session;
use Set::Object;
+use strict;
my $delay = 5;
}
sub add {
- my ($self, $notification) = @_;
+ my ($self, $kernel, $notification) = @_[OBJECT, KERNEL, ARG0];
my $block = Clutter::Group->new();
$block->set_opacity(0);
my $effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc');
my $timeline = Clutter::Effect->fade($effect, $block, 255);
- $self->{'kernel'}->delay_add('notifications_expire', $delay);
+ $kernel->delay_add(notifications_expire, $delay);
$timeline->start();
}
my ($self) = @_[OBJECT];
for my $block ($self->{'blocks'}->members()) {
- if ($block->expire <= time()) {
+ if ($block->{'expire'} <= time()) {
$self->{'stage'}->remove($block->{'block'});
$self->{'blocks'}->remove($block);
}
sub init {
my $self = shift;
+ $self->{'kernel'}->state('notifications_add', $self, 'add');
$self->{'kernel'}->state('notifications_expire', $self, 'expire');
}
use Clutter;
use Audio::MPD;
use POSIX qw/strftime/;
+use POE::Session;
use base ('Display::Plugin');
+use strict;
sub new {
my $proto = shift;
}
sub display {
- my $self = shift;
+ my ($self, $kernel) = @_[OBJECT, KERNEL];
my $current = $self->{'mpd'}->current();
$self->{'file'} = $current->file();
- $self->{'notifications'}->add($self->{'status'});
+ $kernel->yield('notifications_add', $self->{'status'});
}
- return 1;
+ $kernel->delay('mpd_display', 5);
}
sub init {
my $self = shift;
+ $self->{'kernel'}->state('mpd_display', $self, 'display');
+
$self->{'status'} = Clutter::Label->new('Sans 20', "Song\nAlbum");
$self->{'status'}->set_color(Clutter::Color->parse('White'));
$self->{'status'}->set_ellipsize('end');
- Glib::Timeout->add_seconds(5, $self->can('display'), $self);
+ $self->{'kernel'}->delay('mpd_display', 5);
}
1;