~ubuntu-branches/ubuntu/oneiric/padre/oneiric

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2009-04-28 16:21:53 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090428162153-9p3ygfznr9xt08sn
Tags: 0.34-1
* New upstream release

* bump liborlite-perl (build-)dependency to 1.20
* bump liborlite-migrate-perl (build-)dependency to 0.03
* refresh patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
use base qw(Padre::Wx::Dialog);
10
10
 
11
 
our $VERSION = '0.33';
 
11
our $VERSION = '0.34';
12
12
 
13
13
sub _new_panel {
14
14
        my ( $self, $parent ) = splice( @_, 0, 2 );
38
38
                        ],
39
39
                        []
40
40
                ],
 
41
                [   [   'Wx::CheckBox', 'editor_fold_pod', ( $config->editor_fold_pod ? 1 : 0 ),
 
42
                                Wx::gettext('Auto-fold POD markup when code folding enabled')
 
43
                        ],
 
44
                        []
 
45
                ],
41
46
                [   [   'Wx::CheckBox', 'editor_beginner', ( $config->editor_beginner ? 1 : 0 ),
42
47
                                Wx::gettext('Perl beginner mode')
43
48
                        ],
293
298
        return;
294
299
}
295
300
 
 
301
sub _run_params_panel {
 
302
        my ( $self, $treebook ) = @_;
 
303
 
 
304
        my $config   = Padre->ide->config;
 
305
        my $document = Padre::Current->document;
 
306
 
 
307
        my $intrp_args_text = Wx::gettext(<<'END_TEXT');
 
308
i.e.
 
309
        include directory:  -I<dir>
 
310
        enable tainting checks:  -T
 
311
        enable many useful warnings:  -w
 
312
        enable all warnings:  -W
 
313
        disable all warnings:  -X
 
314
END_TEXT
 
315
 
 
316
        # Default values stored in host configuration
 
317
        my $defaults_table = [
 
318
                [   [ 'Wx::StaticText', undef,                          Wx::gettext('Interpreter arguments:') ],
 
319
                        [ 'Wx::TextCtrl',   'run_interpreter_args_default', $config->run_interpreter_args_default ]
 
320
                ],
 
321
                [   [ 'Wx::StaticText', undef, '' ],
 
322
                        [ 'Wx::StaticText', undef, $intrp_args_text ]
 
323
                ],
 
324
                [   [ 'Wx::StaticText', undef,                     Wx::gettext('Script arguments:') ],
 
325
                        [ 'Wx::TextCtrl',   'run_script_args_default', $config->run_script_args_default ]
 
326
                ],
 
327
        ];
 
328
 
 
329
        # Per document values (overwrite defaults) stored in history
 
330
        my $doc_flag = 0;                        # value of 1 means that there is no document currently open
 
331
        my $filename = Wx::gettext('Unsaved');
 
332
        my $path     = Wx::gettext('N/A');
 
333
        my %run_args = (
 
334
                interpreter => '',
 
335
                script      => '',
 
336
        );
 
337
 
 
338
        # Trap exception if there is no document currently open
 
339
        eval {
 
340
                unless ( $document->is_new )
 
341
                {
 
342
                        ( $filename, $path ) = File::Basename::fileparse( Padre::Current->filename );
 
343
                        foreach my $arg ( keys %run_args ) {
 
344
                                my $type = "run_${arg}_args_${filename}";
 
345
                                $run_args{$arg} = Padre::DB::History->previous($type)
 
346
                                        if Padre::DB::History->previous($type);
 
347
                        }
 
348
                }
 
349
        };
 
350
        if ($@) {
 
351
                $filename = Wx::gettext('No Document');
 
352
                $doc_flag = 1;
 
353
        }
 
354
 
 
355
        my $currentdoc_table = [
 
356
                [   [ 'Wx::StaticText', undef, Wx::gettext('Document name:') ],
 
357
                        [ 'Wx::TextCtrl', undef, $filename, Wx::wxTE_READONLY ]
 
358
                ],
 
359
                [   [ 'Wx::StaticText', undef, Wx::gettext('Document location:') ],
 
360
                        [ 'Wx::TextCtrl', undef, $path, Wx::wxTE_READONLY ]
 
361
                ],
 
362
                [   [ 'Wx::StaticText', undef,                            Wx::gettext('Interpreter arguments:') ],
 
363
                        [ 'Wx::TextCtrl',   "run_interpreter_args_$filename", $run_args{interpreter} ]
 
364
                ],
 
365
                [   [ 'Wx::StaticText', undef, '' ],
 
366
                        [ 'Wx::StaticText', undef, $intrp_args_text ]
 
367
                ],
 
368
                [   [ 'Wx::StaticText', undef,                       Wx::gettext('Script arguments:') ],
 
369
                        [ 'Wx::TextCtrl',   "run_script_args_$filename", $run_args{script} ]
 
370
                ],
 
371
        ];
 
372
 
 
373
        my $panel = Wx::Panel->new(
 
374
                $treebook,
 
375
                -1,
 
376
                Wx::wxDefaultPosition,
 
377
                Wx::wxDefaultSize,
 
378
                Wx::wxTAB_TRAVERSAL | Wx::wxVSCROLL | Wx::wxHSCROLL,
 
379
        );
 
380
        my $main_sizer = Wx::BoxSizer->new(Wx::wxVERTICAL);
 
381
 
 
382
        my $notebook = Wx::Notebook->new($panel);
 
383
 
 
384
        my $defaults_subpanel = $self->_new_panel($notebook);
 
385
        $self->fill_panel_by_table( $defaults_subpanel, $defaults_table );
 
386
        $notebook->AddPage( $defaults_subpanel, Wx::gettext('Default') );
 
387
 
 
388
        my $currentdoc_subpanel = $self->_new_panel($notebook);
 
389
        $self->fill_panel_by_table( $currentdoc_subpanel, $currentdoc_table ) unless $doc_flag;
 
390
        $notebook->AddPage(
 
391
                $currentdoc_subpanel,
 
392
                sprintf( Wx::gettext('Current Document: %s'), $filename )
 
393
        );
 
394
 
 
395
        $main_sizer->Add( $notebook, 1, Wx::wxGROW );
 
396
        $panel->SetSizerAndFit($main_sizer);
 
397
 
 
398
        return $panel;
 
399
}
 
400
 
296
401
sub dialog {
297
402
        my ( $self, $win, $main_startup, $editor_autoindent, $main_functions_order, $perldiag_locales ) = @_;
298
403
 
329
434
 
330
435
        my $appearance = $self->_appearance_panel($tb);
331
436
        $tb->AddPage( $appearance, Wx::gettext('Appearance') );
 
437
        $tb->AddPage(
 
438
                $self->_run_params_panel($tb),
 
439
                Wx::gettext('Run Parameters')
 
440
        );
332
441
 
333
442
        #my $plugin_manager = $self->_pluginmanager_panel($tb);
334
443
        #$tb->AddPage( $plugin_manager, Wx::gettext('Plugin Manager') );
484
593
                $data->{editor_wordwrap} ? 1 : 0
485
594
        );
486
595
        $config->set(
 
596
                'editor_fold_pod',
 
597
                $data->{editor_fold_pod} ? 1 : 0
 
598
        );
 
599
        $config->set(
487
600
                'editor_beginner',
488
601
                $data->{editor_beginner} ? 1 : 0
489
602
        );
503
616
                'main_output_ansi',
504
617
                $data->{main_output_ansi} ? 1 : 0
505
618
        );
 
619
        $config->set(
 
620
                'run_interpreter_args_default',
 
621
                $data->{run_interpreter_args_default}
 
622
        );
 
623
        $config->set(
 
624
                'run_script_args_default',
 
625
                $data->{run_script_args_default}
 
626
        );
 
627
 
 
628
        # Quite like in _run_params_panel, trap exception if there
 
629
        # is no document currently open
 
630
        eval {
 
631
                unless ( Padre::Current->document->is_new )
 
632
                {
 
633
 
 
634
                        # These are a bit different as run_* variable name depends
 
635
                        # on current document's filename
 
636
                        foreach ( grep { /^run_/ && !/_default$/ } ( keys %$data ) ) {
 
637
                                next if Padre::DB::History->previous($_) eq $data->{$_};
 
638
                                Padre::DB::History->create(
 
639
                                        type => $_,
 
640
                                        name => $data->{$_},
 
641
                                );
 
642
                        }
 
643
                }
 
644
        };
506
645
 
507
646
        # The slightly different one
508
647
        my $editor_currentline_color = $data->{editor_currentline_color};