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 :
 
GtkList Constructor

GtkList Constructor

GtkList (void);

Creating a GtkList widget is straightforward, populating it slightly less so. Each item added to the list container must itself be contained in a GtkListItem. In its simplest and most common form, all that means is that the GtkListItem is created with a label, the text content of which will be displayed in the list.

Example 22. Constructing a GtkList

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

function echo_it($list, $listitem) {
/* collect the text from the selected list item's label */
  $listlabel = $listitem->child;
/* filter list items according to child object type */
  if($listlabel->get_name() == 'GtkLabel') {
    $name = $listlabel->get();
    $label = &new GtkLabel("You chose $name just now");
/* create a popup window and display a message relevant to selected item */
    $popup = &new GtkWindow(GTK_WINDOW_POPUP);
    $popup->set_uposition((gdk::screen_width()/2)+50, 
(gdk::screen_height()/3));
    $popup->add($label);
    $popup->show_all();
/* connect the list item's own deselect signal (not the list's) */
    $listitem->connect_object('deselect', create_function('$popup', 
'$popup->destroy();'), $popup);
  }
  else gtk::main_quit();
}

$window = &new GtkWindow(GTK_WINDOW_DIALOG);
$window->set_position(GTK_WIN_POS_CENTER);
$window->connect_object('destroy', array('gtk', 'main_quit'));

$list = &new GtkList();
/* the contents of this array will populate the list */
$fill = array('Angela', 'Belinda', 'Carolyn', 'Danike', 'Etha', 'Fiona', 
'Gertraud', 'Heidi', 'Jessica', 'Kirstin', 'Lorinda', 'Marianne');

foreach(range(0, count($fill)-1) as $i) 
  $listitem[] = &new GtkListItem($fill[$i]);

$list->append_items($listitem);

$enditem = &new GtkListItem();
/* a list item is also a container */
$button = &new GtkButton('Close');
$enditem->add($button);
/* there is no way to append() a single item - but GtkList is a container
widget, so it's okay to use add() */
$list->add($enditem);
$list->connect('select-child', 'echo_it');
$list->show_all();

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

gtk::main();
?>

 
   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