~ubuntu-branches/ubuntu/precise/padre/precise

« back to all changes in this revision

Viewing changes to lib/Padre/Action/Plugins.pm

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2010-05-08 09:17:22 UTC
  • mfrom: (1.2.1 upstream) (10.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100508091722-y6008jtk0ap6znyn
Tags: 0.60.ds1-3
rules: run tests with HOME=$fake_home to avoud failing when $HOME points
to a non-existent location. Closes: #579289

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package Padre::Action::Plugins;
2
 
 
3
 
# Fully encapsulated Run menu
4
 
 
5
 
use 5.008;
6
 
use strict;
7
 
use warnings;
8
 
use Params::Util    ();
9
 
use Padre::Constant ();
10
 
use Padre::Config   ();
11
 
use Padre::Wx       ();
12
 
use Padre::Action   ();
13
 
use Padre::Current qw{_CURRENT};
14
 
 
15
 
our $VERSION = '0.50';
16
 
 
17
 
 
18
 
 
19
 
 
20
 
 
21
 
#####################################################################
22
 
# Padre::Action::Plugins Methods
23
 
 
24
 
sub new {
25
 
        my $class = shift;
26
 
        my $main  = shift;
27
 
 
28
 
        # Create the empty object as normal, it won't be used usually
29
 
        my $self = bless {}, $class;
30
 
 
31
 
        # Add additional properties
32
 
        $self->{main} = $main;
33
 
 
34
 
        # Link to the Plugin Manager
35
 
        Padre::Action->new(
36
 
                name       => 'plugins.plugin_manager',
37
 
                label      => Wx::gettext('Plugin Manager'),
38
 
                comment    => Wx::gettext('Show the Padre plugin manager to enable or disable plugins'),
39
 
                menu_event => sub {
40
 
                        require Padre::Wx::Dialog::PluginManager;
41
 
                        Padre::Wx::Dialog::PluginManager->new(
42
 
                                $_[0],
43
 
                                Padre->ide->plugin_manager,
44
 
                        )->show;
45
 
                },
46
 
        );
47
 
 
48
 
        # TODO: should be replaced by a link to http://cpan.uwinnipeg.ca/chapter/World_Wide_Web_HTML_HTTP_CGI/Padre
49
 
        # better yet, by a window that also allows the installation of all the plugins that can take into account
50
 
        # the type of installation we have (ppm, stand alone, rpm, deb, CPAN, etc.)
51
 
        Padre::Action->new(
52
 
                name       => 'plugins.plugin_list',
53
 
                label      => Wx::gettext('Plugin List (CPAN)'),
54
 
                menu_event => sub {
55
 
                        Padre::Wx::launch_browser('http://cpan.uwinnipeg.ca/search?query=Padre%3A%3APlugin%3A%3A&mode=dist');
56
 
                },
57
 
        );
58
 
 
59
 
        Padre::Action->new(
60
 
                name       => 'plugins.edit_my_plugin',
61
 
                label      => Wx::gettext('Edit My Plugin'),
62
 
                comment    => Wx::gettext('My-Plugin is a plugin where developers could extend their Padre installation'),
63
 
                menu_event => sub {
64
 
                        my $file = File::Spec->catfile(
65
 
                                Padre::Constant::CONFIG_DIR,
66
 
                                qw{ plugins Padre Plugin My.pm }
67
 
                        );
68
 
                        return $self->error( Wx::gettext("Could not find the Padre::Plugin::My plugin") ) unless -e $file;
69
 
 
70
 
                        # Use the plural so we get the "close single unused document"
71
 
                        # behaviour, and so we get a free freezing and refresh calls.
72
 
                        $_[0]->setup_editors($file);
73
 
                },
74
 
        );
75
 
 
76
 
        Padre::Action->new(
77
 
                name       => 'plugins.reload_my_plugin',
78
 
                label      => Wx::gettext('Reload My Plugin'),
79
 
                comment    => Wx::gettext('This function reloads the My-Plugin without restarting Padre'),
80
 
                menu_event => sub {
81
 
                        Padre->ide->plugin_manager->reload_plugin('Padre::Plugin::My');
82
 
                },
83
 
        );
84
 
 
85
 
        Padre::Action->new(
86
 
                name       => 'plugins.reset_my_plugin',
87
 
                label      => Wx::gettext('Reset My Plugin'),
88
 
                comment    => Wx::gettext('Reset the My-Plugin to the default'),
89
 
                menu_event => sub {
90
 
                        my $ret = Wx::MessageBox(
91
 
                                Wx::gettext("Reset My Plugin"),
92
 
                                Wx::gettext("Reset My Plugin"),
93
 
                                Wx::wxOK | Wx::wxCANCEL | Wx::wxCENTRE,
94
 
                                $main,
95
 
                        );
96
 
                        if ( $ret == Wx::wxOK ) {
97
 
                                my $manager = Padre->ide->plugin_manager;
98
 
                                $manager->unload_plugin('Padre::Plugin::My');
99
 
                                $manager->reset_my_plugin(1);
100
 
                                $manager->load_plugin('Padre::Plugin::My');
101
 
                        }
102
 
                },
103
 
        );
104
 
 
105
 
        Padre::Action->new(
106
 
                name       => 'plugins.reload_all_plugins',
107
 
                label      => Wx::gettext('Reload All Plugins'),
108
 
                comment    => Wx::gettext('Reload all plugins from disk'),
109
 
                menu_event => sub {
110
 
                        Padre->ide->plugin_manager->reload_plugins;
111
 
                },
112
 
        );
113
 
 
114
 
        Padre::Action->new(
115
 
                name       => 'plugins.reload_current_plugin',
116
 
                label      => Wx::gettext('(Re)load Current Plugin'),
117
 
                comment    => Wx::gettext('Reloads (or initially loads) the current plugin'),
118
 
                menu_event => sub {
119
 
                        Padre->ide->plugin_manager->reload_current_plugin;
120
 
                },
121
 
        );
122
 
 
123
 
        #       Padre::Action->new(
124
 
        #               $tools,
125
 
        #               name       => 'plugins.test_a_plugin',
126
 
        #               label      => Wx::gettext('Test A Plugin From Local Dir'),
127
 
        #               menu_event => sub {
128
 
        #                       Padre->ide->plugin_manager->test_a_plugin;
129
 
        #               },
130
 
        #       );
131
 
 
132
 
 
133
 
        Padre::Action->new(
134
 
                name       => 'plugins.install_cpan',
135
 
                label      => Wx::gettext("Install CPAN Module"),
136
 
                comment    => Wx::gettext('Install a Perl module from CPAN'),
137
 
                menu_event => sub {
138
 
                        require Padre::CPAN;
139
 
                        require Padre::Wx::CPAN;
140
 
                        my $cpan = Padre::CPAN->new;
141
 
                        my $gui = Padre::Wx::CPAN->new( $cpan, $_[0] );
142
 
                        $gui->show;
143
 
                }
144
 
        );
145
 
 
146
 
        Padre::Action->new(
147
 
                name       => 'plugins.install_local',
148
 
                label      => Wx::gettext("Install Local Distribution"),
149
 
                menu_event => sub {
150
 
                        $self->install_file( $_[0] );
151
 
                },
152
 
        );
153
 
 
154
 
        Padre::Action->new(
155
 
                name       => 'plugins.install_remote',
156
 
                label      => Wx::gettext("Install Remote Distribution"),
157
 
                menu_event => sub {
158
 
                        $self->install_url( $_[0] );
159
 
                },
160
 
        );
161
 
 
162
 
        Padre::Action->new(
163
 
                name       => 'plugins.cpan_config',
164
 
                label      => Wx::gettext("Open CPAN Config File"),
165
 
                menu_event => sub {
166
 
                        $self->cpan_config( $_[0] );
167
 
                },
168
 
        );
169
 
 
170
 
        return $self;
171
 
}
172
 
 
173
 
1;
174
 
 
175
 
# Copyright 2008-2009 The Padre development team as listed in Padre.pm.
176
 
# LICENSE
177
 
# This program is free software; you can redistribute it and/or
178
 
# modify it under the same terms as Perl 5 itself.