]> git.etc.gen.nz Git - picture-display.git/commitdiff
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 967dac943fcc585631fa606cffa9abcd8043affe..b4bb8589f168056adc95a8f99754f7025cb0e47a 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 04e920c7b51cbd4505f81e5cfdcf0abd067bf3ee..42733aa93c2860bc7269aa82583b91a475862e8e 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 8d81fe946c15ce0a69c5c00c8bcb635fbd7f2633..93a2279420f9cdbf39bf6d0ab7a8ddae269ec738 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