lib/App/SeismicUnixGui/messages/help_button_messages.pm untested

filter: Statementstmt 0.0% 0 / 48 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 88 CC 8 SCAR 22.4
CC
8
Cov
0%
set_pdf
20.0
BEGIN
6.0
get
6.0
CRAP 9.4
1 package App::SeismicUnixGui::messages::help_button_messages;
2  
3 use Moose;
4 our $VERSION = '0.0.2';
5  
6 =head1 DOCUMENTATION
7  
8  
9 =head2 SYNOPSIS
10  
11 PERL PROGRAM NAME: help_button_messages.pm
12 AUTHOR: Juan Lorenzo
13 DATE: June 22 2017
14  
15 DESCRIPTION
16
17  
18 BASED ON:
19  
20
21 =cut
22  
23 =head2 USE
24  
25 =head3 NOTES
26  
27 =head4 Examples
28  
29 =head2 CHANGES and their DATE
30  
31 V 0.2.0 April 2023 Introduce viewing of pdf files
32  
33 =cut
34  
35 =head2 Notes from bash
36
37 =cut
38  
39 my $path4SeismicUnixGui;
40  
41 BEGIN {
42  
43 my $starting_point = '/';
44 my $path2find = "*/App/SeismicUnixGui/script";
45 my $fifo = 'tbd';
46  
47 if ( length $ENV{'SeismicUnixGui'} ) {
48  
49 $path4SeismicUnixGui = $ENV{'SeismicUnixGui'};
50  
51 }
52 else {
53 # When environment variables can not be found in Perl
54 # system(
55 #" echo \"find $starting_point -path \'$path2find\' -print 2>/dev/null > $fifo \" "
56 # );
57 system(
58 "find $starting_point -path \'$path2find\' -print > $fifo 2>/dev/null & "
59 );
60  
61 # wait around until the file is populated with something inside
62 while ( !( -e $fifo )
63 or ( -e $fifo and -z $fifo ) )
64 {
65 # print "waiting...\n";
66 }
67  
68 # read file contents
69 open my $fh, "<", $fifo or die "Can not open '$fifo': $!";
70  
71 chomp( my @script_list = <$fh> );
72  
73 close $fh;
74  
75 $path4SeismicUnixGui = $script_list[0] . '/..';
76 print(
77 "\nL24. Warning: Using default, help_button_messages, L_SU = $path4SeismicUnixGui\n"
78 );
79  
80 }
81  
82 }
83  
84 my $help_button_messages = {
85  
86 _About => 'About', # default
87 _item => 'item',
88  
89 };
90  
91 my sub clear {
92  
93 $help_button_messages->{_About} = '';
94 $help_button_messages->{_item} = '';
95  
96 }
97  
98 sub get {
99 my ($self) = @_;
100  
101 if ( length $help_button_messages->{_About} ) {
102  
103 my $item = $help_button_messages->{_About};
104 my $pathNmodule_pm = '../messages' . '/' . $item;
105  
106 # print("L_SU,help_menubutton,$pathNmodule_pm \n");
107 system("tkpod $pathNmodule_pm &\n\n");
108  
109 }
110 else {
111 print("help_button_messages, missing item\n");
112 }
113  
114 return ();
115 }
116  
117 sub get_pdf {
118 my ($self) = @_;
119  
120 if ( length $help_button_messages->{_item} ) {
121  
122 my $inbound_pdf =
123 $path4SeismicUnixGui . '/doc/' . $help_button_messages->{_item};
124  
125 # print("help_button_messages,get_pdf, $inbound_pdf\n");
126 system("evince $inbound_pdf &");
127  
128 }
129 else {
130 print("help_button_messages, missing item\n");
131 }
132  
133 return ();
134 }
135  
136 sub set {
137 my ( $self, $item ) = @_;
138  
139 if ( length $item ) {
140  
141 $help_button_messages->{_item} = $item;
142  
143 }
144 else {
145 print("help_button_messages, missing item\n");
146 }
147  
148 return ();
149 }
150  
151 sub set_pdf {
152 my ( $self, $item ) = @_;
153  
154 if ( length $item ) {
155  
156 if ( $item eq 'InstallationGuide' ) {
157  
158 $help_button_messages->{_item} =
159 'SeismicUnixGuiInstallationGuide0.87.6.pdf';
160  
161 }
162 elsif ( $item eq 'Tutorial' ) {
163  
164 $help_button_messages->{_item} =
165 'SeismicUnixGuiTutorial0.87.6.pdf';
166
167
168 } else{
169 print("help_button_messages, set_pdf, unexpectedly here\n");
170 print("help_button_messages, set_pdf, not ready for $item\n");
171 }
172  
173 }
174 else {
175 print("help_button_messages, set_pdf, missing item\n");
176 }
177  
178 return ();
179 }
180  
181 1;
182