blib/lib/Gtk2/Ex/FormFactory/Label.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 11 totaltotal 0.0% 0 / 61 CC 4 SCAR 18.7
CC
4
Cov
0%
object_to_widget
20.0
get_type
2.0
has_label
2.0
CRAP 6.5
1 package Gtk2::Ex::FormFactory::Label;
2  
3 use strict;
4  
5 use base qw( Gtk2::Ex::FormFactory::Widget );
6  
7 sub get_type { "label" }
8 sub has_label { shift->get_object eq '' }
9  
10 sub get_with_markup { shift->{with_markup} }
11 sub get_for { shift->{for} }
12 sub get_bold { shift->{bold} }
13  
14 sub set_with_markup { shift->{with_markup} = $_[1] }
15 sub set_for { shift->{for} = $_[1] }
16 sub set_bold { shift->{bold} = $_[1] }
17  
18 sub new {
19 my $class = shift;
20 my %par = @_;
21 my ($with_markup, $for, $bold) = @par{'with_markup','for','bold'};
22  
23 my $self = $class->SUPER::new(@_);
24
25 $self->set_with_markup($with_markup);
26 $self->set_for($for);
27 $self->set_bold($bold);
28
29 return $self;
30 }
31  
32 sub object_to_widget {
33 my $self = shift;
34  
35 return unless $self->get_attr;
36  
37 if ( $self->get_with_markup ) {
38 $self->get_gtk_widget->set_markup($self->get_object_value);
39 } elsif ( $self->get_bold ) {
40 $self->get_gtk_widget->set_markup("<b>".$self->get_object_value."</b>");
41 } else {
42 $self->get_gtk_widget->set_text($self->get_object_value);
43 }
44  
45 1;
46 }
47  
48 sub empty_widget {
49 my $self = shift;
50
51 $self->get_gtk_widget->set_text("");
52
53 1;
54 }
55  
56 1;
57  
58 __END__