<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>westworld: a webmasters best friend &#187; PHP-GTK</title>
	<atom:link href="http://www.westworld.be/tag/php-gtk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.westworld.be</link>
	<description>A webmasters best friend</description>
	<lastBuildDate>Tue, 17 Aug 2010 10:37:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP GTK: liststore error (undefined class constant)</title>
		<link>http://www.westworld.be/php-gtk/php-gtk-liststore-error-undefined-class-constant/</link>
		<comments>http://www.westworld.be/php-gtk/php-gtk-liststore-error-undefined-class-constant/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 14:42:28 +0000</pubDate>
		<dc:creator>westworld</dc:creator>
				<category><![CDATA[PHP-GTK]]></category>

		<guid isPermaLink="false">http://www.westworld.be/?p=180</guid>
		<description><![CDATA[Been experimenting with php-gtk over the last few days. When I was trying to use a liststore, php threw a fatal error. &#8220;Undefined class constant &#8216;TYPE_STRING&#8217;&#8221;. After testing the example from the PHP_GTK site I got the same errror. The PHP-GTK example is out of date. Starting with PHP-GTK 2.0.0 the TYPE constants were moved [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Been experimenting with php-gtk over the last few days. When I was trying to use a <strong>liststore</strong>,  php threw a fatal error. <strong>&#8220;Undefined class constant &#8216;TYPE_STRING&#8217;&#8221;</strong>.<span id="more-180"></span><br />
After testing the example from the PHP_GTK site I got the same errror. The PHP-GTK example is out of date. <em>Starting with PHP-GTK 2.0.0 the TYPE constants were moved from the Gtk::class to Gobject, so use Gobject::TYPE_STRING instead.</em><br />
Below is the correct code.</p>
<textarea cols="40" rows="10" name="code" class="Xml"><?php
/*  GtkListStore example
 Here we create a list of the largest cities.
 For that we need a list store with two columns:
 The name and the number of inhabitants.
 The "name" is of type "string", and the number
 of inhabitants is of type long (big integer).
*/
$store = new GtkListStore(Gobject::TYPE_STRING, Gobject::TYPE_LONG);
 
/*
* Using the "set" method
*/
 
//at first, get an iterator for a new row
$iterator = $store->append();
//now use that to set the name at that row (column 0)
$store->set($iterator, 0, 'Tokio');
//same row: set the inhabitants into column 1
$store->set($iterator, 1, 34100000);
 
//You can set a whole row at once:
$iterator = $store->append();
//we add the data "Mexico city" at column 0 and 
// "22 million" at column 1 at the row $iterator
$store->set($iterator, 0, 'Mexico city', 1, 22650000);
 
//Or, even faster: don't even create an iterator variable
$store->set($store->append(), 0, 'Seoul', 1, 22250000);
 
 
/*
* Using "append" to add a row without an iterator
*/
$store->append(array('New York', 21850000));
$store->append(array('São Paulo', 20200000));
 
 
/*
* And now show what we've got in the store
*/
function echoRow($store, $path, $iter)
{
    $city   = $store->get_value($iter, 0);
    $number = $store->get_value($iter, 1);
    echo $city . ' has ' . $number . " inhabitants.\r\n";
}
$store->foreach('echoRow');
?></textarea>
	<!-- WordPress Code Snippet -->
	<script type="text/javascript" src="http://www.westworld.be/wp-content/plugins/wordpress-code-snippet/js/shCore.js"></script><script type="text/javascript" src="http://www.westworld.be/wp-content/plugins/wordpress-code-snippet/js/shBrushXml.js"></script>
	<link type="text/css" rel="stylesheet" href="http://www.westworld.be/wp-content/plugins/wordpress-code-snippet/css/SyntaxHighlighter.css"/>
	
	<script language="javascript">
	dp.SyntaxHighlighter.ClipboardSwf = 'http://www.westworld.be/wp-content/plugins/wordpress-code-snippet/js/clipboard.swf';
	dp.SyntaxHighlighter.HighlightAll('code');
	</script>
	<!-- End WordPress Code Snippet -->
	

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.westworld.be/php-gtk/php-gtk-liststore-error-undefined-class-constant/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
