blib/lib/Gapp/ActionGroup.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 60 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Gapp::ActionGroup;
2 {
3 $Gapp::ActionGroup::VERSION = '0.60';
4 }
5  
6 use Moose;
7 use MooseX::SemiAffordanceAccessor;
8 use MooseX::Types::Moose qw( ArrayRef ClassName HashRef Object );
9  
10 extends 'Gapp::Object';
11  
12 use Gapp::Actions::Util;
13  
14 has '+gclass' => (
15 default => 'Gtk2::ActionGroup',
16 );
17  
18 has 'name' => (
19 is => 'rw',
20 isa => 'Str',
21 default => '',
22 );
23  
24 has 'actions' => (
25 is => 'rw',
26 isa => 'ArrayRef',
27 default => sub { [ ] },
28 );
29  
30 has 'action_args' => (
31 is => 'rw',
32 isa => 'ArrayRef',
33 default => sub { [ ] },
34 );
35  
36 {
37 my $anon = 1;
38  
39 around BUILDARGS => sub {
40 my ( $orig, $class, %opts ) = @_;
41 $opts{name} ||= 'ActionGroup::__ANON__::' . $anon++;
42 $opts{args} = [$opts{name}];
43 $class->$orig( %opts );
44 };
45 }
46  
47 after _construct_gobject => sub {
48 my ( $self ) = @_;
49 my $gobject = $self->gobject;
50
51 my @actions;
52 for my $a ( @{ $self->actions } ) {
53
54 # if it is an array-ref/hash-ref, coerce
55 if ( is_ArrayRef( $a ) || is_HashRef( $a ) ) {
56 push @actions, to_GappAction( $a );
57 }
58
59 # if it is a Gapp::Action, apply it to the action group
60 elsif ( is_Object( $a ) ) {
61 push @actions, $a;
62 }
63
64 # if it is a class, apply all the actions to the group
65 elsif ( is_ClassName ( $a ) ) {
66 push @actions, ACTION_REGISTRY( $a )->actions;
67 }
68 }
69
70 # create the gtk action widgets and add them
71 # the the action group gtk widget
72 map { $gobject->add_action( $_->create_gtk_action( args => $self->action_args ) ) } @actions;
73 };
74  
75 1;
76  
77  
78  
79  
80 __END__