Gtk/Widget/Box.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 51 CC 6 SCAR 32.6
CC
6
Cov
0%
build
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 26.0
1 # You may distribute under the terms of the GNU General Public License
2 #
3 # (C) Paul Evans, 2008-2010 -- leonerd@leonerd.org.uk
4  
5 package Circle::FE::Gtk::Widget::Box;
6  
7 use strict;
8 use warnings;
9  
10 use constant type => "Box";
11  
12 use Glib qw( TRUE FALSE );
13  
14 sub build
15 {
16 my $class = shift;
17 my ( $obj, $tab ) = @_;
18  
19 my $orientation = $obj->prop("orientation");
20 my $widget;
21 if( $orientation eq "vertical" ) {
22 $widget = Gtk2::VBox->new();
23 }
24 elsif( $orientation eq "horizontal" ) {
25 $widget = Gtk2::HBox->new();
26 }
27 else {
28 die "Unrecognised orientation '$orientation'";
29 }
30  
31 my $do_end;
32  
33 foreach my $c ( @{ $obj->prop("children") } ) {
34 if( $c->{child} ) {
35 my $childwidget = $tab->build_widget( $c->{child} );
36 $widget->pack_start( $childwidget, $c->{expand}, $c->{expand}, 0 );
37 }
38 else {
39 # Ah.. Here's a spacer.
40 $do_end = 1;
41 last;
42 }
43 }
44  
45 if( $do_end ) {
46 foreach my $c ( reverse @{ $obj->prop("children") } ) {
47 last unless $c->{child};
48 my $childwidget = $tab->build_widget( $c->{child} );
49 $widget->pack_end( $childwidget, $c->{expand}, $c->{expand}, 0 );
50 }
51 }
52  
53 return $widget;
54 }
55  
56 1;