Glade-Perl-Two source code generator - (the old version Glade-Perl is here)

A logo

NB If you want to generate code from the old glade (versions <= 0.6.4) you need to download the old package Glade-Perl

This is a collection of modules that will read a <GTK-Interface> XML file produced by Gtk+/Gnome UI builder Glade (versions <= 0.6.4), construct and optionally show the UI using the Gtk2-Perl bindings. It is possible, using Glade, for you to specify a language of 'Perl' and generate source code from Glade's 'Build' button.

Glade-Perl-Two can write the perl modules to construct/run the UI together with a skeleton "App" and a working subclass for you to edit. The modules generated are pretty much OO code and can be combined and split in any way that you wish.

Glade-Perl-Two will generate code to construct all the widgets that Glade-2 knows about apart from the Gnome and GnomeDb ones.

You can read the online documentation or download Glade-Perl-Two and find software that we depend on.

Glade::Two::Generate

Glade::Two::Generate is the user interface to the whole shebang. There are many options but in broad terms it will do either or both:

  1. Show and run the interface. Any missing signal handlers are hijacked to show a simple message box but any existing handlers will do what they are expected to.
  2. Produce the perl OO classes necessary to construct and run the UI.
    AUTOLOAD OO style (default)
    • ProjectUI.pm a perl class/module that contains a class for each toplevel window/dialog, each with a standard method (new) that will construct the UI.
    • ProjectSIGS.pm a perl class/module that contains a class for each toplevel window/dialog, with skeleton signal handlers for any that were missing at build time.
    • Project.pm a perl class/module that is a copy of projectSIGS.pm for you to edit to become your "App". You can generate the UI again and again without changing any of your signal handlers as it is only written the first time through (if missing). If you add signal definitions to your Glade-2 project, skeletons for the handlers will be generated in the projectSIGS.pm file and you can cut-and-paste them from there into the relevant class in the project.pm "App" module
    • SubProject.pm a perl class/module that subclasses project.pm that you can edit to subclass your "App". You can generate the UI again and again without changing any of your signal handlers as it is only written the first time through (if missing).
    Libglade style
    • ProjectLIBGLADE.pm a perl class/module that initialises the Libglade bindings and has skeleton signal handlers that you can edit to form your "App". You can generate the UI again and again without changing any of your signal handlers as it is only written the first time through (if missing).
  3. If you specifiy a filename (or STDOUT) as the output filename all the generated code will be written to this file (or STDOUT), but of course you will not have any valid perl files to run later.

It use()s and respects any existing signal handler subs that you specify at Build time The point of this is that you can write the signal handlers one by one and supply them to the Build phase so that they are used instead of autoloaded stubs that would otherwise be called.

There are several support modules.
Glade::Two::App Controls the site/user/project options
Glade::Two::Gtk Handles the Gtk widget calls
Glade::Two::Gnome Handles the Gnome and extended widget calls (Not working yet)
Glade::Two::Source Writes the perl source code
Glade::Two::Project Handles the project options and sets the defaults

Glade::Two::Run

The package also contains module Glade::Two::Run that has some run-time Gtk and other utilities needed for the Generate phase AND any subsequent code runs. It is included in the Glade-Perl-Two tarball downloads (below) and must be available when the generated source code is run. Please feel free to distribute the single Glade::Two::Run module file with your application.

Glade-Perl-Two online documentation

Some of the module documentation is available online. The files should be up to date but there are versions in the distribution tarballs.
README What the module does and how it works
INSTALL How to install the modules
Changelog What I have changed in each (recent) version

DEPENDENCIES

Glade-2 UI builder

You can download the latest versions of Glade-2 ( >= 1.1.0) from the Glade homepage .

Gtk2-Perl bindings

The latest versions of Gtk2-Perl bindings are available for download at the Sourceforge project page (version 0.01 available soon after 16 November 2002)

There is a daily CVS snapshot or you can visit the CVS repository. The module is called 'gtk2-perl'.

Perl modules

You can download the latest versions of perl modules from CPAN or better still from your local mirror.


DOWNLOADS

Glade-Perl-Two development versions - code, test, install and documentation files.

The tarballs below contain all Glade-Perl-Two modules needed to generate perl source code from a Glade-2 file and then run it.

Glade-Perl-Two is also available on CPAN although it is probably best to download it from your local CPAN mirror

If you download and try Glade-Perl-Two, PLEASE email me and let me know how you got on. I would really like some criticism, especially if you have problems or ideas for the FAQ. Also, please send me any real-world Glade-2 files (or widgets snipped from them) that fail or don't work as you expect.

You can email me at dermot at glade.perl.connectfree.co.uk or dermot.musgrove at virgin.net


N.B. The latest versions require Gtk2-Perl >= 0.01