| 
<?
if(strtoupper(substr(PHP_OS, 0,3)) == 'WIN')
 dl('php_gtk.dll');
 else
 dl('php_gtk.so');
 include_once('class-menu.php');
 
 $w = &new gtkwindow();
 $w->connect('destroy-event','shutdown');
 $w->connect('delete-event','shutdown');
 $w->set_position('center');
 
 // We realize the window to get the gdkwindow needed to
 // create Xpm if we want to display icons in our menu
 $w->realize();
 $gdkwindow  = $w->window;
 
 // We also create a gtkaccelgroup to manage accelkeys
 // the class menu will attempt to create its own if none is given at creation time
 $accelgroup = &new gtkaccelgroup();
 $w->add_accel_group($accelgroup);
 
 // So we declare the menu and add it to the window
 $menu = &new menu($gdkwindow,$accelgroup);
 
 // We now can add entrys to the menu
 // first the file menu
 $menu->add_menu_item('file',null,'file');
 // Second we want a open file option in the file menu
 $menu->add_menu_item($keyid='open',$parent='file',$label='_open',
 $callback='openfilefunctionname',$imgfile='img/fileopen.xpm');
 //we also want a separator in the menu file
 $menu->add_sep('file');
 $menu->add_menu_item('quit','file','_quit','shutdown','img/exit.xpm'); # you can now pass $xpmdatas or array(gdkpixmap,gdkkbitmask) instead of a file as image
 $menu->add_menu_item('help',null,'help');
 $menu->add_menu_item('about','help','about','about_function_name');
 //You can add check menu item too by setting is_checkmenuitem patameter to TRUE.
 $menu->add_menu_item('check','help','checkitem','callbackfuntion',null,
 $is_sensitive=TRUE,$is_checkmenuitem=TRUE,$is_checked=FALSE);
 
 # now add an entry with a beautifull right click menu
 $box = &new gtkvbox();
 $entry = &new gtkentry();
 $box->pack_start($menu->bar);
 $box->pack_start($entry);
 $w->add($box);
 $w->show_all();
 gtk::main();
 
 function shutdown(){
 gtk::main_quit();
 }
 ?>
 |