« Plagger/Plugin/Notify/Eject/mswin32.pm
↑ Summary
Plagger/Plugin/Notify/OpenBrowser/FirefoxRemote.pm »
| 1 | package Plagger::Plugin::Notify::Growl; | ||
| 2 | use strict; | ||
| 3 | use base qw( Plagger::Plugin ); | ||
| 4 | |||
| 5 | use Encode; | ||
| 6 | use Mac::Growl ':all'; | ||
| 7 | |||
| 8 | sub register { | ||
| 9 | my($self, $context) = @_; | ||
| 10 | |||
| 11 | $context->register_hook( | ||
| 12 | $self, | ||
| 13 | 'publish.init' => \&initialize, | ||
| 14 | 'publish.entry' => \&entry, | ||
| 15 | ); | ||
| 16 | } | ||
| 17 | |||
| 18 | sub initialize { | ||
| 19 | my ($self, $context) = @_; | ||
| 20 | my @updates; | ||
| 21 | for my $update ($context->update->feeds){ | ||
| 22 | push @updates, encode_utf8($update->title_text); | ||
| 23 | } | ||
| 24 | Mac::Growl::RegisterNotifications("plagger", [@updates],[@updates]); | ||
| 25 | } | ||
| 26 | |||
| 27 | sub entry { | ||
| 28 | my($self, $context, $args) = @_; | ||
| 29 | Mac::Growl::PostNotification( | ||
| 30 | "plagger", | ||
| 31 | encode_utf8($args->{feed}->title_text), | ||
| 32 | encode_utf8($args->{entry}->title_text), | ||
| 33 | encode_utf8($args->{entry}->body_text) | ||
| 34 | ); | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; | ||
| 38 | |||
| 39 |