1 package Display::Notifications;
11 my ($proto, $kernel, $session, $stage) = @_;
12 my $class = ref($proto) || $proto;
16 'session' => $session,
20 $self->{'blocks'} = Set::Object->new();
22 bless ($self, $class);
28 my ($self, $kernel, $notification) = @_[OBJECT, KERNEL, ARG0];
30 my $block = Clutter::Group->new();
31 $block->set_opacity(0);
33 my $bg = Clutter::Rectangle->new(Clutter::Color->parse('Black'));
34 $bg->set_width($self->{'stage'}->get_width() - 20);
35 $bg->set_opacity(100);
38 $block->add($notification);
40 $bg->set_height($notification->get_height() + 10);
41 $bg->set_anchor_point(1, $bg->get_height());
42 $bg->set_position(10, $self->{'stage'}->get_height() - 10);
44 $notification->set_anchor_point(1, $notification->get_height());
45 $notification->set_position(20, $self->{'stage'}->get_height() - 20);
46 $notification->set_width($bg->get_width() - 20);
48 my $expire = time() + $delay;
50 $self->{'blocks'}->insert( {
55 $self->{'stage'}->add($block);
56 my $effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc');
57 my $timeline = Clutter::Effect->fade($effect, $block, 255);
59 $kernel->delay_add('notifications_expire', $delay);
65 my ($self) = @_[OBJECT];
67 for my $block ($self->{'blocks'}->members()) {
68 if ($block->{'expire'} <= time()) {
69 my $old_effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc' );
70 my $old = Clutter::Effect->fade($old_effect, $block->{'block'}, 0, $self->can('post_fade_out'), $self);
77 my ($old_timeline, $self) = @_;
79 for my $block ($self->{'blocks'}->members()) {
80 if ($block->{'expire'} <= time()) {
81 $self->{'stage'}->remove($block->{'block'});
82 $self->{'blocks'}->remove($block);
84 $block->{'block'}->remove_all()
92 $self->{'kernel'}->state('notifications_add', $self, 'add');
93 $self->{'kernel'}->state('notifications_expire', $self, 'expire');