GladeXML::signal_connect

GladeXML::signal_connect

Connects all signals with the given handler to a callback function.

In glade, you can "connect" signals to "handlers". These handlers can be named like functions but not necessarily have to be: When using this signal_connect() function you can connect the handler "clicker" to a function called "test". When using signal_autoconnect() this is not possible as glade connects only handlers to functions of the same name as the handler.

Try to extend the example with the following (after glade instantiation and before gtk_main):
function tester()
{
    echo 'test' . "\r\n";
}
$glade->signal_connect( 'test', 'tester');
If you click the close button now, you will see an "test" output line in the shell prompt.

If you want to connect to a function of an object, you should use the following construct:
$glade->signal_connect( 'test', array( $obj, 'function'));
which would cause the 'function' function of the $obj object to be used as the callback for the test handler. Instead of an object you can use a normal string; this means the static function of this class is called:
$glade->signal_connect( 'test', array( 'gtk', 'main_quit'));
This would be the same as a call of gtk::main_quit().

You can pass any type and number of additional parameters to the callback function. Note that the first parameter will be the calling widget.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.