blib/lib/Gapp/ButtonBox.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 66 CC 3 SCAR 17.5
CC
3
Cov
0%
BUILDARGS
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.8
1 package Gapp::ButtonBox;
2 {
3 $Gapp::ButtonBox::VERSION = '0.60';
4 }
5  
6 use Moose;
7 use MooseX::SemiAffordanceAccessor;
8  
9 use Carp;
10 use Gapp::Button;
11 use Gapp::Types qw( GappWidget GappActionOrArrayRef );
12  
13 extends 'Gapp::Container';
14  
15 has '+gclass' => (
16 default => 'Gtk2::ButtonBox',
17 );
18  
19 has 'buttons' => (
20 is => 'rw',
21 isa => 'Maybe[ArrayRef]',
22 );
23  
24 sub BUILDARGS {
25 my $class = shift;
26 my %args = @_ == 1 && is_HashRef( $_[0] ) ? %{$_[0]} : @_;
27
28 # headers visible
29 for my $att ( qw(layout_style) ) {
30 $args{properties}{$att} = delete $args{$att} if exists $args{$att};
31 }
32
33 __PACKAGE__->SUPER::BUILDARGS( %args );
34 }
35  
36  
37 before '_construct_gobject' => sub {
38 my ( $self ) = @_;
39
40 if ( $self->buttons && ! @{ $self->content } ) {
41
42 my @content;
43
44 for ( @{ $self->buttons } ) {
45
46 if ( is_GappWidget( $_ ) ) {
47 push @content, $_;
48 }
49 elsif ( is_GappActionOrArrayRef( $_ ) ) {
50 push @content, Gapp::Button->new( action => $_ );
51 }
52 else {
53 carp qq[invalid value ($_) passed to buttons attribute: ] .
54 qq[ must be a GappWidget or a GappAction ];
55 }
56
57 }
58
59 $self->set_content( \@content );
60 }
61 };
62  
63 1;
64  
65  
66 __END__