line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::ebug::Wx::Plugin::Configurable::Base; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1743
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
|
|
507
|
use base qw(Class::Accessor::Fast Class::Publisher |
5
|
1
|
|
|
1
|
|
6
|
Devel::ebug::Wx::Plugin::Listener::Base); |
|
1
|
|
|
|
|
2
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub register_configurable { |
8
|
0
|
|
|
0
|
0
|
|
my( $self ) = @_; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$self->add_subscription |
11
|
|
|
|
|
|
|
( ref( $self ), 'configuration_changed', |
12
|
0
|
|
|
0
|
|
|
sub { $self->configuration_changed( $_[2] ) } ); |
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub configuration_changed { |
16
|
0
|
|
|
0
|
0
|
|
my( $self, $data ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$self->apply_configuration( $data ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub set_configuration { |
22
|
0
|
|
|
0
|
0
|
|
my( $class, $sm, $data ) = @_; |
23
|
0
|
|
|
|
|
|
my $cfg = $sm->get_service( 'configuration' ) |
24
|
|
|
|
|
|
|
->get_config( $data->{section} ); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
foreach my $key ( @{$data->{keys}} ) { |
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$cfg->set_value( $key->{key}, $key->{value} ); |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
$class->notify_subscribers( 'configuration_changed', $data ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_configuration { |
33
|
0
|
|
|
0
|
0
|
|
my( $class, $sm ) = @_; |
34
|
0
|
|
|
|
|
|
my $keys = $class->get_configuration_keys; |
35
|
0
|
|
|
|
|
|
my $cfg = $sm->get_service( 'configuration' ) |
36
|
|
|
|
|
|
|
->get_config( $keys->{section} ); |
37
|
0
|
|
|
|
|
|
my $use_defaults = 1; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
foreach my $key ( @{$keys->{keys}} ) { |
|
0
|
|
|
|
|
|
|
40
|
0
|
|
0
|
|
|
|
$key->{value} = $cfg->get_value( $key->{key} ), |
41
|
|
|
|
|
|
|
$use_defaults &&= !defined $key->{value}; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
0
|
|
|
|
|
if( $use_defaults ) { |
44
|
0
|
|
|
|
|
|
foreach my $key ( @{$keys->{keys}} ) { |
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$key->{value} = $key->{default}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $keys; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |