view release on metacpan or search on metacpan
lib/App/Chart/DBI.pm view on Meta::CPAN
my $notes_filename = notes_filename();
### $notes_filename
if (! -e $notes_filename) {
require App::Chart::Database::Create;
App::Chart::Database::Create::initial_notes ($notes_filename);
}
require DBI;
my $dbh = DBI->connect ("dbi:SQLite:dbname=$database_filename",
'', '', {RaiseError=>1});
$dbh->func(90_000, 'busy_timeout'); # 90 seconds
$dbh->{'sqlite_unicode'} = 1;
$dbh->do ('ATTACH DATABASE ' . $dbh->quote($notes_filename)
. ' AS notesdb');
my ($dbversion) = do {
local $dbh->{RaiseError} = undef;
local $dbh->{PrintError} = undef;
$dbh->selectrow_array
("SELECT value FROM extra WHERE key='database-schema-version'")
};
lib/App/Chart/Gtk2/DeleteDialog.pm view on Meta::CPAN
# 'response' signal handler
sub _do_response {
my ($self, $response) = @_;
if ($response eq 'ok') {
my $symbol = $self->get('symbol');
if (defined $symbol) {
# deleting is normally quite fast, but can be noticeable if the system
# is a bit loaded or there's a lot of daily data
require Gtk2::Ex::WidgetCursor;
Gtk2::Ex::WidgetCursor->busy;
my $notes_too = $self->{'notes_check'}->get_active;
App::Chart::Database->delete_symbol ($symbol, $notes_too);
}
}
$self->destroy;
}
# return true if $symbol has any notes in the database
sub symbol_any_notes {
lib/App/Chart/Gtk2/Diagnostics.pm view on Meta::CPAN
# 'delete-event', which in turn defaults to a destroy
$self->signal_emit ('close');
}
}
sub refresh {
my ($self) = @_;
### refresh: "$self"
my $textview = $self->{'textview'};
# can be a bit slow counting the database the first time, so show busy
require Gtk2::Ex::WidgetCursor;
Gtk2::Ex::WidgetCursor->busy;
require Gtk2::Ex::TextBufferBits;
Gtk2::Ex::TextBufferBits::replace_lines
($textview->get_buffer, $self->str());
}
sub str {
my ($class_or_self) = @_;
my $self = ref $class_or_self ? $class_or_self : undef;
lib/App/Chart/Gtk2/Ex/ToplevelBits.pm view on Meta::CPAN
if (exists $options{'modal'}) {
$dialog->set_modal ($options{'modal'});
}
if (exists $options{'transient_for'}) {
$dialog->set_transient_for ($options{'transient_for'});
}
} else {
### new dialog $class
if (eval { require Gtk2::Ex::WidgetCursor }) {
Gtk2::Ex::WidgetCursor->busy;
}
require Module::Load;
Module::Load::load ($class);
$dialog = $class->Glib::Object::new
((defined $screen ? (screen => $screen) : ()),
(exists $options{'modal'} ? (modal => $options{'modal'}) : ()),
(exists $options{'transient_for'} ? (transient_for => $options{'transient_for'}) : ()),
%$properties);
if ($options{'hide_on_delete'}) {
lib/App/Chart/Gtk2/JobsRunningDialog.pm view on Meta::CPAN
&& ($job->isa('App::Chart::Gtk2::Job::Download')
# not a subclass at the moment ...
|| $job->get('name') eq __('Vacuum database')));
}
# 'response' signal handler
sub _do_response {
my ($self, $response) = @_;
if ($response eq 'ok') {
Gtk2::Ex::WidgetCursor->busy;
if (my $parent = $self->get_transient_for) {
$parent->destroy;
} else {
warn 'JobsRunningDialog: no parent to destroy';
}
$self->destroy;
} elsif ($response eq 'close') {
# as per a keyboard close, defaults to raising 'delete-event', which
# in turn defaults to a destroy
lib/App/Chart/Gtk2/Main.pm view on Meta::CPAN
label => __('_Annotations'),
callback => sub {
my ($action, $self) = @_;
require App::Chart::Gtk2::AnnotationsDialog;
App::Chart::Gtk2::AnnotationsDialog->popup ($self->get_symbol, $self);
},
},
{ name => 'ViewStyle',
label => __('_View Style'),
callback => sub { my ($action, $self) = @_;
Gtk2::Ex::WidgetCursor->busy;
require App::Chart::Gtk2::ViewStyleDialog;
my $vs = App::Chart::Gtk2::ViewStyleDialog->instance_for_screen($self);
$vs->present;
my $view = $self->{'view'};
$vs->set (view => $view,
viewstyle => $view->get('viewstyle'));
}
},
{ name => 'Raw',
label => __('_Raw data'),
lib/App/Chart/Gtk2/Main.pm view on Meta::CPAN
},
},
{ name => 'Ticker',
label => __('_Ticker'),
is_active => 0,
tooltip => __('Show a stock ticker of share prices at the bottom of the window.
Mouse button-1 there drags it back or forward. Button-3 pops up a menu of options, including which symbol list it shows.'),
callback => sub {
my ($action, $self) = @_;
Gtk2::Ex::WidgetCursor->busy; # can take a moment to load
$self->get_or_create_ticker;
},
},
{ name => 'Toolbar',
label => __('T_oolbar'),
tooltip => __('Show (or not) the toolbar.'),
is_active => 1,
},
],
$self);
lib/App/Chart/Gtk2/Main.pm view on Meta::CPAN
value => 1,
},
{ name => 'Monthly',
label =>__('_Monthly'),
accelerator => __p('Main-accelerator-key','<Ctrl>M'),
tooltip => __('Display monthly data.'),
value => 2,
}],
0, # initial
sub { my ($action, $current_action, $self) = @_;
Gtk2::Ex::WidgetCursor->busy;
$self->{'view'}->set (timebase_class =>
$timebases[$action->get_current_value]);
},
$self);
my $ui = $self->{'ui'} = Gtk2::UIManager->new;
$ui->insert_action_group ($actiongroup, 0);
$self->add_accel_group ($ui->get_accel_group);
$ui->add_ui_from_string (<<'HERE');
<ui>
lib/App/Chart/Gtk2/Main.pm view on Meta::CPAN
# 'delete-symbol' broadcast handler
sub _do_delete_symbol {
my ($self, $symbol) = @_;
my $self_symbol = $self->{'symbol'};
### Main delete-symbol: $symbol
### showing: $self_symbol
# when currently displayed symbol is deleted goto next, or if no next
# then previous, or if no previous then go to displaying nothing
if (defined $self_symbol && $self_symbol eq $symbol) {
Gtk2::Ex::WidgetCursor->busy;
($symbol, my $symlist) = $self->smarker->next ('database');
if (! defined $symbol) {
### next is undef
($symbol, $symlist) = $self->smarker->prev ('database');
### prev: $symbol
}
_goto_with_history ($self, $symbol, $symlist);
}
}
lib/App/Chart/Gtk2/Main.pm view on Meta::CPAN
my $symlist = App::Chart::Gtk2::Symlist->new_from_key_maybe ($symlist_key);
return ($symbol, $symlist);
}
sub _history_symbol_symlist_to_place {
my ($symbol, $symlist) = @_;
return [ $symbol, $symlist && $symlist->key ];
}
sub _goto {
my ($self, $symbol, $symlist) = @_;
Gtk2::Ex::WidgetCursor->busy;
$self->{'symbol'} = $symbol;
$self->{'symlist'} = $symlist;
$self->{'view'}->set('symbol', $symbol);
if (my $webmenu = $self->{'webmenu'}) { $webmenu->set('symbol', $symbol); }
$self->signal_emit ('symbol-changed', $symbol);
if ($symbol) {
require App::Chart::Gtk2::Job::Latest;
App::Chart::Gtk2::Job::Latest->start_for_view ($symbol, $symlist);
}
lib/App/Chart/Gtk2/Main.pm view on Meta::CPAN
sub goto_symbol {
my ($self, $symbol, $symlist) = @_;
### Main goto: $symbol, $symlist && $symlist->key
_goto_with_history ($self, $symbol, $symlist);
$self->smarker->goto ($symbol, $symlist);
}
sub goto_next {
my ($self) = @_;
Gtk2::Ex::WidgetCursor->busy;
my ($symbol, $symlist) = $self->smarker->next ('database');
# require App::Chart::Gtk2::Symlist;
# my ($symbol, $symlist)
# = App::Chart::Gtk2::Symlist::next ($self->{'symbol'}, $self->{'symlist'});
if ($symbol) {
_goto_with_history ($self, $symbol, $symlist);
} else {
_message ($self, __('At end of lists'));
}
}
sub go_prev {
my ($self) = @_;
Gtk2::Ex::WidgetCursor->busy;
my ($symbol, $symlist) = $self->smarker->prev ('database');
# require App::Chart::Gtk2::Symlist;
# my ($symbol, $symlist)
# = App::Chart::Gtk2::Symlist::previous ($self->{'symbol'}, $self->{'symlist'});
if ($symbol) {
_goto_with_history ($self, $symbol, $symlist);
} else {
_message ($self, __('At start of lists'));
}
}
lib/App/Chart/Gtk2/RawDialog.pm view on Meta::CPAN
_refresh_page ($self, $pagewidget);
}
sub _refresh_page {
my ($self, $pagewidget) = @_;
### _refresh_page(): $pagewidget->{'dirty'}
### for: $self->{'symbol'}
if ($pagewidget->{'dirty'}) {
Gtk2::Ex::WidgetCursor->busy;
$pagewidget->{'dirty'} = 0;
my $symbol = $self->{'symbol'};
if (my $datasheet = $pagewidget->{'datasheet'}) {
### datasheet query
$datasheet->query ({bind_values => [$symbol]}, 0);
} elsif (my $seriestreeview = $pagewidget->{'seriestreeview'}) {
my $series;
if ($symbol) {
require App::Chart::Series::Database;
lib/App/Chart/Gtk2/SeriesTreeView.pm view on Meta::CPAN
$self->refresh;
}
}
sub refresh {
my ($self) = @_;
my $series = $self->{'series'};
if (DEBUG) { print "SeriesTreeView refresh ",$series//'undef',"\n"; }
require Gtk2::Ex::WidgetCursor;
Gtk2::Ex::WidgetCursor->busy;
my $model = $self->{'model'}
= App::Chart::Gtk2::SeriesModel->new (series => $series);
$self->set_model ($model);
}
sub _do_entry_activate {
my ($entry, $self) = @_;
$self->set_symbol ($entry->get_text);
}
lib/App/Chart/Gtk2/VacuumDialog.pm view on Meta::CPAN
'Gtk2::Dialog',
signals => { destroy => \&_do_destroy };
use constant { RESPONSE_START => 0,
RESPONSE_STOP => 1,
RESPONSE_CLEAR => 2 };
# sub popup {
# my ($class) = @_;
# require Gtk2::Ex::WidgetCursor;
# Gtk2::Ex::WidgetCursor->busy;
# my $dialog = $class->instance;
# $dialog->present;
# return $dialog;
# }
sub INIT_INSTANCE {
my ($self) = @_;
$self->set_title (__('Chart: Vacuum'));
$self->add_buttons (__('_Start') => $self->RESPONSE_START,
lib/App/Chart/Gtk2/WatchlistDialog.pm view on Meta::CPAN
} else {
$label->set_text (__('(No list)'));
}
if (($symlist||0) eq ($self->{'symlist'}||0)) {
### symlist unchanged
return;
}
### new symlist: "$symlist"
Gtk2::Ex::WidgetCursor->busy;
my $model = $symlist && App::Chart::Gtk2::WatchlistModel->new ($symlist);
{
my $reorderable = $symlist && $symlist->can_edit;
my $symbols_treeview = $self->{'symbols_treeview'};
### $reorderable
$symbols_treeview->set (model => $model,
reorderable => $reorderable);
# FIXME: what was this? dragging text to add a symbol? doing it turns
lib/App/Chart/Gtk2/WatchlistDialog.pm view on Meta::CPAN
$self->signal_emit ('close');
} elsif ($response eq 'help') {
require App::Chart::Manual;
App::Chart::Manual->open(__p('manual-node','Watchlist'), $self);
}
}
sub refresh {
my ($self) = @_;
Gtk2::Ex::WidgetCursor->busy;
if (my $symlist = $self->{'symlist'}) {
require App::Chart::Gtk2::Job::Latest;
App::Chart::Gtk2::Job::Latest->start_symlist ($symlist);
}
}
sub _do_symbol_menu_popup {
my ($treeview, $event) = @_;
if ($event->button == 3) {
require App::Chart::Gtk2::WatchlistSymbolMenu;
lib/App/Chart/Vacuum.pm view on Meta::CPAN
sub vacuum_notes {
my $notes_filename = App::Chart::DBI::notes_filename();
my $notes_oldsize = -s $notes_filename;
App::Chart::Download::status (__x('VACUUM notes.sqdb ({oldsize} bytes)',
oldsize => $notes_oldsize));
require DBI;
my $nbh = DBI->connect ("dbi:SQLite:dbname=$notes_filename",
'', '', {RaiseError=>1});
$nbh->func(90_000, 'busy_timeout'); # 90 seconds
$nbh->{sqlite_unicode} = 1;
$nbh->do ('VACUUM');
my $notes_newsize = -s $notes_filename;
print __x("Notes was {oldsize} now {newsize} bytes\n",
oldsize => $notes_oldsize,
newsize => $notes_newsize);
}
sub vacuum_database {
my $dbh = App::Chart::DBI->instance;
maybe/Build-PL view on Meta::CPAN
'Glib::Ex::ConnectProperties' => 0,
'Glib::Ex::SignalIds' => 0, # my Glib-Ex-ObjectBits
# Gtk2::Ex::GtkGCobj => 0,
'Gtk2::Ex::CrossHair' => 0,
'Gtk2::Ex::Dragger' => 0,
'Gtk2::Ex::Lasso' => 0,
'Gtk2::Ex::NoShrink' => 0,
'Gtk2::Ex::TickerView' => 0,
# version 2 for busy() working on newly opened dialogs
'Gtk2::Ex::WidgetCursor' => 2,
'HTML::TableExtract' => 0,
# only needed for an LME plastics hack actually
'HTML::TreeBuilder' => 0,
'IO::String' => 0,
'List::MoreUtils' => 0,
misc/t-database.pl view on Meta::CPAN
### $ref
exit 0;
}
{
my $filename = '/tmp/x.sqdb';
$ENV{'DBI_TRACE'} = '1';
require DBI;
my $dbh = DBI->connect ("dbi:SQLite:dbname=$filename",
'', '', {RaiseError=>1});
$dbh->func(5_000, 'busy_timeout'); # 90 seconds
# $dbh->do ('CREATE TABLE foo (bar TEXT)');
$dbh->begin_work;
$dbh->do ("INSERT INTO foo (bar) VALUES ('hello')");
# $dbh->commit;
sleep 100;
exit 0;
}
{
App::Chart::Download::vacuum ();
exit 0;
}
{
my $dbh = App::Chart::DBI->instance();
print $dbh->func('busy_timeout'),"\n";
exit 0;
my $sth = $dbh->table_info(undef, 'notesdb', '%', undef);
my $aref = $sth->fetchall_arrayref;
$sth->finish;
print Dumper($aref);
exit 0;
}
# return true if $dbh contains a table called $table
sub dbh_table_exists {