line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gtk2::Ex::Spinner; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
554
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
1832
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.21; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant DEBUG => 0; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Glib::Object::Subclass |
12
|
|
|
|
|
|
|
Gtk2::HBox::, |
13
|
|
|
|
|
|
|
properties => [Glib::ParamSpec->string |
14
|
|
|
|
|
|
|
('value', |
15
|
|
|
|
|
|
|
'value', |
16
|
|
|
|
|
|
|
'Integer', |
17
|
|
|
|
|
|
|
1, |
18
|
|
|
|
|
|
|
Glib::G_PARAM_READWRITE), |
19
|
|
|
|
|
|
|
]; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub INIT_INSTANCE { |
22
|
|
|
|
|
|
|
my ($self) = @_; |
23
|
|
|
|
|
|
|
$self->{'value'} = 1; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $spin_adj = Gtk2::Adjustment->new (1, # initial |
26
|
|
|
|
|
|
|
0, 9999, # range |
27
|
|
|
|
|
|
|
1, # step increment |
28
|
|
|
|
|
|
|
10, # page_increment |
29
|
|
|
|
|
|
|
0); # page_size (not applicable) |
30
|
|
|
|
|
|
|
my $spin = $self->{'spin'} = Gtk2::SpinButton->new ($spin_adj, 1, 0); |
31
|
|
|
|
|
|
|
$spin->show; |
32
|
|
|
|
|
|
|
$self->pack_start ($spin, 0,0,0); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$spin->signal_connect (value_changed => \&_update); |
35
|
|
|
|
|
|
|
_update ($spin); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub SET_PROPERTY { |
39
|
|
|
|
|
|
|
my ($self, $pspec, $newval) = @_; |
40
|
|
|
|
|
|
|
my $pname = $pspec->get_name; |
41
|
|
|
|
|
|
|
$self->{$pname} = $newval; # per default GET_PROPERTY |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->{'spin'}->set_value ($newval) if $pname eq 'value'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _update { |
47
|
|
|
|
|
|
|
my ($spin) = @_; |
48
|
|
|
|
|
|
|
my $self = $spin->parent; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
if ($self->{'update_in_progress'}) { return; } |
51
|
|
|
|
|
|
|
local $self->{'update_in_progress'} = 1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $value = $self->{'spin'}->get_value; |
54
|
|
|
|
|
|
|
if ($value ne $self->{'value'}) { |
55
|
|
|
|
|
|
|
$self->{'value'} = $value; |
56
|
|
|
|
|
|
|
$self->notify('value'); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_value { |
61
|
|
|
|
|
|
|
my ($self) = @_; |
62
|
|
|
|
|
|
|
return $self->{'value'}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |