I am going through the book PHP-GTK and trying out listing 4-1
One thing I notice is that with the following code some odd output occurs:
<?php
//listing4-1b.php
function setParentFunction($widget)
{
//get the widgets parent
$parent = $widget->get_parent();
//echo a mssg about the widget
echo 'The ' . get_class($widget) .' has ';
if (isset($parent))
{
//ech the class of the parent widget
echo 'a '. get_class($parent);
}
else {
//the widget does not have a parent
echo 'no';
}
echo " parent. \n";
}
//start with widgets
$frame = new GtkFrame('i am a frame');
$button = new GtkButton('i am a button');
//connect the event to our test function
$button->connect('parent-set', 'setParentFunction');
$frame->add($button);
?>
The output is:
# php listing4-1b.php
The GtkButton has a GtkFrame parent.
The GtkButton has no parent.
Now, I can understand why the first signal is getting emitted and causing the first line of output:
The GtkButton has a GtkFrame parent.
But, I don't understand why the 2nd 'parent change' is reported to have happened:
The GtkButton has no parent.
I expected only to see the signal getting emitted / and handled only once in this short script.
Does this 2nd signal get emmitted when the script closes down?