Cookbook/Recipe03/Main.pm

filter: Statementstmt 100% 11 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 15 / 15 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Cookbook/Recipe03/About.pm ↑ Summary Cookbook/Recipe04/About.pm »
1 package Padre::Plugin::Cookbook::Recipe03::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  
7 # Version required
8 our $VERSION = '0.24';
9 2 ▶use parent qw( Padre::Plugin::Cookbook::Recipe03::FBP::MainFB );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 sub new {
13 my $class = shift;
14 my $main = shift;
15  
16 # Create the about
17 my $self = $class->SUPER::new($main);
18  
19 # add package name to main dialog #fails as min size naff
20 my @package = split /::/x, __PACKAGE__,;
21 $self->package_name->SetLabel( $package[3] );
22  
23 $self->CenterOnParent;
24  
25 return $self;
26 }
27  
28  
29 #######
30 # Event Handler Button About Clicked
31 #######
32 sub about_clicked {
33 my $self = shift;
34 my $main = $self->main;
35  
36 load_dialog_about($self);
37  
38 return;
39 }
40  
41  
42 #######
43 # Clean up our Classes, Padre::Plugin, POD out of date as of v0.84
44 #######
45 sub plugin_disable {
46 my $self = shift;
47  
48 # Close the dialog if it is hanging around
49 $self->clean_dialog;
50  
51 # Unload all our child classes
52 $self->unload(
53 qw{
54 Padre::Plugin::Cookbook::Recipe03::About
55 Padre::Plugin::Cookbook::Recipe03::FBP::AboutFB
56 }
57 );
58  
59 $self->SUPER::plugin_disable(@_);
60  
61 return 1;
62 }
63  
64 ########
65 # Composed Method,
66 # Load About Dialog, only once
67 #######
68 sub load_dialog_about {
69 my $self = shift;
70 my $main = $self->main;
71  
72 # Close the dialog if it is hanging around
73 $self->clean_dialog;
74  
75 # Create the new about
76 require Padre::Plugin::Cookbook::Recipe03::About;
77 $self->{dialog} = Padre::Plugin::Cookbook::Recipe03::About->new($main);
78 $self->{dialog}->ShowModal;
79  
80 return;
81 }
82  
83 ########
84 # Composed Method clean_dialog
85 ########
86 sub clean_dialog {
87 my $self = shift;
88  
89 # Close the main dialog if it is hanging around
90 if ( $self->{dialog} ) {
91 $self->{dialog}->Hide;
92 $self->{dialog}->Destroy;
93 delete $self->{dialog};
94 }
95  
96 return 1;
97 }
98 1;
99  
100 __END__
« Cookbook/Recipe03/About.pm ↑ Summary Cookbook/Recipe04/About.pm »