Cast Purple ::在Pidgin插件中将GTK2 :: TextView对话?

时间:2013-08-09 17:11:46

标签: perl gtk2 pidgin

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

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)."::" }));
}

0 个答案:

没有答案