Webhosting and cheap domain registration service
  

 Home

GtkSocket
Prev GtkSocket Constructor Next

GtkSocket Constructor

GtkSocket (void);

Creates a new socket instance. Note that you have to realize the socket after you have added the widget to a parent container.

The other part of the example can be found at the constructor of the GtkPlug widget.

Example 36. How to use a GtkSocket

<?php
if( !extension_loaded('gtk')) {	
	dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); 
}

function checkSocketState( $objButton, $objSocket, $lblStatus)
{
	if( $objSocket->window == null) {
		$lblStatus->set_text( 'The plug has disconnected');
	} else if( count( $objSocket->window->children) > 0) {
		$lblStatus->set_text( 'The plug has plugged in');
	} else {
		$lblStatus->set_text( 'Nobody plugged in');
	}
}

$objSocket		= &new GtkSocket();

$window	= &new GtkWindow();
$window->set_title( 'socket window');
$window->set_default_size( 300, 300);
$window->connect_object('destroy', array('gtk', 'main_quit'));

$vbox = &new GtkVBox();
$vbox->pack_start_defaults( $objSocket);

$lblStatus = &new GtkLabel( 'status messages go here');
$vbox->pack_start_defaults( $lblStatus);

$btnCheck = &new GtkButton( 'check socket state');
$btnCheck->connect( 'clicked', 'checkSocketState', $objSocket, $lblStatus);
$vbox->pack_start_defaults( $btnCheck);

$window->add( $vbox);
$window->show_all();

function unrealized( $objSocket, $btnCheck, $lblStatus) {
	echo 'The plug has disconnected' . "\r\n";
	checkSocketState( $btnCheck, $objSocket, $lblStatus);
}
$objSocket->connect( 'unrealize', 'unrealized', $btnCheck, $lblStatus);

//realize *after* adding it to a box or window
$objSocket->realize();

$socketid = $objSocket->window->xid;
echo 'socket id to use: ' . $socketid . "\r\n";

if( $GLOBALS['argc'] == 2) {
	//steal the given window
	$objSocket->steal( $GLOBALS['argv'][1]);
}

checkSocketState( null, $objSocket, $lblStatus);

gtk::main();
?>

Prev Home Next
GtkSocket Up GtkSocket::steal

 

  

Network sites:

Cheap domain registrar's cheap domain registration service

$8.95 domain registration : Buy domain name or register domain name 

 
 
Quotes:
A man is ethical only when life, as such, is sacred to him, that of plants and animals as that of his fellow men, and when he devotes himself helpfully to all life that is in need of help.  
 
 

Disclaimer: This documentation is provided only for the benefits of our webhosting customers.
For authoritative source of the documentation, please refer to http://gtk.php.net/docs.php