~ubuntu-branches/debian/sid/padre/sid

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov, gregor herrmann, Damyan Ivanov
  • Date: 2009-11-18 17:48:27 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20091118174827-srz62scl23gdl88v
Tags: 0.50.ds1-1
[ gregor herrmann ]
* debian/control: change dependency on "libclass-xsaccessor-array-perl
  (>= 1.02)" to "libclass-xsaccessor-perl (>= 1.05-2) |
  libclass-xsaccessor-array-perl (>= 1.02)".

[ Damyan Ivanov ]
* New upstream release
  + copyright: add a new translator
    - describe share/doc/perlopref copyright and licensing
  + update patches:
    - refresh disable-tcp-server.patch
    - drop fix-man-whatis.patch and fix-pod.patch (merged upstream)
    - drop fix-helpprovider-with-no-perlopref.patch: no longer necessary
* repack.sh: in 0.49 padre.exe moved from script/ to bin/
  + perlopref is now properly licensed
* add perl (>= 5.10.1) as a preferred alternative to versioned (build)
  dependencies on libtest-simple-perl and libpod-simple-perl
* update debian/not-real-manual.list for 0.50 (one file added, two files
  changed in size)
* rules: remove cruft from padre.deb
  + license etc from perlopref directory (already present in d/copyright)
  + remove .po files from the .deb (there are .mo files installed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Padre::Wx::Dialog::FilterTool;
 
2
 
 
3
use 5.008;
 
4
use strict;
 
5
use warnings;
 
6
use Padre::Wx       ();
 
7
use Padre::Wx::Icon ();
 
8
 
 
9
our $VERSION = '0.50';
 
10
our @ISA     = 'Wx::Dialog';
 
11
 
 
12
use Class::XSAccessor accessors => {
 
13
        _butrun => '_butrun', # run button
 
14
        _combo  => '_combo',  # combo box
 
15
        _names  => '_names',  # list of all recent commands
 
16
        _sizer  => '_sizer',  # the window sizer
 
17
};
 
18
 
 
19
# -- constructor
 
20
 
 
21
sub new {
 
22
        my ( $class, $parent ) = @_;
 
23
 
 
24
        # create object
 
25
        my $self = $class->SUPER::new(
 
26
                $parent,
 
27
                -1,
 
28
                Wx::gettext('Filter through tool'),
 
29
                Wx::wxDefaultPosition,
 
30
                Wx::wxDefaultSize,
 
31
                Wx::wxDEFAULT_FRAME_STYLE | Wx::wxTAB_TRAVERSAL,
 
32
        );
 
33
        $self->SetIcon(Padre::Wx::Icon::PADRE);
 
34
 
 
35
        # create dialog
 
36
        $self->_create;
 
37
 
 
38
        return $self;
 
39
}
 
40
 
 
41
# -- public methods
 
42
 
 
43
sub show {
 
44
        my $self = shift;
 
45
        $self->_refresh_combo;
 
46
        $self->Show;
 
47
}
 
48
 
 
49
# -- gui handlers
 
50
 
 
51
#
 
52
# $self->_on_butclose_clicked;
 
53
#
 
54
# handler called when the close button has been clicked.
 
55
#
 
56
sub _on_butclose_clicked {
 
57
        my $self = shift;
 
58
        $self->Destroy;
 
59
}
 
60
 
 
61
#
 
62
# $self->_on_butrun_clicked;
 
63
#
 
64
# handler called when the run button has been clicked.
 
65
#
 
66
sub _on_butrun_clicked {
 
67
        my $self = shift;
 
68
 
 
69
        my $main = $self->GetParent;
 
70
 
 
71
        my $tool = $self->_combo->GetValue;
 
72
 
 
73
        if ( defined($tool) and ( $tool ne '' ) ) {
 
74
 
 
75
                #               $filtertool = Padre::DB::FilterTool->new(
 
76
                #                       name        => $self->_combo->GetValue,
 
77
                #                       last_update => time,
 
78
                #               );
 
79
                #               $filtertool->insert;
 
80
 
 
81
                $main->filter_tool($tool);
 
82
 
 
83
        }
 
84
 
 
85
        # close dialog
 
86
        $self->Destroy;
 
87
}
 
88
 
 
89
# -- private methods
 
90
 
 
91
#
 
92
# $self->_create;
 
93
#
 
94
# create the dialog itself.
 
95
#
 
96
# no params, no return values.
 
97
#
 
98
sub _create {
 
99
        my $self = shift;
 
100
 
 
101
        # create sizer that will host all controls
 
102
        my $box = Wx::BoxSizer->new(Wx::wxVERTICAL);
 
103
        my $sizer = Wx::GridBagSizer->new( 5, 5 );
 
104
        $sizer->AddGrowableCol(1);
 
105
        $box->Add( $sizer, 1, Wx::wxEXPAND | Wx::wxALL, 5 );
 
106
        $self->_sizer($sizer);
 
107
 
 
108
        $self->_create_fields;
 
109
        $self->_create_buttons;
 
110
        $self->SetSizer($box);
 
111
        $box->SetSizeHints($self);
 
112
        $self->CenterOnParent;
 
113
        $self->_combo->SetFocus;
 
114
 
 
115
}
 
116
 
 
117
#
 
118
# $dialog->_create_fields;
 
119
#
 
120
# create the combo box with the recent commands.
 
121
#
 
122
# no params. no return values.
 
123
#
 
124
sub _create_fields {
 
125
        my $self  = shift;
 
126
        my $sizer = $self->_sizer;
 
127
 
 
128
        my $lab1 = Wx::StaticText->new( $self, -1, Wx::gettext('Filter command:') );
 
129
        my $combo = Wx::ComboBox->new( $self, -1, '' );
 
130
        $sizer->Add( $lab1, Wx::GBPosition->new( 0, 0 ) );
 
131
        $sizer->Add( $combo, Wx::GBPosition->new( 0, 1 ), Wx::GBSpan->new( 1, 3 ), Wx::wxEXPAND );
 
132
        $self->_combo($combo);
 
133
 
 
134
}
 
135
 
 
136
#
 
137
# $dialog->_create_buttons;
 
138
#
 
139
# create the buttons pane.
 
140
#
 
141
# no params. no return values.
 
142
#
 
143
sub _create_buttons {
 
144
        my $self = shift;
 
145
 
 
146
        my $sizer = $self->_sizer;
 
147
 
 
148
        # the buttons
 
149
        my $bs = Wx::Button->new( $self, Wx::wxID_OK,     Wx::gettext('Run') );
 
150
        my $bc = Wx::Button->new( $self, Wx::wxID_CANCEL, Wx::gettext('Close') );
 
151
        Wx::Event::EVT_BUTTON( $self, $bs, \&_on_butrun_clicked );
 
152
        Wx::Event::EVT_BUTTON( $self, $bc, \&_on_butclose_clicked );
 
153
        $sizer->Add( $bs, Wx::GBPosition->new( 2, 2 ) );
 
154
        $sizer->Add( $bc, Wx::GBPosition->new( 2, 3 ) );
 
155
 
 
156
        $bs->SetDefault;
 
157
 
 
158
        $self->_butrun($bs);
 
159
}
 
160
 
 
161
#
 
162
# $dialog->_refresh_combo;
 
163
#
 
164
# refresh combo box
 
165
#
 
166
sub _refresh_combo {
 
167
        my ( $self, $column, $reverse ) = @_;
 
168
 
 
169
        # get list of recent commands, sorted.
 
170
        #       my @names = map { $_->name } Padre::DB::FilterTool->select('ORDER BY name');
 
171
        #       $self->_names( \@names );
 
172
 
 
173
        # clear list & fill it again
 
174
        my $combo = $self->_combo;
 
175
        $combo->Clear;
 
176
 
 
177
        #       $combo->Append($_) foreach @names;
 
178
}
 
179
 
 
180
 
 
181
1;
 
182
 
 
183
__END__
 
184
 
 
185
 
 
186
=head1 NAME
 
187
 
 
188
Padre::Wx::Dialog::FilterTool - dialog to filter selection or document through an external tool
 
189
 
 
190
 
 
191
 
 
192
=head1 DESCRIPTION
 
193
 
 
194
This Dialog askes for the tool which should be used to filter the current
 
195
selection or the whole document.
 
196
 
 
197
 
 
198
=head1 PUBLIC API
 
199
 
 
200
=head2 Constructor
 
201
 
 
202
=over 4
 
203
 
 
204
=item * my $dialog = Padre::Wx::Dialog::FilterTool->new( $parent )
 
205
 
 
206
Create and return a new Wx dialog allowing to select a filter tool. It needs a
 
207
C<$parent> window (usually padre's main window).
 
208
 
 
209
 
 
210
=back
 
211
 
 
212
 
 
213
 
 
214
=head2 Public methods
 
215
 
 
216
=over 4
 
217
 
 
218
=item * $dialog->show;
 
219
 
 
220
Request the dialog to be shown.
 
221
 
 
222
 
 
223
=back
 
224
 
 
225
 
 
226
 
 
227
=head1 COPYRIGHT & LICENSE
 
228
 
 
229
Copyright 2008-2009 The Padre development team as listed in Padre.pm.
 
230
 
 
231
This program is free software; you can redistribute it and/or modify it
 
232
under the same terms as Perl 5 itself.
 
233
 
 
234
 
 
235
=cut
 
236
 
 
237
 
 
238
# Copyright 2008-2009 The Padre development team as listed in Padre.pm.
 
239
# LICENSE
 
240
# This program is free software; you can redistribute it and/or
 
241
# modify it under the same terms as Perl 5 itself.