Question about TreeView selection behavior



Hi everyone.

I've looked through the FAQ and through the list archives about this,
but I can't find anything about this.  I'm actually developing something
with pygtk and have asked a pygtk-specific question on that list, but I
was wondering if there wasn't a problem in the underlying GTK+ widget(s)
involved, or if it was just supposed to work that way.  So, I thought
I'd ask the experts. :)

In reading the documentation for the GtkTreeView and the
GtkTreeSelection regarding tree selection, there is a sentence that
mentions that the "changed" signal is really only a hint that the
selection has changed.  Ok, fine.  Started to experiment and noticed a
few things:

Oh, should point out that I'm using a 2-column tree and a ListStore
model so that it is just a scrollable, single-level list.

1) If the TreeView has been filled with data and it is the only control
in a window, the first row is drawn as selected.  Ok, fair enough.

2) If you manually call unselect_all() on the tree selection, #1 is
*still* true.  This seems kinda strange.

3) If you add other controls to the window and call unselect_all() on
the tree selection, the selection is no longer drawn.  This is actually
where I started originally.

4) If you load the list, call unselect_all() and then click an item in
the list (other than the first one), you get two "changed" signals
emitted from the control.  The first one will *always* be for the first
row in the tree.  Subsequent selections generate the behavior you'd
expect, e.g. only a single "changed" signal is emitted.

5) Given the double "changed" signal, I wondered what the control
thought the initial selection was, so I called selection_foreach()
immediately after the unselect_all().  This resulted in my user function
being called exactly 0 times.  Doesn't seem like the control state is
consistent.

Mostly, I was wondering if anyone else had noticed these things, or had
workarounds, or any ideas.  Even if it's "it's supposed to work that
way", I'd still like to know why it's doing what it seems to be doing.

I'm running a pretty stock RedHat 8 system at the moment, so the
relevant versions are:

gtk2-2.0.6-8
ORBit2-2.4.4
pygtk2-1.99.12-7
orbit-python-1.99.0-4
gnome-python2-1.99.11-8

I tried to upgrade gtk2 by building the RPMS from CVS, but didn't have
any luck.  I'm a little hesitant to just force the install over the top
of the RPMS because I know RedHat does strange things to some of the
installation locations--that's why I was trying to build the RPMS.

Thanks in advance for any information.

ast
-- 
Andrew S. Townley <atownley eircom net>

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]