Cast Purple::Conversation as GTK2::TextView in Pidgin Plugin?

221 Views Asked by At

In the subroutine called when the plugin loads, I have the following:

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

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

In conversation_updated_cb, I have the following:

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

I get the following error message where line 38 is my $spell = Gtk2::Spell->get...:

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

I'm assuming $entry needs to be GTK2::TextView but I have no idea how to do this, and my search-fu failed me.

Full code in ~/.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

There are 0 best solutions below