Re: [gtk-list] Re: referring to children of a container




On Thu, 24 Sep 1998, Scott Gifford wrote:
> 
>   An easy way to deal with this might be to just put the information into
> the parent widget with gtk_set_data.  You could use the address as the key
> (perhaps using sprintf to make things easier), and then store the index as
> the data.  Or perhaps just use the name as the key, and then the index
> number as the data.  All sorts of useful combinations are possible.
> 

Unless I'm missing something, you can't store the index, because it can
change. i.e., if I have pages A,B,C, and I append them in order, my
page-index map is:  A-0 B-1 C-2

But then if I insert D before B, B and C's index changes. That's the
fundamental problem - an index does not correspond to a certain widget,
just to a certain position in the internal list. (frankly I don't know why
this implementation detail is exposed - if it was an array and using an
index got you a speedup, it might make more sense.)

Of course you could update your page-index map every time you insert a
page, but this gets annoying in a hurry and requires you to read the
widget's source and exactly parallel every change it makes to its internal
list. And remember to call your update function whenever you manipulate
the widget.

Havoc




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