blib/lib/Gapp/RadioButton.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 66 CC 6 SCAR 22.3
CC
6
Cov
0%
_construct_gobject
20.0
get_field_value
6.0
widget_to_stash
6.0
CRAP 9.3
1 package Gapp::RadioButton;
2 {
3 $Gapp::RadioButton::VERSION = '0.60';
4 }
5  
6 use Moose;
7 use MooseX::SemiAffordanceAccessor;
8  
9 extends 'Gapp::CheckButton';
10  
11 has '+gclass' => (
12 default => 'Gtk2::RadioButton',
13 );
14  
15 # create and set the actual gobject
16 sub _construct_gobject {
17 my ( $self ) = @_;
18
19 my $gtk_class = $self->gclass;
20 my $gtk_constructor = $self->constructor;
21
22 # determine the radio group
23 my $group = $self->field && $self->parent ?
24 $self->parent->{_rdo_groups}{ $self->field } :
25 undef;
26
27 # use any build-arguments if they exist
28 my $w = $gtk_class->$gtk_constructor( $group, $self->args ? @{$self->args} : ( ) );
29 $self->set_gobject( $w );
30
31 # save the radio group in the parent
32 if ( $self->parent ) {
33 $self->parent->{_rdo_groups}{ $self->field } ||= $w->get_group;
34 }
35
36 return $w;
37 }
38  
39 sub get_field_value {
40 my $self = shift;
41 my $state = $self->gobject->get_active;
42 if ( $state ) {
43 return $self->value;
44 }
45 }
46  
47 sub widget_to_stash {
48 my ( $self, $stash ) = @_;
49 my $state = $self->gobject->get_active;
50 if ( $state ) {
51 $stash->store( $self->field, $self->get_field_value );
52 }
53 }
54  
55 sub stash_to_widget {
56 my ( $self, $stash ) = @_;
57 $self->set_field_value( $stash->fetch( $self->field ) );
58 }
59  
60 sub _connect_changed_handler {
61 my ( $self ) = @_;
62
63 $self->gobject->signal_connect (
64 released => sub { $self->_widget_value_changed; }
65 );
66 }
67  
68 1;
69  
70  
71 __END__