[Gtk-sharp-list] Refreshing TreeView

Vladimir Giszpenc vladimir.giszpenc at gmail.com
Wed Jun 20 09:37:48 EDT 2007


Hi,

When I had a NodeView, in my node I could do the following when the
model changed (in a worker thread).

					Gtk.Application.Invoke (delegate {
						OnChanged();
					});

And magically, the view would refresh just the cell in question and
all was good in the world.  I am trying to accomplish the same with a
TreeView (because I need sorting and to my great chagrin, no one has
volunteered to add sorting to the NodeView).

There is no need to explain to me that only the main GUI thread can
update the GUI.  I get it.

Iterators (Gtk.TreeIter) seem to be very finicky.  I know I get a good
one when I do

             Gtk.TreeIter iter = store.AppendValues(node);

Because I use it to add child rows.

I am adding values to the TreeStore that is inside the TreeModelSort
which is attached to the TreeView.   My renderers do their jobs and
everything shows up as it should.

Can I keep this iter in a Hashtable or something like that?  What do I
keep around so that I can refresh just the row in question later
keeping in mind that it is a store within a store?


Enter worker thread.  Work. Work.  Work.
Data changes...

How do I refresh the view?  Let's say EmitRowChanged is the way for
arguments sake.  that takes a path and a TreeIter.  I can get a path
from the TreeIter, so in my mind it only needs the TreeIter.  Of
course, I can't get this to work using the TreeIter from the above
code.  It has gone stale somehow...

If we changed the music store Treeview example and added number sold
as a column.  Then started a worker thread that randomly buys a song
from the list for a while.  How would the code look to keep the view
fresh *as the worker is working*?  How much does the code change if
the list is sorted?


I apologize for asking the same question others have asked in the
past, but I cannot decipher the answers that have been given.  There
must be a way to refresh a treeview.

Thanks,

Vlad


More information about the Gtk-sharp-list mailing list