From: Joe Laughlin Date: 2004-08-17T03:51:03+09:00 Subject: Re: GTK weirdness Joao Pedrosa wrote: > Hi, > > --- Joe Laughlin wrote: > >> I'm creating a Gtk::TreeViewColumn and attaching its >> model to a >> Gtk::ListStore. The liststore is created to have >> one column of type Object. >> I then create a bunch of columns and renderers and >> and call >> set_cell_data_func() on each column, setting the >> renderer.text attribute to >> equal some atribute in an object that's contained in >> the Gtk::ListStore. >> >> (hope that makes sense!) >> >> So when I run the application, I get a bunch of >> these warnings when I move >> my mouse over the treeview: >> >> GLib-GObject-WARNING **: unable to set property >> `text' of type `gchararray' >> from value of type `VALUE' >> >> Ideas? > > On Windows 2000, ruby 1.8.2 (2004-06-29) > [i386-mswin32], with the "One Click Ruby Install" > (OCRI), GTK 2.4.3 by Tor, Ruby/GTK from the CVS, I was > able to create the following example, which seemed to > work fine. By the way, great Idea. :) > > ---->--- cut ---->----- > require 'gtk2' > include Gtk > > def create_treeview > model = ListStore.new(Object) > treeview = TreeView.new(model) > 3.times{|n| > column = TreeViewColumn.new > column.set_title("Etc#{n}") > text_renderer = CellRendererText.new > column.pack_start(text_renderer, true) > text_renderer.signal_connect('edited'){|cell, > path, value| } > column.set_cell_data_func(text_renderer){|column, > cell, model, iter| > cell.text = iter[0][n].to_s > } > treeview.append_column(column) > } > fill_random_data model > treeview > end > > def fill_random_data model > 10.times{|i| > iter = model.append > iter[0] = ["one#{i}", 2 + i, "three#{i}"] > } > end > > Gtk.init > w = Window.new > w.signal_connect('destroy'){ Gtk.main_quit } > w.title = 'A Test' > w.set_default_size 500,400 > w.add(create_treeview) > w.show_all > Gtk.main > ---->--- cut ---->----- > > Cheers, > Joao > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail - You care about security. So do we. > http://promotions.yahoo.com/new_mail Thanks for the information. I tracked it down to how I created the TreeViewColumn. I was setting :text equal to 0 when creating the TreeViewColumn, which tells the TreeViewColumn to try to find the text for the column in the first column of the model, which is an Object. So when I removed ":text = 0", it worked. Joe