# Gtk::TreeViewColumn not getting GTK\_TYPE\_TREE\_SORTABLE methods

**URL:** <https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512>\
**Category:** Ruby-Gnome 2\
**Created:** [February 6, 2012, 8:54pm UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512 "2012-02-06T20:54:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 6, 2012, 8:54pm UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512/1 "2012-02-06T20:54:52Z")

</div>

Thanks kou for all your help. Sorry to be posting so many problems.  
I’m stuck with this older system, but really want to get the latest  
greatest Ruby/Gtk bindings on board.

So, I have one more snag. I’m not able to see the methods in  
rbgtktreesortable.c from the Gtk::TreeViewColumn class. See my quick  
demo of the issue in irb below.

* * *

irb(main):001:0\> require ‘gtk2’  
=\> true  
irb(main):002:0\> column = Gtk::TreeViewColumn.new  
=\> #\<Gtk::TreeViewColumn:0x29dbde8 ptr=0x2c32840\>  
irb(main):003:0\> column.sort\_column\_id = 1  
NoMethodError: undefined method `sort_column_id=' for #<Gtk::TreeViewColumn:0x29dbde8 ptr=0x2c32840> from (irb):3 from /myscratch/ruby/bin/irb:12:in`’

* * *

I’m sure this is another GTK 2,10 problem. As it looks ok for me on  
newer machines with GTK/2.12

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [February 9, 2012, 12:10am UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512/2 "2012-02-09T00:10:08Z")

</div>

Hi:

I think you might want to look at the ListStore#set\_sort\_column\_id and  
TreeStore#set\_sort\_column\_id, and set\_sort\_func(). It doesn’t make any  
sense to me why you’d be setting a sort order in a column. Maybe  
there’s a mistake in the Ruby/Gnome docs or code? I don’t know, I don’t  
have it installed on this computer.

I’m going to be releasing a gem in a week or so called “visualruby”  
that has a listview object in it that simplifies all the treeview stuff  
tremendously. I will post a message on this board when its available.

Good luck.

Eric

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [February 9, 2012, 1:01am UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512/3 "2012-02-09T01:01:46Z")

</div>

Eric,

I’m looking forward to checking out this “visualruby” project!

You might be interested in browsing some of the treeview-simplifying  
code in Luz:

[~ian-mcintosh/luz/trunk : files for revision 2167](http://bazaar.launchpad.net/~ian-mcintosh/luz/trunk/files) (in the  
utils/ directory)

Specifically, the SmartTreeView and SmartListStore, which are a DSL of  
sorts.

And, on top of those, ObjectTreeView and ObjectListStore, which make  
the assumption that each row is based on one Ruby object, and that the  
data in the liststore columns is derived from that object.

cheers,  
-Ian

2012/2/8 Eric C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [February 9, 2012, 8:33am UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512/4 "2012-02-09T08:33:16Z")

</div>

You can ignore listviewdemo.rb. It has a bunch of debugging crap in it.

E

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [February 9, 2012, 8:22am UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512/5 "2012-02-09T08:22:40Z")

</div>

Hi Ian:

Your code is really outstanding. I’m going to study it over the next  
few days. Its really cool that I bumped into you because we’re both  
writing classes to simplify treeview and listview. Its really  
interesting to see your approach. Your thinking is much more “object  
oriented” than mine.

Instead of subclassing TreeView, and ListStore, I put them together into  
one class, VR\_ListView. The model really isn’t a separate object, it’s  
simply:

@view.model

For example:

FILE = 0  
NAME = 1  
NUMBER = 2 etc.

@view = VR\_ListView.new( [Gdk::Pixbuf, String] , Integer, VR\_Combo,  
[Gtk::Adjustment, TrueClass] )

This would create a model with 6 columns, and 4 headers. The [] brackets  
group multiple model cols into one header.

Gtk::Adjustment is a Spinner (Float)  
TrueClass converts to a checkbox

Then:

@view.set\_headers(“File”, “Number”, “Combo Choice”,“etc”)

Now the headers are “visible” and named. You can now refer to columns  
by their header names or numbers.

@view.set\_visible(false, “Number”, 3) (numbers or header names)  
@view.set\_editable(true, “Combo Choice”, “Number”)

combo = VR\_Combo.new(“Selected”, “Another Choice”, “Choose Me”)  
adj = Gtk::Adjustment.new(…)  
@view.add\_row(pix, “myfile.txt”, 6, combo, adj, true)

Now you can refer to a column, row, or renderer:

@thirdname = @view[3, NAME] # row 3  
@namerenderer = @view.renderer(NAME)  
@viewcolumn = @view.col(“File”) (same as @view.col(0))

@row = @view.row(2) =\> returns iter

You can also do:

@view.each\_renderer

It still has the superclass:

@view.columns.each

I’d love to hear your input on this. I wish I’d seen your work earlier.  
I’ve already learned a lot from it.

Do you think its a bad idea to lump everything together? What are the  
advantages of your method?

I will notify you as soon as I have something good to look at. I’ve  
spent the last 2 full days trying to install my program on my dad’s  
computer. It uses gtksourceview2, and its a bitch to install. I’m  
going to write a post whining about it soon.

Thanks,  
Eric

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [February 10, 2012, 3:18am UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512/6 "2012-02-10T03:18:08Z")

</div>

> Your code is really outstanding. I’m going to study it over the next  
> few days.

Thanks, Eric! Feel free to contact me directly with any questions or  
ideas.

> Do you think its a bad idea to lump everything together? What are the  
> advantages of your method?

One requirement I had for this library was easy subclassing of  
TreeViews (you’ll see why if you checkout Luz). Subclasses can  
continue to add or change columns.

Also, Luz takes advantage of the fact that one Gtk+ model can be  
shared by between TreeViews and ComboBoxes, and for that reason it’s  
helpful to keep the model separate.

If you’d like to improve this library I’m open to working with you on  
github.

best,  
-Ian

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [February 11, 2012, 3:19am UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512/7 "2012-02-11T03:19:38Z")

</div>

Luz is at [Luz in Launchpad](http://launchpad.net/luz)

For those who don’t know, Luz is an open-source live motion graphics  
editor and performer, written in Ruby/Gtk+/OpenGL.

2012/2/10 Eric C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [February 11, 2012, 2:58am UTC](https://www.ruby-forum.com/t/gtk-treeviewcolumn-not-getting-gtk-type-tree-sortable-methods/216512/8 "2012-02-11T02:58:17Z")

</div>

Hi Ian:

I’ve been reading your code, and its awesome. I’m learning a lot. I  
particularly like your class\_eval stuff. I have a few questions, but  
I’ll save them until I understand everything better.

What is your git project name? I didn’t find luz.

Yours,  
Eric
