| 1 | package Padre::Plugin::My; |
|---|
| 2 | |
|---|
| 3 | use 5.008; |
|---|
| 4 | use strict; |
|---|
| 5 | use warnings; |
|---|
| 6 | use Padre::Wx (); |
|---|
| 7 | |
|---|
| 8 | use base 'Padre::Plugin'; |
|---|
| 9 | |
|---|
| 10 | our $VERSION = '0.22'; |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | ##################################################################### |
|---|
| 17 | # Padre::Plugin Methods |
|---|
| 18 | |
|---|
| 19 | sub padre_interfaces { |
|---|
| 20 | 'Padre::Plugin' => 0.19 |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | sub plugin_name { |
|---|
| 24 | 'My Plugin'; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | sub 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 | |
|---|
| 45 | sub 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" ); |
|---|
| 58 | The philosophy behind Padre is that every Perl programmer |
|---|
| 59 | should be able to easily modify and improve their own editor. |
|---|
| 60 | |
|---|
| 61 | To help you get started, we've provided you with your own plugin. |
|---|
| 62 | |
|---|
| 63 | It is located in your configuration directory at: |
|---|
| 64 | $path |
|---|
| 65 | Open it with with Padre and you'll see an explanation on how to add items. |
|---|
| 66 | END_MESSAGE |
|---|
| 67 | |
|---|
| 68 | # Show the About dialog |
|---|
| 69 | Wx::AboutBox( $about ); |
|---|
| 70 | |
|---|
| 71 | return; |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | sub 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 | |
|---|