package TkBList; use Tk; use Milkbone::BList; use Milkbone::Tree; use Milkbone qw(slurp); use strict; use warnings; my $mw = hook("tk_getmain"); register_hook("signed_in", sub { my $blist = $mw->MBBList; $blist->init($mw); register_hook("buddy_in", sub { Milkbone::BList::on_buddy_in } , {-self => $blist}); register_hook("buddy_info_changed", sub { Milkbone::BList::on_buddy_info_changed } , {-self => $blist}); register_hook("buddy_out", \&Milkbone::BList::on_buddy_out, {-self => $blist}); register_hook("add_blist_menu_item", \&Milkbone::BList::add_blist_menu_item, {-self => $blist}); register_hook("protocol_go_away", sub { my $self = $ARGS{-self}; $self->{tree}->configure(-bg => 'gray'); $self->{group_style}->configure(-bg => 'gray'); }, {-self => $blist}); register_hook("protocol_return", sub { my $self = $ARGS{-self}; $self->{tree}->configure(-bg => 'white'); $self->{group_style}->configure(-bg => 'white'); $self->{waiting_msgs} = 0; }, {-self => $blist}); register_hook("error_fatal", sub { $ARGS{-self}->on_destroy; }, {-self => $blist}); register_hook("msg_in", sub { $ARGS{-self}->on_msg_in; }, {-self => $blist}); register_hook("protocol_add_buddy_group", sub { $ARGS{-self}->on_new_group($ARGS{-group}); }, {-self => $blist}); $blist->load_groups; register_hook("goodbye", sub { hook("tk_getmain")->after(300, sub { hook("protocol_signoff"); abort }); }); # $mw->after(30000, [$blist, "on_check_updates"]); }); sub reg_change_hook { my ($blist) = @_; register_hook("get_profile", sub { my ($self, $user, $group) = @ARGS{-self, -user, -group}; $self->on_check_info($user, $group); }, {-self => $blist}); } 1;