Cookbook/Recipe02/Main.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 19 / 19 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Cookbook/Recipe01/Main.pm ↑ Summary Cookbook/Recipe03/About.pm »
1 package Padre::Plugin::Cookbook::Recipe02::Main;
2  
3 2 ▶use v5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶no if $] > 5.017010, warnings => 'experimental';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Version required
9 our $VERSION = '0.24';
10 2 ▶use parent qw( Padre::Plugin::Cookbook::Recipe02::FBP::MainFB );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #######
13 # Method new
14 #######
15 sub new {
16 my $class = shift;
17  
18 # Padre main window integration
19 my $main = shift;
20  
21 # Create the dialog
22 my $self = $class->SUPER::new($main);
23  
24 # define where to display main dialog
25 $self->CenterOnParent;
26 return $self;
27 }
28  
29 my @items = qw/ zero one two three four five six /;
30 state $update_run_yes;
31  
32 #######
33 # Event Handler Button Output Clicked
34 #######
35 sub output_clicked {
36 my $self = shift;
37 my $main = $self->main;
38  
39 $main->show_output(1);
40 my $output = $main->output;
41 $output->clear;
42  
43 $output->AppendText("output cliked \n");
44 $output->AppendText( 'Name: ' . $self->name_value->GetValue() . "\n" );
45 if ($update_run_yes) {
46 $output->AppendText( 'Choice GetSelection: ' . $items[ $self->choices->GetSelection() ] . "\n" );
47 }
48 $output->AppendText( 'Choice GetCurrentSelection: ' . $self->choices->GetCurrentSelection() . "\n" );
49 $output->AppendText( 'User Name GetStringSelection: ' . $self->user_name->GetStringSelection() . "\n" );
50  
51 return;
52 }
53  
54 #######
55 # Event Handler Button Update Clicked
56 #######
57 sub update_clicked {
58 my $self = shift;
59 my $main = $self->main;
60 my $config = $main->config;
61  
62 $self->choices->Clear();
63 $update_run_yes = 1;
64 $self->choices->Append( \@items );
65 $self->choices->SetSelection(3);
66 $self->heading->SetLabel('I am in Control');
67  
68 set_name_label_value($self);
69  
70 return;
71 }
72  
73 #######
74 # Event Handler CheckMark TTennis Clicked
75 #######
76 sub ttennis_checked {
77 my $self = shift;
78 my $main = $self->main;
79  
80 $main->show_output(1);
81 my $output = $main->output;
82  
83 $output->AppendText("ttennis cliked \n");
84 if ( $self->ttennis->GetValue ) {
85 $output->AppendText("TRUE\n");
86 $self->ping->Enable;
87 $self->pong->Enable;
88 } else {
89 $output->AppendText("FALSE\n");
90 $self->ping->SetValue(0);
91 $self->pong->SetValue(0);
92 $self->ping->Disable;
93 $self->pong->Disable;
94 }
95 return;
96 }
97  
98 #######
99 # Event Handler CheckMark Ping Clicked
100 #######
101 sub ping_checked {
102 my $self = shift;
103 my $main = $self->main;
104  
105 # $main->show_output(1);
106 my $output = $main->output;
107 $output->AppendText("ping checked \n");
108 if ( $self->ping->GetValue ) {
109 $output->AppendText("TRUE\n");
110 $self->pong->SetValue(0);
111 } else {
112 $output->AppendText("FALSE\n");
113 }
114 return;
115 }
116  
117 #######
118 # Event Handler CheckMark Pong Clicked
119 #######
120 sub pong_checked {
121 my $self = shift;
122 my $main = $self->main;
123  
124 # $main->show_output(1);
125 my $output = $main->output;
126 $output->AppendText("pong checked \n");
127 if ( $self->pong->GetValue ) {
128 $output->AppendText("TRUE\n");
129 $self->ping->SetValue(0);
130 } else {
131 $output->AppendText("FALSE\n");
132 }
133 return;
134 }
135  
136 #######
137 # Composed Method set_name_label_value
138 #######
139 sub set_name_label_value {
140 my $self = shift;
141 my $main = $self->main;
142 my $config = $main->config;
143 my $output = $main->output;
144  
145 given ( $self->user_name->GetStringSelection() ) {
146 when ('nick') {
147 $self->name_label->SetLabel( 'user ' . $_ . ' name' );
148 $self->name_value->SetValue( $config->identity_nickname );
149 }
150 when ('cpan') {
151 $self->name_label->SetLabel( 'user ' . $_ . ' name' );
152 $self->name_value->SetValue( $config->identity_name );
153 }
154 when ('e-mail') {
155 $self->name_label->SetLabel( 'user ' . $_ . ' name' );
156 $self->name_value->SetValue( $config->identity_email );
157 }
158 default {
159 $output->AppendText("huston! we have a problem\n I think you have added another radio button option\n")
160 }
161 }
162 return;
163 }
164  
165 1;
166  
167 __END__
« Cookbook/Recipe01/Main.pm ↑ Summary Cookbook/Recipe03/About.pm »