<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: TreeModel ZERO, a taste of life as it should be</title>
	<link>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be</link>
	<description>From the mind of Philip</description>
	<pubDate>Sun, 14 Mar 2010 22:22:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: pvanhoof</title>
		<link>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38339</link>
		<pubDate>Tue, 18 Aug 2009 15:10:02 +0000</pubDate>
		<guid>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38339</guid>
					<description>Btw. the columnbinding idea comes from .NET: http://tinyurl.com/ogt2uu and http://aaronreed.sys-con.com/node/48806/mobile</description>
		<content:encoded><![CDATA[<p>Btw. the columnbinding idea comes from .NET: <a href='http://tinyurl.com/ogt2uu' rel='nofollow'>http://tinyurl.com/ogt2uu</a> and <a href='http://aaronreed.sys-con.com/node/48806/mobile' rel='nofollow'>http://aaronreed.sys-con.com/node/48806/mobile</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: pvanhoof</title>
		<link>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38337</link>
		<pubDate>Tue, 18 Aug 2009 10:44:23 +0000</pubDate>
		<guid>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38337</guid>
					<description>@Benjamin and pixelpapst: Yeah, I think all of your observations (from the both of you) are valid. As I wrote there are many ways to represent a tree and did I just take a simple route. Perhaps it's indeed better to simply immediately return iterator and not iterable for the get_children. Best way to know is to write some code and see what works and what is needed &amp; where. Gtk.ColumnBinding is of course wrong, should be GLib.ColumnBinding everywhere and I think the ColumnBinding should be solely at the View's side, never at the Model (models don't care about presentation of the data, only about the data).

II have not thought (enough) about Gtk.TreeSortable yet. When properly iterable I think sorting should (if possible) happen at the source model instead of in a decorator, but I can see the need for such a Gtk.TreeSortable of course (for non-sortable source models).

I would probably make GLib.TreeSortable an interface that can be implemented. And then have a wrapping GLib.TreeSortableWrap that implements it, and that wraps (decorates) non-sortable GLib.TreeModels by keeping a mapping of all its sorted nodes to the non-sorted nodes in the wrapped source model.

As for pixelpapst's suggestion to try to get this in in early current versions of GLib and Gtk+: it all depends on the decision to accept the proposal to have a collection framework in GLib. If this ain't accepted, this kind of &quot;doing it right&quot; ain't possible in a practical way.</description>
		<content:encoded><![CDATA[<p>@Benjamin and pixelpapst: Yeah, I think all of your observations (from the both of you) are valid. As I wrote there are many ways to represent a tree and did I just take a simple route. Perhaps it&#8217;s indeed better to simply immediately return iterator and not iterable for the get_children. Best way to know is to write some code and see what works and what is needed &#038; where. Gtk.ColumnBinding is of course wrong, should be GLib.ColumnBinding everywhere and I think the ColumnBinding should be solely at the View&#8217;s side, never at the Model (models don&#8217;t care about presentation of the data, only about the data).</p>
<p>II have not thought (enough) about Gtk.TreeSortable yet. When properly iterable I think sorting should (if possible) happen at the source model instead of in a decorator, but I can see the need for such a Gtk.TreeSortable of course (for non-sortable source models).</p>
<p>I would probably make GLib.TreeSortable an interface that can be implemented. And then have a wrapping GLib.TreeSortableWrap that implements it, and that wraps (decorates) non-sortable GLib.TreeModels by keeping a mapping of all its sorted nodes to the non-sorted nodes in the wrapped source model.</p>
<p>As for pixelpapst&#8217;s suggestion to try to get this in in early current versions of GLib and Gtk+: it all depends on the decision to accept the proposal to have a collection framework in GLib. If this ain&#8217;t accepted, this kind of &#8220;doing it right&#8221; ain&#8217;t possible in a practical way.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: pixelpapst</title>
		<link>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38336</link>
		<pubDate>Tue, 18 Aug 2009 09:30:10 +0000</pubDate>
		<guid>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38336</guid>
					<description>@Philip:
looks like a very good start, please keep rocking on this ! :-)
your proposed Gtk.TreeModel has both these, which I find confusing:
	Gtk.ColumnBinding binding;
	GLib.ColumnBinding column_binding;
probably you mean only GLib.ColumnBinding, and some support stuff for mapping CellRenderers to column names / numbers ?

AFAIK GLib 2.90 has not even been opened, so theoretically there would be time enough to polish these interfaces a bit and get them into GLib 3.0.
Then we could also ship GTK+ with a simplified Gtk.TreeView2 (maybe call it Gtk.NodeView or something ?), and deprecate Gtk.TreeView but carry it around for the whole 3.x timeline. Gtk.TreeModel could implement the new interfaces but be supplemented over time by simpler implementations.

Your GLib.TreeIterable interface strikes me as something you would want on the concrete Iterator, not as a subclass of Iterable, because you want to iterate over the children of the currently iterated-to row. So maybe it would better be named TreeIterator.
Also, maybe get_children should return TreeIterator directly, instead of TreeIterable ? (The former would return another iterator, which should be enough; the latter would return &quot;the node&quot; in an Iterable form, which wouldn't necessarily have an equivalent gobject class.)

Maybe demanding that the rows (nodes ?) returned by a GLib.TreeIterator implement a simple property interface in the spirit of your Glib.ColumnBinding would be ok ? I'm thinking something like this:

interface GLib.ColumnAccessor {
	GLib.Value get_value (int column);
}

We have enough introspection to check at runtime if this interface is implemented, and skip over the row if it's not. This check might be too costly in real-world treeviews, though.
Then again, just reusing the (overriable) GObject.get_property() class method might be completely enough. (Just do the mapping of property name to per-class property number at a higher level in Gtk.TreeView.)

@Benjamin:
agreed that the different iterator representations are the most horrible part of the API (possibly only fighting for 1st place with the whole column API).
About making ITERS_PERSIST the default: maybe a looser guarantee would be enough, where iterators gain a is_valid property, or emit a signal when the row below their butt disappears. 
Then the new TreeView could still cache them all day long, and trying sane fallbacks when they invalidate.

From the TreeModel API I fuzzyly remember that at least one representation of the Iterators was designed to be stored in a fixed-size space within TreeView, probably in an array. This is not something we can easily fullfil with a simplified implement-your-own-iterator API approach, but maybe that particular design constraint is just not that important.
Iterators might have to be cloneable, though.

Sorry for my long ramblings. :-)</description>
		<content:encoded><![CDATA[<p>@Philip:<br />
looks like a very good start, please keep rocking on this ! :-)<br />
your proposed Gtk.TreeModel has both these, which I find confusing:<br />
	Gtk.ColumnBinding binding;<br />
	GLib.ColumnBinding column_binding;<br />
probably you mean only GLib.ColumnBinding, and some support stuff for mapping CellRenderers to column names / numbers ?</p>
<p>AFAIK GLib 2.90 has not even been opened, so theoretically there would be time enough to polish these interfaces a bit and get them into GLib 3.0.<br />
Then we could also ship GTK+ with a simplified Gtk.TreeView2 (maybe call it Gtk.NodeView or something ?), and deprecate Gtk.TreeView but carry it around for the whole 3.x timeline. Gtk.TreeModel could implement the new interfaces but be supplemented over time by simpler implementations.</p>
<p>Your GLib.TreeIterable interface strikes me as something you would want on the concrete Iterator, not as a subclass of Iterable, because you want to iterate over the children of the currently iterated-to row. So maybe it would better be named TreeIterator.<br />
Also, maybe get_children should return TreeIterator directly, instead of TreeIterable ? (The former would return another iterator, which should be enough; the latter would return &#8220;the node&#8221; in an Iterable form, which wouldn&#8217;t necessarily have an equivalent gobject class.)</p>
<p>Maybe demanding that the rows (nodes ?) returned by a GLib.TreeIterator implement a simple property interface in the spirit of your Glib.ColumnBinding would be ok ? I&#8217;m thinking something like this:</p>
<p>interface GLib.ColumnAccessor {<br />
	GLib.Value get_value (int column);<br />
}</p>
<p>We have enough introspection to check at runtime if this interface is implemented, and skip over the row if it&#8217;s not. This check might be too costly in real-world treeviews, though.<br />
Then again, just reusing the (overriable) GObject.get_property() class method might be completely enough. (Just do the mapping of property name to per-class property number at a higher level in Gtk.TreeView.)</p>
<p>@Benjamin:<br />
agreed that the different iterator representations are the most horrible part of the API (possibly only fighting for 1st place with the whole column API).<br />
About making ITERS_PERSIST the default: maybe a looser guarantee would be enough, where iterators gain a is_valid property, or emit a signal when the row below their butt disappears.<br />
Then the new TreeView could still cache them all day long, and trying sane fallbacks when they invalidate.</p>
<p>From the TreeModel API I fuzzyly remember that at least one representation of the Iterators was designed to be stored in a fixed-size space within TreeView, probably in an array. This is not something we can easily fullfil with a simplified implement-your-own-iterator API approach, but maybe that particular design constraint is just not that important.<br />
Iterators might have to be cloneable, though.</p>
<p>Sorry for my long ramblings. :-)
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Benjamin Otte</title>
		<link>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38335</link>
		<pubDate>Tue, 18 Aug 2009 07:07:29 +0000</pubDate>
		<guid>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38335</guid>
					<description>Some nits  have to pick:
1) TreeIterable should return Iterable as children, and not TreeIterables. Or am I missing something?
2) TreeIterable and TreeModel are distinct, so both of these interfaces should require Iterable, but not each other. That way you get the LIST_ONLY flag by querying if TreeIterable was implemented.
3) ITERS_PERSIST should be a requirement. A lot of the complexity of tree views currently comes from the fact that code wants to reference particular rows in the model, but cannot do so, because both iters and paths are not persistent. That's why GtkTreeRowReference was invented.
4) Current code now has 3 ways to reference rows: GtkTreeIter, GtkTreePath and the just mentioned GtkTreeRowReference. Is that really necessary?
5) Your TreeIterable has an n_children property. For a lot of data (like a Tracker query ;)) you don't know the number of results in advance. I'm not sure how/if you want to support that usecase.
6) How does GtkTreeSortable fit into your design?

And that's just the first few things I came up with. ;)</description>
		<content:encoded><![CDATA[<p>Some nits  have to pick:<br />
1) TreeIterable should return Iterable as children, and not TreeIterables. Or am I missing something?<br />
2) TreeIterable and TreeModel are distinct, so both of these interfaces should require Iterable, but not each other. That way you get the LIST_ONLY flag by querying if TreeIterable was implemented.<br />
3) ITERS_PERSIST should be a requirement. A lot of the complexity of tree views currently comes from the fact that code wants to reference particular rows in the model, but cannot do so, because both iters and paths are not persistent. That&#8217;s why GtkTreeRowReference was invented.<br />
4) Current code now has 3 ways to reference rows: GtkTreeIter, GtkTreePath and the just mentioned GtkTreeRowReference. Is that really necessary?<br />
5) Your TreeIterable has an n_children property. For a lot of data (like a Tracker query ;)) you don&#8217;t know the number of results in advance. I&#8217;m not sure how/if you want to support that usecase.<br />
6) How does GtkTreeSortable fit into your design?</p>
<p>And that&#8217;s just the first few things I came up with. ;)
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Chris Jones</title>
		<link>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38330</link>
		<pubDate>Mon, 17 Aug 2009 21:55:30 +0000</pubDate>
		<guid>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38330</guid>
					<description>Yes, being able to store millions of items efficiently would be great for the rare occasions when that happens.

What I care about though is the API for developers and how ridiculous it is currently. I don't want to have to care about iterators or store objects, I just want to say &quot;here is my data, make a list&quot; and get back to having fun!</description>
		<content:encoded><![CDATA[<p>Yes, being able to store millions of items efficiently would be great for the rare occasions when that happens.</p>
<p>What I care about though is the API for developers and how ridiculous it is currently. I don&#8217;t want to have to care about iterators or store objects, I just want to say &#8220;here is my data, make a list&#8221; and get back to having fun!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Christian Hergert</title>
		<link>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38329</link>
		<pubDate>Mon, 17 Aug 2009 20:22:59 +0000</pubDate>
		<guid>http://pvanhoof.be/blog/index.php/2009/08/17/treemodel-zero-a-taste-of-life-as-it-should-be#comment-38329</guid>
					<description>I like it.  The next treeview *must* be designed around holding millions of items with bound memory usage and speed.  Iterating the entire model when attached is unacceptable (like it is now).  Everything lazy!

Thanks for the post.</description>
		<content:encoded><![CDATA[<p>I like it.  The next treeview *must* be designed around holding millions of items with bound memory usage and speed.  Iterating the entire model when attached is unacceptable (like it is now).  Everything lazy!</p>
<p>Thanks for the post.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
