~ubuntu-branches/ubuntu/karmic/padre/karmic

« back to all changes in this revision

Viewing changes to lib/Padre/Wx/Menu/Perl.pm

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-07-03 23:35:34 UTC
  • mfrom: (5.1.2 karmic)
  • Revision ID: james.westby@ubuntu.com-20090703233534-i81q25s451pyid2d
Tags: 0.36-3
* remove build dep on locales-all (Closes: #535248) (LP: #394128)
* Debian Policy 3.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
use 5.008;
6
6
use strict;
7
7
use warnings;
8
 
use List::Util      ();
9
 
use File::Spec      ();
10
 
use File::HomeDir   ();
11
 
use Params::Util    ();
12
 
use Padre::Locale   ();
 
8
use List::Util    ();
 
9
use File::Spec    ();
 
10
use File::HomeDir ();
 
11
use Params::Util qw{_INSTANCE};
13
12
use Padre::Wx       ();
14
13
use Padre::Wx::Menu ();
 
14
use Padre::Locale   ();
 
15
use Padre::Current qw{_CURRENT};
15
16
 
16
 
our $VERSION = '0.35';
 
17
our $VERSION = '0.36';
17
18
our @ISA     = 'Padre::Wx::Menu';
18
19
 
19
20
#####################################################################
33
34
        $self->{config} = $main->config;
34
35
 
35
36
        # Perl-Specific Searches
 
37
        $self->{find_brace} = $self->Append(
 
38
                -1,
 
39
                Wx::gettext("Find Unmatched Brace")
 
40
        );
36
41
        Wx::Event::EVT_MENU(
37
42
                $main,
38
 
                $self->Append(
39
 
                        -1,
40
 
                        Wx::gettext("Find Unmatched Brace")
41
 
                ),
 
43
                $self->{find_brace},
42
44
                sub {
43
45
                        my $doc = $_[0]->current->document;
44
 
                        return unless Params::Util::_INSTANCE( $doc, 'Padre::Document::Perl' );
 
46
                        return unless _INSTANCE( $doc, 'Padre::Document::Perl' );
45
47
                        $doc->find_unmatched_brace;
46
48
                },
47
49
        );
48
50
 
 
51
        $self->{find_variable} = $self->Append(
 
52
                -1,
 
53
                Wx::gettext("Find Variable Declaration")
 
54
        );
49
55
        Wx::Event::EVT_MENU(
50
56
                $main,
51
 
                $self->Append( -1, Wx::gettext("Find Variable Declaration") ),
 
57
                $self->{find_variable},
52
58
                sub {
53
59
                        my $doc = $_[0]->current->document;
54
 
                        return unless Params::Util::_INSTANCE( $doc, 'Padre::Document::Perl' );
 
60
                        return unless _INSTANCE( $doc, 'Padre::Document::Perl' );
55
61
                        $doc->find_variable_declaration;
56
62
                },
57
63
        );
59
65
        $self->AppendSeparator;
60
66
 
61
67
        # Perl-Specific Refactoring
 
68
        $self->{rename_variable} = $self->Append(
 
69
                -1,
 
70
                Wx::gettext("Lexically Rename Variable")
 
71
        );
62
72
        Wx::Event::EVT_MENU(
63
73
                $main,
64
 
                $self->Append(
65
 
                        -1,
66
 
                        Wx::gettext("Lexically Rename Variable")
67
 
                ),
 
74
                $self->{rename_variable},
68
75
                sub {
69
76
                        my $doc = $_[0]->current->document;
70
 
                        return unless Params::Util::_INSTANCE( $doc, 'Padre::Document::Perl' );
71
 
                        my $dialog = Padre::Wx::History::TextDialog->new(
 
77
                        return unless _INSTANCE( $doc, 'Padre::Document::Perl' );
 
78
                        require Padre::Wx::History::TextEntryDialog;
 
79
                        my $dialog = Padre::Wx::History::TextEntryDialog->new(
72
80
                                $_[0],
73
81
                                Wx::gettext("Replacement"),
74
82
                                Wx::gettext("Replacement"),
142
150
}
143
151
 
144
152
sub refresh {
145
 
        my $self   = shift;
146
 
        my $config = $self->{config};
147
 
 
 
153
        my $self    = shift;
 
154
        my $current = _CURRENT(@_);
 
155
        my $config  = $current->config;
 
156
        my $perl    = !!( _INSTANCE( $current->document, 'Padre::Document::Perl' ) );
 
157
 
 
158
        # Disable document-specific entries if we are in a Perl project
 
159
        # but not in a Perl document.
 
160
        $self->{find_brace}->Enable($perl);
 
161
        $self->{find_variable}->Enable($perl);
 
162
        $self->{rename_variable}->Enable($perl);
 
163
 
 
164
        # Apply config-driven state
148
165
        $self->{ppi_highlight}->Check( $config->ppi_highlight );
149
 
 
150
 
        #$self->{run_stacktrace}->Check( $config->run_stacktrace );
151
166
        $self->{autocomplete_brackets}->Check( $config->autocomplete_brackets );
152
167
 
153
168
        return;