Gavin Brown > Gtk2-Ex-PrintDialog > Gtk2::Ex::PrintDialog

Download:
Gtk2-Ex-PrintDialog-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Gtk2::Ex::PrintDialog - a simple, pure Perl dialog for printing PostScript data in GTK+ applications.

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 GNOME Human Interface Guidelines (HIG). It allows the user to print to any printer installed on the system, or to an external command such as lpr, or to print a PostScript or PDF file.

This module is UNSTABLE, the behaviour and API 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 Gtk2::Ex::PrintDialog. These dialogs are subclasse of Gtk2::Dialog 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 get_data().

        $dialog->set_filename($file);

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

LOCALISATION ISSUES ^

If the Locale::gettext 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:

$backend = Gtk2::Ex::PrintDialog::$^O->new

The constructor.

$backend->get_printers

Returns an array of printer names.

$backend->print_file($printer, $file)

Prints the contents of $file to the printer named $file

$backend->get_default_print_command

Returns the path to the default print command, if applicable (eg 'lpr')

$backend->can_print_pdf

Returns a true value if PDF printing is supported, undef otherwise.

$backend->print_to_pdf($data, $file)

Prints the PostScript data in $data to the PDF 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)
Ghostscript, for the ps2pdf command (recommended)

SEE ALSO ^

Gnome2::Print provides Perl bindings to the "offical" GNOME printing library. If you want a simple way to generate PostScript data, consider PostScript::Simple.

TO DO ^

Implement a "Print Preview" function, maybe using Poppler.
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.

syntax highlighting: