use Clutter;
use Set::Object;
-my $delay = 15;
+my $delay = 5;
sub new {
- my $proto = shift;
+ my ($proto, $kernel, $session, $stage) = @_;
my $class = ref($proto) || $proto;
- my $self = {};
+ my $self = {
+ 'kernel' => $kernel,
+ 'session' => $session,
+ 'stage' => $stage,
+ };
$self->{'blocks'} = Set::Object->new();
bless ($self, $class);
+ $self->init();
return $self;
}
my ($self, $notification) = @_;
my $block = Clutter::Group->new();
+ $block->set_opacity(0);
my $bg = Clutter::Rectangle->new(Clutter::Color->parse('Black'));
- $bg->set_width($self->{'stage'}->get_width() - 40);
+ $bg->set_width($self->{'stage'}->get_width() - 20);
$bg->set_opacity(100);
$block->add($bg);
$notification->set_anchor_point(1, $notification->get_height());
$notification->set_position(20, $self->{'stage'}->get_height() - 20);
+ $notification->set_width($bg->get_width() - 20);
my $expire = time() + $delay;
- $self->{'blocks'}->add( {
+ $self->{'blocks'}->insert( {
'expire' => $expire,
'block' => $block
});
$self->{'stage'}->add($block);
my $effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc');
my $timeline = Clutter::Effect->fade($effect, $block, 255);
- $timeline->start();
- $self->{'stage'}->delay_add(notification_expire, $expire, $self);
+ $self->{'kernel'}->delay_add('notifications_expire', $delay);
+
+ $timeline->start();
}
sub expire {
- my $self = shift;
+ my ($self) = @_[OBJECT];
for my $block ($self->{'blocks'}->members()) {
if ($block->expire <= time()) {
}
}
+sub init {
+ my $self = shift;
+
+ $self->{'kernel'}->state('notifications_expire', $self, 'expire');
+}
+
1;
use Clutter;
sub new {
- my ($class,$kernel,$session,$stage) = @_;
+ my ($class,$kernel,$session,$stage,$notifications) = @_;
my $self = {
'kernel' => $kernel,
'session' => $session,
'stage' => $stage,
+ 'notifications' => $notifications,
};
bless ($self, $class);
use POSIX qw/strftime/;
use base ('Display::Plugin');
-my $delay = 15;
-
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
$self->{'file'} = $current->file();
- $self->{'bg'}->set_height($self->{'status'}->get_height() + 10);
- $self->{'bg'}->set_anchor_point(1, $self->{'bg'}->get_height());
- $self->{'bg'}->set_position(10, $self->{'stage'}->get_height() - 10);
-
- $self->{'status'}->set_anchor_point(1, $self->{'status'}->get_height());
- $self->{'status'}->set_position(20, $self->{'stage'}->get_height() - 20);
-
- if (! $self->{'active'}) {
- $self->{'block'}->set_opacity(0);
- $self->{'stage'}->add($self->{'block'});
- my $effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc');
- my $timeline = Clutter::Effect->fade($effect, $self->{'block'}, 255);
- $timeline->start();
-
- $self->{'active'} = time() + $delay;
- }
-
- Glib::Timeout->add_seconds($delay, $self->can('hide_display'), $self);
+ $self->{'notifications'}->add($self->{'status'});
}
return 1;
}
-sub hide_display {
- my $self = shift;
-
- if ($self->{'active'} <= time()) {
- $self->{'stage'}->remove($self->{'block'});
-
- $self->{'active'} = 0;
- }
-
- return 0;
-}
-
sub init {
my $self = shift;
- $self->{'block'} = Clutter::Group->new();
-
- $self->{'bg'} = Clutter::Rectangle->new(Clutter::Color->parse('Black'));
- $self->{'bg'}->set_width($self->{'stage'}->get_width() - 20);
- $self->{'bg'}->set_opacity(100);
-
$self->{'status'} = Clutter::Label->new('Sans 20', "Song\nAlbum");
$self->{'status'}->set_color(Clutter::Color->parse('White'));
$self->{'status'}->set_ellipsize('end');
- $self->{'status'}->set_width($self->{'bg'}->get_width() - 20);
-
- $self->{'block'}->add($self->{'bg'});
- $self->{'block'}->add($self->{'status'});
Glib::Timeout->add_seconds(5, $self->can('display'), $self);
}
use lib "$FindBin::Bin/lib";
+use Display::Notifications;
+
my $full_screen = 1;
GetOptions(
$stage->set_size(800, 600);
}
- my @modules = loadModules($kernel, $session, $stage);
+ my $notifications = Display::Notifications->new($kernel, $session, $stage);
+
+ my @modules = loadModules($kernel, $session, $stage, $notifications);
$stage->show_all();
}
sub loadModules {
- my ($kernel, $session, $stage) = @_;
+ my ($kernel, $session, $stage, $notifications) = @_;
my @modules;
for my $module (plugins()) {
if ($@) {
warn "Failed to load plugin: $module ($@)\n";
} else {
- push @modules, $module->new($kernel, $session, $stage);
+ push @modules, $module->new($kernel, $session, $stage, $notifications);
}
}