Finance-Quant
view release on metacpan or search on metacpan
scripts/FINANCE_QUANT_TRAY view on Meta::CPAN
$statusicon->signal_connect( 'activate', sub { print "1\n" } );
$statusicon->signal_connect( 'popup-menu', \&config_it );
my $vbox = Gtk2::VBox->new;
my $b = Gtk2::Button->new_from_stock( "gtk-close" );
$b->signal_connect('button_press_event' => sub { exit });
$vbox->pack_start( $b, TRUE, TRUE, 0 );
$window->add( $vbox );
$vbox->show_all;
#$window->show_all();
#$window1->show_all();
#$window2->show_all();
# messageTypes: info warning question error
my $id3 = Glib::Timeout->add (10000, sub {
my ($screen,$rect)=$statusicon->get_geometry;
my ($x,$y,$w, $h) = $rect->values;
# print "exposed $x $y $w $h\n";
my @message = ();
my $reports=`tree /tmp/Finance-Quant/ | egrep -c '*html'`;
my $bt=`tree /tmp/Finance-Quant/ | egrep -c '*data'`;
my $stb=`tree -f /tmp/Finance-Quant/ | egrep -c 'ibes-strong-buy'`;
my $symbols = `tree /tmp/Finance-Quant/ | egrep directories`;
my $charts=`tree -f /tmp/Finance-Quant/ | egrep -c 'charts'`;
# $symbols =~ s/^(.*)directories, (.*)files/$2/;
my $test = Gtk2::Ex::ZNotify->new(
type => 'popup',
# parent_widget => $window, # undefind, use x y location
"messageType" => "info",
"timeout" => 10000,
"message" => "".($symbols)."strong buy:".($stb-1)."\nbacktests:".$bt."reports:".$reports." charts:".$charts,
"x" => ($x + $w/2),
"y" => ($y + $h ),
);
$test->show_all();
return 1; # don't run again
});
Gtk2->main;
sub click {
return 1;
}
#right click menu
sub menu {
my $menu = Gtk2::Menu->new();
#VCI
my $menu_VCI = Gtk2::ImageMenuItem->new_with_label("CLI UI");
$menu_VCI->set_image(Gtk2::Image->new_from_stock('gtk-refresh',
'menu'));
$menu_VCI->signal_connect(activate => sub {
print system ('financequant &');
});
$menu->add($menu_VCI);
#configure
my $menu_pref = Gtk2::ImageMenuItem->new_with_label("XML DUMP");
$menu_pref->signal_connect(activate => sub {
my $response=0;
my $error =0;
print system ('FINANCE_QUANT_XML_RESULTS');
print $response;
});
$menu_pref->set_image(Gtk2::Image->new_from_stock('gtk-preferences','menu'));
$menu->add($menu_pref);
#configure
my $menu_http = Gtk2::ImageMenuItem->new_with_label("HTTP REPORTS");
$menu_http->signal_connect(activate => sub {
system("FINANCE_QUANT_HTTP_SERVER &");
});
$menu_http->set_image(Gtk2::Image->new_from_stock('gtk-media-play','menu'));
$menu->add($menu_http);
#separator
my $menu_sep = Gtk2::SeparatorMenuItem->new();
$menu->add($menu_sep);
#Quit
my $menu_quit = Gtk2::ImageMenuItem->new_with_label("Quit");
$menu_quit->signal_connect(activate => sub {Gtk2->main_quit});
$menu_quit->set_image(Gtk2::Image->new_from_stock('gtk-quit', 'menu'));
$menu->add($menu_quit);
return $menu;
}
#Program interfaces
sub interface {
my $interface = Gtk2::Menu->new;
#menu items for VCI
#Progress bar for number of downloads; just a countng bar
#Add the correct controls to menu
my $menu_vci_connect = Gtk2::ImageMenuItem->new_with_label("Connect");
$interface->add($menu_vci_connect);
my $menu_vci_stop = Gtk2::ImageMenuItem->new_with_label("Stop");
$interface->add($menu_vci_stop);
$interface->show_all;
}
sub config_it{
my $menu = menu();
$menu->show_all();
#to position the menu under the icon, instead of at mouse position
my ($x, $y, $push_in) = Gtk2::StatusIcon::position_menu($menu, $statusicon);
print "$x, $y, $push_in\n";
$menu->popup( undef, undef, sub{return ($x,$y,0)} , undef, 0, 0 );
return 1;
}
1;
__DATA__
=head1 NAME
FINANCE_QUANT_TRAY
=head1 DESCRIPTION
TRAY icon displaying calculation progress
=head1 SYNOPSIS
FINANCE_QUANT_TRAY
=head1 SEE ALSO
part of Finance::Quant
=head1 AUTHOR
Hagen Geissler, E<lt>santex@cpan.org<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2012 by Hagen Geissler
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.12.4 or,
at your option, any later version of Perl 5 you may have available.
=cut
( run in 0.862 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )