Re: Problem with subclassing with Glib::Object::Subclass and Gtk3
- From: Yuri Myasoedov <ymyasoedov yandex ru>
- To: gtk-perl mailing list <gtk-perl-list gnome org>
- Subject: Re: Problem with subclassing with Glib::Object::Subclass and Gtk3
- Date: Fri, 10 Apr 2015 10:33:05 +0300
Hm. It seems the problem is in Glib::Object::Introspection XS function _invoke_fallback_vfunc:
__PACKAGE__->_invoke_fallback_vfunc($provider_package,
$vfunc_name,
$implementer_package,
_);
It can't handle undef parameters. For example, in "screen-changed" handler (I didn't connect any handlers to
this signal in my class):
void user_function (GtkWidget *widget, GdkScreen *previous_screen, gpointer user_data)
where "previous_screen" -- the previous screen, or NULL if the widget was not associated with a screen before.
In my case "previous_screen" is undef because it should be NULL in C. But Glib::Object::Introspection
requires that "previous_screen" should be Gtk3::Gdk::Screen and it fails when "previous_screen" is undef:
"undef is not of type Gtk3::Gdk::Screen".
09.04.2015, 22:29, "Yuri Myasoedov" <ymyasoedov yandex ru>:
Hi!
I have a problem with migration of my code to Gtk3. Just a simple example. I want to subclass from
Gtk3::Button with Glib::Object::Subclass.
There is no new signals, no properties and so on... BTW, when I switched to Gtk3, I have to define two
additional
signals, PARENT_SET and HIERARCHY_CHANGED. This code just works if I replace Gtk3 to Gtk2. But it doesn't
when I use Gtk3. I've got a error: "undef is not of type Gtk3::Gdk::Screen at
/usr/lib/perl5/site_perl/Glib/Object/Introspection.pm line 246."
What's wrong with it? Can I still use Glib::Object::Subclass for inheritance for Gtk3?
#!/usr/bin/perl
use strict;
use warnings;
package MyButton;
use Gtk3;
use Glib::Object::Subclass
Gtk3::Button::,
signals => {},
properties => [],
;
sub INIT_INSTANCE {
my $self = shift;
return $self;
}
sub PARENT_SET {
my $self = shift;
warn "PARENT_SET was called\n";
}
sub HIERARCHY_CHANGED {
my $self = shift;
warn "HIERARCHY_CHANGED was called\n";
}
package main;
use Gtk3 -init;
my $window = Gtk3::Window->new();
$window->signal_connect(delete_event => sub { Gtk3->main_quit() });
my $my_button = MyButton->new(label => "Test");
$window->add($my_button);
$window->show_all();
Gtk3->main();
[ysm helios tmp]$ perl test.pl
(1.pl:7631): Gtk-WARNING **: Theme parsing error: gtk-widgets.css:2:16: Theming engine 'adwaita' not found
PARENT_SET was called
HIERARCHY_CHANGED was called
undef is not of type Gtk3::Gdk::Screen at /usr/lib/perl5/site_perl/Glib/Object/Introspection.pm line 246.
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]