]>
Dogcows Code - chaz/homebank/blob - plugins/hello.pl
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;
110 $window->add($button);
118 sub on_enter_main_loop
{
123 my $t = HomeBank
::Transaction-
>new;
124 print "Transaction:::::::: $t: ", $t->amount, "\n";
126 $temp = HomeBank
::Account-
>get(7);
127 print "retained account: ", $temp->name, "\n";
131 my $txn = HomeBank
::Transaction-
>new;
132 $txn->amount(12.3456);
133 print Dumper
($txn), $txn->amount, "\n";
136 my @ret = HomeBank-
>hook("my_hook", @_, $temp, [qw
/foo bar baz/, $txn], { asf
=> 42, quux
=> \
1, meh
=> HomeBank-
>main_window });
137 #my @ret = HomeBank->hook("my_hook", @_, HomeBank->main_window, {
138 #foo => 'bar', baz => 42
142 print "adding back account...\n";
143 $ACC->name("vacation with a different name");
145 HomeBank
::Account-
>compute_balances;
146 print "account name is ", $ACC->name, " and balance is ", $ACC->balance, "\n";
147 print Dumper
($ACC->transactions);
149 my $cloned = $ACC->clone;
150 $cloned->name("vacation copy");
152 #my $asdf = $cloned->open;
153 #$asdf->set_title("this is a new friggin account");
155 #my $z = HomeBank::Account->get_by_name('Checking');
156 for my $xc (HomeBank
::File-
>transactions) {
159 my $date = DateTime-
>new($xc->date)->datetime;
160 print "transaction of amount: ", $xc->amount, "\t", $xc->wording, ", ", $xc->info, ", $num, $date\n";
163 HomeBank
::File-
>owner('Billy Murphy');
164 #HomeBank::File->anonymize;
165 print HomeBank
::File-
>owner, "\n";
167 HomeBank
::File-
>baz($ACC);
170 sub on_deep_hook_recursion
{
173 print STDERR
"recursion is too deep ($level)\n";
179 print "This is MY HOOK!!!!!!\n";
187 if ($_[2]->isa('HomeBank::Boolean')) {
188 print "it is a home;;boolean\n";
190 if ($_[2]->isa('Types::Serialiser::Boolean')) {
191 print "it is a types serialiser thingy\n";
193 if ($_[2]->isa('HomeBank::BooleanBase')) {
194 print "it is a base bool\n";
198 if ($win && ref($win) eq 'HASH') {
201 $w->set_title("this is MY HOOK setting a window title");
205 #print "transferred account: ", $acc->name, "\n";
207 #my $fff = HomeBank::File->foo({foo => 'asdf', bar => 123456789});
208 my $fff = HomeBank
::File-
>meh([qw
/hello this is a test 82/, \
1, {foo
=> 'bar'}, 48]);
211 print "my hook done\n";
215 my ($self, $hook) = @_;
216 warn "Unhandled hook '$hook'\n";
217 #HomeBank->warn($hook, 'Hook not handled.');
222 print "DESTROYING HELLO WORLD!!!!!!\n";
224 print "there is a test_win...\n";
226 $test_win->destroy if $test_win;
230 print "the perl plugin is being configured.....\n";
231 HomeBank-
>info("Hello Prefs", "YEEEEEARGGH!!!!!");
234 #__PACKAGE__->meta->make_immutable;
This page took 0.053819 seconds and 5 git commands to generate.