SYNOPSIS

        use Gtk2::Ex::PrintDialog;

        my $dialog = Gtk2::Ex::PrintDialog->new;        # a new dialog

        $dialog->set_data($postscript_data);            # supply some postscript data

        $dialog->set_filename($postscript_file);        # get postscript from a file

        $dialog->run;                                   # show the dialog to the user

DESCRIPTION

This module implements a dialog widget that can be used to print PostScript data. It is intended to be a lightweight and pure-perl alternative to the Gnome2::Print libraries.

This module uses a simple system of operating-system specific backends that are used to do the job of printing. Currently, only a generic Linux/Unix backend (implemented using Net::CUPS) is available, more will be added in the future.

The dialog itself is intended to comply with the \s-1GNOME\s0 Human Interface Guidelines (\s-1HIG\s0). It allows the user to print to any printer installed on the system, or to an external command such as \*(C`lpr\*(C', or to print a PostScript or \s-1PDF\s0 file.

This module is \s-1UNSTABLE\s0, the behaviour and \s-1API\s0 of its components may change in the future.

OBJECT HIERARCHY

Glib::Object +----Gtk2::Object +----Gtk2::Widget +----Gtk2::Container +----Gtk2::Bin +----Gtk2::Window +----Gtk2::Dialog +----Gtk2::Ex::PrintDialog

METHODS

my $dialog = Gtk2::Ex::PrintDialog->new;

Returns an instance of \*(C`Gtk2::Ex::PrintDialog\*(C'. These dialogs are subclasse of \*(C`Gtk2::Dialog\*(C' so all corresponding methods, signals and properties from that class are also available.

The dialog will handle user actions itself so you will probably not need to connect to any signals.

$dialog->set_data($data);

This tells the dialog to use the PostScript data in $data. This might be PostScript data you create yourself, or from another application. This data can subsequently retrieved using \*(C`get_data()\*(C'.

$dialog->set_filename($file);

This tells the dialog to use the PostScript data in $file. The file name can be subsequently retrieved using \*(C`get_filename()\*(C'. The contents of the file are read into memory when \*(C`set_filename()\*(C' is called, so any subequent calls to \*(C`get_data()\*(C' will return the contents of $file.

LOCALISATION ISSUES

If the \*(C`Locale::gettext\*(C' module is available on the system, and your application uses it, all the strings used in the dialog will be automagically translated, as long as these default values are translated in your .mo files.

WRITING BACKENDS

Backends are Perl modules with names of the form

C<Gtk2::Ex::PrintDialog::$^O>

See perlvar for details of the $^O variable. The module must have the following methods: The constructor. Returns an array of printer names. Prints the contents of $file to the printer named $file Returns the path to the default print command, if applicable (eg '\*(C`lpr\*(C'') Returns a true value if \s-1PDF\s0 printing is supported, \*(C`undef\*(C' otherwise. Prints the PostScript data in $data to the \s-1PDF\s0 file named $file. Consult Gtk2::Ex::PrintDialog::Unix for an example. Please note that this interface may change in the future.

PREREQUISITES

Gtk2
Locale::gettext (recommended)
Net::CUPS (for the Unix/Linux backend)

RELATED TO Gtk2::Ex::PrintDialog…

Gnome2::Print provides Perl bindings to the \*(L"offical\*(R" \s-1GNOME\s0 printing library. If you want a simple way to generate PostScript data, consider PostScript::Simple.

TO DO

More backends.

AUTHOR

Gavin Brown (gavin dot brown at uk dot com)

COPYRIGHT

(c) 2005 Gavin Brown. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.