]>
Dogcows Code - chaz/homebank/blob - plugins/hello.pl
0b133c55cf795647a7e56520253d240b84d00f2d
4 # ABSTRACT: This is the "hello world" of HomeBank plugins.
5 # AUTHOR: Charles McGarvey <chazmcgarvey@brokenzipper.com>
6 # WEBSITE: http://acme.tld/
7 # (These comments are read, before the plugin is executed, to provide some
8 # information to HomeBank and the user about what this plugin is.)
10 eval { HomeBank-
>version } or die "Cannot run outside of HomeBank";
15 use Scalar
::Util qw
/weaken/;
23 #default => "Booya!!!";
33 my $self = $class->SUPER::new
(@_);
35 $self->on(account_inserted
=> sub {
37 print "account inserted: ", Dumper
($acc);
38 print "account name is ", $acc->name, " and balance is ", $acc->bank_balance, "\n";
39 #$acc->name("FOOOOBAR!");
40 if ($acc->name eq 'Vacation') {
44 print Dumper
($acc->is_inserted);
45 if ($acc->is_inserted) {
46 print "IT IS INSERTED\n";
48 print "not inserted\n";
50 print Dumper
($acc->transactions);
53 #print $self->cool_beans, "\n";
54 #$self->cool_beans(123);
55 #print $self->cool_beans, "\n";
60 sub on_create_main_window
{
66 $window = HomeBank-
>main_window;
70 print Dumper
($window);
71 $window->set_title("foo bar baz");
72 print $window->get_title, "\n";
74 HomeBank-
>hook("my_hook", $window);
83 my $window = Gtk3
::Window-
>new('toplevel');
86 print Dumper
($window);
87 $window->set_title("Hello World");
88 #$window->signal_connect(delete_event => sub { Gtk3->main_quit });
89 $window->signal_connect(delete_event
=> sub { undef $test_win });
91 my $button = Gtk3
::Button-
>new('Click Me!');
93 print Dumper
($button);
94 $button->signal_connect(clicked
=> sub {
95 print "Hello Gtk3-Perl: $counter (perl plugin: $self)\n";
97 #if ($temp->is_inserted) {
98 #print "$temp is inserted\n";
100 #print "$temp is NOT inserted\n";
102 #if ($counter == 5) {
105 my $acc = HomeBank
::Account-
>get(rand(10));
106 print "Changin account named ", $acc->name, " to ", $acc->name($acc), "\n";
107 HomeBank-
>main_window->queue_draw;
109 $window->add($button);
117 sub on_enter_main_loop
{
122 my $t = HomeBank
::Transaction-
>new;
123 print "Transaction:::::::: $t: ", $t->amount, "\n";
125 $temp = HomeBank
::Account-
>get(7);
126 print "retained account: ", $temp->name, "\n";
130 my $txn = HomeBank
::Transaction-
>new;
131 $txn->amount(12.3456);
132 print Dumper
($txn), $txn->amount, "\n";
135 my @ret = HomeBank-
>hook("my_hook", @_, $temp, [qw
/foo bar baz/, $txn], { asf
=> 42, quux
=> \
1, meh
=> HomeBank-
>main_window });
136 #my @ret = HomeBank->hook("my_hook", @_, HomeBank->main_window, {
137 #foo => 'bar', baz => 42
141 print "adding back account...\n";
142 $ACC->name("vacation with a different name");
144 HomeBank
::Account-
>compute_balances;
145 print "account name is ", $ACC->name, " and balance is ", $ACC->balance, "\n";
146 print Dumper
($ACC->transactions);
148 my $cloned = $ACC->clone;
149 $cloned->name("vacation copy");
151 #my $asdf = $cloned->open;
152 #$asdf->set_title("this is a new friggin account");
154 #my $z = HomeBank::Account->get_by_name('Checking');
155 for my $xc (HomeBank
::File-
>transactions) {
158 my $date = DateTime-
>new($xc->date)->datetime;
159 print "transaction of amount: ", $xc->amount, "\t", $xc->memo, ", ", $xc->info, ", $num, $date\n";
162 HomeBank
::File-
>owner('Billy Murphy');
163 #HomeBank::File->anonymize;
164 print HomeBank
::File-
>owner, "\n";
166 HomeBank
::File-
>baz($ACC);
169 sub on_deep_hook_recursion
{
172 print STDERR
"recursion is too deep ($level)\n";
178 print "This is MY HOOK!!!!!!\n";
186 if ($_[2]->isa('HomeBank::Boolean')) {
187 print "it is a home;;boolean\n";
189 if ($_[2]->isa('Types::Serialiser::Boolean')) {
190 print "it is a types serialiser thingy\n";
192 if ($_[2]->isa('HomeBank::BooleanBase')) {
193 print "it is a base bool\n";
197 if ($win && ref($win) eq 'HASH') {
200 $w->set_title("this is MY HOOK setting a window title");
204 #print "transferred account: ", $acc->name, "\n";
206 #my $fff = HomeBank::File->foo({foo => 'asdf', bar => 123456789});
207 my $fff = HomeBank
::File-
>meh([qw
/hello this is a test 82/, \
1, {foo
=> 'bar'}, 48]);
210 print "my hook done\n";
214 my ($self, $hook) = @_;
215 warn "Unhandled hook '$hook'\n";
216 #HomeBank->warn($hook, 'Hook not handled.');
221 print "DESTROYING HELLO WORLD!!!!!!\n";
223 print "there is a test_win...\n";
225 $test_win->destroy if $test_win;
229 print "the perl plugin is being configured.....\n";
230 HomeBank-
>info("Hello Prefs", "YEEEEEARGGH!!!!!");
233 #__PACKAGE__->meta->make_immutable;
This page took 0.051843 seconds and 4 git commands to generate.