| 1 | package Jaipo::UI; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | #~ use Smart::Comments; | ||
| 6 | use base qw/Class::Accessor::Fast/; | ||
| 7 | __PACKAGE__->mk_accessors (qw/core options trigger_name sp_id/); | ||
| 8 | |||
| 9 | =encoding utf8 | ||
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | Jaipo::UI - UI dispacher | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | |||
| 18 | use Jaipo::UI; | ||
| 19 | |||
| 20 | my $ui = Jaipo::UI->new("console"); | ||
| 21 | |||
| 22 | =head1 FUNCTIONS | ||
| 23 | |||
| 24 | =head2 new | ||
| 25 | |||
| 26 | Return a UI object. | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | sub new { | ||
| 31 | my $class = shift; | ||
| 32 | my $self = {}; | ||
| 33 | bless $self , $class; | ||
| 34 | $self->init; | ||
| 35 | return $self; | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | sub init { | ||
| 40 | my $class = shift; | ||
| 41 | $class->notifier( {} ); | ||
| 42 | if( $^O =~ m/linux/i ) { | ||
| 43 | $class->_init_linux; | ||
| 44 | } | ||
| 45 | elsif( $^O =~ m/darwin/i ) { | ||
| 46 | $class->_init_osx; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | sub _init_linux { | ||
| 51 | my $class = shift; | ||
| 52 | use Jaipo::Notify::LibNotify; | ||
| 53 | my $notify = Jaipo::Notify::LibNotify->new; | ||
| 54 | $class->notifier( $notify ); | ||
| 55 | print "Desktop::Notify Notifier Initialized\n"; | ||
| 56 | } | ||
| 57 | |||
| 58 | sub _init_osx { | ||
| 59 | use Mac::Growl; | ||
| 60 | Mac::Growl::RegisterNotifications( 'Jaipo', ['Updates' ] , [ 'Updates' ] ); | ||
| 61 | print "Mac::Growl Notifier Initialized\n"; | ||
| 62 | } | ||
| 63 | |||
| 64 | sub create { | ||
| 65 | my ( $class, $args ) = @_; | ||
| 66 | if ( $^O =~ m/linux/i ) { | ||
| 67 | $class->_create_linux($args); | ||
| 68 | } | ||
| 69 | elsif ( $^O =~ m/darwin/i ) { | ||
| 70 | $class->_create_osx($args); | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | sub _create_osx { | ||
| 75 | my ($class,$args) = @_; | ||
| 76 | Mac::Growl::PostNotification( 'Jaipo', 'Updates' , 'Jaipo', $args->{message} ); | ||
| 77 | } | ||
| 78 | |||
| 79 | sub _create_linux { | ||
| 80 | my ($class,$args) = @_; | ||
| 81 | $class->notifier->yell( $args->{message} ); | ||
| 82 | } | ||
| 83 | |||
| 84 | =head1 AUTHOR | ||
| 85 | |||
| 86 | BlueT - Matthew Lien - 練喆明, C<< <BlueT at BlueT.org> >> | ||
| 87 | |||
| 88 | =head1 BUGS | ||
| 89 | |||
| 90 | Please report any bugs or feature requests to C<bug-jaipo-ui at rt.cpan.org>, or through | ||
| 91 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Jaipo-UI>. I will be notified, and then you'll | ||
| 92 | automatically be notified of progress on your bug as I make changes. | ||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | =head1 SUPPORT | ||
| 98 | |||
| 99 | You can find documentation for this module with the perldoc command. | ||
| 100 | |||
| 101 | perldoc Jaipo::UI | ||
| 102 | |||
| 103 | |||
| 104 | You can also look for information at: | ||
| 105 | |||
| 106 | =over 4 | ||
| 107 | |||
| 108 | =item * RT: CPAN's request tracker | ||
| 109 | |||
| 110 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Jaipo-UI> | ||
| 111 | |||
| 112 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 113 | |||
| 114 | L<http://annocpan.org/dist/Jaipo-UI> | ||
| 115 | |||
| 116 | =item * CPAN Ratings | ||
| 117 | |||
| 118 | L<http://cpanratings.perl.org/d/Jaipo-UI> | ||
| 119 | |||
| 120 | =item * Search CPAN | ||
| 121 | |||
| 122 | L<http://search.cpan.org/dist/Jaipo-UI> | ||
| 123 | |||
| 124 | =back | ||
| 125 | |||
| 126 | |||
| 127 | =head1 ACKNOWLEDGEMENTS | ||
| 128 | |||
| 129 | |||
| 130 | =head1 COPYRIGHT & LICENSE | ||
| 131 | |||
| 132 | Copyright 2009 BlueT - Matthew Lien - 練喆明, all rights reserved. | ||
| 133 | |||
| 134 | This program is free software; you can redistribute it and/or modify it | ||
| 135 | under the same terms as Perl itself. | ||
| 136 | |||
| 137 | |||
| 138 | =cut | ||
| 139 | |||
| 140 | 1; # End of Jaipo::UI |