tails-persistence-setup 2.2.1
[tails-persistence-setup.git] / lib / Tails / Persistence / Role / SetupStep.pm
blob16a18f8a06a0cc610c541f8b25d7c5d8cfe7af77
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.1;
10 use strictures 2;
11 use autodie qw(:all);
13 use Function::Parameters;
14 use Glib qw{TRUE FALSE};
15 use Gtk3 qw{-init};
17 use Locale::gettext;
18 use POSIX;
19 setlocale(LC_MESSAGES, "");
20 textdomain("tails-persistence-setup");
22 use Moo::Role;
23 use MooX::late;
24 use namespace::clean;
26 with 'Tails::Role::HasEncoding';
27 with 'Tails::Persistence::Role::HasStatusArea';
29 requires '_build_main_widget';
30 requires 'go_button_pressed';
33 =head1 ATTRIBUTES
35 =cut
37 has 'name' => (
38 required => 1,
39 is => 'ro',
40 isa => 'Str',
43 has 'main_widget' => (
44 lazy_build => 1,
45 is => 'rw',
46 isa => 'Gtk3::VBox',
49 foreach (qw{title subtitle description}) {
50 has $_ => (
51 lazy_build => 1,
52 is => 'rw',
53 isa => 'Gtk3::Label',
57 has 'go_button' => (
58 lazy_build => 1,
59 is => 'rw',
60 isa => 'Gtk3::Button',
62 foreach (qw{go_callback success_callback}) {
63 has $_ => (
64 required => 1,
65 is => 'ro',
66 isa => 'CodeRef',
70 foreach (qw{drive_vendor drive_model}) {
71 has $_ => (
72 required => 1,
73 is => 'ro',
74 isa => 'Str',
79 =head1 CONSTRUCTORS
81 =cut
83 method _build_title () {
84 my $label = Gtk3::Label->new('');
85 $label->set_alignment(0.0, 0.5);
86 my $attrlist = Pango::AttrList->new;
87 $attrlist->insert($_)
88 foreach ( Pango::AttrScale->new(1.3),Pango::AttrWeight->new('bold') );
89 $label->set_attributes($attrlist);
90 $label->set_padding(10, 10);
92 return $label;
95 method _build_subtitle () {
96 my $label = Gtk3::Label->new('');
97 $label->set_alignment(0.0, 0.5);
98 my $attrlist = Pango::AttrList->new;
99 $attrlist->insert($_)
100 foreach ( Pango::AttrScale->new(1.1),Pango::AttrWeight->new('bold') );
101 $label->set_attributes($attrlist);
102 $label->set_padding(10, 10);
103 $label->set_line_wrap(TRUE);
104 $label->set_line_wrap_mode('word');
105 $label->set_single_line_mode(FALSE);
107 return $label;
110 method _build_description () {
111 my $label = Gtk3::Label->new('');
112 $label->set_alignment(0.0, 0.5);
113 $label->set_padding(10, 10);
114 $label->set_line_wrap(TRUE);
115 $label->set_line_wrap_mode('word');
116 $label->set_single_line_mode(FALSE);
118 return $label;
121 method _build_go_button () {
122 my $button = Gtk3::Button->new;
123 $button->set_sensitive(FALSE);
124 $button->set_can_default(TRUE);
125 $button->signal_connect('clicked', sub { $self->go_button_pressed });
127 return $button;
130 no Moo::Role;