Creates a new plug which will be connected to the socket specified by the socket_id.
You should make sure that the socket exists when connecting the plug to it. If it does not, the results are undefined. Probably a new GtkWindow will be created and the plug embedded in this window, but you shouldn't rely on that behavior.
The following example creates a plug which connects to the socket created in the constructor example of GtkSocket.
Ejemplo 32. Plugging into a socket
<?php if( !extension_loaded('gtk')) { dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); } if( $GLOBALS['argc'] != 2) { die( 'Please pass the socket id as parameter!' . "\r\n"); } $socketid = $GLOBALS['argv'][1]; $plug = &new GtkPlug( $socketid); $plug->set_default_size( 300, 300); $plug->connect_object('destroy', array('gtk', 'main_quit')); $plug->set_title( 'plug'); $label = &new GtkLabel( 'hello from outer space'); $plug->add( $label); $plug->show_all(); function changeLabel( $objButton, $objLabel, $strLabel) { $objLabel->set_text( $strLabel); } $window = &new GtkWindow(); $window->set_title( 'plug controller'); $window->set_default_size( 200, 300); $window->connect_object('destroy', array('gtk', 'main_quit')); $vbox = &new GtkVBox(); $arLabels = array( 'Hello!', 'Yes, I can control you', 'Don\'t believe it, heh?'); foreach( $arLabels as $strLabel) { $btn = &new GtkButton( $strLabel); $btn->connect( 'clicked', 'changeLabel', $label, $strLabel); $vbox->pack_start_defaults( $btn); } $window->add( $vbox); $window->show_all(); gtk::main(); ?> |