Add logo support to notifications.
authorAndrew Ruthven <puck@catalyst.net.nz>
Wed, 24 Sep 2008 04:46:55 +0000 (16:46 +1200)
committerAndrew Ruthven <puck@dirk.wgtn.cat-it.co.nz>
Wed, 24 Sep 2008 04:46:55 +0000 (16:46 +1200)
lib/Display/Notifications.pm
lib/Display/Plugins/Asterisk.pm
lib/Display/Plugins/MPD.pm
share/Asterisk.png [new file with mode: 0644]
share/MPD.png [new file with mode: 0644]

index 967dac9..b4bb858 100644 (file)
@@ -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;
 
index 04e920c..42733aa 100644 (file)
@@ -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'});
 }
 
 
index 8d81fe9..93a2279 100644 (file)
@@ -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 (file)
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 (file)
index 0000000..7b50fce
Binary files /dev/null and b/share/MPD.png differ