package Jaipo::Notify::LibNotify;

use warnings;
use strict;
#~ use Smart::Comments;
use Data::Dumper;
use base qw(Desktop::Notify);

=encoding utf8

=head1 NAME

Jaipo::Notify::LibNotify - A easy-to-use interface to show desktop notifications with libnotify.


Jaipo::Notify::LibNotify is a easy-to-use interface to show desktop notifications with libnotify.
It doesn't use libnotify directly, but talking to libnotify via dbus.

	use Jaipo::Notify::LibNotify;

	my $notify = Jaipo::Notify::LibNotify->new();
	# yell for Service Notify.
	$notify->yell('Cannot connect to M$-Mi$roBlo$: $!');

	# display for message displaying.
	$notify->display("From Mr.Right: Hello Darling. How are you today?");
	# pop_box for message displaying.
	$notify->pop_box("Are you using M$ windows without buying license?");
	# get current timeout setting
	print Data::Dumper $notify->timeout;

	# set yell timeout to 10 seconds. default is 5.
	$notify->timeout("yell" => 10);

	# set display timeout to 5 seconds.  default is 3.
	$notify->timeout("yell" => 5);


=head2 new

Return a object which talks to libnotify via dbus.


sub new {
	my $class = shift;
	#~ print Dumper $class;
	my $self = Desktop::Notify->new(@_); 
	bless $self, $class;
	$self->{timeout_yell} = 5000;
	$self->{timeout_display} = 3000;
	return $self;

=head2 yell

yell for Service Notify.
Pops a notification with title "Jaipo Service Notify" and the given message content from you.


sub yell {
	my ($self, $msg) = @_;
		"summary" => 'Jaipo Service Notify',
		"body" => $msg,
		"timeout" => $self->{timeout_yell},

=head2 display

display for message displaying.
Pops a notification with title "You've Got Message!" and the given message content from you.


sub display { 
        my ($self, $msg) = @_;
        #~ $self->SUPER::display("Name", @args);
		"summary" => "Jaipo: You've Got Message!",
		"body" => $msg,
		"timeout" => $self->{timeout_display},

=head2 pop_box

pop_box for special message displaying.
Pops a window box with title "Pop!" and the given message content from you.


sub pop_box { 
        my ($self, $msg) = @_;
        #~ $self->SUPER::display("Name", @args);
		"summary" => "Jaipo: Pop!",
		"body" => $msg,
		#~ "timeout" => $self->{timeout_display},

=head2 timeout

timeout for changing/getting the current timeout value.


sub timeout {
	my $self = shift;
	my %timeout = (
		"timeout_yell" => $self->{timeout_yell} / 1000,
		"timeout_display" => $self->{timeout_display} / 1000,
	if (not @_) {
		# do nothing
	}elsif ( $_[0] eq "yell" ) {
		$self->{timeout_yell} = $_[1] * 1000;
	} elsif ( $_[0] eq "display" ) {
		$self->{timeout_display} = $_[1] * 1000;
	return \%timeout;

=head1 AUTHOR

BlueT - Matthew Lien - 練喆明, C<< <BlueT at> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-jaipo-notify-libnotify at>, or through
the web interface at L<>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Jaipo::Notify::LibNotify

You can also look for information at:

=over 4

=item * RT: CPAN's request tracker


=item * AnnoCPAN: Annotated CPAN documentation


=item * CPAN Ratings


=item * Search CPAN





Copyright 2009 BlueT - Matthew Lien - 練喆明, all rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.


1; # End of Jaipo::Notify::LibNotify