Gtk::TreeViewColumn not getting GTK_TYPE_TREE_SORTABLE methods

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

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

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 (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. [email protected]:

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

E

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

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

Luz is at Luz in Launchpad

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. [email protected]:

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