Wrangler/Wx/StatusBar.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 69 CC 10 SCAR 43.0
CC
10
Cov
0%
new
110.0
Destroy
2.0
BEGIN
2.0
CRAP 74.0
1 package Wrangler::Wx::StatusBar;
2  
3 use strict;
4 use warnings;
5  
6 use Wx qw(wxID_ANY wxSB_FLAT wxST_SIZEGRIP);
7 use base qw(Wx::StatusBar);
8 # use Wx::Event qw(EVT_PAINT);
9  
10 sub new {
11 my ($self,$parent) = @_;
12  
13 $self = $self->SUPER::new($parent, wxID_ANY, wxST_SIZEGRIP | wxSB_FLAT );
14  
15 ## register event listeners
16 Wrangler::PubSub::subscribe('dir.activated', sub {
17 $self->SetStatusText("$_[0] entered", 0);
18 }, __PACKAGE__);
19 Wrangler::PubSub::subscribe('file.activated', sub {
20 $self->SetStatusText("$_[0] activated", 0);
21 }, __PACKAGE__);
22 Wrangler::PubSub::subscribe('selection.changed', sub {
23 my $item = $_[0] == 1 ? 'item' : 'items';
24 my $etcetera = '';
25 my ($cntImages,$cntAudio,$cntVideo);
26 if($_[0] > 1 && ref($_[1])){
27 for(@{$_[1]}){
28 next unless $_->{'MIME::mediaType'};
29 $cntImages++ if $_->{'MIME::mediaType'} eq 'image';
30 $cntAudio++ if $_->{'MIME::mediaType'} eq 'audio';
31 $cntVideo++ if $_->{'MIME::mediaType'} eq 'video';
32 }
33 $etcetera .= ', '.$cntImages.' images' if $cntImages;
34 $etcetera .= ', '.$cntAudio.' audio-files' if $cntAudio;
35 $etcetera .= ', '.$cntVideo.' videos' if $cntVideo;
36 }
37 $self->SetStatusText("$_[0] $item selected".$etcetera, 0);
38 }, __PACKAGE__);
39 Wrangler::PubSub::subscribe('status.update', sub {
40 $self->SetStatusText($_[0], 0);
41 }, __PACKAGE__);
42  
43 # EVT_PAINT($self, sub {
44 $self->SetStatusStyles(0,wxSB_FLAT); # does not work: flat-style is not settable on construction
45 # });
46  
47 return $self;
48 }
49  
50 sub Destroy {
51 my $self = shift;
52  
53 Wrangler::PubSub::unsubscribe_owner(__PACKAGE__);
54  
55 $self->SUPER::Destroy();
56 }
57  
58 1;