blib/lib/Gapp/Assistant.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 78 CC 7 SCAR 19.1
CC
7
Cov
0%
find_page
12.0
set_current_page
12.0
current_page
6.0
CRAP 6.8
1 package Gapp::Assistant;
2 {
3 $Gapp::Assistant::VERSION = '0.60';
4 }
5  
6 use Moose;
7 use MooseX::SemiAffordanceAccessor;
8 use MooseX::Types::Moose qw( HashRef );
9  
10 use MooseX::Types::Moose qw( Undef );
11 use Gapp::Types qw( GappActionOrArrayRef );
12 use Gapp::Meta::Widget::Native::Trait::AssistantPage;
13 extends 'Gapp::Window';
14  
15 has '+gclass' => (
16 default => 'Gtk2::Assistant',
17 );
18  
19 has 'forward_page_func' => (
20 is => 'rw',
21 isa => GappActionOrArrayRef|Undef,
22 );
23  
24  
25 sub current_page {
26 my ( $self ) = @_;
27
28 my @pages = $self->children;
29
30 my $num = $self->gobject->get_current_page;
31
32 for my $page ( @pages ) {
33 return $page if $page->page_num == $num;
34 }
35 }
36  
37 sub find_page {
38 my ( $self, $page_name ) = @_;
39
40 if ( ! defined $page_name || $page_name eq '' ) {
41 $self->meta->throw_errow(
42 qq[you did not supply a page name,\n] .
43 qq[usage: Gapp::Assistant::find_page( $self, $page_name )]
44 );
45 return;
46 }
47
48 for my $page ( $self->children ) {
49 return $page if $page->name eq $page_name;
50 }
51 }
52  
53 sub set_current_page {
54 my ( $self, $page_name ) = @_;
55
56 if ( ! defined $page_name ) {
57 $self->meta->throw_errow(
58 qq[you did not supply a page name,\n] .
59 qq[usage: Gapp::Assistant::find_page( $self, $page_name )]
60 );
61 return;
62 }
63
64 for my $page ( $self->children ) {
65 if ( $page->page_name eq $page_name ) {
66 $self->gobject->set_current_page( $page->num );
67 }
68 }
69 }
70  
71  
72  
73  
74 sub BUILD {
75 my $self = shift;
76 $self->signal_connect( 'prepare' => sub {
77 my ( $self ) = @_;
78 my $page = $self->current_page;
79 $page->validate if $page->validator;
80 }, $self);
81 }
82  
83  
84 1;
85  
86 __END__