Consistently "use strictures 2" in all source files.
[tails-persistence-setup.git] / lib / Tails / Persistence / Role / SetupStep.pm
blob06ef78ddd1cdf074e918f243af61492b0be0e8fe
1 =head1 NAME
3 Tails::Persistence::Role::SetupStep - role for persistence setup steps
5 =cut
7 package Tails::Persistence::Role::SetupStep;
9 use 5.10.0;
10 use strictures 2;
11 use autodie qw(:all);
13 use Glib qw{TRUE FALSE};
14 use Gtk3 qw{-init};
16 use Locale::gettext;
17 use POSIX;
18 setlocale(LC_MESSAGES, "");
19 textdomain("tails-persistence-setup");
21 use Moo::Role;
22 use MooX::late;
23 use namespace::clean;
25 with 'Tails::Role::HasEncoding';
26 with 'Tails::Persistence::Role::HasStatusArea';
28 requires '_build_main_box';
29 requires 'go_button_pressed';
32 =head1 ATTRIBUTES
34 =cut
36 has 'name' => (
37 required => 1,
38 is => 'ro',
39 isa => 'Str',
42 has 'main_box' => (
43 lazy_build => 1,
44 is => 'rw',
45 isa => 'Gtk3::VBox',
48 foreach (qw{title subtitle description}) {
49 has $_ => (
50 lazy_build => 1,
51 is => 'rw',
52 isa => 'Gtk3::Label',
56 has 'go_button' => (
57 lazy_build => 1,
58 is => 'rw',
59 isa => 'Gtk3::Button',
61 foreach (qw{go_callback success_callback}) {
62 has $_ => (
63 required => 1,
64 is => 'ro',
65 isa => 'CodeRef',
69 foreach (qw{drive_vendor drive_model}) {
70 has $_ => (
71 required => 1,
72 is => 'ro',
73 isa => 'Str',
78 =head1 CONSTRUCTORS
80 =cut
82 sub _build_title {
83 my $self = shift;
85 my $label = Gtk3::Label->new('');
86 $label->set_alignment(0.0, 0.5);
87 my $attrlist = Pango::AttrList->new;
88 $attrlist->insert($_)
89 foreach ( Pango::AttrScale->new(1.3),Pango::AttrWeight->new('bold') );
90 $label->set_attributes($attrlist);
91 $label->set_padding(10, 10);
93 return $label;
96 sub _build_subtitle {
97 my $self = shift;
99 my $label = Gtk3::Label->new('');
100 $label->set_alignment(0.0, 0.5);
101 my $attrlist = Pango::AttrList->new;
102 $attrlist->insert($_)
103 foreach ( Pango::AttrScale->new(1.1),Pango::AttrWeight->new('bold') );
104 $label->set_attributes($attrlist);
105 $label->set_padding(10, 10);
106 $label->set_line_wrap(TRUE);
107 $label->set_line_wrap_mode('word');
108 $label->set_single_line_mode(FALSE);
110 return $label;
113 sub _build_description {
114 my $self = shift;
116 my $label = Gtk3::Label->new('');
117 $label->set_alignment(0.0, 0.5);
118 $label->set_padding(10, 10);
119 $label->set_line_wrap(TRUE);
120 $label->set_line_wrap_mode('word');
121 $label->set_single_line_mode(FALSE);
123 return $label;
126 sub _build_go_button {
127 my $self = shift;
129 my $button = Gtk3::Button->new;
130 $button->set_sensitive(FALSE);
131 $button->set_can_default(TRUE);
132 $button->signal_connect('clicked', sub { $self->go_button_pressed });
134 return $button;
137 no Moo::Role;