blib/lib/Gapp/SpinButton.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 64 CC 4 SCAR 17.0
CC
4
Cov
0%
BUILDARGS
12.0
set_field_value
6.0
get_field_value
2.0
CRAP 5.5
1 package Gapp::SpinButton;
2 {
3 $Gapp::SpinButton::VERSION = '0.60';
4 }
5  
6 use Moose;
7 use MooseX::SemiAffordanceAccessor;
8  
9 extends 'Gapp::Entry';
10  
11 has '+gclass' => (
12 default => 'Gtk2::SpinButton',
13 );
14  
15 has range => (
16 is => 'rw',
17 isa => 'ArrayRef',
18 default => sub{ [0,999] },
19 );
20  
21 has step => (
22 is => 'rw',
23 isa => 'Num',
24 default => 1,
25 );
26  
27 has page => (
28 is => 'rw',
29 isa => 'Maybe[Num]',
30 );
31  
32 has '+constructor' => (
33 default => 'new_with_range',
34 );
35  
36 sub BUILDARGS {
37 my $class = shift;
38 my %args = @_ == 1 && is_HashRef( $_[0] ) ? %{$_[0]} : @_;
39
40 for my $att ( qw(digits climb_rate) ) {
41 $args{properties}{$att} = delete $args{$att} if exists $args{$att};
42 }
43
44 __PACKAGE__->SUPER::BUILDARGS( %args );
45 }
46  
47 before '_construct_gobject' => sub {
48 my ( $self ) = @_;
49 $self->set_args( [ @{ $self->range }, $self->step ]);
50 };
51  
52 # returns the value of the widget
53 sub get_field_value {
54 $_[0]->gobject->get_value;
55 }
56  
57 sub set_field_value {
58 my ( $self, $value ) = @_;
59 $self->gobject->set_value( defined $value ? $value : 0 );
60 }
61  
62 sub widget_to_stash {
63 my ( $self, $stash ) = @_;
64 $stash->store( $self->field, $self->get_field_value );
65 }
66  
67 sub stash_to_widget {
68 my ( $self, $stash ) = @_;
69 $self->set_field_value( $stash->fetch( $self->field ) );
70 }
71  
72 sub _connect_changed_handler {
73 my ( $self ) = @_;
74  
75 $self->gobject->signal_connect (
76 changed => sub { $self->_widget_value_changed },
77 );
78 }
79  
80 1;
81  
82  
83 __END__