Skip Menu |

This queue is for tickets about the Gtk3 CPAN distribution.

Report information
The Basics
Id: 132538
Status: new
Priority: 0/
Queue: Gtk3

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Consider "return $self" in all set_* methods
Currently all the widget ->set_* methods just return undef. Certain code styles become a lot more convenient if they instead return the object itself, so you can do things like $vbox->add( Gtk3::Entry->new ->set_sensitive( 0 ) ->set_alignment( ... ) ); Without it you have to do lots of temporary variables: my $entry = Gtk3::Entry->new; $entry->set_sensitive( 0 ); $entry->set_alignment( ... ); $vbox->add( $entry ); or maybe $vbox->add( do { my $entry = Gtk3::Entry->new; ... $entry; } ); If I have to do this a lot (as I often do around Gtk*) I usually make myself a helper: my $set = sub { my $self = shift; my ( $attr, @args ) = @_; my $method = "set_$attr"; $self->$method( @args ); return $self; }; $vbox->add( Gtk3::Entry->new ->$set( sensitive => 0 ) ->$set( alignment => ... ) ); but having that feature built-in would be handy indeed. See also Object::Tap [https://metacpan.org/pod/Object::Tap] -- Paul Evans