From: Andrew Ruthven Date: Wed, 24 Sep 2008 04:46:55 +0000 (+1200) Subject: Add logo support to notifications. X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4343360ab75ba4c1df2594d913fb1470ab270120;p=picture-display.git Add logo support to notifications. --- diff --git a/lib/Display/Notifications.pm b/lib/Display/Notifications.pm index 967dac9..b4bb858 100644 --- a/lib/Display/Notifications.pm +++ b/lib/Display/Notifications.pm @@ -25,7 +25,7 @@ sub new { } sub add { - my ($self, $kernel, $notification) = @_[OBJECT, KERNEL, ARG0]; + my ($self, $kernel, $notification, $logo) = @_[OBJECT, KERNEL, ARG0, ARG1]; my $block = Clutter::Group->new(); $block->set_opacity(0); @@ -42,8 +42,20 @@ sub add { $bg->set_position(10, $self->{'stage'}->get_height() - 10); $notification->set_anchor_point(1, $notification->get_height()); - $notification->set_position(20, $self->{'stage'}->get_height() - 20); - $notification->set_width($bg->get_width() - 20); + + if (defined $logo) { + $block->add($logo); + $logo->set('keep-aspect-ratio' => 1); + $logo->set('sync-size' => 1); + $logo->set_height($notification->get_height()); + + $logo->set_position(20, $self->{'stage'}->get_height() - $bg->get_height - 20); + $notification->set_width($bg->get_width() - $logo->get_width() - 20 - 20); + $notification->set_position(20 + $logo->get_width() + 20, $self->{'stage'}->get_height() - 20); + } else { + $notification->set_position(20, $self->{'stage'}->get_height() - 20); + $notification->set_width($bg->get_width() - 20); + } my $expire = time() + $delay; diff --git a/lib/Display/Plugins/Asterisk.pm b/lib/Display/Plugins/Asterisk.pm index 04e920c..42733aa 100644 --- a/lib/Display/Plugins/Asterisk.pm +++ b/lib/Display/Plugins/Asterisk.pm @@ -7,6 +7,8 @@ use Carp; use POE qw( Component::Client::Asterisk::Manager ); use Data::Dumper; +use Clutter; +use FindBin qw/$Bin/; sub new { my $proto = shift; @@ -16,6 +18,8 @@ sub new { bless ($self, $class); + $self->{'logo'} = Clutter::Texture->new("$Bin/share/Asterisk.png"); + $self->{'kernel'}->state('asterisk_delayed_start', $self, 'delayed_start'); POE::Component::Client::Asterisk::Manager->new( @@ -104,7 +108,7 @@ sub dial { $text->set_color(Clutter::Color->parse('White')); $text->set_ellipsize('end'); - $kernel->post('display', 'notifications_add', $text); + $kernel->post('display', 'notifications_add', $text, $self->{'logo'}); } diff --git a/lib/Display/Plugins/MPD.pm b/lib/Display/Plugins/MPD.pm index 8d81fe9..93a2279 100644 --- a/lib/Display/Plugins/MPD.pm +++ b/lib/Display/Plugins/MPD.pm @@ -5,6 +5,7 @@ use Audio::MPD; use POSIX qw/strftime/; use POE::Session; use base ('Display::Plugin'); +use FindBin qw/$Bin/; use strict; my $delay = 5; @@ -40,7 +41,7 @@ sub display { $self->{'file'} = $current->file(); - $kernel->yield('notifications_add', $self->{'status'}); + $kernel->yield('notifications_add', $self->{'status'}, $self->{'logo'}); } $self->delay(); @@ -55,6 +56,8 @@ sub init { $self->{'status'}->set_color(Clutter::Color->parse('White')); $self->{'status'}->set_ellipsize('end'); + $self->{'logo'} = Clutter::Texture->new("$Bin/share/MPD.png"); + $self->{'kernel'}->yield('mpd_display'); } diff --git a/share/Asterisk.png b/share/Asterisk.png new file mode 100644 index 0000000..fb23d6c Binary files /dev/null and b/share/Asterisk.png differ diff --git a/share/MPD.png b/share/MPD.png new file mode 100644 index 0000000..7b50fce Binary files /dev/null and b/share/MPD.png differ