Hi,
i have some trouble with Gtk::TreeStore.insert
The following little example works like it should.
require ‘gtk2’
class Win
def initialize
win = Gtk::Window.new
win.set_default_size 400, 200
@model = Gtk::TreeStore.new String, String, String
view = Gtk::TreeView.new @model
view.headers_visible = true
view.reorderable = false
view.selection.mode = Gtk::SelectionMode::SINGLE
view_headers = ['one', 'two', 'three']
0.upto(2) do |i|
renderer = Gtk::CellRendererText.new
column = Gtk::TreeViewColumn.new view_headers[i], renderer, :text
=> i
view.append_column column
end
10.times do |i|
make_row "first #{i}", "second #{i}", "third #{i}", i
end
win.add view
win.show_all
end
def make_row first, second, third, i
iter = @model.append @head_iter
if @head_iter.nil?
iter.set_value 0, first
else
iter.set_value 1, second
iter.set_value 2, third
end
@head_iter = iter if @head_iter.nil?
end
end
win = Win.new
Gtk.main
but if i change the row
iter = @model.append @head_iter
to
iter = @model.insert nil, i
it throws this error message:
tree.rb:30:in insert': Fixnum isn't supported (TypeError) from tree.rb:30:in
make_row’
from tree.rb:22:in initialize' from tree.rb:21:in
times’
from tree.rb:21:in initialize' from tree.rb:42:in
new’
from tree.rb:42
Afaik this is a bug. Can someone confirm (and fix) it? I’ve looked at
the sources, but could not found any errors.
Cheers, detlef