OxyScripts.com
Menu spacer Home Tutorials Articles Code Forums irc.freenode.net #oxyscripts
Main (PHP)
Home Forums PHP News PHP Tutorials Articles PHP Code Snippets Contact Us Sysadmin Resources Books Template Shop
3rd Party Streams
SlashDot PHPDeveloper.org PHP.Net
Resources
PHP Manual MySQL Manual Smarty Manual PEAR Manual PHP-GTK Manual Symfony Manual
Code Snippets
Authentication Database Graphics HTTP Miscellaneous Time/Date
Affiliates
Scripts TutorialMan TutorialGuide CodingForums.com PHP Scripts Cheap Web Hosting Affordable Web Hosting Dreamweaver Templates

Search This Site :     PHP Function Reference :
 
GtkItemFactory Constructor

GtkItemFactory Constructor

GtkItemFactory (GtkType container_type, String path, GtkAccelGroup accel_group);

Creates a new instance of the GtkItemFactory class. One factory can be used for one menu, and not more. This means that if you want to have a standard GtkMenuBar at the top of a window and an additional right-click popup menu, you have to use 2 item factories.

The container_type determines, which type the root menu will have: GtkMenu, GtkMenuBar or GtkOptionMenu. To get the GtkType you want, just use the the get_type() function of this class:
$type = GtkMenuBar::get_type();     

The path is a unique name for this menu, enclosed in < and >, e.g. <mainmenu>. This path has to be unique in the whole application.

The accel_group is the accelerator group belonging to this window and is responsible for the menu shortcuts. It can be NULL, but then the menu shortcuts won't work.

Example 18. Using a GtkItemFactory

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

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

$accelgroup	= &new GtkAccelGroup();
$window->add_accel_group( $accelgroup);

$fac	= &new GtkItemFactory( GtkMenuBar::get_type(), "<mainmenu>", $accelgroup);

function quit( $number, $item) {
	gtk::main_quit();
}
$arItems	= array(
array( "/_File/_Open", null, null, 0, null ),
array( "/_File/_Save", null, null, 0, null ),
array( "/_File/_Quit", "<CTRL>Q", 'quit', 0, null )
);

$fac->create_items( $arItems);

$window->add( $fac->get_widget( "<mainmenu>"));
$window->show_all();
gtk::main();
?>

A more sophisticated example can be found at the create_items() function.

 
   Print this page

Top Sponsor
Symantec\'s Norton SystemWorks 2006
Sponsors
CA
Sponsors
AdWords Dominator 125*125
Advertisting

Affiliates
VertexTemplates PHPFreaks CodeWalkers StarGeek DevScripts CGI & PHP Scripts PHP CMS

Shopping Rebates   Sell It 4 You   Flash Page Counters   Get Insured
GPS Tracking Service   Charity Donate Info   Web Site Hosting   VOIP Service

Privacy Policy | Links | Site Map | Advertising

All content on OxyScripts.com is (©)2002-2007

 
Powered by Adrastea - Version 1.0.0. Copyright © Rune Solutions, 2004-2005