Glade::PerlGenerate - Generate Perl source from a Glade XML project file.
The simplest way to run Glade::PerlGenerate is to use the supplied script 'glade2perl' that is also called by Glade when you hit the 'Build' button.
glade2perl Project.glade 2
Otherwise you can control every aspect of the source generation by calling the same methods that glade2perl calls:
use Glade::PerlGenerate;
Glade::PerlGenerate->Form_from_Glade_File(
'author' => 'Dermot Musgrove <dermot.musgrove@virgin.net>', 'description' => "This is an example of the Glade-Perl source code generator", 'verbose' => 2, 'indent' => ' ', 'tabwidth' => 4, 'diag_wrap' => 0, 'write_source' => 'True', 'dont_show_UI' => 'True', 'autoflush' => 'True', 'use_modules' => 'Example::BusForm_mySUBS', 'log_file' => 'Test.log', 'glade_filename'=> "Example/BusForm.glade"
);
OR if you want to generate the UI directly from an XML string
Glade::PerlGenerate->Form_from_XML(
'xml' => $xml_string, 'use_modules' => ['Example::Project_mySUBS']
);
Glade::PerlGenerate reads a <GTK-Interface> definition from a Glade file (or a string) using XML::Parser, converts it into a hash of hashes and works its way through this to show the UI using Gtk-Perl bindings. The module can also optionally generate Perl source code to show the UI and handle the signals. Any signal handlers that are specified in the project file but not visible at Generate time will be hijacked to show a 'missing_handler' message_box and a stub for it will be defined in the the UI class for dynamic AUTOLOAD()ing.
The stub will simply show a message_box to prove that the handler has been called and you can write your own with the same name in another module. You then quote this module to the next Generate run and Glade::PerlGenerate will use these handlers and not define stubs.
These options can be specified to the
Glade::PerlGenerate->Form_from_Glade_File() and
Glade::PerlGenerate->Form_from_XML()
methods or with the same name in the options XML files.
Boolean values can be specified as True|true|Yes|yes|1 or
False|false|No|no|0|''|undef
e.g. Dermot Musgrove <dermot.musgrove@virgin.net
e.g. 0.53-pre1
e.g. Christmas eve 2001
e.g This is a reference form that contains all the widgets that Glade
knows about
use() any other modulesIn an options file, a newline separated list of modules to be use()d by generated classes
e.g ['Existing::mySUBS', 'Some::Other::Module']
eg ISO-8859-1
0.6123 I have CPAN version 0.6123
19991001 I have the gnome.org CVS version of 'gnome-perl'
that I downloaded on Oct 1st 1999
1.0.58 I have the released version 1.0.58 of 'gnome-libs'
19991001 I have the gnome.org CVS version of 'gnome-libs'
that I downloaded on Oct 1st 1999
options() or
Form_from_File() although it is logged in the project_options file
options() or
Form_from_File() although it is logged in the project_options file
options() or
Form_from_File() although it is logged in the project_options file
options() or
Form_from_File() although it is saved in the file itself.
eg ISO-8859-1
e.g. ' ' (2 spaces)
e.g. 4
STDOUT Write sources to STDOUT but there will be nothing to run later
File.pm Write sources to File.pm They will not run from here
and you must cut-paste them
True - write the sources to standard files.
undef Don't write source code
...widget... generates a widget hierarchy eg $form->{'__WH'}{'vbox2'}{'table1'}...
...class... generates a class hierarchy eg $form->{'__CH'}{'GtkVBox'}{'vbox2'}{'GtkTable'}{'table1'}...
...both... both widget and class hierarchies generated
...ordered... generates an ordered hierarchy that reflects the order that child
widgets were added to the UI eg $form->{'__WH'}{'vbox2'}{'table1'}{'__C'}[2]...
e.g. widget_hierarchy
AUTOLOAD - OO class implements missing signal handlers with an AUTOLOAD sub
Libglade - generate libglade code and signal handlers
split - generates each class in its own .pm file.
e.g. pt_BR
0 - Quiet/no diagnostics (glade2perl uses this) 1 - Main project messages and errors only 2 - also warnings 4 - also project options and more diagnostics 6 - also source code as it is generated 8 - also lookups and conversions 10 - everything (more than you want?)
0 - no breaks (not easy to read on 80 column displays). 80 - should display comfortably on 80 column display 132 - Wrap diagnostics so that lines are about 132 characters long
e.g. ' ' (2 spaces)
e.g. /home/dermot/Devel/Test/Project1.glade2perl.log
e.g. de
<?xml version="1.0" encoding="ISO-8859-1"?>
<glade2perl-Options>
<app>
<allow_gnome>1</allow_gnome>
<date>Tue Apr 10 05:04:00 BST 2001</date>
<description>No description</description>
<logo>Logo.xpm</logo>
<name>Reference</name>
<use_modules>Reference_mySUBS</use_modules>
<version>0.58</version>
</app>
<diag>
<log>/home/dermot/Devel/Glade-Perl/Example/Reference/Project.glade2perl.log</log>
</diag>
<glade>
<directory>/home/dermot/Devel/Glade-Perl/Example/Reference</directory>
<file>/home/dermot/Devel/Glade-Perl/Example/Reference/Project.glade</file>
<name_from>Specified as arg to Glade::PerlGenerate->Form_from_Glade_File</name_from>
<pixmaps_directory>/home/dermot/Devel/Glade-Perl/Example/Reference/pixmaps</pixmaps_directory>
<start_directory>/home/dermot/Devel/Glade-Perl/Example/Reference</start_directory>
</glade>
<glade2perl>
<date>Thu Apr 26 13:32:49 BST 2001</date>
<dont_show_UI>1</dont_show_UI>
<logo>/home/dermot/Devel/Glade-Perl/Example/Reference/pixmaps/glade2perl_logo.xpm</logo>
<my_gnome_libs>1.2.13</my_gnome_libs>
<my_gtk_perl>20010601</my_gtk_perl>
<package>Glade::PerlProject</package>
<start_time>Tue Jun 12 11:59:49 BST 2001</start_time>
<version>0.58</version>
<xml>
<params>Params supplied</params>
<project>/home/dermot/Devel/Glade-Perl/Example/Reference/Project.glade2perl.xml</project>
<set_by>Glade::PerlGenerate->use_Glade_Project</set_by>
</xml>
</glade2perl>
<source>
<style>sxplit</style>
</source>
<test>
<directory>/home/dermot/Devel/Glade-Perl/Example/Reference</directory>
<first_form>ReferenceForm</first_form>
<name>Reference</name>
<use_module>src::Reference</use_module>
</test>
<type>glade2perl</type> </glade2perl-Options>
<?xml version="1.0" encoding="ISO-8859-1"?>
<glade2perl-Options>
<app>
<author>Dermot Musgrove <dermot.musgrove@virgin.net></author>
</app>
<diag>
<LANG>en</LANG>
<indent> </indent>
<verbose>2</verbose>
</diag>
<glade2perl>
<author>Dermot Musgrove <dermot.musgrove@virgin.net></author>
<logo>/home/dermot/Devel/HTML-Site/pixmaps/glade2perl_logo.xpm</logo>
<mru>/home/dermot/Devel/Glade-Perl/Example/Reference/Project.glade</mru>
<name>Glade::PerlGenerate</name>
<start_time>Tue Jun 12 11:59:49 BST 2001</start_time>
<xml>
<app_defaults>Application defaults</app_defaults>
<base_defaults>Glade::PerlRun defaults</base_defaults>
<encoding>ISO-8859-1</encoding>
<params>DEFAULT</params>
<site>/etc/glade2perl.xml</site>
<user>/home/dermot/.glade2perl.xml</user>
</xml>
</glade2perl>
<source>
<LANG>en</LANG>
<indent> </indent>
<tabwidth>4</tabwidth>
<write>1</write>
</source>
</glade2perl-Options>
<?xml version="1.0" encoding="ISO-8859-1"?>
<G2P-Options>
<app>
<copying># This library is released under the same conditions as Perl, that
# is, either of the following:
#
# a) the GNU General Public License as published by the Free
# Software Foundation; either version 1, or (at your option) any
# later version.
#
# b) the Artistic License.
#
# If you use this library in a commercial enterprise, you are invited,
# but not required, to pay what you feel is a reasonable fee to cpan.org
# at http://www.perl.org or contact donors@perlmongers.org for details.
# </copying>
</app>
<glade2perl>
<my_gtk_perl>0.7007</my_gtk_perl>
</glade2perl>
</G2P-Options>
The module will report several errors or warnings that warn of problems with the Glade file or other unexpected occurences. These are to help me cater for new widgets or widget properties and not because Glade creates inconsistent project files but they do point out errors in hand-edited XML.
If the split style is used, the typical filename will be
projectSIGS_class .pm (one file per class).
If the split style is used, the typical filename will be
project_class .pm (one file per class).
Glade::Run(3) glade2perl(1)
Documentation that came with the module is in Directory 'Documentation' in files README, Changelog, FAQ, FAQ.i18n, TODO, NEWS, ROADMAP etc.
The test file for make test is test.pl which is runnable and has
examples of user options.
A Perl script to generate source code from the Glade 'Build' button or menuitem
is in file 'Example/glade2perl' and is installed when you make install.
You can also call this script from the command line.
A module that subclasses the test example is in file Example/SubBus.pm. This module will use (inherit or subclass) the generated perl classes and also use the supplied signal handlers module (Example/BusForm_mySUBS.pm)
Dermot Musgrove <dermot.musgrove@virgin.net>