| Perl-Dist-WiX documentation | Contained in the Perl-Dist-WiX distribution. |
Perl::Dist::WiX::Asset::Launcher - Start menu launcher asset for a Win32 Perl
This document describes Perl::Dist::WiX::Asset::Launcher version 1.500.
my $batlauncher = Perl::Dist::WiX::Asset::Launcher->new(
parent => $dist,
name => 'CPAN Client',
bin => 'cpan',
);
$batlauncher->install();
my $exelauncher = Perl::Dist::WiX::Asset::Launcher->new(
parent => $dist,
name => 'Padre Development Environment',
bin => 'padre',
exe => 1,
);
$exelauncher->install();
This asset creates a Start Menu entry for a script or executable file in the perl binary directory.
This class is a Perl::Dist::WiX::Role::Asset and shares its API.
The new constructor takes a series of parameters, validates then
and returns a new Perl::Dist::WiX::Asset::Launcher object.
It inherits all the parameters described in the Perl::Dist::WiX::Role::Asset->new() method documentation, and adds the additional parameters described below.
The required name parameter is the name of the link in the start menu.
The bin parameter is the name of the script or executable file to link
to.
The exe parameter specifies if the file is an executable file, as opposed to
a script that has been converted to a batch file.
The directory_id parameter specifies the directory that the Start menu
link is to be created in.
The install method installs the Start Menu link described by the Perl::Dist::WiX::Asset::Launcher object and returns true (or throws an exception.)
Bugs should be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-Dist-WiX
For other issues, contact the author.
Curtis Jewell <csjewell@cpan.org>
Adam Kennedy <adamk@cpan.org>
Copyright 2009 - 2010 Curtis Jewell.
Copyright 2007 - 2009 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
| Perl-Dist-WiX documentation | Contained in the Perl-Dist-WiX distribution. |
package Perl::Dist::WiX::Asset::Launcher;
use 5.010; use Moose; use MooseX::Types::Moose qw( Str Bool ); use File::Spec::Functions qw( catfile ); use Perl::Dist::WiX::Exceptions; our $VERSION = '1.500'; $VERSION =~ s/_//ms; with 'Perl::Dist::WiX::Role::NonURLAsset';
has name => ( is => 'bare', isa => Str, reader => 'get_name', required => 1, );
has bin => ( is => 'bare', isa => Str, reader => '_get_bin', required => 1, );
has exe => ( is => 'bare', isa => Bool, reader => '_get_exe', default => 0, );
has directory_id => ( is => 'bare', isa => Str, reader => '_get_directory_id', default => 'D_App_Menu_Tools', );
sub install { my $self = shift; my $bin = $self->_get_bin(); my $ext = $self->_get_exe() ? '.exe' : '.bat'; # Check the script exists my $to = catfile( $self->_get_image_dir(), 'perl', 'bin', "$bin$ext" ); if ( not -f $to ) { PDWiX::File->throw( file => $to, message => 'File does not exist' ); } my $icons = $self->_get_icons(); my $icon_type = ref $icons; $icon_type ||= '(undefined type)'; if ( 'Perl::Dist::WiX::IconArray' ne $icon_type ) { PDWiX->throw( "Icons array is of type $icon_type, " . 'not a Perl::Dist::WiX::IconArray' ); } my $icon_id = $self->_get_icons() ->add_icon( $self->_get_icon_file($bin), "$bin$ext" ); # Add the icon. $self->_add_icon( name => $self->get_name(), filename => $to, fragment => 'StartMenuIcons', icon_id => $icon_id, directory_id => $self->_get_directory_id(), ); return 1; } ## end sub install sub _get_icon_file { my $self = shift; my $name = shift; my ( $dir, $file ); # Start with the parent reference contained in this asset. my $class = ref $self->_get_parent(); no strict 'refs'; ## no critic(ProhibitNoStrict) while ( defined $class and $class ne 'Moose::Object' ) { # Get the directory of this class's dist_dir and check for the icon. $dir = $class->dist_dir(); $file = catfile( $dir, "$name.ico" ); if ( -f $file ) { return $file; } # Pick up the first parent of the class, and try again. $class = ${"${class}::ISA"}[0]; } ## end while ( defined $class and...) PDWiX::File->throw( message => 'File not found.', file => "$name.ico" ); return; } ## end sub _get_icon_file no Moose; __PACKAGE__->meta->make_immutable; 1; __END__