Acme-Gtk2-Ex-Builder
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
use strict;
use warnings;
use Gtk2 -init;
use Acme::Gtk2::Ex::Builder;
my $app = build {
widget Window => contain {
info id => 'window';
set title => 'Awesome App';
set default_size => 200, 100;
set position => 'center';
on delete_event => sub { Gtk2->main_quit; };
widget Button => contain {
set label => 'Action';
on clicked => sub { say 'Seoul Perl Mongers!' };
};
};
};
README.mkdn view on Meta::CPAN
};
my $window = $app->find('my-window');
# FUNCTIONS
## build
This function acts like ordinary "new" method.
It is exported by default and returns [Acme::Gtk2::Ex::Builder](http://search.cpan.org/perldoc?Acme::Gtk2::Ex::Builder) object.
It can contains several `widget` functions.
my $app = build {
widget Window;
widget Dialog;
widget FileChooser;
widget VBox;
};
## widget
README.mkdn view on Meta::CPAN
## set
This function calls `$widget->set_KEY(VALUE)` function
for specified widget.
See [Gtk2](http://search.cpan.org/perldoc?Gtk2) and Gtk2 API reference.
my $app = build {
widget Window => contain {
set title => 'Awesome App';
set default_size => 200, 100;
set position => 'center';
};
};
## prop
This function sets properties for specified widget.
Actually it is same as `$widget->set(KEY, VALUE)`.
See [Gtk2](http://search.cpan.org/perldoc?Gtk2) and Gtk2 API reference.
my $app = build {
widget Window => contain {
info id => 'window';
set position => 'center';
prop title => 'Window Example';
prop opacity => 0.8;
prop 'default-width' => 640;
prop 'default-height' => 480;
on delete_event => \&quit;
};
};
## contain
This function is used to set attributes, set properties,
connect signal, add additional information or contain children widgets.
my $app = build {
examples/window.pl view on Meta::CPAN
use autodie;
use Gtk2 '-init';
use Acme::Gtk2::Ex::Builder;
my $app = build {
widget Window => contain {
info id => 'window';
set position => 'center';
prop title => 'Window Example';
prop opacity => 0.8;
prop 'default-width' => 640;
prop 'default-height' => 480;
on delete_event => \&quit;
};
};
$app->find('window')->show_all;
Gtk2->main;
sub quit {
Gtk2->main_quit;
}
lib/Acme/Gtk2/Ex/Builder.pm view on Meta::CPAN
}
else {
$widget = "Gtk2::$class"->new(@params);
}
if ($self->_current && ref($self->_current) ne __PACKAGE__) {
given (ref $self->_current) {
when (/Gtk2::VBox|Gtk2::HBox/) {
$self->_current->pack_start($widget, 0, 0, 1);
}
default {
$self->_current->add($widget);
}
};
}
$self->_current_push( $widget );
local *_info = sub {
my $key = shift;
my @values = @_;
lib/Acme/Gtk2/Ex/Builder.pm view on Meta::CPAN
when ('id') {
$self->find($values[0], $self->_current);
}
when ('packing') {
given (ref $self->_current(1)) {
when (/Gtk2::VBox|Gtk2::HBox/) {
$self->_current(1)->set_child_packing($self->_current, @values);
}
}
}
default {
}
}
$self->{_info}{$self->_current}{$key} = \@values;
};
local *_on = sub {
my $signal = shift;
my $_code = shift;
my $data = shift;
lib/Acme/Gtk2/Ex/Builder.pm view on Meta::CPAN
use strict;
use warnings;
use Gtk2 -init;
use Acme::Gtk2::Ex::Builder;
my $app = build {
widget Window => contain {
info id => 'window';
set title => 'Awesome App';
set default_size => 200, 100;
set position => 'center';
on delete_event => sub { Gtk2->main_quit; };
widget Button => contain {
set label => 'Action';
on clicked => sub { say 'Seoul Perl Mongers!' };
};
};
};
lib/Acme/Gtk2/Ex/Builder.pm view on Meta::CPAN
};
};
my $window = $app->find('my-window');
=head1 FUNCTIONS
=head2 build
This function acts like ordinary "new" method.
It is exported by default and returns L<Acme::Gtk2::Ex::Builder> object.
It can contains several C<widget> functions.
my $app = build {
widget Window;
widget Dialog;
widget FileChooser;
widget VBox;
};
=head2 widget
lib/Acme/Gtk2/Ex/Builder.pm view on Meta::CPAN
=head2 set
This function calls C<< $widget->set_KEY(VALUE) >> function
for specified widget.
See L<Gtk2> and Gtk2 API reference.
my $app = build {
widget Window => contain {
set title => 'Awesome App';
set default_size => 200, 100;
set position => 'center';
};
};
=head2 prop
This function sets properties for specified widget.
Actually it is same as C<< $widget->set(KEY, VALUE) >>.
See L<Gtk2> and Gtk2 API reference.
my $app = build {
widget Window => contain {
info id => 'window';
set position => 'center';
prop title => 'Window Example';
prop opacity => 0.8;
prop 'default-width' => 640;
prop 'default-height' => 480;
on delete_event => \&quit;
};
};
=head2 contain
This function is used to set attributes, set properties,
connect signal, add additional information or contain children widgets.
my $app = build {
( run in 0.385 second using v1.01-cache-2.11-cpan-0a6323c29d9 )