App-Chart
view release on metacpan or search on metacpan
lib/App/Chart/Gtk2/IntradayDialog.pm view on Meta::CPAN
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with Chart. If not, see <http://www.gnu.org/licenses/>.
package App::Chart::Gtk2::IntradayDialog;
use 5.010;
use strict;
use warnings;
use Gtk2 1.220;
use List::Util 'min';
use Regexp::Common 'whitespace';
use POSIX ();
use Glib::Ex::ConnectProperties;
use Gtk2::Ex::CrossHair;
use Locale::TextDomain ('App-Chart');
use Gtk2::Ex::EntryBits;
use Gtk2::Ex::Units;
use App::Chart::Glib::Ex::MoreUtils;
use App::Chart;
use App::Chart::Gtk2::GUI;
use App::Chart::IntradayHandler;
use App::Chart::Gtk2::IntradayImage;
use App::Chart::Gtk2::IntradayModeComboBox;
use App::Chart::Gtk2::Job;
use App::Chart::Gtk2::Job::Intraday;
# uncomment this to run the ### lines
#use Smart::Comments;
use Glib::Object::Subclass
'Gtk2::Dialog',
properties => [Glib::ParamSpec->string
('symbol',
__('Symbol'),
'The symbol of the stock or commodity to be shown',
'', # default
Glib::G_PARAM_READWRITE),
Glib::ParamSpec->string
('mode',
'mode',
'The graph mode, such as 1 day or 5 days',
'', # default
Glib::G_PARAM_READWRITE)];
use constant { RESPONSE_REFRESH => 0,
RESPONSE_CROSS => 1,
RESPONSE_SAVE => 2,
RESPONSE_PRINT => 3 };
sub INIT_INSTANCE {
my ($self) = @_;
$self->{'symbol'} = ''; # defaults
$self->{'mode'} = '';
my $combobox = $self->{'combobox'}
= App::Chart::Gtk2::IntradayModeComboBox->new;
$combobox->show;
$self->add_accel_group ($combobox->accelgroup);
$self->action_area->add ($combobox);
Glib::Ex::ConnectProperties->new ([$self,'symbol'],
[$combobox,'symbol']);
Glib::Ex::ConnectProperties->new ([$combobox,'mode'],
[$self,'mode']);
my $crossbutton = $self->{'crossbutton'}
= Gtk2::CheckButton->new (__('Cr_oss'));
$crossbutton->set_active (0);
$self->add_action_widget ($crossbutton, RESPONSE_CROSS);
$self->set_title (__('Chart: Intraday'));
$self->{'refresh_button'}
= $self->add_button ('gtk-refresh' => RESPONSE_REFRESH);
$self->add_buttons ('gtk-print' => RESPONSE_PRINT,
'gtk-save' => RESPONSE_SAVE,
'gtk-close' => 'close',
'gtk-help' => 'help');
# this is an "after" to allow a user's signals to be called first on
# 'close' or 'delete-event', since we're going to $self->destroy on those
$self->signal_connect_after (response => \&_do_response);
my $vbox = $self->vbox;
# display symbol and mode in a label, since can't be certain the window
# manager will have a good title bar
my $title_label = $self->{'title_label'} = Gtk2::Label->new ('');
_update_title_label ($self);
$vbox->pack_start ($title_label, 0,0,0);
# centre in area, don't grow image beyond desired size
my $align = Gtk2::Alignment->new (0.5, 0.5, 0, 0);
$vbox->pack_start ($align, 1,1,0);
my $image = $self->{'image'} = App::Chart::Gtk2::IntradayImage->new;
$align->add ($image);
Glib::Ex::ConnectProperties->new ([$self,'symbol'],
[$image,'symbol']);
Glib::Ex::ConnectProperties->new ([$self,'mode'],
[$image,'mode']);
my $crosshair = $self->{'crosshair'}
= Gtk2::Ex::CrossHair->new (widget => $image,
foreground => 'orange');
Glib::Ex::ConnectProperties->new ([$crossbutton,'active'],
[$crosshair,'active']);
$image->add_events ('button-press-mask');
$image->signal_connect (button_press_event =>\&_do_image_button_press_event);
my $progress_label = $self->{'progress_label'} = Gtk2::Label->new ('');
$vbox->pack_start ($progress_label, 0,0,0);
my $hbox = Gtk2::HBox->new();
$vbox->pack_start ($hbox, 0,0,0);
$hbox->pack_start (Gtk2::Label->new (__('Symbol')), 0,0,0);
my $entry = Gtk2::Entry->new ();
$self->{'entry'} = $entry;
$hbox->pack_start ($entry, 1, 1, 0.5 * Gtk2::Ex::Units::em($entry));
$entry->signal_connect (activate => \&_do_entry_activate);
my $button = Gtk2::Button->new_with_label (__('Enter'));
$hbox->pack_start ($button, 0,0,0);
( run in 1.084 second using v1.01-cache-2.11-cpan-2398b32b56e )