Dialogs/Meta/Widget/Trait/MessageDialog.pm untested

filter: Statementstmt 0.0% 0 / 56 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 79 CC 1 SCAR 6.9
CC
1
Cov
0%
_build_text_widget
2.0
_build_secondary_widget
2.0
register_implementation
2.0
CRAP 2.0
1 package GappX::Dialogs::Meta::Widget::Trait::MessageDialog;
2 {
3 $GappX::Dialogs::Meta::Widget::Trait::MessageDialog::VERSION = '0.005';
4 }
5  
6 use Moose::Role;
7 use MooseX::SemiAffordanceAccessor;
8  
9 use Gapp::Types qw( GappDialogImage );
10  
11 use Gapp::HBox;
12 use Gapp::Image;
13 use Gapp::Label;
14  
15  
16 has 'alert' => (
17 is => 'rw',
18 isa => 'Bool',
19 default => 0,
20 );
21  
22 has 'image' => (
23 is => 'ro',
24 isa => GappDialogImage,
25 default => sub {
26 Gapp::Image->new(
27 stock => [ 'gtk-dialog-info', 'dialog' ],
28 fill => 0,
29 expand => 0,
30 );
31 },
32 trigger => sub { $_[1]->set_fill(0); $_[1]->set_expand(0); },
33 coerce => 1,
34 lazy => 1,
35 );
36  
37 has 'text_widget' => (
38 is => 'ro',
39 isa => 'Gapp::Widget',
40 lazy_build => 1,
41 );
42  
43 sub _build_text_widget {
44 Gapp::Label->new(
45 markup => '<b>' . $_[0]->text . '</b>',
46 fill => 0,
47 expand => 0,
48 properties => { xalign => 0 }
49 );
50 };
51  
52 has 'secondary_widget' => (
53 is => 'ro',
54 isa => 'Gapp::Widget',
55 lazy_build => 1,
56 );
57  
58 sub _build_secondary_widget {
59 Gapp::Label->new(
60 markup => $_[0]->secondary,
61 fill => 0,
62 expand => 0,
63 properties => { xalign => 0, wrap => 1 }
64 );
65 };
66  
67 has 'text' => (
68 is => 'rw',
69 isa => 'Str',
70 default => '',
71 );
72  
73 has 'secondary' => (
74 is => 'rw',
75 isa => 'Str',
76 default => '',
77 );
78  
79 has 'hbox' => (
80 is => 'ro',
81 default => sub {
82 my $self = shift;
83 Gapp::HBox->new(
84 content => [
85 $self->image,
86
87 Gapp::VBox->new (
88 content => [ $self->text_widget, $self->secondary_widget ],
89 fill => 1,
90 expand => 1,
91 )
92
93 ],
94 fill => 1,
95 expand => 0,
96 );
97 },
98 lazy => 1,
99 );
100  
101 around BUILDARGS => sub {
102 my ( $orig, $class, %opts ) = @_;
103 $opts{buttons} ||= [ qw(gtk-ok ok) ];
104 $opts{icon} ||= 'gtk-dialog-info';
105 $opts{title} ||= '';
106 return $class->$orig( %opts );
107 };
108  
109 before '_build_gobject' => sub {
110 my ( $self ) = @_;
111 $self->add( $self->hbox );
112 };
113  
114 after '_build_gobject' => sub {
115 my ( $self ) = @_;
116 $self->hbox->gobject->show_all;
117 };
118  
119 before 'run' => sub {
120 print "\a\n" if $_[0]->alert;
121 };
122  
123 package Gapp::Meta::Widget::Custom::Trait::MessageDialog;
124 {
125 $Gapp::Meta::Widget::Custom::Trait::MessageDialog::VERSION = '0.005';
126 }
127 sub register_implementation { 'GappX::Dialogs::Meta::Widget::Trait::MessageDialog' };
128  
129  
130 1;
131  
132  
133  
134 __END__