[Gtk-sharp-list] Dynamically populating a TreeStore

Chris Ridd chris.ridd@isode.com
Wed, 18 Aug 2004 10:56:38 +0100


On 18/8/04 1:15 am, Jonathan Pryor <jonpryor@vt.edu> wrote:

> On Tue, 2004-08-17 at 07:38, Chris Ridd wrote:
>> That would probably *nearly* work for me, except that my nodes might not
>> have children when they're expanded, but I don't really want to lose the
>> twisty in case children are added later on.
> 
> Simple solution: don't remove the "dummy" children. :-)

Heh.

> Of course, the problem with that is then people will expand your row and
> see your dummy children, which probably isn't desirable.
> 
> Solution: capture the RowExpanded event (as I did), and if you didn't
> add any children, call Gtk.TreeView.CollapseRow() to explicitly collapse
> the row.  (In other words, do the opposite of what I do -- CollapseRow()
> instead of ExpandRow().)  This should keep the arrows present while
> preventing the user from seeing your dummy nodes.

That might work, but the auto close might confuse people.

I think perhaps ending up with the twisty disappearing in the case of no
real children is "OK", or at least in line with how the equivalent Windows
control does it. Since GNOME seems to want to behave like Windows...

> Or, figure out how to display the disclosure triangles without having
> any children present.  I failed in that task, hence my use of "dummy"
> children.

I suspect it isn't possible, which is annoying.

Incidentally, when I used your code the call to ExpandRow caused recursive
calls to my RowExpanded handler. So I didn't do that :-)

What worked very well was to add the real children *before* removing the
dummy child. I'm hazy on TreeIters, but possibly removing the single dummy
child invalidated the parent's iter somehow, whereas adding the children
first didn't.

Cheers,

Chris