On Fri, 6 Sep 2019 at 16:57, Mike Martin via gtk-perl-list <
gtk-perl-list@gnome.org> wrote:

> How do I use Gtk macros in perl-gtk?
> eg in c
> What is the corresponding method in perl-gtk

I assume you're talking about Gtk3.

Macros are not introspected unless they evaluate to simple scalar values.
The "IS" type checking macros are replaces by normal Perl type checking

use v5.22;
use Gtk3 '-init';

my $x = Gtk3::Button->new_with_label('foo');
say "The type of x is: ", ref($x);

will print out:

The type of x is: Gtk3::Button

If you want to check if an instance is of a certain type, you can use

use v5.22;
use Gtk3 '-init';

my $x = Gtk3::Button->new_with_label('Foo');

say "x is a button" if $x->isa('Gtk3::Button');
say "x is a container" if $x->isa('Gtk3::Container');
say "x is a widget" if $x->isa('Gtk3::Widget');
say "x is a window" if $x->isa('Gtk3::Window');

will print out:

x is a button
x is a container
x is a widget

Hope this helps.


[@] ebassi [@gmail.com]
gtk-perl-list mailing list
  • Using Gtk macros Mike Martin via gtk-perl-list
    • Re: Using Gtk macros Emmanuele Bassi via gtk-perl-list

Reply via email to