App/Chart/Gtk2/Ex/BindingBits.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 54 CC 3 SCAR 16.7
CC
3
Cov
0%
activate_button_event
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.3
1 # binding set replaced by an rc parse_string in program,
2 #
3 # lookup through widget bindings won't take Pointer_Button1 etc
4  
5  
6  
7 # Copyright 2009, 2010, 2011 Kevin Ryde
8  
9 # This file is part of Chart.
10 #
11 # Chart is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by the
13 # Free Software Foundation; either version 3, or (at your option) any later
14 # version.
15 #
16 # Chart is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 # for more details.
20 #
21 # You should have received a copy of the GNU General Public License along
22 # with Chart. If not, see <http://www.gnu.org/licenses/>.
23  
24 package App::Chart::Gtk2::Ex::BindingBits;
25 use 5.008;
26 use strict;
27 use warnings;
28 use Carp;
29 use Gtk2;
30 use Scalar::Util;
31  
32 # uncomment this to run the ### lines
33 #use Smart::Comments;
34  
35  
36 # Think it's better to croak for an unknown bindingset name than to return 0
37 # for not activated, on the basis it picks up typos or bad names.
38 #
39 sub activate_button_event {
40 my ($bindings, $event, $object) = @_;
41  
42 unless (Scalar::Util::blessed($bindings)
43 && $bindings->isa('Gtk2::BindingSet')) {
44 $bindings = Gtk2::BindingSet->find ($bindings)
45 || croak 'No BindingSet called ',$bindings;
46 }
47 my $keyval = Gtk2::Gdk->keyval_from_name('Pointer_Button' . $event->button)
48 || do {
49 ### activate_button_event() unknown: 'Pointer_Button' . $event->button
50 return 0;
51 };
52  
53 my $modifiers = $event->get_state;
54 if ($event->type eq 'button-release') { $modifiers |= 'release-mask'; }
55 ### type : $event->type
56 ### modifiers: "$modifiers"
57  
58 my $found = $bindings->activate ($keyval, $modifiers, $object);
59 ### activate_button() found: $found
60 return $found;
61 }
62  
63 1;
64 __END__