1GladeXML(3)           User Contributed Perl Documentation          GladeXML(3)
2
3
4

NAME

6       Gtk2::GladeXML - (DEPRECATED) Create user interfaces directly from
7       Glade XML files.
8

SYNOPSIS

10         # for a pure gtk+ glade project
11         use Gtk2 -init;
12         use Gtk2::GladeXML;
13         $gladexml = Gtk2::GladeXML->new('example.glade');
14         $gladexml->signal_autoconnect_from_package('main');
15         $quitbtn = $gladexml->get_widget('Quit');
16         Gtk2->main;
17
18         # for glade files using gnome widgets, you must initialize Gnome2
19         # before loading the glade file.
20         use Gnome2;
21         use Gtk2::GladeXML;
22         # this call also initializes gtk+ for us
23         Gnome2::Program->init ($appname, $version);
24         $gladexml = Gtk2::GladeXML->new('gnomeapp.glade');
25         Gtk2->main;
26

ABSTRACT

28       DEPRECATED Gtk2::GladeXML allows Perl programmers to use libglade, a C
29       library which generates graphical user interfaces directly from the XML
30       output of the Glade user interface designer.
31

DESCRIPTION

33       NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
34
35       This module has been deprecated by the Gtk-Perl project.  This means
36       that the module will no longer be updated with security patches, bug
37       fixes, or when changes are made in the Perl ABI.  The Git repo for this
38       module has been archived (made read-only), it will no longer possible
39       to submit new commits to it.  You are more than welcome to ask about
40       this module on the Gtk-Perl mailing list, but our priorities going
41       forward will be maintaining Gtk-Perl modules that are supported and
42       maintained upstream; this module is neither.
43
44       Since this module is licensed under the LGPL v2.1, you may also fork
45       this module, if you wish, but you will need to use a different name for
46       it on CPAN, and the Gtk-Perl team requests that you use your own
47       resources (mailing list, Git repos, bug trackers, etc.) to maintain
48       your fork going forward.
49
50       •   Perl URL: https://gitlab.gnome.org/GNOME/perl-gtk2-gladexml
51
52       •   Upstream URL: https://gitlab.gnome.org/Archive/libglade
53
54       •   Last upstream version: 2.6.4
55
56       •   Last upstream release date: 2009-03-17
57
58       •   Migration path for this module: Gtk3::Builder
59
60       •   Migration module URL: https://metacpan.org/pod/Gtk3
61
62       NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
63
64       Glade is a free user interface builder for GTK+ and GNOME.  After
65       designing a user interface with glade-2 the layout and configuration
66       are saved in an XML file.  libglade is a library which knows how to
67       build and hook up the user interface described in the Glade XML file at
68       application run time.
69
70       This extension module binds libglade to Perl so you can create and
71       manipulate user interfaces in Perl code in conjunction with Gtk2 and
72       even Gnome2.  Better yet you can load a file's contents into a PERL
73       scalar do a few magical regular expressions to customize things and the
74       load up the app. It doesn't get any easier.
75

FUNCTIONS

77       $gladexml = Gtk2::GladeXML->new(GLADE_FILE, [ROOT, DOMAIN])
78           Create a new GladeXML object by loading the data in GLADE_FILE.
79           ROOT is an optional parameter that specifies a point (widget node)
80           from which to start building.  DOMAIN is an optional parameter that
81           specifies the translation domain for the xml file.
82
83       $gladexml = Gtk2::GladeXML->new_from_buffer(BUFFER, [ROOT, DOMAIN])
84           Create a new GladeXML object from the scalar string contained in
85           BUFFER.  ROOT is an optional parameter that specifies a point
86           (widget node) from which to start building.  DOMAIN is an optional
87           parameter that specifies the translation domain for the xml file.
88
89       $widget = $gladexml->get_widget(NAME)
90           Return the widget created by the XML file with NAME or undef if no
91           such name exists.
92
93       $gladexml->signal_autoconnect($callback[, $userdata])
94           Iterates over all signals and calls the given callback:
95
96              sub example_cb {
97                 my ($name, $widget, $signal, $signal_data, $connect, $after, $userdata) = @_;
98              }
99
100           The following two convenience methods use this to provide a more
101           convenient interface.
102
103       $gladexml->signal_autoconnect_from_package([PACKAGE or OBJECT])
104           Sets up the signal handling callbacks as specified in the glade XML
105           data.
106
107           The argument to this method can be a Perl package name or an
108           object.  If a package name is used, each handler named in the Glade
109           XML data will be called as a subroutine in the named package.  If
110           an object is supplied each handler will be called as a method of
111           the object.  If no argument is supplied, the name of the calling
112           package will be used.  A user data argument cannot be supplied
113           however this is seldom necessary when an object is used.
114
115           The names of the subroutines or methods must exactly match the
116           handler name in the XML data.  It is worth noting that callbacks
117           you get for free in c such as gtk_main_quit will not exist in perl
118           and must always be defined, for example:
119
120             sub gtk_main_quit
121             {
122                   Gtk2->main_quit;
123             }
124
125           Otherwise behavior should be exactly as expected with the use of
126           libglade from a C application.
127
128       $gladexml->signal_autoconnect_all (name => handler, ...)
129           Iterates over all named signals and tries to connect them to the
130           handlers specified as arguments (handlers not given as argument are
131           being ignored). This is very handy when implementing your own
132           widgets, where you can't use global callbacks.
133
134       $widget = Gtk2::Glade->set_custom_handler ($callback[, $userdata])
135           This method tells Gtk2::GladeXML how to create handlers for custom
136           widgets.
137
138           You can specify a "custom" widget in a glade file, which allows you
139           to include in your interface widgets that Glade itself doesn't know
140           how to create.  To tell libglade how to instantiate such widgets,
141           you specify a "custom widget handler", a function which returns a
142           Gtk2:Widget object for that custom widget.  This handler needs to
143           be installed sometime before the instantiation of your
144           Gtk2::GladeXML object, by calling "set_custom_handler".
145
146               my $widget = Gtk2::Glade->set_custom_handler( \&my_handler );
147               my $gladexml = Gtk2::GladeXML->new( 'MyApp.glade' );
148
149           The prototype for the custom handler is:
150
151               sub my_handler {
152                   my ($xml,       # The Gtk2::GladeXML object
153                       # the remaining arguments are as specified in the glade file:
154                       $func_name, # The function name
155                       $name,      # the name of the widget to be created
156                       $str1,      # the string1 property
157                       $str2,      # the string2 property
158                       $int1,      # the int1 property
159                       $int2,      # the int2 property
160                       $userdata   # the data passed to set_custom_handler
161                      ) = @_;
162                   ...
163                   return $widget; # a new Gtk2::Widget; you must call ->show on it.
164               }
165

FAQ

167       Where is the option to generate Perl source in Glade?
168           Glade itself only creates the XML description, and relies on extra
169           converter programs to write source code; only a few converters are
170           widely popular.
171
172           In general, however, you don't want to generate source code for a
173           variety of reasons, mostly to do with maintainability.  This
174           message on the glade-devel list explains it best:
175
176           http://lists.ximian.com/archives/public/glade-devel/2003-February/000015.html
177
178       Why does my program crash on startup?
179           Does your glade file use Gnome widgets?  If so, you must initialize
180           Gnome manually; libglade can knows how to create gnome widgets, but
181           can't know how you want to initialize the app.  This is usually
182           sufficient:
183
184             use Gnome2;
185             Gnome2::Program->init ($app_name, $version_string);
186
187           Libglade's API reference mentions this:
188           http://developer.gnome.org/doc/API/2.0/libglade/libglade-modules.html
189

SEE ALSO

191       perl(1), Glib(3pm), Gtk2(3pm)
192
193       The Libglade Reference Manual at
194       <http://developer.gnome.org/doc/API/2.0/libglade/>
195
196       An introductory article that originally appeared in The Perl Review:
197       <http://live.gnome.org/GTK2-Perl/GladeXML/Tutorial>
198

AUTHOR

200       Ross McFarland <rwmcfa1 at neces dot com>, Marc Lehmann <pcg@goof.com>,
201       muppet <scott at asofyet dot org>.  Bruce Alderson provided several
202       examples.  Grant McClean <grant at mclean dot net dot nz> and Marco
203       Antonio Manzo <amnesiac at perl dot org dot mx> contributed
204       documentation.
205
207       Copyright 2003-2006 by the gtk2-perl team.
208
209       This library is free software; you can redistribute it and/or modify it
210       under the terms of the GNU Library General Public License as published
211       by the Free Software Foundation; either version 2 of the License, or
212       (at your option) any later version.
213
214       This library is distributed in the hope that it will be useful, but
215       WITHOUT ANY WARRANTY; without even the implied warranty of
216       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
217       Library General Public License for more details.
218
219       You should have received a copy of the GNU Library General Public
220       License along with this library; if not, see
221       <https://www.gnu.org/licenses/>.
222
223
224
225perl v5.38.0                      2023-07-20                       GladeXML(3)
Impressum