How to emit signals in Glib::Object derived modules?

S

Samuel Abels

Hello,

I am trying to implement a module derived from Glib::Object. This
works fine, except for when I want my module to emit a self-defined
signal.

I know from the Gtk-Perl documentation that the signal has to be
registered first.
So this is what I figured should be right according to the docs:

------------------------------------------------
#!/usr/bin/env perl
package TestClass;
use strict;
use Gtk2 '-init';
use vars qw(@ISA $VERSION);
@ISA = qw(Glib::Object);

$VERSION = 0.01;

use Glib::Object::Subclass
TestClass::,
signals => {
my_new_signal => {
class_closure => sub { print "BLA\n" },
flags => [qw(run-first)],
return_type => undef,
param_types => []
}
};


sub new {
[...];
}
------------------------------------------------

Unfortunately, this produces an error message:

Uncaught exception from user code:
package RouterInterfaceConfig has not been registered with
GPerl at /usr/lib/perl5/Glib/Object/Subclass.pm line 225.
BEGIN failed--compilation aborted at ./test.pl line 11.

Google was not helpful. I'm clueless.

Any hints?

Thanks,
Samuel
 
A

Anno Siegel

Samuel Abels said:
Hello,

I am trying to implement a module derived from Glib::Object. This
works fine, except for when I want my module to emit a self-defined
signal.

I know from the Gtk-Perl documentation that the signal has to be
registered first.
So this is what I figured should be right according to the docs:

------------------------------------------------
#!/usr/bin/env perl
package TestClass;
use strict;
use Gtk2 '-init';
use vars qw(@ISA $VERSION);
@ISA = qw(Glib::Object);

I don't know any specifics, but this will come to late for "use" to
see it. Put a BEGIN block around the @ISA assignment and try again.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top