Changeset 9636
- Timestamp:
- 12/12/09 07:06:05 (2 years ago)
- Location:
- trunk/Padre/lib/Padre
- Files:
-
- 2 edited
-
Action/Plugins.pm (modified) (1 diff)
-
Wx/Menu/Plugins.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Action/Plugins.pm
r9469 r9636 171 171 } 172 172 173 ##################################################################### 174 # Module Tools 175 176 sub install_file { 177 my $self = shift; 178 my $main = shift; 179 180 # Ask what we should install 181 my $dialog = Wx::FileDialog->new( 182 $main, 183 Wx::gettext("Select distribution to install"), 184 '', # Default directory 185 '', # Default file 186 'CPAN Packages (*.tar.gz)|*.tar.gz', # wildcard 187 Wx::wxFD_OPEN | Wx::wxFD_FILE_MUST_EXIST 188 ); 189 $dialog->CentreOnParent; 190 if ( $dialog->ShowModal == Wx::wxID_CANCEL ) { 191 return; 192 } 193 my $string = $dialog->GetPath; 194 $dialog->Destroy; 195 unless ( defined $string and $string =~ /\S/ ) { 196 $main->error( Wx::gettext("Did not provide a distribution") ); 197 return; 198 } 199 200 $self->install_pip( $main, $string ); 201 return; 202 } 203 204 sub install_url { 205 my $self = shift; 206 my $main = shift; 207 208 # Ask what we should install 209 my $dialog = Wx::TextEntryDialog->new( 210 $main, 211 Wx::gettext("Enter URL to install\ne.g. http://svn.ali.as/cpan/releases/Config-Tiny-2.00.tar.gz"), 212 "pip", 213 '', 214 ); 215 if ( $dialog->ShowModal == Wx::wxID_CANCEL ) { 216 return; 217 } 218 my $string = $dialog->GetValue; 219 $dialog->Destroy; 220 unless ( defined $string and $string =~ /\S/ ) { 221 $main->error( Wx::gettext("Did not provide a distribution") ); 222 return; 223 } 224 225 $self->install_pip( $main, $string ); 226 return; 227 } 228 229 sub install_pip { 230 my $self = shift; 231 my $main = shift; 232 my $module = shift; 233 234 # Find 'pip', used to install modules 235 require File::Which; 236 my $pip = scalar File::Which::which('pip'); 237 unless ( -f $pip ) { 238 $main->error( Wx::gettext("pip is unexpectedly not installed") ); 239 return; 240 } 241 242 $main->setup_bindings; 243 244 # Run with console Perl to prevent unexpected results under wperl 245 my $perl = Padre::Perl::cperl(); 246 my $cmd = qq{"$perl" "$pip" "$module"}; 247 local $ENV{AUTOMATED_TESTING} = 1; 248 Wx::Perl::ProcessStream::Process->new->Run( $cmd, 'CPAN_mod', $main ); 249 250 return; 251 } 252 253 sub cpan_config { 254 my $self = shift; 255 my $main = shift; 256 257 # Locate the CPAN config file(s) 258 my $default_dir = ''; 259 eval { 260 require CPAN; 261 $default_dir = $INC{'CPAN.pm'}; 262 $default_dir =~ s/\.pm$//is; # remove .pm 263 }; 264 265 # Load the main config first 266 if ( $default_dir ne '' ) { 267 my $core = File::Spec->catfile( $default_dir, 'Config.pm' ); 268 if ( -e $core ) { 269 $main->setup_editors($core); 270 return; 271 } 272 } 273 274 # Fallback to a personal config 275 my $user = File::Spec->catfile( 276 File::HomeDir->my_home, 277 '.cpan', 'CPAN', 'MyConfig.pm' 278 ); 279 if ( -e $user ) { 280 $main->setup_editors($user); 281 return; 282 } 283 284 $main->error( Wx::gettext("Failed to find your CPAN configuration") ); 285 } 286 173 287 1; 174 288 -
trunk/Padre/lib/Padre/Wx/Menu/Plugins.pm
r9469 r9636 192 192 193 193 194 #####################################################################195 # Module Tools196 197 sub install_file {198 my $self = shift;199 my $main = shift;200 201 # Ask what we should install202 my $dialog = Wx::FileDialog->new(203 $main,204 Wx::gettext("Select distribution to install"),205 '', # Default directory206 '', # Default file207 'CPAN Packages (*.tar.gz)|*.tar.gz', # wildcard208 Wx::wxFD_OPEN | Wx::wxFD_FILE_MUST_EXIST209 );210 $dialog->CentreOnParent;211 if ( $dialog->ShowModal == Wx::wxID_CANCEL ) {212 return;213 }214 my $string = $dialog->GetPath;215 $dialog->Destroy;216 unless ( defined $string and $string =~ /\S/ ) {217 $main->error( Wx::gettext("Did not provide a distribution") );218 return;219 }220 221 $self->install_pip( $main, $string );222 return;223 }224 225 sub install_url {226 my $self = shift;227 my $main = shift;228 229 # Ask what we should install230 my $dialog = Wx::TextEntryDialog->new(231 $main,232 Wx::gettext("Enter URL to install\ne.g. http://svn.ali.as/cpan/releases/Config-Tiny-2.00.tar.gz"),233 "pip",234 '',235 );236 if ( $dialog->ShowModal == Wx::wxID_CANCEL ) {237 return;238 }239 my $string = $dialog->GetValue;240 $dialog->Destroy;241 unless ( defined $string and $string =~ /\S/ ) {242 $main->error( Wx::gettext("Did not provide a distribution") );243 return;244 }245 246 $self->install_pip( $main, $string );247 return;248 }249 250 sub install_pip {251 my $self = shift;252 my $main = shift;253 my $module = shift;254 255 # Find 'pip', used to install modules256 require File::Which;257 my $pip = scalar File::Which::which('pip');258 unless ( -f $pip ) {259 $main->error( Wx::gettext("pip is unexpectedly not installed") );260 return;261 }262 263 $main->setup_bindings;264 265 # Run with console Perl to prevent unexpected results under wperl266 my $perl = Padre::Perl::cperl();267 my $cmd = qq{"$perl" "$pip" "$module"};268 local $ENV{AUTOMATED_TESTING} = 1;269 Wx::Perl::ProcessStream::Process->new->Run( $cmd, 'CPAN_mod', $main );270 271 return;272 }273 274 sub cpan_config {275 my $self = shift;276 my $main = shift;277 278 # Locate the CPAN config file(s)279 my $default_dir = '';280 eval {281 require CPAN;282 $default_dir = $INC{'CPAN.pm'};283 $default_dir =~ s/\.pm$//is; # remove .pm284 };285 286 # Load the main config first287 if ( $default_dir ne '' ) {288 my $core = File::Spec->catfile( $default_dir, 'Config.pm' );289 if ( -e $core ) {290 $main->setup_editors($core);291 return;292 }293 }294 295 # Fallback to a personal config296 my $user = File::Spec->catfile(297 File::HomeDir->my_home,298 '.cpan', 'CPAN', 'MyConfig.pm'299 );300 if ( -e $user ) {301 $main->setup_editors($user);302 return;303 }304 305 $main->error( Wx::gettext("Failed to find your CPAN configuration") );306 }307 308 194 1; 309 195
Note: See TracChangeset
for help on using the changeset viewer.
