Re: Locating child-widgets (by name) without Glade-code



From: "Owen Taylor" <otaylor redhat com>

On Fri, 2003-08-15 at 11:46, Gus Koppel wrote:
Is there an (official) way in GTK+ 2.2 to get a pointer to a GtkWidget
by the name of the widget, like Glade imposes it by its lookup_widget
()-function and GLADE_HOOK_OBJECT ()-lists?
[...]
And if there isn't a similar GTK+-function (as I suppose), is using
gtk_container_get_children () and recursively comparing the names of the
children against the searched one the correct + most efficient way?

I don't really see any reason to look up children by name if you
aren't using Glade or libglade. Just keep pointers to the children
you need to reference. [...]

I suppose what Gus wants is just having all widgets kept some
kind-of-together. Perhaps he should create a global
GHashTable and keep pointers to all created widgets
in there by yourself (BTW, isnt't it what Glade does?),
maybe providing some functions for accesing the table
and adding/removing widgets.

However, it doesn't really do anything special
or smart. Passing all pointers as function parameters
or keeping them global/local/struct members would do
exactly as well as that. And it needs no extra code.

Regards,
Waldek Maleska







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