App/Chart/Gtk2/Ex/ToplevelBits.pm

filter: Statementstmt 33.3% 18 / 54 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 60.0% 6 / 10 Podpod 100% 1 / 1 totaltotal 20.0% 25 / 125 CC 24 SCAR 43.0
CC
24
Cov
17%
popup
156.0
_screen
56.0
__ANON__
20.0
CRAP 73.6
« App/Chart/Gtk2/Symlist/Alphabetical.pm ↑ Summary App/Chart/Glib/Ex/DirBroadcast.pm »
1 # parent => $widget ?
2  
3 # Copyright 2007, 2008, 2009, 2010 Kevin Ryde
4  
5 # This file is part of Chart.
6 #
7 # Chart is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 3, or (at your option) any later
10 # version.
11 #
12 # Chart is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # for more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with Chart. If not, see <http://www.gnu.org/licenses/>.
19  
20 package App::Chart::Gtk2::Ex::ToplevelBits;
21 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use List::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use App::Chart::Gtk2::Ex::ToplevelSingleton;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 # uncomment this to run the ### lines
29 #use Smart::Comments;
30  
31 # screen
32 # parent
33 # with_properties
34 # init_properties
35 # modal
36 # hide_on_delete
37  
38 0 ▶sub popup {
Subroutine popup: not called CC=12 SCAR=50.5
Pod documented
39 0 my ($class, %options) = @_;
40 ### ToplevelBits popup(): $class
41  
42 0 ▶ my $properties = $options{'properties'} || {};
Condition0%0/2
$options{'properties'} || {}
l!l
00
MC/DC0%0/1
$options{'properties'} || {}
$options{'properties'}
Truth table0%0/2
A
A= $options{'properties'}
Aresult
11
00
43 my $screen = _screen
44 0 ▶ ($options{'transient_for'} || $options{'parent'} || $options{'screen'});
Condition0%0/6
$options{'transient_for'} || $options{'parent'} || $options{'screen'}
l!l&&r!l&&!r
000
$options{"transient_for"} or $options{"parent"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$options{'transient_for'} || $options{'parent'} || $options{'screen'}
$options{"transient_for"} $options{"parent"} $options{'screen'}
Truth table0%0/4
A or B || C
A= $options{"transient_for"}B= $options{"parent"}C= $options{'screen'}
ABCresult
1XX1
01X1
0011
0000
45  
46 my $dialog = List::Util::first
47 0 ▶ {$_->isa($class)
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
$_->isa($class) and !defined($screen) || $_->get_screen == $screen and _object_properties_equal($_, $properties) 0 0 0
Condition0%0/6
$_->isa($class) and !defined($screen) || $_->get_screen == $screen
!ll&&!rl&&r
000
not defined $screen or $_->get_screen == $screen
l!l&&r!l&&!r
000
MC/DC0%0/3
$_->isa($class) and !defined($screen) || $_->get_screen == $screen
$_->isa($class) not defined $screen $_->get_screen == $screen
Truth table0%0/4
A and not(B) or C
A= $_->isa($class)B= not defined $screenC= $_->get_screen == $screen
ABCresult
0XX0
1000
11X1
1011
48 && (! defined $screen || $_->get_screen == $screen)
49 && _object_properties_equal($_,$properties)}
50 0 Gtk2::Window->list_toplevels;
51 ### ToplevelBits found: $dialog
52  
53 0 ▶ if ($dialog) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dialog) { } 0 0 0
54 0 ▶ if (exists $options{'modal'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $options{"modal"}) 0 0 0
55 0 $dialog->set_modal ($options{'modal'});
56 }
57 0 ▶ if (exists $options{'transient_for'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $options{"transient_for"}) 0 0 0
58 0 $dialog->set_transient_for ($options{'transient_for'});
59 }
60  
61 } else {
62 ### new dialog $class
63 0 ▶ if (eval { require Gtk2::Ex::WidgetCursor }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Gtk2::Ex::WidgetCursor } }) 0 0 0
64 0 Gtk2::Ex::WidgetCursor->busy;
65 }
66  
67 0 require Module::Load;
68 0 Module::Load::load ($class);
69 $dialog = $class->Glib::Object::new
70 ((defined $screen ? (screen => $screen) : ()),
71 (exists $options{'modal'} ? (modal => $options{'modal'}) : ()),
72 0 ▶ (exists $options{'transient_for'} ? (transient_for => $options{'transient_for'}) : ()),
Branch: 3 branches
BranchTrueFalseTotal
defined $screen ? : 0 0 0
exists $options{'modal'} ? : 0 0 0
exists $options{'transient_for'} ? : 0 0 0
73 %$properties);
74 0 ▶ if ($options{'hide_on_delete'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"hide_on_delete"}) 0 0 0
75 0 $dialog->signal_connect (delete_event => \&Gtk2::Widget::hide_on_delete);
76 }
77 }
78  
79 # if (! $dialog->visible) {
80 # if (my $func = $options{'newly_visible_func'}) {
81 # $func->($dialog);
82 # }
83 # }
84 0 $dialog->present;
85 0 return $dialog;
86 }
87  
88 0 ▶sub _screen {
Subroutine _screen: not called CC=7 SCAR=40.3
89 0 my ($obj) = @_;
90 0 ▶ if (! defined $obj) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $obj) 0 0 0
91 0 return Gtk2::Gdk::Screen->get_default;
92 }
93 # don't want $display->get_screen($screennum)
94 0 ▶ if ($obj->isa('Gtk2::Gdk::Display')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->isa("Gtk2::Gdk::Display")) 0 0 0
95 0 return $obj->get_default_screen;
96 }
97 0 ▶ if (my $func = $obj->can('get_screen')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $func = $obj->can("get_screen")) 0 0 0
98 0 ▶ return $obj->$func || croak "No screen for target $obj";
Condition0%0/2
$obj->$func || croak("No screen for target $obj")
l!l
00
MC/DC0%0/1
$obj->$func || croak("No screen for target $obj")
$obj->$func
Truth table0%0/2
A
A= $obj->$func
Aresult
11
00
99 }
100 0 ▶ if (my $func = $obj->can('get_default_screen')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $func = $obj->can("get_default_screen")) 0 0 0
101 0 ▶ return $obj->$func || croak "No default screen for target $obj";
Condition0%0/2
$obj->$func || croak("No default screen for target $obj")
l!l
00
MC/DC0%0/1
$obj->$func || croak("No default screen for target $obj")
$obj->$func
Truth table0%0/2
A
A= $obj->$func
Aresult
11
00
102 }
103 0 return $obj;
104 }
105  
106 0 ▶sub _object_properties_equal {
Subroutine _object_properties_equal: not called CC=4 SCAR=30.0
107 0 my ($obj, $properties) = @_;
108 0 ▶ while (my ($pname, $value) = each %$properties) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$properties) 0 0 0
109 0 ▶ my $pspec = $obj->find_property ($pname)
Condition0%0/2
$obj->find_property($pname) || croak(q[No such property '], $pname, q['])
l!l
00
MC/DC0%0/1
$obj->find_property($pname) || croak(q[No such property '], $pname, q['])
$obj->find_property($pname)
Truth table0%0/2
A
A= $obj->find_property($pname)
Aresult
11
00
110 || croak "No such property '",$pname,"'";
111 0 ▶ if ($pspec->values_cmp ($value, $obj->get($pname)) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pspec->values_cmp($value, $obj->get($pname)) != 0) 0 0 0
112 0 return 0;
113 }
114 }
115 0 return 1;
116 }
117  
118 1 1;
119 __END__
« App/Chart/Gtk2/Symlist/Alphabetical.pm ↑ Summary App/Chart/Glib/Ex/DirBroadcast.pm »