Re: documentation on lookup_widget (was: gtk-app-devel-list Digest, Vol 14, Issue 10)



Alf Stockton wrote:

Where can I find documentation on lookup-widget. I have looked through
the documentation I have on GTK+ and cannot find any reference.

lookup_widget () is a Glade specific function. I don't think there is
any reference documentation of it anywhere.

However, I wrote a pretty simple, similar but more generic version of
this. While lookup_widget () only works on projects created by Glade, my
function works independent from Glade and does the same. See

http://www.spamkiller.bytechase.cx/democode/widget_find_by_name.c

This one is optimized for GTK+ API compliance, not for performance. It
could be made significantly faster (and less compatible) by directly
accessing some of GTK+'s internal structures. However, I found there's
absolutely no need for that. You can easily traverse thousands of
widgets peer second by this. The performance killers are others.

To work with functions like this one you just need to assign reasonable
names to all widgets you want to access by it. This can easily be done
in Glade. Then, for instance, to enable an "OK" button in a main window
(named "B_OK") you could simply code

    gtk_widget_set_sensitive (WFBN ("B_OK"), TRUE);

without need of keeping any pointers to any widgets you want to access,
except for the main window where the widgets are in.

While certainly being a bit slower than keeping pointer variables to all
widgets you may want to access, I found this way is much easier, since
you don't have to care about and maintain anything but widget names.



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