[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
calling superclass size_request method
- From: Kevin Ryde <user42 zip com au>
- To: gtk-perl-list gnome org
- Subject: calling superclass size_request method
- Date: Thu, 18 Oct 2007 09:06:05 +1000
With the debian packaged perl-gtk 1.140 and glib 1.161, and gtk 2.12.0
and glib 2.14.1, I had a little go at subclassing a GtkLabel, and in a
"size_request" method calling up to the corresponding superclass code
using signal_chain_from_overridden(). See Foo.pm and main.pl below,
"perl main.pl".
Alas signal_chain_from_overridden doesn't seem to touch the requisition
object, it just stays as size "0x0", where I hoped for something like
"72x17" (which is the case with no signal_request method in the
subclass). Have I misunderstood something fundamental? I was sort of
copying what the histogramplot.pl example does, and wanted something
like in C
GTK_WIDGET_CLASS (my_foo_parent_class)->size_request (widget, requisition);
I suspect actually for what I'm trying to do (tinkering with a clock as
a subclass of GtkLabel) I ought to calculate a desired size on my own,
in advance, instead of asking the superclass and manipulating its
result. But playing around made me wonder what I was doing wrong
seemingly not to reach the superclass code at all.
package Foo;
use strict;
use warnings;
use Gtk2;
use Glib::Object::Subclass
Gtk2::Label::,
signals => { size_request => \&do_size_request };
sub do_size_request ($$) {
my ($self, $req) = @_;
print "this is Foo::do_size_request\n";
print "text is '",$self->get_text,"'\n";
print "before chain: ",$req->width(),"x",$req->height(),"\n";
Glib::Object::signal_chain_from_overridden ($self, $req);
print "after chain: ",$req->width(),"x",$req->height(),"\n";
}
1;
BEGIN { push @INC, '.'; }
use strict;
use warnings;
use Gtk2 '-init';
use Foo;
my $window = Gtk2::Window->new('toplevel');
my $foo = Foo->new();
$foo->set_text ('hello world');
$window->add ($foo);
$window->show_all;
my $req = $foo->size_request();
print "main: size ",$req->width,"x",$req->height,"\n";
Gtk2->main();
exit 0;
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]