1

在插件加载时调用的子例程中,我有以下内容:

my $plugin = shift;
my $purple_handle = Purple::Conversations::get_handle();

Purple::Signal::connect($purple_handle, "conversation-updated", $plugin, \&conversation_updated_cb, "");

在 conversation_updated_cb 中,我有以下内容:

my $conv = shift;
my $entry = $conv.entry; # $entry defined for convenience of explanation
my $spell = Gtk2::Spell->get_from_text_view($entry);

我在第 38 行的位置收到以下错误消息my $spell = Gtk2::Spell->get...

Perl function exited abnormally: `Purple::Conversation...' is not of type Gtk2::TextView at (eval 26) line 38.

我假设 $entry 需要是 GTK2::TextView 但我不知道该怎么做,我的搜索失败了。

~/.purple/plugins/testplugin.pl 中的完整代码:

use Purple;
use Gtk2::Spell;

# this part taken from Hello World perl example on pidgin.im
%PLUGIN_INFO = (
    perl_api_version => 2,
    name => "A Perl Test Plugin",
    version => "0.1",
    summary => "Test plugin for the Perl interpreter.",
    description => "Your description here",
    author => "John H. Kelm <johnhkelm\@gmail.com",
    url => "http://pidgin.im",
    load => "plugin_load",
    unload => "plugin_unload"
);
sub plugin_init {
    return %PLUGIN_INFO;
}
sub plugin_load {
    my $plugin = shift;
    Purple::Debug::info("testplugin", "plugin_load() - Test Plugin Loaded.\n");

    my $purple_handle = Purple::Conversations::get_handle();
    Purple::Signal::connect($purple_handle, "conversation-updated", $plugin, \&conversation_updated_cb, "");
}
sub plugin_unload {
    my $plugin = shift;
    Purple::Debug::info("testplugin", "plugin_unload() - Test Plugin Unloaded.\n");
}
sub conversation_updated_cb {
    my $conv = shift;
    my $entry = $conv.entry;

    Purple::Debug::info("Test Plugin", Dumper( \%{ref ($conv)."::" }));
    Purple::Debug::info("Test Plugin", Dumper( \%{ref ($conv.entry)."::" }));

    my $spell = Gtk2::Spell->get_from_text_view($entry);
    Purple::Debug::info("Test Plugin", Dumper( \%{ref ($conv.entry)."::" }));
}
4

0 回答 0