~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/Padre/Wx/Dialog/QuickMenuAccess.pm

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
use Padre::DB             ();
8
8
use Padre::Wx             ();
9
9
use Padre::Wx::Icon       ();
 
10
use Padre::Wx::HtmlWindow ();
10
11
use Padre::Wx::Role::Main ();
11
12
use Padre::Logger;
12
13
 
13
14
# package exports and version
14
 
our $VERSION = '0.90';
 
15
our $VERSION = '0.92';
15
16
our @ISA     = qw{
16
17
        Padre::Wx::Role::Main
17
18
        Wx::Dialog
38
39
                $main,
39
40
                -1,
40
41
                Wx::gettext('Quick Menu Access'),
41
 
                Wx::wxDefaultPosition,
42
 
                Wx::wxDefaultSize,
43
 
                Wx::wxDEFAULT_FRAME_STYLE | Wx::wxTAB_TRAVERSAL,
 
42
                Wx::DefaultPosition,
 
43
                Wx::DefaultSize,
 
44
                Wx::DEFAULT_FRAME_STYLE | Wx::TAB_TRAVERSAL,
44
45
        );
45
46
 
46
47
        # Dialog's icon as is the same as Padre
64
65
 
65
66
        # Open the selected menu item if the user pressed OK
66
67
        my $selection = $self->_list->GetSelection;
 
68
        return if $selection == Wx::NOT_FOUND;
67
69
        my $action    = $self->_list->GetClientData($selection);
68
 
        $self->Destroy;
 
70
        $self->Hide;
69
71
        my %actions     = %{ Padre::ide->actions };
70
72
        my $menu_action = $actions{ $action->{name} };
71
73
        if ($menu_action) {
84
86
 
85
87
                        eval { &$event($main); };
86
88
                        if ($@) {
87
 
                                my $error = $@;
88
 
                                Wx::MessageBox(
89
 
                                        sprintf( Wx::gettext('Error while trying to perform Padre action: %s'), $error ),
90
 
                                        Wx::gettext('Error'),
91
 
                                        Wx::wxOK,
92
 
                                        $main,
93
 
                                );
94
 
                                TRACE("Error while trying to perform Padre action: $error") if DEBUG;
 
89
                                $main->error(sprintf( Wx::gettext('Error while trying to perform Padre action: %s'), $@ ));
 
90
                                TRACE("Error while trying to perform Padre action: $@") if DEBUG;
95
91
                        } else {
96
92
 
97
93
                                # And insert a recently used tuple if it is not found
124
120
        my $self = shift;
125
121
 
126
122
        # create sizer that will host all controls
127
 
        my $sizer = Wx::BoxSizer->new(Wx::wxVERTICAL);
 
123
        my $sizer = Wx::BoxSizer->new(Wx::VERTICAL);
128
124
        $self->_sizer($sizer);
129
125
 
130
126
        # create the controls
148
144
        my $sizer = $self->_sizer;
149
145
 
150
146
        $self->{ok_button} = Wx::Button->new(
151
 
                $self, Wx::wxID_OK, Wx::gettext('&OK'),
 
147
                $self, Wx::ID_OK, Wx::gettext('&OK'),
152
148
        );
153
149
        $self->{ok_button}->SetDefault;
154
150
        $self->{cancel_button} = Wx::Button->new(
155
 
                $self, Wx::wxID_CANCEL, Wx::gettext('&Cancel'),
 
151
                $self, Wx::ID_CANCEL, Wx::gettext('&Cancel'),
156
152
        );
157
153
 
158
 
        my $buttons = Wx::BoxSizer->new(Wx::wxHORIZONTAL);
 
154
        my $buttons = Wx::BoxSizer->new(Wx::HORIZONTAL);
159
155
        $buttons->AddStretchSpacer;
160
 
        $buttons->Add( $self->{ok_button},     0, Wx::wxALL | Wx::wxEXPAND, 5 );
161
 
        $buttons->Add( $self->{cancel_button}, 0, Wx::wxALL | Wx::wxEXPAND, 5 );
162
 
        $sizer->Add( $buttons, 0, Wx::wxALL | Wx::wxEXPAND | Wx::wxALIGN_CENTER, 5 );
 
156
        $buttons->Add( $self->{ok_button},     0, Wx::ALL | Wx::EXPAND, 5 );
 
157
        $buttons->Add( $self->{cancel_button}, 0, Wx::ALL | Wx::EXPAND, 5 );
 
158
        $sizer->Add( $buttons, 0, Wx::ALL | Wx::EXPAND | Wx::ALIGN_CENTER, 5 );
163
159
 
164
 
        Wx::Event::EVT_BUTTON( $self, Wx::wxID_OK, \&_on_ok_button_clicked );
 
160
        Wx::Event::EVT_BUTTON( $self, Wx::ID_OK, \&_on_ok_button_clicked );
165
161
}
166
162
 
167
163
#
184
180
        );
185
181
        $self->_list(
186
182
                Wx::ListBox->new(
187
 
                        $self, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, [],
188
 
                        Wx::wxLB_SINGLE
 
183
                        $self, -1, Wx::DefaultPosition, Wx::DefaultSize, [],
 
184
                        Wx::LB_SINGLE
189
185
                )
190
186
        );
191
187
 
192
188
        # Shows how many items are selected and information about what is selected
193
 
        require Padre::Wx::HtmlWindow;
194
189
        $self->_status_text(
195
190
                Padre::Wx::HtmlWindow->new(
196
191
                        $self,
197
192
                        -1,
198
 
                        Wx::wxDefaultPosition,
 
193
                        Wx::DefaultPosition,
199
194
                        [ -1, 70 ],
200
 
                        Wx::wxBORDER_STATIC
 
195
                        Wx::BORDER_STATIC
201
196
                )
202
197
        );
203
198
 
204
199
        $self->_sizer->AddSpacer(10);
205
 
        $self->_sizer->Add( $search_label,       0, Wx::wxALL | Wx::wxEXPAND, 2 );
206
 
        $self->_sizer->Add( $self->_search_text, 0, Wx::wxALL | Wx::wxEXPAND, 2 );
207
 
        $self->_sizer->Add( $matches_label,      0, Wx::wxALL | Wx::wxEXPAND, 2 );
208
 
        $self->_sizer->Add( $self->_list,        1, Wx::wxALL | Wx::wxEXPAND, 2 );
209
 
        $self->_sizer->Add( $self->_status_text, 0, Wx::wxALL | Wx::wxEXPAND, 2 );
 
200
        $self->_sizer->Add( $search_label,       0, Wx::ALL | Wx::EXPAND, 2 );
 
201
        $self->_sizer->Add( $self->_search_text, 0, Wx::ALL | Wx::EXPAND, 2 );
 
202
        $self->_sizer->Add( $matches_label,      0, Wx::ALL | Wx::EXPAND, 2 );
 
203
        $self->_sizer->Add( $self->_list,        1, Wx::ALL | Wx::EXPAND, 2 );
 
204
        $self->_sizer->Add( $self->_status_text, 0, Wx::ALL | Wx::EXPAND, 2 );
210
205
 
211
206
        $self->_setup_events;
212
207
 
227
222
                        my $code  = $event->GetKeyCode;
228
223
 
229
224
                        $self->_list->SetFocus
230
 
                                if ( $code == Wx::WXK_DOWN )
231
 
                                or ( $code == Wx::WXK_UP )
232
 
                                or ( $code == Wx::WXK_NUMPAD_PAGEDOWN )
233
 
                                or ( $code == Wx::WXK_PAGEDOWN );
 
225
                                if ( $code == Wx::K_DOWN )
 
226
                                or ( $code == Wx::K_UP )
 
227
                                or ( $code == Wx::K_NUMPAD_PAGEDOWN )
 
228
                                or ( $code == Wx::K_PAGEDOWN );
234
229
 
235
230
                        $event->Skip(1);
236
231
                }
255
250
                $self->_list,
256
251
                sub {
257
252
                        my $selection = $self->_list->GetSelection;
258
 
                        if ( $selection != Wx::wxNOT_FOUND ) {
 
253
                        if ( $selection != Wx::NOT_FOUND ) {
259
254
                                my $action = $self->_list->GetClientData($selection);
260
255
                                $self->_status_text->SetPage( $self->_label( $action->{value}, $action->{name} ) );
261
256
                        }