<?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();
?>
|