FormFactory/Widget.pm

filter: Statementstmt 3.3% 12 / 360 Branchbran 0.0% 0 / 166 Conditioncond 0.0% 0 / 32 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 2.5% 3 / 119 Podpod 23.8% 27 / 113 totaltotal 5.1% 42 / 809 CC 99 SCAR 47.6
CC
99
Cov
2%
update_widget_activity
552.0
new
342.0
update
240.0
CRAP 116.3
↑ Summary FormFactory/Rules.pm »
1 package Gtk2::Ex::FormFactory::Widget;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 my $NAME_CNT = 0;
8 2 my %WIDGET_NAMES;
9  
10 #========================================================================
11 # Accessors for user specified attributes
12 #========================================================================
13 0 ▶sub get_name { shift->{name} }
Subroutine get_name: not called CC=1 SCAR=6.9
Pod undocumented
14 0 ▶sub get_object { shift->{object} }
Subroutine get_object: not called CC=1 SCAR=6.9
Pod undocumented
15 0 ▶sub get_attr { shift->{attr} }
Subroutine get_attr: not called CC=1 SCAR=6.9
Pod undocumented
16 0 ▶sub get_properties { shift->{properties} }
Subroutine get_properties: not called CC=1 SCAR=6.9
Pod undocumented
17 0 ▶sub get_label { shift->{label} }
Subroutine get_label: not called CC=1 SCAR=6.9
Pod undocumented
18 0 ▶sub get_label_for { shift->{label_for} }
Subroutine get_label_for: not called CC=1 SCAR=6.9
Pod undocumented
19 0 ▶sub get_label_markup { shift->{label_markup} }
Subroutine get_label_markup: not called CC=1 SCAR=6.9
Pod undocumented
20 0 ▶sub get_label_group { shift->{label_group} }
Subroutine get_label_group: not called CC=1 SCAR=6.9
Pod undocumented
21 0 ▶sub get_widget_group { shift->{widget_group} }
Subroutine get_widget_group: not called CC=1 SCAR=6.9
Pod undocumented
22 0 ▶sub get_tip { shift->{tip} }
Subroutine get_tip: not called CC=1 SCAR=6.9
Pod undocumented
23 0 ▶sub get_inactive { shift->{inactive} }
Subroutine get_inactive: not called CC=1 SCAR=6.9
Pod undocumented
24 0 ▶sub get_active { shift->{active} }
Subroutine get_active: not called CC=1 SCAR=6.9
Pod undocumented
25 0 ▶sub get_rules { shift->{rules} }
Subroutine get_rules: not called CC=1 SCAR=6.9
Pod undocumented
26 0 ▶sub get_expand { shift->{expand} }
Subroutine get_expand: not called CC=1 SCAR=6.9
Pod undocumented
27 0 ▶sub get_expand_h { shift->{expand_h} }
Subroutine get_expand_h: not called CC=1 SCAR=6.9
Pod undocumented
28 0 ▶sub get_expand_v { shift->{expand_v} }
Subroutine get_expand_v: not called CC=1 SCAR=6.9
Pod undocumented
29 0 ▶sub get_scrollbars { shift->{scrollbars} }
Subroutine get_scrollbars: not called CC=1 SCAR=6.9
Pod undocumented
30 0 ▶sub get_signal_connect { shift->{signal_connect} }
Subroutine get_signal_connect: not called CC=1 SCAR=6.9
Pod undocumented
31 0 ▶sub get_signal_connect_after { shift->{signal_connect_after} }
Subroutine get_signal_connect_after: not called CC=1 SCAR=6.9
Pod undocumented
32 0 ▶sub get_width { shift->{width} }
Subroutine get_width: not called CC=1 SCAR=6.9
Pod undocumented
33 0 ▶sub get_height { shift->{height} }
Subroutine get_height: not called CC=1 SCAR=6.9
Pod undocumented
34 0 ▶sub get_customize_hook { shift->{customize_hook} }
Subroutine get_customize_hook: not called CC=1 SCAR=6.9
Pod undocumented
35 0 ▶sub get_changed_hook { shift->{changed_hook} }
Subroutine get_changed_hook: not called CC=1 SCAR=6.9
Pod undocumented
36 0 ▶sub get_changed_hook_after { shift->{changed_hook_after} }
Subroutine get_changed_hook_after: not called CC=1 SCAR=6.9
Pod undocumented
37 0 ▶sub get_active_cond { shift->{active_cond} }
Subroutine get_active_cond: not called CC=1 SCAR=6.9
Pod undocumented
38 0 ▶sub get_active_depends { shift->{active_depends} }
Subroutine get_active_depends: not called CC=1 SCAR=6.9
Pod undocumented
39 #------------------------------------------------------------------------
40 0 ▶sub set_name { shift->{name} = $_[1] }
Subroutine set_name: not called CC=1 SCAR=6.9
Pod undocumented
41 0 ▶sub set_object { shift->{object} = $_[1] }
Subroutine set_object: not called CC=1 SCAR=6.9
Pod undocumented
42 0 ▶sub set_attr { shift->{attr} = $_[1] }
Subroutine set_attr: not called CC=1 SCAR=6.9
Pod undocumented
43 0 ▶sub set_properties { shift->{properties} = $_[1] }
Subroutine set_properties: not called CC=1 SCAR=6.9
Pod undocumented
44 0 ▶sub set_label { shift->{label} = $_[1] }
Subroutine set_label: not called CC=1 SCAR=6.9
Pod undocumented
45 0 ▶sub set_label_for { shift->{label_for} = $_[1] }
Subroutine set_label_for: not called CC=1 SCAR=6.9
Pod undocumented
46 0 ▶sub set_label_markup { shift->{label_markup} = $_[1] }
Subroutine set_label_markup: not called CC=1 SCAR=6.9
Pod undocumented
47 0 ▶sub set_label_group { shift->{label_group} = $_[1] }
Subroutine set_label_group: not called CC=1 SCAR=6.9
Pod undocumented
48 0 ▶sub set_widget_group { shift->{widget_group} = $_[1] }
Subroutine set_widget_group: not called CC=1 SCAR=6.9
Pod undocumented
49 0 ▶sub set_tip { shift->{tip} = $_[1] }
Subroutine set_tip: not called CC=1 SCAR=6.9
Pod undocumented
50 0 ▶sub set_inactive { shift->{inactive} = $_[1] }
Subroutine set_inactive: not called CC=1 SCAR=6.9
Pod undocumented
51 0 ▶sub set_active { shift->{active} = $_[1] }
Subroutine set_active: not called CC=1 SCAR=6.9
Pod undocumented
52 0 ▶sub set_rules { shift->{rules} = $_[1] }
Subroutine set_rules: not called CC=1 SCAR=6.9
Pod undocumented
53 0 ▶sub set_expand { shift->{expand} = $_[1] }
Subroutine set_expand: not called CC=1 SCAR=6.9
Pod undocumented
54 0 ▶sub set_expand_h { shift->{expand_h} = $_[1] }
Subroutine set_expand_h: not called CC=1 SCAR=6.9
Pod undocumented
55 0 ▶sub set_expand_v { shift->{expand_v} = $_[1] }
Subroutine set_expand_v: not called CC=1 SCAR=6.9
Pod undocumented
56 0 ▶sub set_scrollbars { shift->{scrollbars} = $_[1] }
Subroutine set_scrollbars: not called CC=1 SCAR=6.9
Pod undocumented
57 0 ▶sub set_signal_connect { shift->{signal_connect} = $_[1] }
Subroutine set_signal_connect: not called CC=1 SCAR=6.9
Pod undocumented
58 0 ▶sub set_signal_connect_after { shift->{signal_connect_after} = $_[1] }
Subroutine set_signal_connect_after: not called CC=1 SCAR=6.9
Pod undocumented
59 0 ▶sub set_width { shift->{width} = $_[1] }
Subroutine set_width: not called CC=1 SCAR=6.9
Pod undocumented
60 0 ▶sub set_height { shift->{height} = $_[1] }
Subroutine set_height: not called CC=1 SCAR=6.9
Pod undocumented
61 0 ▶sub set_customize_hook { shift->{customize_hook} = $_[1] }
Subroutine set_customize_hook: not called CC=1 SCAR=6.9
Pod undocumented
62 0 ▶sub set_changed_hook { shift->{changed_hook} = $_[1] }
Subroutine set_changed_hook: not called CC=1 SCAR=6.9
Pod undocumented
63 0 ▶sub set_changed_hook_after { shift->{changed_hook_after} = $_[1] }
Subroutine set_changed_hook_after: not called CC=1 SCAR=6.9
Pod undocumented
64 0 ▶sub set_active_cond { shift->{active_cond} = $_[1] }
Subroutine set_active_cond: not called CC=1 SCAR=6.9
Pod undocumented
65 0 ▶sub set_active_depends { shift->{active_depends} = $_[1] }
Subroutine set_active_depends: not called CC=1 SCAR=6.9
Pod undocumented
66 #========================================================================
67  
68 #========================================================================
69 # Accessors for internal attributes
70 #========================================================================
71 0 ▶sub get_context { shift->{form_factory}->get_context }
Subroutine get_context: not called CC=1 SCAR=6.9
Pod undocumented
72 0 ▶sub get_form_factory { shift->{form_factory} }
Subroutine get_form_factory: not called CC=1 SCAR=6.9
Pod undocumented
73 0 ▶sub get_parent { shift->{parent} }
Subroutine get_parent: not called CC=1 SCAR=6.9
Pod undocumented
74 0 ▶sub get_gtk_widget { shift->{gtk_widget} }
Subroutine get_gtk_widget: not called CC=1 SCAR=6.9
Pod undocumented
75 0 ▶sub get_gtk_parent_widget { $_[0]->{gtk_parent_widget} ||
Subroutine get_gtk_parent_widget: not called CC=2 SCAR=17.9
Pod undocumented
76 0 ▶ $_[0]->{gtk_widget} }
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"gtk_parent_widget"} or $_[0]{"gtk_widget"} 0 0 0
77 0 ▶sub get_gtk_properties_widget { $_[0]->{gtk_properties_widget} ||
Subroutine get_gtk_properties_widget: not called CC=2 SCAR=17.9
Pod documented
78 0 ▶ $_[0]->{gtk_widget} }
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"gtk_properties_widget"} or $_[0]{"gtk_widget"} 0 0 0
79 0 ▶sub get_gtk_label_widget { shift->{gtk_label_widget} }
Subroutine get_gtk_label_widget: not called CC=1 SCAR=6.9
Pod undocumented
80 0 ▶sub get_layout_data { shift->{layout_data} }
Subroutine get_layout_data: not called CC=1 SCAR=6.9
Pod undocumented
81 0 ▶sub get_in_update { shift->{in_update} }
Subroutine get_in_update: not called CC=1 SCAR=6.9
Pod undocumented
82 0 ▶sub get_no_widget_update { shift->{no_widget_update} }
Subroutine get_no_widget_update: not called CC=1 SCAR=6.9
Pod undocumented
83 0 ▶sub get_backup_widget_value { shift->{backup_widget_value} }
Subroutine get_backup_widget_value: not called CC=1 SCAR=6.9
Pod undocumented
84 0 ▶sub get_widget_activity { shift->{widget_activity} }
Subroutine get_widget_activity: not called CC=1 SCAR=6.9
Pod undocumented
85 0 ▶sub get_built { shift->{built} }
Subroutine get_built: not called CC=1 SCAR=6.9
Pod undocumented
86 #------------------------------------------------------------------------
87 0 ▶sub set_form_factory { weaken( shift->{form_factory} = $_[1])}
Subroutine set_form_factory: not called CC=1 SCAR=6.9
Pod undocumented
88 0 ▶sub set_parent { weaken( shift->{parent} = $_[1])}
Subroutine set_parent: not called CC=1 SCAR=6.9
Pod undocumented
89 0 ▶sub set_gtk_widget { shift->{gtk_widget} = $_[1] }
Subroutine set_gtk_widget: not called CC=1 SCAR=6.9
Pod documented
90 0 ▶sub set_gtk_parent_widget { shift->{gtk_parent_widget} = $_[1] }
Subroutine set_gtk_parent_widget: not called CC=1 SCAR=6.9
Pod documented
91 0 ▶sub set_gtk_properties_widget { shift->{gtk_properties_widget}= $_[1] }
Subroutine set_gtk_properties_widget: not called CC=1 SCAR=6.9
Pod undocumented
92 0 ▶sub set_gtk_label_widget { shift->{gtk_label_widget} = $_[1] }
Subroutine set_gtk_label_widget: not called CC=1 SCAR=6.9
Pod undocumented
93 0 ▶sub set_layout_data { shift->{layout_data} = $_[1] }
Subroutine set_layout_data: not called CC=1 SCAR=6.9
Pod undocumented
94 0 ▶sub set_in_update { shift->{in_update} = $_[1] }
Subroutine set_in_update: not called CC=1 SCAR=6.9
Pod undocumented
95 0 ▶sub set_no_widget_update { shift->{no_widget_update} = $_[1] }
Subroutine set_no_widget_update: not called CC=1 SCAR=6.9
Pod undocumented
96 0 ▶sub set_backup_widget_value { shift->{backup_widget_value} = $_[1] }
Subroutine set_backup_widget_value: not called CC=1 SCAR=6.9
Pod undocumented
97 0 ▶sub set_widget_activity { shift->{widget_activity} = $_[1] }
Subroutine set_widget_activity: not called CC=1 SCAR=6.9
Pod undocumented
98 0 ▶sub set_built { shift->{built} = $_[1] }
Subroutine set_built: not called CC=1 SCAR=6.9
Pod undocumented
99 #========================================================================
100  
101 #========================================================================
102 # Methods, which may be implemented by Widget subclasses
103 #========================================================================
104 0 ▶sub get_type { die $_[0]." misses type() method" }
Subroutine get_type: not called CC=1 SCAR=6.9
Pod documented
105 0 ▶sub get_gtk_signal_widget { $_[0]->get_gtk_widget }
Subroutine get_gtk_signal_widget: not called CC=1 SCAR=6.9
Pod documented
106 0 ▶sub get_gtk_tip_widgets { [ $_[0]->get_gtk_widget ] }
Subroutine get_gtk_tip_widgets: not called CC=1 SCAR=6.9
Pod documented
107 0 ▶sub get_gtk_check_widget { $_[0]->get_gtk_widget }
Subroutine get_gtk_check_widget: not called CC=1 SCAR=6.9
Pod documented
108 0 ▶sub get_widget_check_value { undef }
Subroutine get_widget_check_value: not called CC=1 SCAR=6.9
Pod documented
109 0 ▶sub has_additional_attrs { "" }
Subroutine has_additional_attrs: not called CC=1 SCAR=6.9
Pod documented
110 0 ▶sub has_label { 0 }
Subroutine has_label: not called CC=1 SCAR=6.9
Pod documented
111 0 ▶sub object_to_widget { 1 }
Subroutine object_to_widget: not called CC=1 SCAR=6.9
Pod documented
112 0 ▶sub widget_to_object { 1 }
Subroutine widget_to_object: not called CC=1 SCAR=6.9
Pod documented
113 0 ▶sub empty_widget { 1 }
Subroutine empty_widget: not called CC=1 SCAR=6.9
Pod documented
114 0 ▶sub backup_widget_value { 1 }
Subroutine backup_widget_value: not called CC=1 SCAR=6.9
Pod documented
115 0 ▶sub restore_widget_value { 1 }
Subroutine restore_widget_value: not called CC=1 SCAR=6.9
Pod documented
116 0 ▶sub isa_container { 0 }
Subroutine isa_container: not called CC=1 SCAR=6.9
Pod undocumented
117 0 ▶sub widget_data_has_changed { $_[0]->get_backup_widget_value ne
Subroutine widget_data_has_changed: not called CC=1 SCAR=6.9
Pod undocumented
118 $_[0]->get_widget_check_value }
119  
120 #========================================================================
121  
122 #========================================================================
123 # Widget constructor - must be called by subclasses
124 #========================================================================
125 0 ▶sub new {
Subroutine new: not called CC=18 SCAR=58.3
Pod undocumented
126 0 my $class = shift;
127 0 my %par = @_;
128 my ($name, $object, $attr, $properties, $label, $label_group) =
129 0 @par{'name','object','attr','properties','label','label_group'};
130 my ($widget_group, $inactive, $rules, $expand, $scrollbars) =
131 0 @par{'widget_group','inactive','rules','expand','scrollbars'};
132 my ($signal_connect, $width, $height, $customize_hook) =
133 0 @par{'signal_connect','width','height','customize_hook'};
134 my ($changed_hook, $tip, $expand_h, $expand_v, $label_markup) =
135 0 @par{'changed_hook','tip','expand_h','expand_v','label_markup'};
136 my ($active, $signal_connect_after, $label_for) =
137 0 @par{'active','signal_connect_after','label_for'};
138 my ($active_cond, $active_depends, $changed_hook_after) =
139 0 @par{'active_cond','active_depends','changed_hook_after'};
140  
141 0 ▶ $active = 1 if not defined $active;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $active 0 0 0
142  
143 #-- Short notation: 'object.attr', so you may omit 'object'
144 0 ▶ if ( $attr and $attr =~ /^([^.]+)\.(.*)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr and $attr =~ /^([^.]+)\.(.*)/) 0 0 0
Condition0%0/3
$attr and $attr =~ /^([^.]+)\.(.*)/
!ll&&!rl&&r
000
MC/DC0%0/2
$attr and $attr =~ /^([^.]+)\.(.*)/
$attr $attr =~ /^([^.]+)\.(.*)/
Truth table0%0/3
A and B
A= $attrB= $attr =~ /^([^.]+)\.(.*)/
ABresult
0X0
100
111
145 0 $object = $1;
146 0 $attr = $2;
147 }
148  
149 #-- Set a default for the Widget's name
150 0 ▶ if ( not $name and $object and $attr ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $name and $object and $attr) { } 0 0 0
elsif (not $name) { } 0 0 0
Condition0%0/6
not $name and $object and $attr
!ll&&!rl&&r
000
not $name and $object
!ll&&!rl&&r
000
MC/DC0%0/3
not $name and $object and $attr
not $name $object $attr
Truth table0%0/4
not(A) and B and C
A= not $nameB= $objectC= $attr
ABCresult
0XX0
10X0
1100
1111
151 #-- Default name is object.attr, if both
152 #-- object and attr are set
153 0 my $cnt = 1;
154 0 my $add = "";
155 #-- Add a number, if the name is registered already
156 0 ▶ while ( exists $WIDGET_NAMES{"$object.$attr$add"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $WIDGET_NAMES{"$object.$attr$add"}) 0 0 0
157 0 ++$cnt;
158 0 $add="_$cnt";
159 }
160 0 $name = "$object.$attr$add";
161  
162 } elsif ( not $name ) {
163 #-- Widgets non associated with an object and
164 #-- an attribute get a name derived from the
165 #-- Widget's type
166 0 ▶ $name ||= $class->get_type."_".$NAME_CNT++;
Condition0%0/2
$name ||= $class->get_type . '_' . $NAME_CNT++
l!l
00
MC/DC0%0/1
$name ||= $class->get_type . '_' . $NAME_CNT++
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
167 }
168  
169 #-- Check if widget name is not already registered
170 croak "Widget name '$name' is already registered"
171 0 ▶ if exists $WIDGET_NAMES{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $WIDGET_NAMES{$name} 0 0 0
172  
173 #-- Store widget name
174 0 $WIDGET_NAMES{$name} = 1;
175  
176 #-- By default make widget insensitive when it's not active
177 0 ▶ $inactive ||= "insensitive";
Condition0%0/2
$inactive ||= "insensitive"
l!l
00
MC/DC0%0/1
$inactive ||= "insensitive"
$inactive
Truth table0%0/2
A
A= $inactive
Aresult
11
00
178
179 #-- Expanding defaults
180 0 ▶ $expand_h = $expand_v = $expand if defined $expand;
Branch: 1 branch
BranchTrueFalseTotal
if defined $expand 0 0 0
181 0 ▶ $expand = 0 unless defined $expand;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expand 0 0 0
182 0 ▶ $expand_h = 1 unless defined $expand_h;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expand_h 0 0 0
183 0 ▶ $expand_v = 0 unless defined $expand_v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expand_v 0 0 0
184
185 0 ▶ croak "'inactive' must be 'insensitive' or 'invisible'"
Branch: 1 branch
BranchTrueFalseTotal
unless $inactive eq "insensitive" or $inactive eq "invisible" 0 0 0
Condition0%0/3
$inactive eq "insensitive" or $inactive eq "invisible"
l!l&&r!l&&!r
000
MC/DC0%0/2
$inactive eq "insensitive" or $inactive eq "invisible"
$inactive eq "insensitive" $inactive eq "invisible"
Truth table0%0/3
A or B
A= $inactive eq "insensitive"B= $inactive eq "invisible"
ABresult
1X1
011
000
186 unless $inactive eq 'insensitive' or
187 $inactive eq 'invisible';
188  
189 0 my $self = bless {
190 name => $name,
191 object => $object,
192 attr => $attr,
193 properties => $properties,
194 label => $label,
195 label_for => $label_for,
196 label_group => $label_group,
197 label_markup => $label_markup,
198 widget_group => $widget_group,
199 tip => $tip,
200 active => $active,
201 inactive => $inactive,
202 rules => $rules,
203 expand => $expand,
204 expand_h => $expand_h,
205 expand_v => $expand_v,
206 scrollbars => $scrollbars,
207 signal_connect => $signal_connect,
208 signal_connect_after => $signal_connect_after,
209 width => $width,
210 height => $height,
211 customize_hook => $customize_hook,
212 changed_hook => $changed_hook,
213 changed_hook_after => $changed_hook_after,
214 active_cond => $active_cond,
215 active_depends => $active_depends,
216 layout_data => {},
217 }, $class;
218
219 0 return $self;
220 }
221  
222 0 ▶sub debug_dump {
Subroutine debug_dump: not called CC=1 SCAR=6.9
Pod undocumented
223 0 my $self = shift;
224 0 my ($level) = @_;
225 0 print " "x$level;
226 0 print $self->{name}."|".$self->{attr}."\n";
227 0 1;
228 }
229  
230 #========================================================================
231 # Cleanup of widget data; break circular references
232 #========================================================================
233 0 ▶sub cleanup {
Subroutine cleanup: not called CC=2 SCAR=17.9
Pod undocumented
234 0 my $self = shift;
235
236 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print "CLEANUP: $self " . $self->get_name . '(' . $self->get_attr . ")\n" 0 0 0
237 print "CLEANUP: $self ".$self->get_name."(".$self->get_attr.")\n";
238
239 #-- Break circular references with the parent object
240 0 $self->set_parent(undef);
241
242 #-- Cut references to Gtk widgets - otherwise the Perl
243 #-- garbage collector is confused. We have heavy circular
244 #-- referencing from FormFactory widgets to Gtk widgets,
245 #-- e.g. from callback closures.
246 0 $self->set_gtk_widget(undef);
247 0 $self->set_gtk_parent_widget(undef);
248 0 $self->set_gtk_properties_widget(undef);
249 0 $self->set_gtk_label_widget(undef);
250  
251 #-- Deregister the Widget name
252 0 delete $WIDGET_NAMES{$self->get_name};
253  
254 #-- Delete all references to this widget from the
255 #-- associated Context
256 0 $self->get_context->deregister_widget ($self);
257
258 #-- Destroy reference to the FormFactory
259 0 $self->set_form_factory(undef);
260  
261 0 1;
262 }
263  
264 #========================================================================
265 # Convenience method: get Object Proxy of this Widget
266 #========================================================================
267 0 ▶sub get_proxy {
Subroutine get_proxy: not called CC=1 SCAR=6.9
Pod documented
268 0 $_[0]->get_form_factory
269 ->get_context
270 ->get_proxy($_[0]->get_object);
271 }
272  
273 #========================================================================
274 # Build this Widget, using the FormFactory's Layout instance
275 #========================================================================
276 0 ▶sub build {
Subroutine build: not called CC=2 SCAR=17.9
Pod undocumented
277 0 my $self = shift;
278
279 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print "$self->build\n" 0 0 0
280 print "$self->build\n";
281
282 #-- The Layout object actually builds all widgets
283 0 $self->get_form_factory
284 ->get_layouter
285 ->build_widget($self);
286  
287 0 $self->set_built(1);
288  
289 0 1;
290 }
291  
292 #========================================================================
293 # Connect all Gtk signals of this widget
294 #========================================================================
295 0 ▶sub connect_signals {
Subroutine connect_signals: not called CC=7 SCAR=40.3
Pod undocumented
296 0 my $self = shift;
297  
298 #-- Some widgets have not Gtk pendant, so there
299 #-- may be no signal connecting at all
300 0 my $gtk_widget = $self->get_gtk_widget;
301 0 ▶ return unless $gtk_widget;
Branch: 1 branch
BranchTrueFalseTotal
unless $gtk_widget 0 0 0
302  
303 #-- Need the context
304 0 my $context = $self->get_context;
305  
306 #-- Register the widget here...
307 #-- (deregistering is done in ->cleanup)
308 0 $context->register_widget($self);
309  
310 #-- On focus-in we backup the current object value
311 #-- (probably we need to restore this if the user
312 #-- enters invalid data)
313 0 ▶ $self->get_gtk_check_widget->signal_connect ("focus-in-event", sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
314 0 $self->backup_widget_value;
315 0 0;
316 0 });
317  
318 #-- On focus-out we check for valid data
319 0 ▶ $self->get_gtk_check_widget->signal_connect ("focus-out-event", sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
320 0 $self->check_widget_value;
321 0 0;
322 0 });
323  
324 #-- Connect the changed signal, if the widgets provides
325 #-- a method for this
326 0 ▶ $self->connect_changed_signal
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("connect_changed_signal") 0 0 0
327 if $self->can("connect_changed_signal");
328  
329 #-- Connect additional user specified signals
330 0 my $signal_connect = $self->get_signal_connect;
331 0 ▶ if ( $signal_connect ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($signal_connect) 0 0 0
332 0 my $signal_widget = $self->get_gtk_signal_widget;
333 0 ▶ while ( my ($signal, $callback) = each %{$signal_connect} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$signal_connect;}) 0 0 0
334 0 $signal_widget->signal_connect ( $signal => $callback );
335 }
336 }
337  
338 #-- Connect additional user specified signals (after)
339 0 my $signal_connect_after = $self->get_signal_connect_after;
340 0 ▶ if ( $signal_connect_after ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($signal_connect_after) 0 0 0
341 0 my $signal_widget = $self->get_gtk_signal_widget;
342 0 ▶ while ( my ($signal, $callback) = each %{$signal_connect_after} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$signal_connect_after;}) 0 0 0
343 0 $signal_widget->signal_connect ( $signal => $callback );
344 }
345 }
346 0 1;
347 }
348  
349 #========================================================================
350 # Lookup a widget
351 #========================================================================
352 0 ▶sub get_widget {
Subroutine get_widget: not called CC=2 SCAR=17.9
Pod documented
353 0 my $self = shift;
354 0 my ($name) = @_;
355
356 0 my $widget;
357 0 my $form_factory = $self->get_form_factory;
358  
359 croak "Widget '$name' not registered to this ".
360 "form factory ('".$form_factory->get_name."')"
361 0 ▶ unless $widget = $form_factory->get_widgets_by_name->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $widget = $form_factory->get_widgets_by_name->{$name} 0 0 0
362  
363 0 return $widget;
364 }
365  
366  
367 #========================================================================
368 # Lookup a widget reference
369 #========================================================================
370 0 ▶sub lookup_widget {
Subroutine lookup_widget: not called CC=7 SCAR=40.3
Pod documented
371 0 my $self = shift;
372 0 my ($name) = @_;
373
374 0 ▶ if ( $name =~ /sibling\s*\((.*?)\)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /sibling\s*\((.*?)\)/) { } 0 0 0
375 0 my $sibling_idx = $1;
376 0 my $siblings = $self->get_parent->get_content;
377 0 my $self_idx;
378 0 foreach my $sibling ( @{$siblings} ) {
379 0 ▶ if ( $sibling eq $self ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sibling eq $self) 0 0 0
380 0 ▶ $self_idx ||= 0;
Condition0%0/2
$self_idx ||= 0
l!l
00
MC/DC0%0/1
$self_idx ||= 0
$self_idx
Truth table0%0/2
A
A= $self_idx
Aresult
11
00
381 0 last;
382 }
383 0 ++$self_idx;
384 }
385 0 ▶ die "Impossible" unless defined $self_idx;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self_idx 0 0 0
386 0 my $sibling = $siblings->[$sibling_idx+$self_idx];
387 0 ▶ die "Can't find sibling($sibling_idx)" unless $sibling;
Branch: 1 branch
BranchTrueFalseTotal
unless $sibling 0 0 0
388 0 return $sibling;
389 } else {
390 0 return $self->get_form_factory->get_widget($name);
391 }
392 }
393  
394 #========================================================================
395 # Update this widgets resp. transfer the object's value to the Widget
396 #========================================================================
397 0 ▶sub update {
Subroutine update: not called CC=15 SCAR=54.8
Pod documented
398 0 my $self = shift;
399 0 my ($change_state) = @_;
400  
401 0 ▶ $change_state = '' if not defined $change_state;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $change_state 0 0 0
402  
403 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print 'update_widget(' . $self->get_name . ", $change_state)\n" 0 0 0
404 print "update_widget(".$self->get_name.", $change_state)\n";
405  
406 #-- Check if widget updating is temoprarily disabled
407 #-- (refer to widget_value_changed() for this)
408 0 ▶ return if $self->get_no_widget_update;
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_no_widget_update 0 0 0
409
410 #-- Is no object associated with this widget?
411 0 ▶ if ( not $self->get_object ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->get_object) 0 0 0
412 #-- Only a activity update may be possible, if
413 #-- an Gtk widget is present at all
414 0 ▶ if ( $self->get_gtk_parent_widget ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_gtk_parent_widget) 0 0 0
415 0 my $active = $self->get_active;
416 0 ▶ $active = $active ? "active" : "inactive";
Branch: 1 branch
BranchTrueFalseTotal
$active ? : 0 0 0
417 0 $self->update_widget_activity ( $active );
418 }
419 0 return;
420 }
421  
422 #-- We're going to change the widget's state. This will
423 #-- trigger the widget's changed signal. To prevent, that
424 #-- this triggers an object update again, we set this
425 #-- widget into update state (refer to widget_value_changed()
426 #-- for details)
427 0 $self->set_in_update(1);
428  
429 #-- Do we have an activity update? (if $change state is given,
430 #-- and contains the string 'inactive') - Default is to detect
431 #-- activity by the correspondent Proxy method (see below)
432 0 my $active;
433 0 ▶ $active = $change_state =~ /inactive/ ? 0 : 1
Branch: 2 branches
BranchTrueFalseTotal
if $change_state ne "" 0 0 0
$change_state =~ /inactive/ ? : 0 0 0
434 if $change_state ne '';
435  
436 #-- Now transform the object's activity state into a
437 #-- correspondent widget sensivity/visibility.
438 0 ▶ if ( $self->get_object and $self->get_gtk_parent_widget ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_object and $self->get_gtk_parent_widget) 0 0 0
Condition0%0/3
$self->get_object and $self->get_gtk_parent_widget
!ll&&!rl&&r
000
MC/DC0%0/2
$self->get_object and $self->get_gtk_parent_widget
$self->get_object $self->get_gtk_parent_widget
Truth table0%0/3
A and B
A= $self->get_objectB= $self->get_gtk_parent_widget
ABresult
0X0
100
111
439 #-- Get object's activity state
440 0 ▶ $active = $self->get_proxy($self->get_object)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $active 0 0 0
441 ->get_attr_activity($self->get_attr)
442 if not defined $active;
443  
444 #-- And set visibility or sensitivity accordingly,
445 #-- dependend on what's defined in the widget
446 0 $self->update_widget_activity ( $active );
447 }
448  
449 #-- Transfer object value to widget
450 0 ▶ if ( $change_state eq '' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($change_state eq '') { } 0 0 0
elsif ($change_state =~ /empty/) { } 0 0 0
451 0 ▶ $self->object_to_widget
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_proxy->get_object 0 0 0
452 if $self->get_proxy->get_object;
453 } elsif ( $change_state =~ /empty/ ) {
454 0 $self->empty_widget;
455 }
456  
457 #-- Set widget into normal update state
458 0 $self->set_in_update(0);
459  
460 0 1;
461 }
462  
463 #========================================================================
464 # Update this widget, and it's child; overwritten by Container class
465 #========================================================================
466 0 ▶sub update_all {
Subroutine update_all: not called CC=1 SCAR=6.9
Pod documented
467 0 my $self = shift;
468
469 #-- For a non Container widget, this is the same as update()
470 0 $self->update(@_);
471
472 0 1;
473 }
474  
475 #========================================================================
476 # Update this widget's activity state: (in)sensitive / (in)visible
477 #========================================================================
478 0 ▶sub update_widget_activity {
Subroutine update_widget_activity: not called CC=23 SCAR=63.1
Pod documented
479 0 my $self = shift;
480 0 my ($active) = @_;
481
482 0 ▶ $active = 0 if $active eq 'inactive';
Branch: 1 branch
BranchTrueFalseTotal
if $active eq "inactive" 0 0 0
483
484 #-- Use the Widget's activity value over the given $active
485 0 ▶ if ( defined $self->get_widget_activity ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->get_widget_activity) 0 0 0
486 0 $active = $self->get_widget_activity;
487 }
488  
489 #-- Get associated object (if there is one)
490 0 my $object_name = $self->get_object;
491 0 ▶ my $object = $object_name ? $self->get_proxy->get_object : undef;
Branch: 1 branch
BranchTrueFalseTotal
$object_name ? : 0 0 0
492
493 #-- If there is an object association but the object is
494 #-- currently not defined, set widget inactive
495 0 ▶ if ( $object_name && ! defined $object ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object_name and not defined $object) { } 0 0 0
Condition0%0/3
$object_name and not defined $object
!ll&&!rl&&r
000
MC/DC0%0/2
$object_name and not defined $object
$object_name not defined $object
Truth table0%0/3
A and not(B)
A= $object_nameB= not defined $object
ABresult
0X0
100
111
496 0 $active = 0;
497 }
498 #-- Otherwise check if an additional condition needs to be applied
499 else {
500 0 my $cond = $self->get_active_cond;
501 0 ▶ $active = &$cond($object) if $cond;
Branch: 1 branch
BranchTrueFalseTotal
if $cond 0 0 0
502 }
503  
504 0 my $action = $self->get_inactive;
505  
506 0 ▶ if ( $active eq 'insensitive' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($active eq 'insensitive') { } 0 0 0
elsif ($active eq 'invisible') { } 0 0 0
elsif ($active eq 'sensitive') { } 0 0 0
elsif ($active eq 'visible') { } 0 0 0
507 0 $action = "insensitive";
508 0 $active = 0;
509 }
510 elsif ( $active eq 'invisible' ) {
511 0 $action = "invisible";
512 0 $active = 0;
513 }
514 elsif ( $active eq 'sensitive' ) {
515 0 $action = "insensitive";
516 0 $active = 1;
517 }
518 elsif ( $active eq 'visible' ) {
519 0 $action = "invisible";
520 0 $active = 1;
521 }
522  
523 0 ▶ if ( $active ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($active) { } 0 0 0
524 #-- Make the widget visible resp. sensitive
525 0 ▶ if ( $action eq 'invisible' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq 'invisible') { } 0 0 0
526 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print ' update_widget_activity(' . $self->get_name . ", show)\n" 0 0 0
527 print " update_widget_activity(".
528 $self->get_name.
529 ", show)\n";
530 0 $self->get_gtk_parent_widget->show;
531 0 ▶ $self->get_gtk_label_widget->show
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_gtk_label_widget 0 0 0
532 if $self->get_gtk_label_widget;
533 } else {
534 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print ' update_widget_activity(' . $self->get_name . ", sensitive)\n" 0 0 0
535 print " update_widget_activity(".
536 $self->get_name.
537 ", sensitive)\n";
538 0 $self->get_gtk_parent_widget->show;
539 0 ▶ $self->get_gtk_label_widget->show
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_gtk_label_widget 0 0 0
540 if $self->get_gtk_label_widget;
541 0 $self->get_gtk_parent_widget->set_sensitive(1);
542 0 ▶ $self->get_gtk_label_widget->set_sensitive(1)
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_gtk_label_widget 0 0 0
543 if $self->get_gtk_label_widget;
544 }
545
546 } else {
547 #-- Make the widget invisible resp. insensitive
548 0 ▶ if ( $action eq 'invisible' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq 'invisible') { } 0 0 0
549 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print ' update_widget_activity(' . $self->get_name . ", hide)\n" 0 0 0
550 print " update_widget_activity(".
551 $self->get_name.
552 ", hide)\n";
553 0 $self->get_gtk_parent_widget->hide;
554 0 ▶ $self->get_gtk_label_widget->hide
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_gtk_label_widget 0 0 0
555 if $self->get_gtk_label_widget;
556 } else {
557 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print ' update_widget_activity(' . $self->get_name . ", insensitive)\n" 0 0 0
558 print " update_widget_activity(".
559 $self->get_name.
560 ", insensitive)\n";
561 0 $self->get_gtk_parent_widget->set_sensitive(0);
562 0 ▶ $self->get_gtk_label_widget->set_sensitive(0)
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_gtk_label_widget 0 0 0
563 if $self->get_gtk_label_widget;
564 }
565 }
566  
567 #-- Remember state
568 0 $self->set_active($active);
569  
570 0 1;
571 }
572  
573 #========================================================================
574 # Convenience method: get the Object's value
575 #========================================================================
576 0 ▶sub get_object_value {
Subroutine get_object_value: not called CC=3 SCAR=24.8
Pod documented
577 0 my $self = shift;
578 0 my ($attr) = @_;
579  
580 #-- By default get the primary attribute
581 0 ▶ $attr ||= $self->get_attr;
Condition0%0/3
$attr ||= $self->get_attr
l!l&&r!l&&!r
000
MC/DC0%0/2
$attr ||= $self->get_attr
$attr $self->get_attr
Truth table0%0/3
A ||= B
A= $attrB= $self->get_attr
ABresult
1X1
011
000
582  
583 #-- Return nothing if this widget has no associated Object
584 0 ▶ return if not $self->get_object;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->get_object 0 0 0
585  
586 #-- Otherweise use the Proxy to return the Object's value
587 0 return $self->get_proxy($self->get_object)
588 ->get_attr ($attr);
589 }
590  
591 #========================================================================
592 # Convenience method: set the Object's value
593 #========================================================================
594 0 ▶sub set_object_value {
Subroutine set_object_value: not called CC=3 SCAR=24.8
Pod documented
595 0 my $self = shift;
596 0 my ($attr, $value) = @_;
597  
598 #-- If only one argument is given this is the value of
599 #-- the default attribute of this widget
600 0 ▶ if ( @_ == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) 0 0 0
601 0 $value = $attr;
602 0 $attr = $self->get_attr;
603 }
604  
605 #-- Do nothing if this widget has no associated Object
606 0 ▶ return if not $self->get_object;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->get_object 0 0 0
607  
608 #-- Otherwise use the Proxy to set the Object's value
609 0 return $self->get_proxy($self->get_object)
610 ->set_attr ($attr => $value );
611 }
612  
613 #========================================================================
614 # Check the widget value against the specified rules
615 #========================================================================
616 0 ▶sub check_widget_value {
Subroutine check_widget_value: not called CC=6 SCAR=37.4
Pod documented
617 0 my $self = shift;
618
619 #-- Return true, if this Widget has no associated rules
620 0 my $rules = $self->get_rules;
621 0 ▶ return 1 if not defined $rules;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rules 0 0 0
622  
623 #-- Check only if data changed
624 0 ▶ return 1 unless $self->widget_data_has_changed;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->widget_data_has_changed 0 0 0
625  
626 #-- Rule checking is done by a Rules Object associated
627 #-- with the FormFactory of this Widget
628 0 my $rule_checker = $self->get_form_factory->get_rule_checker;
629  
630 0 my $message;
631 0 ▶ if ( $self->get_form_factory->get_sync && $self->get_object ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_form_factory->get_sync and $self->get_object) { } 0 0 0
Condition0%0/3
$self->get_form_factory->get_sync and $self->get_object
!ll&&!rl&&r
000
MC/DC0%0/2
$self->get_form_factory->get_sync and $self->get_object
$self->get_form_factory->get_sync $self->get_object
Truth table0%0/3
A and B
A= $self->get_form_factory->get_syncB= $self->get_object
ABresult
0X0
100
111
632 #-- If the FormFactory is in Sync mode, check
633 #-- the Object's value (access is faster than getting
634 #-- the Widget value)
635 0 $message = $rule_checker->check (
636 $rules,
637 $self->get_label,
638 $self->get_object_value
639 );
640 } else {
641 #-- If the FormFactory is not in Sync mode, the
642 #-- Widget value is checked
643 0 $message = $rule_checker->check (
644 $rules,
645 $self->get_label,
646 $self->get_widget_check_value
647 );
648 }
649  
650 #-- Restore the Widget value and print an error dialog,
651 #-- if the Rule check failed.
652 0 ▶ if ( $message ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($message) 0 0 0
653 0 $self->restore_widget_value;
654 0 $self->show_error_message (
655 message => $message,
656 );
657 }
658
659 0 return 0;
660 }
661  
662 #========================================================================
663 # Callback method, called if the user changed the Widget
664 #========================================================================
665 0 ▶sub widget_value_changed {
Subroutine widget_value_changed: not called CC=10 SCAR=47.0
Pod documented
666 0 my $self = shift;
667  
668 #-- Do nothing if this Widget is already in update state
669 #-- (otherwise recursive updates may be triggered)
670 0 ▶ return if $self->get_in_update;
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_in_update 0 0 0
671
672 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print $self->get_type . '(' . $self->get_name . ") value changed\n" 0 0 0
673 print $self->get_type."(".$self->get_name.") value changed\n";
674  
675 0 ▶ my $object = $self->get_object ? $self->get_proxy->get_object : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->get_object ? : 0 0 0
676  
677 0 ▶ if ( $self->get_form_factory->get_sync ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_form_factory->get_sync) { } 0 0 0
678 #-- Call the Widget's change hook
679 0 my $changed_hook = $self->get_changed_hook;
680 0 ▶ &$changed_hook($object, $self)
Branch: 1 branch
BranchTrueFalseTotal
if $changed_hook 0 0 0
681 if $changed_hook;
682  
683 #-- Apply all changes and update dependent
684 #-- widgets accordingly
685 0 ▶ $self->apply_changes if $object;
Branch: 1 branch
BranchTrueFalseTotal
if $object 0 0 0
686  
687 #-- Call Widget's change_after_hook
688 0 my $changed_hook_after = $self->get_changed_hook_after;
689 0 ▶ &$changed_hook_after($object, $self)
Branch: 1 branch
BranchTrueFalseTotal
if $changed_hook_after 0 0 0
690 if $changed_hook_after;
691  
692 } else {
693 #-- Changing the object normally triggers this
694 #-- change also in the widget (refer to
695 #-- Context->update_object_attr_widgets). We need
696 #-- to prevent this.
697 0 $self->set_no_widget_update(1);
698  
699 #-- Call the Widget's change hook, if one was set
700 0 my $changed_hook = $self->get_changed_hook;
701 0 ▶ &$changed_hook($object, $self)
Branch: 1 branch
BranchTrueFalseTotal
if $changed_hook 0 0 0
702 if $changed_hook;
703  
704 #-- Now update all dependent widgets
705 0 $self->get_form_factory
706 ->get_context
707 ->update_object_attr_widgets(
708 $self->get_object, $self->get_attr
709 );
710  
711 #-- Set widget into normal update state again
712 0 $self->set_no_widget_update(0);
713  
714 #-- Call Widget's change_after_hook
715 0 my $changed_hook_after = $self->get_changed_hook_after;
716 0 ▶ &$changed_hook_after($object, $self)
Branch: 1 branch
BranchTrueFalseTotal
if $changed_hook_after 0 0 0
717 if $changed_hook_after;
718 }
719  
720 0 1;
721 }
722  
723 #========================================================================
724 # Transfer the Widget value to the Object; no activity update
725 #========================================================================
726 0 ▶sub apply_changes {
Subroutine apply_changes: not called CC=2 SCAR=17.9
Pod documented
727 0 my $self = shift;
728  
729 0 ▶ $Gtk2::Ex::FormFactory::DEBUG &&
Branch: 1 branch
BranchTrueFalseTotal
$Gtk2::Ex::FormFactory::DEBUG and print 'apply_changes ' . $self->get_type . '(' . $self->get_name . ")\n" 0 0 0
730 print "apply_changes ".$self->get_type."(".$self->get_name.")\n";
731
732 #-- No widget update when setting the object value
733 0 $self->set_no_widget_update(1);
734  
735 #-- Set object value from current widget value
736 0 $self->widget_to_object;
737  
738 #-- Widget updates allowed again
739 0 $self->set_no_widget_update(0);
740
741 0 1;
742 }
743  
744 #========================================================================
745 # Apply all changes incl. children
746 # (here the samy as apply, overriden by Container)
747 #========================================================================
748 0 ▶sub apply_changes_all { shift->apply_changes }
Subroutine apply_changes_all: not called CC=1 SCAR=6.9
Pod undocumented
749  
750 #========================================================================
751 # Commit the Widget's Proxy Buffer (if Proxy is buffered at all)
752 #========================================================================
753 0 ▶sub commit_proxy_buffers {
Subroutine commit_proxy_buffers: not called CC=5 SCAR=34.0
Pod undocumented
754 0 my $self = shift;
755  
756 0 ▶ return unless $self->get_object;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->get_object 0 0 0
757  
758 #-- Nothing to do in synced FormFactories
759 #-- where the Proxy doesn't buffer
760 0 my $proxy = $self->get_proxy;
761 0 ▶ return 1 unless $proxy->get_buffered;
Branch: 1 branch
BranchTrueFalseTotal
unless $proxy->get_buffered 0 0 0
762
763 #-- Commit the Proxy's attribute buffer to the object
764 0 $proxy->commit_attr($self->get_attr);
765  
766 #-- And probably additional attributes...
767 0 ▶ if ( $self->has_additional_attrs ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_additional_attrs) 0 0 0
768 0 my $add_attrs = $self->has_additional_attrs;
769 0 my $object = $self->get_object;
770 0 foreach my $add_attr ( @{$add_attrs} ) {
771 0 my $get_attr_name_method = "get_attr_$add_attr";
772 0 my $attr = $self->$get_attr_name_method();
773 0 $proxy->commit_attr($attr);
774 }
775 }
776  
777 0 return 1;
778 }
779  
780 #========================================================================
781 # Commit proxy buffer changes incl. children
782 # (here the samy as apply, overriden by Container)
783 #========================================================================
784 0 ▶sub commit_proxy_buffers_all { shift->commit_proxy_buffers }
Subroutine commit_proxy_buffers_all: not called CC=1 SCAR=6.9
Pod undocumented
785  
786 #========================================================================
787 # Commit the Widget's Proxy Buffer (if Proxy is buffered at all)
788 #========================================================================
789 0 ▶sub discard_proxy_buffers {
Subroutine discard_proxy_buffers: not called CC=5 SCAR=34.0
Pod undocumented
790 0 my $self = shift;
791  
792 0 ▶ return unless $self->get_object;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->get_object 0 0 0
793  
794 #-- Nothing to do in synced FormFactories
795 #-- where the Proxy doesn't buffer
796 0 my $proxy = $self->get_proxy;
797 0 ▶ return 1 unless $proxy->get_buffered;
Branch: 1 branch
BranchTrueFalseTotal
unless $proxy->get_buffered 0 0 0
798
799 #-- Discard the Proxy's attribute buffer
800 0 $proxy->discard_attr($self->get_attr);
801  
802 #-- And probably additional attributes...
803 0 ▶ if ( $self->has_additional_attrs ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_additional_attrs) 0 0 0
804 0 my $add_attrs = $self->has_additional_attrs;
805 0 my $object = $self->get_object;
806 0 foreach my $add_attr ( @{$add_attrs} ) {
807 0 my $get_attr_name_method = "get_attr_$add_attr";
808 0 my $attr = $self->$get_attr_name_method();
809 0 $proxy->discard_attr($attr);
810 }
811 }
812  
813 0 return 1;
814 }
815  
816 #========================================================================
817 # Commit proxy buffer changes incl. children
818 # (here the samy as apply, overriden by Container)
819 #========================================================================
820 0 ▶sub discard_proxy_buffers_all { shift->discard_proxy_buffers }
Subroutine discard_proxy_buffers_all: not called CC=1 SCAR=6.9
Pod undocumented
821  
822 #========================================================================
823 # Show an error dialog
824 #========================================================================
825 0 ▶sub show_error_message {
Subroutine show_error_message: not called CC=2 SCAR=17.9
Pod documented
826 0 my $self = shift;
827 0 my %par = @_;
828 0 my ($message, $type) = @par{'message','type'};
829  
830 0 ▶ $type ||= "error";
Condition0%0/2
$type ||= "error"
l!l
00
MC/DC0%0/1
$type ||= "error"
$type
Truth table0%0/2
A
A= $type
Aresult
11
00
831  
832 0 $type = "GTK_MESSAGE_".uc($type);
833  
834 0 my $dialog = Gtk2::MessageDialog->new (
835 $self->get_form_factory->get_form_factory_gtk_window,
836 'GTK_DIALOG_DESTROY_WITH_PARENT',
837 $type,
838 'GTK_BUTTONS_CLOSE',
839 $message,
840 );
841  
842 0 ▶ $dialog->signal_connect( "response", sub { $dialog->destroy } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
843 0 $dialog->set_position ('center');
844 0 $dialog->set ( modal => 1 );
845 0 $dialog->show;
846  
847 0 1;
848 }
849  
850 2 1;
851  
852 __END__
↑ Summary FormFactory/Rules.pm »