| SystemTray-Applet documentation | Contained in the SystemTray-Applet distribution. |
SystemTray::Applet - OS agnostic system tray applets
Version 0.02
This code wraps existing gui toolkits and lets you create a system tray applet that doesn't require knowledge of the users toolkit.
use SystemTray::Applet;
my $foo = SystemTray::Applet->new("text" => "hello world");
$applet = SystemTray::Applet->new( "text" => "hello world" );
This method looks for the highest priority plugin under the SystemTray::Applet namespace and passes the plugin name and any arguments passed in to create. This allows developers to use SystemTray::Applet to construct one of its system specific subclasses without knowing which ones may be installed.
If no plugins are found or object construction fails undef is returned.
$applet = System::Tray::Applet::CmdLine->create( "text" => "hello world" );
This method is the SystemTray applet constructor. It should not be called directly. It should be called via SystemTray::Applet->new or as a subclasses constructor e.g. SystemTray::Applet::Create->create();
The following arguments can be passed as name value pairs
Note : The callback does not need to call $self->display() or $self->schedule() as the module takes care of that.
If the object can not be constucted undef is returned.
$self->init();
Subclass specific init method for object initialization.
This should not be call directly as it is only used by system specific subclasses.
This should return true in subclasses.
$self->icon("foo.ico");
This method sets the objects icon by calling the system specific create icon method in the subclass
$self->create_icon();
Subclass specific create_icon method for creating an icon class used by the system specific gui code.
This should not be called directly as it is only provided by the system specific subclass.
$self->display();
Subclass specific display method for updating the GUI representation of the applet.
This should not be called directly as it is only provided by the system specific subclass.
$self->schedule();
Subclass specific schedule method for scheduling the callback.
This should not be called directly as it is only provided by the system specific subclass.
$self->start();
Subclass specific method for starting the gui up. This never returns.
Peter Sinnott, <psinnott at cpan.org>
Please report any bugs or feature requests to bug-systemtray-applet at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SystemTray-Applet. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc SystemTray::Applet
You can also look for information at:
Copyright 2008 Peter Sinnott, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| SystemTray-Applet documentation | Contained in the SystemTray-Applet distribution. |
package SystemTray::Applet; use warnings; use strict; use Module::Pluggable::Ordered search_path => [ "SystemTray::Applet" ];
our $VERSION = '0.02';
sub new { my ( $class , %args ) = @_; my $fake = bless( {} , $class ); my @plugins = $fake->plugins_ordered(); if( @plugins ) { return create( $plugins[0] , %args ); } else { warn( "No plugins available" ); return undef; } }
sub create { my ( $class , %args ) = @_; my $self = {}; bless( $self , $class ); if( defined( $args{"icon"} ) ) { my $icon = $self->create_icon($args{"icon"}); if( $icon ) { $self->{"icon"} = $icon; } } if( defined( $args{"text"} ) ) { $self->{"text"} = $args{"text"}; } if( defined( $args{"frequency"} ) ) { if( int($args{"frequency"}) != 0 ) { $self->{"frequency"} = $args{"frequency"}; } else { $self->{"frequency"} = -1; } } else { $self->{"frequency"} = -1; } if( defined( $args{"callback"} ) ) { $self->{"callback"} = sub { my ( $self ) = @_; $args{"callback"}->($self);$self->display();$self->schedule()}; } else { $self->{"frequency"} = -1; } if( defined($args{"immediate"}) && $args{"immediate"} ) { unless( defined($self->{"callback"} ) ) { warn( "No callback available to call" ); return undef; } } unless( defined( $self->init() ) ) { return undef; } if( defined($args{"immediate"}) && $args{"immediate"} ) { $args{"callback"}->($self); } $self->display(); $self->schedule(); $self->start(); }
sub init { my ( $self ) = @_; die( "You can not use " . ref($self) . " directly , you must use a subclass" ); }
sub icon { my ( $self , $icon ) = @_; $self->{"icon"} = $self->create_icon($icon); }
sub create_icon { my ( $self ) = @_; die( "You can not use " . ref($self) . " directly , you must use a subclass" ); }
sub display { my ( $self ) = @_; die( "You can not use " . ref($self) . " directly , you must use a subclass" ); }
sub schedule { my ( $self ) = @_; die( "You can not use " . ref($self) . " directly , you must use a subclass" ); }
sub start { my ( $self ) = @_; die( "You can not use " . ref($self) . " directly , you must use a subclass" ); }
1; # End of SystemTray::Applet