Re: Locating child-widgets (by name) without Glade-code [EOT by my side]



"Waldek Maleska" wrote:

I'll take a look at your solution, it might be helpful some way :)

I definitely think it is.

But if it is based on linear search - and that's what you mentioned
previously - it's definitely a reason to _not_ use it, algorithm
complexity is too high.

The algorithm is rather simple I think. Slight loss of speed is the only
issue, since it's a linear search indeed. If I had accessed GTK's
internal structures it could be even faster. However, if not used in
loops but in event handlers or (de)initializers in a sensible way that's
no problem.

IMHO the advantage of not having to maintain (possibly huge) lists of
pointers and global variables for every widget outweighs the execution
speed issue by far. I just need to maintain / pass one variable per
window to be able to access (obtain a pointer to) every (properly named)
widget it contains. I can add widgets any time without having to care
about pointer storage, growth of sources and binary and possibly unfreed
resources at all. The "name"-property of widgets is well suited to
locate them at runtime.



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