App-TimeTracker-Gtk2TrayIcon
view release on metacpan or search on metacpan
Changes
INSTALL
LICENSE
MANIFEST
META.json
META.yml
README
bin/tracker_gtk_trayicon.pl
dist.ini
lib/App/TimeTracker/Gtk2TrayIcon.pm
share/busy.png
share/lazy.png
t/00-load.t
t/it_lives.t
lib/App/TimeTracker/Gtk2TrayIcon.pm view on Meta::CPAN
use File::ShareDir qw(dist_file);
sub init {
my ($class, $run) = @_;
my $storage_location = App::TimeTracker::Proto->new->home;
my $lazy =
-e 'share/lazy.png'
? 'share/lazy.png'
: dist_file( 'App-TimeTracker-Gtk2TrayIcon', 'lazy.png' );
my $busy =
-e 'share/busy.png'
? 'share/busy.png'
: dist_file( 'App-TimeTracker-Gtk2TrayIcon', 'busy.png' );
Gtk2->init;
my $img = Gtk2::Image->new_from_file($lazy);
my $window = Gtk2::TrayIcon->new(__PACKAGE__);
my $eventbox = Gtk2::EventBox->new;
$eventbox->add($img);
my $current;
my $t = AnyEvent->timer(
after => 0,
interval => 5,
cb => sub {
my $task =
App::TimeTracker::Data::Task->current($storage_location);
if ($task) {
$img->set_from_file($busy);
$current = $task->say_project_tags;
}
else {
$img->set_from_file($lazy);
$current = 'nothing';
}
} );
$eventbox->signal_connect(
'enter-notify-event' => sub {
unless ( $current eq 'nothing' ) {
( run in 0.432 second using v1.01-cache-2.11-cpan-87723dcf8b7 )