Ticket #195: My.pm

File My.pm, 1.4 KB (added by richardh, 6 years ago)

My.pm plugin illustrating usage

Line 
1package Padre::Plugin::My;
2
3use 5.008;
4use strict;
5use warnings;
6use Padre::Wx ();
7
8use base 'Padre::Plugin';
9
10our $VERSION = '0.22';
11
12
13
14
15
16#####################################################################
17# Padre::Plugin Methods
18
19sub padre_interfaces {
20    'Padre::Plugin' => 0.19
21}
22
23sub plugin_name {
24    'My Plugin';
25}
26
27sub menu_plugins_simple {
28    my $self = shift;
29    return $self->plugin_name => [
30        'About' => sub { $self->about },
31        'Say Hello' => sub { $self->hello },
32        # 'A Sub-Menu...' => [
33        #     'Sub-Menu Entry' => sub { $self->about },
34        # ],
35    ];
36}
37
38
39
40
41
42#####################################################################
43# Custom Methods
44
45sub about {
46    my $self = shift;
47
48    # Locate this plugin
49    my $path = File::Spec->catfile(
50        Padre->ide->config_dir,
51        qw{ plugins Padre Plugin My.pm }
52    );
53
54    # Generate the About dialog
55    my $about = Wx::AboutDialogInfo->new;
56    $about->SetName("My Plugin");
57    $about->SetDescription( <<"END_MESSAGE" );
58The philosophy behind Padre is that every Perl programmer
59should be able to easily modify and improve their own editor.
60
61To help you get started, we've provided you with your own plugin.
62
63It is located in your configuration directory at:
64$path
65Open it with with Padre and you'll see an explanation on how to add items.
66END_MESSAGE
67
68    # Show the About dialog
69    Wx::AboutBox( $about );
70
71    return;
72}
73
74sub hello {
75    #Clear the results panel and say 'hello world'
76    my $self=shift;
77    $self->clear;
78    $self->say('hello world');
79   
80};
81