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, $logo) = @_[OBJECT, KERNEL, ARG0, ARG1];
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());
48 $logo->set('keep-aspect-ratio' => 1);
49 $logo->set('sync-size' => 1);
50 $logo->set_height($notification->get_height());
52 $logo->set_position(20, $self->{'stage'}->get_height() - $bg->get_height - 20);
53 $notification->set_width($bg->get_width() - $logo->get_width() - 20 - 20);
54 $notification->set_position(20 + $logo->get_width() + 20, $self->{'stage'}->get_height() - 20);
56 $notification->set_position(20, $self->{'stage'}->get_height() - 20);
57 $notification->set_width($bg->get_width() - 20);
60 my $expire = time() + $delay;
62 $self->{'blocks'}->insert( {
67 $self->{'stage'}->add($block);
68 my $effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc');
69 my $timeline = Clutter::Effect->fade($effect, $block, 255);
71 $kernel->delay_add('notifications_expire', $delay);
77 my ($self) = @_[OBJECT];
79 for my $block ($self->{'blocks'}->members()) {
80 if ($block->{'expire'} <= time()) {
81 my $old_effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc' );
82 my $old = Clutter::Effect->fade($old_effect, $block->{'block'}, 0, $self->can('post_fade_out'), $self);
89 my ($old_timeline, $self) = @_;
91 for my $block ($self->{'blocks'}->members()) {
92 if ($block->{'expire'} <= time()) {
93 $self->{'stage'}->remove($block->{'block'});
94 $self->{'blocks'}->remove($block);
96 $block->{'block'}->remove_all()
104 $self->{'kernel'}->state('notifications_add', $self, 'add');
105 $self->{'kernel'}->state('notifications_expire', $self, 'expire');