# TreeModel, again

**URL:** <https://www.ruby-forum.com/t/treemodel-again/100814>\
**Category:** Ruby-Gnome 2\
**Created:** [August 1, 2006, 8:38am UTC](https://www.ruby-forum.com/t/treemodel-again/100814 "2006-08-01T08:38:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [August 1, 2006, 8:38am UTC](https://www.ruby-forum.com/t/treemodel-again/100814/1 "2006-08-01T08:38:59Z")

</div>

I’ve been reading everything I can on implementing a TreeModel in Ruby.  
Seems it can’t be done at the moment.

It looks like PyGTK has a GenericTreeModel that can be inherited from  
and implemented. I’ve been wondering what it would take to do something  
like this in ruby-gtk?

bye  
John

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [August 3, 2006, 12:07pm UTC](https://www.ruby-forum.com/t/treemodel-again/100814/2 "2006-08-03T12:07:45Z")

</div>

On Tue, 2006-08-01 at 08:34 +0200, John A. wrote:

> I’ve been reading everything I can on implementing a TreeModel in Ruby.  
> Seems it can’t be done at the moment.
> 
> It looks like PyGTK has a GenericTreeModel that can be inherited from  
> and implemented. I’ve been wondering what it would take to do something  
> like this in ruby-gtk?

I’ve been thinking about this - seems like it would be possible to  
create a ruby class (in c), the methods of which would be called by  
implementations of the various c functions required for a TreeModel.  
TreeIter structures might cause some problems though.

I’d like to start writing some code to do this, so please let me know if  
I’m on the wrong track.

bye  
John

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [August 3, 2006, 12:36pm UTC](https://www.ruby-forum.com/t/treemodel-again/100814/3 "2006-08-03T12:36:46Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [August 3, 2006, 12:41pm UTC](https://www.ruby-forum.com/t/treemodel-again/100814/4 "2006-08-03T12:41:10Z")

</div>

On Wed, 2006-08-02 at 16:45 +0300, Dobai-Pataky B. wrote:

> [http://ruby-gnome2.sourceforge.jp/hiki.cgi?cmd=view&p=Gtk%3A%](http://ruby-gnome2.sourceforge.jp/hiki.cgi?cmd=view&p=Gtk%3A%25)  
> 3ATreeModel&key=treemodel  
> module Gtk::TreeModel is not what you want?

It’s exactly what I want. But this

class OtherModel \< Gtk::TreeModel  
end

doesn’t work because TreeModel is a module not a class. Neither does

class OtherModel \< GLib::Object  
include Gtk::TreeModel  
type\_register  
end

because = \<\<EOF  
TypeError: Not a subclass of GLib::Instantiatable  
from (irb):9:in `append\_features’  
from (irb):9  
EOF

And looking through the archives for the list the last few questions  
along these lines were answered in the negative.

So, I’d be very happy if you knew of some way of implementing TreeModel  
in Ruby only - then I wouldn’t have to go and write a bunch of c code,  
for which a grumpy and pedantic state of mind is necessary 😉

bye  
John

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [August 3, 2006, 12:49pm UTC](https://www.ruby-forum.com/t/treemodel-again/100814/5 "2006-08-03T12:49:13Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [August 3, 2006, 1:16pm UTC](https://www.ruby-forum.com/t/treemodel-again/100814/6 "2006-08-03T13:16:10Z")

</div>

On Wed, 2006-08-02 at 19:00 +0300, Dobai-Pataky B. wrote:

> i see `append\_features’ is missing from GLib::OBject, so it can’t  
> include Gtk::TreeModel  
> i just ran a  
> grep -r append\_features //usr/lib/ruby/site\_ruby/  
> Binary file //usr/lib/ruby/site\_ruby/1.8/i686-linux/glib2.so matches
> 
> so i guess you should look at the sources to find out how  
> Gtk::TreeModel was included in Gtk::TreeStore  
> [http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ATreeStore](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ATreeStore)  
> it should be easier than writing that c code 😉

OK, so what I think I’ve discovered ( after a couple of hours spelunking  
the sources, and a few minutes reading the developer docs 😑 ) is that  
TreeStore includes TreeModel because it’s hooked up that way in the gtk  
sources, and then code in glib/src figures out those relationships.

So what I would really like to know for now is this: is writing the code  
for a TreeModel that can be implemented in Ruby Really Hard™, or is  
it just that nobody’s gotten around to it yet?

bye  
John

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
