| | 30 | } |
| | 31 | |
| | 32 | =head2 C<open_in_file_browser> |
| | 33 | |
| | 34 | Padre::Wx::Directory::OpenInFileBrowserAction->open_in_file_browser($filename); |
| | 35 | |
| | 36 | Single shot method to open the provided C<$filename> in the file browser |
| | 37 | On win32, selects it in Windows Explorer |
| | 38 | On UNIX, opens the containing folder for it using either KDE or GNOME |
| | 39 | |
| | 40 | =cut |
| | 41 | |
| | 42 | sub open_in_file_browser { |
| | 43 | my ($class, $filename) = @_; |
| | 44 | my $self = $class->new(@_); |
| | 45 | my $main = Padre::Current->main; |
| | 46 | |
| | 47 | unless ($filename) { |
| | 48 | $main->error( Wx::gettext("No filename") ); |
| | 49 | return; |
| | 50 | } |
| | 51 | |
| | 52 | my $error; |
| | 53 | if (Padre::Constant::WIN32) { |
| | 54 | |
| | 55 | # In windows, simply execute: explorer.exe /select,"$filename" |
| | 56 | $filename =~ s/\//\\/g; |
| | 57 | $error = $self->_execute( 'explorer.exe', "/select,\"$filename\"" ); |
| | 58 | } elsif (Padre::Constant::UNIX) { |
| | 59 | my $parent_folder = File::Basename::dirname($filename); |
| | 60 | $error = $self->_execute_unix($parent_folder); |
| | 61 | } else { |
| | 62 | |
| | 63 | # Unsupported |
| | 64 | $error = sprintf( Wx::gettext("Unsupported OS: %s"), '$^O' ); |
| | 65 | } |
| | 66 | |
| | 67 | if ($error) { |
| | 68 | $main->error($error); |
| | 69 | } |
| | 70 | |
| | 71 | return; |
| | 72 | } |
| | 73 | |
| | 74 | =head2 C<open_with_default_system_editor> |
| | 75 | |
| | 76 | Padre::Wx::Directory::OpenInFileBrowserAction->open_in_file_browser($filename); |
| | 77 | |
| | 78 | Single shot method to open the provided C<$filename> using the default system editor |
| | 79 | |
| | 80 | =cut |
| | 81 | |
| | 82 | sub open_with_default_system_editor { |
| | 83 | my ($class, $filename) = @_; |
| | 84 | my $self = $class->new(@_); |
| | 85 | my $main = Padre::Current->main; |
| | 86 | |
| | 87 | unless ($filename) { |
| | 88 | $main->error( Wx::gettext("No filename") ); |
| | 89 | return; |
| | 90 | } |
| | 91 | |
| | 92 | my $error; |
| | 93 | if (Padre::Constant::WIN32) { |
| | 94 | |
| | 95 | # Win32 |
| | 96 | require Padre::Util::Win32; |
| | 97 | Padre::Util::Win32::ExecuteProcessAndWait( |
| | 98 | directory => $self->{cwd}, |
| | 99 | file => $filename, |
| | 100 | parameters => '', |
| | 101 | show => 1 |
| | 102 | ); |
| | 103 | } elsif (Padre::Constant::UNIX) { |
| | 104 | |
| | 105 | # Unix |
| | 106 | $error = $self->_execute_in_file_mananger($filename); |
| | 107 | } else { |
| | 108 | |
| | 109 | # Unsupported |
| | 110 | $error = sprintf( Wx::gettext("Unsupported OS: %s"), '$^O' ); |
| | 111 | } |
| | 112 | |
| | 113 | if ($error) { |
| | 114 | $main->error($error); |
| | 115 | } |
| | 116 | |
| | 117 | return; |
| 65 | | } |
| 66 | | |
| 67 | | =head2 C<open_in_file_browser> |
| 68 | | |
| 69 | | $action->open_in_file_browser($filename); |
| 70 | | |
| 71 | | Opens the provided C<$filename> in the file browser |
| 72 | | On win32, selects it in Windows Explorer |
| 73 | | On UNIX, opens the containing folder for it using either KDE or GNOME |
| 74 | | |
| 75 | | =cut |
| 76 | | |
| 77 | | sub open_in_file_browser { |
| 78 | | my ( $self, $filename ) = @_; |
| 79 | | my $main = Padre::Current->main; |
| 80 | | |
| 81 | | unless ($filename) { |
| 82 | | $main->error( Wx::gettext("No filename") ); |
| 83 | | return; |
| 84 | | } |
| 85 | | |
| 86 | | my $error; |
| 87 | | if (Padre::Constant::WIN32) { |
| 88 | | |
| 89 | | # In windows, simply execute: explorer.exe /select,"$filename" |
| 90 | | $filename =~ s/\//\\/g; |
| 91 | | $error = $self->_execute( 'explorer.exe', "/select,\"$filename\"" ); |
| 92 | | } elsif (Padre::Constant::UNIX) { |
| 93 | | my $parent_folder = File::Basename::dirname($filename); |
| 94 | | $error = $self->_execute_unix($parent_folder); |
| 95 | | } else { |
| 96 | | |
| 97 | | # Unsupported |
| 98 | | $error = sprintf( Wx::gettext("Unsupported OS: %s"), '$^O' ); |
| 99 | | } |
| 100 | | |
| 101 | | if ($error) { |
| 102 | | $main->error($error); |
| 103 | | } |
| 104 | | |
| 105 | | return; |
| 106 | | } |
| 107 | | |
| 108 | | =head2 C<open_with_default_system_editor> |
| 109 | | |
| 110 | | $action->open_in_file_browser($filename); |
| 111 | | |
| 112 | | Opens the provided C<$filename> using the default system editor |
| 113 | | |
| 114 | | =cut |
| 115 | | |
| 116 | | sub open_with_default_system_editor { |
| 117 | | my ( $self, $filename ) = @_; |
| 118 | | |
| 119 | | my $main = Padre::Current->main; |
| 120 | | unless ($filename) { |
| 121 | | $main->error( Wx::gettext("No filename") ); |
| 122 | | return; |
| 123 | | } |
| 124 | | |
| 125 | | my $error; |
| 126 | | if (Padre::Constant::WIN32) { |
| 127 | | |
| 128 | | # Win32 |
| 129 | | require Padre::Util::Win32; |
| 130 | | Padre::Util::Win32::ExecuteProcessAndWait( |
| 131 | | directory => $self->{cwd}, |
| 132 | | file => $filename, |
| 133 | | parameters => '', |
| 134 | | show => 1 |
| 135 | | ); |
| 136 | | } elsif (Padre::Constant::UNIX) { |
| 137 | | |
| 138 | | # Unix |
| 139 | | $error = $self->_execute_in_file_mananger($filename); |
| 140 | | } else { |
| 141 | | |
| 142 | | # Unsupported |
| 143 | | $error = sprintf( Wx::gettext("Unsupported OS: %s"), '$^O' ); |
| 144 | | } |
| 145 | | |
| 146 | | if ($error) { |
| 147 | | $main->error($error); |
| 148 | | } |
| 149 | | |
| 150 | | return; |