wiki:PadrePluginCookbook03

Version 6 (modified by bowtie, 3 years ago) (diff)

--

Padre::Plugin::Cookbook Recipe-03

  • Every Plug-in needs an About dialogue or Multiple Dialogues.
  • This page complements Padre::Plugin::Cookbook Recipe-03, it is not meant to be installable, just an aid, with a suggested layout, enjoy. More detail will follow in subsequent Cookbooks.
  • You can either svn Padre::Plugin::Cookbook of build your own with Cookbook03.zip in Attachments.

Step 1 - Create Skeleton

Padre can do this for you see Project Skeleton Generation

  • Assumption you are building in your copy of Padre trunk.
Padre-Plugin-Cookbook03/
├── fbp
│   ├── AboutFB.fbp
│   └── MainFB.fbp
├── lib
│   └── Padre
│       └── Plugin
│           ├── Cookbook03
│           │   ├── About.pm
│           │   ├── FBP
│           │   │   ├── AboutFB.pm
│           │   │   └── MainFB.pm
│           │   └── Main.pm
│           └── Cookbook03.pm
└── t
    ├── 00-load.t
    ├── 01-Cookbook03.t
    ├── 02-Main.t
    ├── 03-About.t
    ├── 04-pod.t
    ├── 05-pod-coverage.t
    └── 06-perlcritic.t

Step 2 multiple.fbp (xml)

  • Use wxFormBuilder, v3.1.70
  • Multiple! Why, well it's either a Wx thing or FormBuilder limitation, this is pants! Glade allows multi-dialogue's in single file.
  • The naming convention chosen starts to make more sense when you think about multiple dialogue's.
  • There is no pretty table to explain what's going on, you have to use wxFormBuilder, I suggest that you also read the *FB.fbp & *FB.pm files as well.

Create MainFb.fbp

wxWidgetPropertiesEvents
IconTypenamelabel/titlepublicothertypevalue

wxWidget project

Project

Cookbook03

n/a

n/a

n/a

n/a

n/a

wxWidget dialog

Dialog

Padre::Plugin::Cookbook03::FBP::MainFB

Main

n/a

wxRESIZE_BORDER

n/a

n/a

Create AboutFb.fbp

wxWidgetPropertiesEvents
IconTypenamelabel/titlepublicothertypevalue

wxWidget project

Project

Cookbook03

n/a

n/a

n/a

n/a

n/a

wxWidget dialog

Dialog

Padre::Plugin::Cookbook03::FBP::AboutFB

Main

n/a

wxRESIZE_BORDER

n/a

n/a

Step 3 Padre::Plugin::FormBuilder

  • Padre::Plugin::FormBuilder dose not support Wx menus yet, hence fudge work around in Main.
  • Use generator to create MainFB.pm from MainFB.fbp
  • Use generator to create AboutFB.pm from AboutFB.fbp
    • Tip have Padre::Plugin::Cookbook03.pm Open before running generator.
  • Padre::Plugin::FormBuilder use FBP::Perl ();
  • You need to read Source FBP::Perl for which Wx features are supported, it's the only reference :(

Step 4 Perl Plug-in Code

  • Read POD for Padre::Plugin
  • Read POD for Cookbook03.pm, Main.pm and About.pm.

Plug-in tests

Test nameNumberResult
00-load.t1..1All tests successful.
01-Cookbook03.t1..14All tests successful.
02-Main.t1..7All tests successful.
03-About.t1..6All tests successful.
04-pod.t1..5All tests successful.
05-pod-coverage.t1..5All tests successful.
06-perlcritic.t1..5All tests successful.
  • Ticket #1227 add POD to *FB.pm
  • All tests successful if you use replacement PerlX.pm
  • critiques welcome.

Step 5 Run

  • perl dev -a -die
  • You should now have Cookbook03 in your Tools menu, enjoy.

Foot Notes

Why Main, So we can have About

Well I needed a convention that I could expand upon. Which made sense to me, so here goes:

  • MainFB.fbp is generated by wxFormBuilder,
  • MainFB.pm is geneated from previous by Padre::Plugin::FormBuilder.

The FB tells me it's nought to do with me (FB FormBuilder).

  • Main.pm is the event handler for MainFb.pm.
  • About.pm is the event handler for AboutFB.pm.

Garbage

  • Padre::Plugin POD dictates that sub plugin_disable is required. See POD.

This is the flow of this Plug-in, note garbage is done by loading class not event handler.

  • Padre Plugin loads
    • Cookbook03
      sub load_dialog_main {
      
      • Main & MainFB loaded
        sub load_dialog_about {
        
        • About & AboutFB loaded
      • Main unload About
        sub plugin_disable {
        
    • Cookbook03 unload Main
      sub plugin_disable {
      
  • Padre plugin unload Cookbook03
    sub plugin_disable {
    

This process works, In that it dose not crap over Padre, But the Reload All Plugins is not predictable. either that or some one can kick me.

__END__

Attachments (4)

Download all attachments as: .zip