| 1 | package Padre::Document::PSGI; | ||
| 2 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | $Padre::Document::PSGI::VERSION = '1.200'; | |
| 4 | } | ||
| 5 | |||
| 6 | # ABSTRACT: Handlers PSGI files in Padre | ||
| 7 | |||
| 8 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 0 | ▶ | use Padre::Logger; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 12 | use Padre::Document::Perl; | ||
| 13 | use Padre::MimeTypes; | ||
| 14 | |||
| 15 | our @ISA = 'Padre::Document::Perl'; | ||
| 16 | |||
| 17 | use Class::XSAccessor accessors => [qw(icon_path icon_set panel plugin process)]; | ||
| 18 | |||
| 19 | |||
| 20 | sub on_load { | ||
| 21 | my $self = shift; | ||
| 22 | |||
| 23 | TRACE('->on_load') if DEBUG; | ||
| 24 | |||
| 25 | require Scalar::Util; | ||
| 26 | Scalar::Util::weaken( $self->{plugin} ); | ||
| 27 | } | ||
| 28 | |||
| 29 | |||
| 30 | sub set_tab_icon { | ||
| 31 | my $self = shift; | ||
| 32 | return if $self->icon_set; | ||
| 33 | |||
| 34 | TRACE( ' setting icon to ' . $self->icon_path ) if DEBUG; | ||
| 35 | |||
| 36 | my $main = Padre->ide->wx->main; | ||
| 37 | my $id = $main->find_id_of_editor( $self->editor ); | ||
| 38 | my $icon = Wx::Bitmap->new( $self->icon_path, Wx::wxBITMAP_TYPE_PNG ); | ||
| 39 | $main->notebook->SetPageBitmap( $id, $icon ); | ||
| 40 | |||
| 41 | $self->icon_set(1); | ||
| 42 | } | ||
| 43 | |||
| 44 | |||
| 45 | sub restore_cursor_position { | ||
| 46 | my $self = shift; | ||
| 47 | |||
| 48 | # editor_enable gets called before the tab has been created when opening a new psgi file, | ||
| 49 | # so we set the icon inside this method which is conveniently triggered after the tab | ||
| 50 | # has been created in Padre::Wx::Main::setup_editor | ||
| 51 | $self->set_tab_icon; | ||
| 52 | |||
| 53 | return $self->SUPER::restore_cursor_position(@_); | ||
| 54 | } | ||
| 55 | |||
| 56 | |||
| 57 | sub store_cursor_position { | ||
| 58 | my $self = shift; | ||
| 59 | $self->plugin->on_doc_close($self) if ( caller(1) )[3] eq 'Padre::Wx::Main::close'; | ||
| 60 | return $self->SUPER::store_cursor_position(@_); | ||
| 61 | } | ||
| 62 | |||
| 63 | |||
| 64 | 1; | ||
| 65 | |||
| 66 | __END__ | ||