App-XUL
view release on metacpan or search on metacpan
lib/App/XUL.pm view on Meta::CPAN
my $path = abs_path($0);
$path =~ s/\/MacOS\/[^\/]+//;
system(
'"'.$path."/Resources/perl/server/server.pl".'" '.
'"'.$path."/Resources/perl/modules/".'" 3000 &'
);
exec(
$path."/Frameworks/XUL.framework/xulrunner-bin",
"-app", $path."/Resources/application.ini",}.
($self->{'debug'} ? '"-jsconsole"' : '').
');'."\n";
}
else {
return '';
}
}
sub _get_file_maxosx_infoplist
{
my ($self) = @_;
return <<EOFSRC
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>start.pl</string>
<key>CFBundleGetInfoString</key>
<string>XULExplorer 1.0a1pre, © 2007-2008 Contributors</string>
<key>CFBundleIconFile</key>
<string>$self->{'name'}</string>
<key>CFBundleIdentifier</key>
<string>org.mozilla.mccoy</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$self->{'name'}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0a1pre</string>
<key>CFBundleSignature</key>
<string>MOZB</string>
<key>CFBundleVersion</key>
<string>1.0a1pre</string>
<key>NSAppleScriptEnabled</key>
<true/>
</dict>
</plist>
EOFSRC
}
1;
__END__
=head1 NAME
App::XUL - Perl extension for creating deployable platform-independent
standalone desktop applications based on XUL and XULRunner.
=for html <span style="color:red">WARNING: PRE-ALPHA - DON'T USE FOR PRODUCTION!</span>
=head1 SYNOPSIS
use App::XUL;
my $app = App::XUL->new(name => 'MyApp');
$app->add(
Window(id => 'main',
Div(id => 'container', 'style' => 'background:black',
Button(label => 'click', oncommand => sub {
ID('container')->style('background:red');
}),
),
),
);
$app->bundle(path => '/path/to/myapp.app', os => 'macosx');
XUL (+ XULRunner) makes it easy to create applications based
on XML, CSS and JavaScript. App::XUL tries to simplify this
even more by exchanging XML and JavaScript with Perl and
providing an easy way to create deployable applications for the
platforms XULRunner exists for.
=head1 WHY XUL/XULRUNNER
XUL provides a set of powerful user widgets that look good
and work as expected. They can be created with minimal effort
and their appearance can be manipulated using CSS.
XUL is based on B<web technologies like XML, CSS and JavaScript>.
So anyone who is able to use these is able to create cool
desktop applications.
Here is the homepage of the L<XUL|https://developer.mozilla.org/En/XUL>
and L<XULRunner|https://developer.mozilla.org/en/xulrunner> projects at Mozilla.
=head1 DESCRIPTION
=head2 new() - Creating an application
The constructor new() is used to create a new application
my $app = App::XUL->new(name => 'MyApp');
=head3 Options
=head4 name => I<string>
The name of the application. Later also used as the application executable's name.
=head2 add() - Add a window to an application
add() adds a window to the XUL application. The XML for the window tag
and its contained tags is created using Perl functions. The names of
the Perl functions used to create the XML tags corresponds to the
tagnames, just the first letter is uppercase:
$app->add(
Window(id => 'main',
Div(id => 'container', 'style' => 'background:black',
Button(label => 'click', oncommand => sub {
ID('container')->style('background:red');
}),
);
)
);
Keep in mind, that add will fail if the added tag is NOT a window tag.
In XUL the root is always a window tag.
The first window beeing added is considered the main window and shown
on startup.
=head2 bundle() - Creating a deployable executable
$app->bundle(path => '/path/to/myapp.app', os => 'macosx');
This will create a complete standalone XUL application containing all XML code.
Some general information about
L<XUL application deployment|https://wiki.mozilla.org/XUL:XUL_Application_Packaging>.
=head3 Options
=head4 path => I<string>
=head4 os => I<string>
The systems currently supported are:
=over 1
( run in 0.704 second using v1.01-cache-2.11-cpan-2398b32b56e )