[Glade-users] globals vs locals... again
- From: wiggs novum-millennium org (James K. Wiggs)
- Subject: [Glade-users] globals vs locals... again
- Date: Thu, 5 Oct 2000 20:17:03 -0700 (PDT)
On Fri, 6 Oct 2000, James Cameron wrote:
"James K. Wiggs" wrote:
The names assigned to the various widgets in these sub-GUIs are
generated automatically when they are created, but it would be possible
for duplicate names to be created. If this is the case, what will
lookup_widget() do?
It will return the latest created widget with the name you specify, I
think.
See support.c, function lookup_widget(), and the code in interface.c
which performs gtk_object_set_data() calls for each widget created. The
function works by associating a named piece of data with the toplevel
widget. The name is the widget being created.
Hmmm. OK, looks like all of the construction functions do a
gtk_object_set_data_full(), using the address of the top-level window, to
associate the name with a pointer to the widget. Then lookup_widget()
first does a loop looking for the parentless widget, i.e. the top-level
window, and then does a gtk_object_get_data with the given name string to
find the appropriate address for the desired widget. As I recall,
gtk_object_get_data/set_data maintains a keyed data list within any
GtkObject. OK, so I can see how this works. Now I just have to get
around my problem.
The sub-GUIs in question are all created in a similar fashion, and each
one is laid out within a GtkTable widget. I can do similar calls to the
gtk_object_set_data_full() routine, passing the address of said table
instead of the top-level window. Then if I did a modified version of
lookup_widget() which only looked at the child objects of the widget, not
doing that loop up to the top-level, I could pass it the address of the
frame containing the table and I should be able to get the right widgets
in the right order. Does this sound reasonable?
I recall one Motif interface builder made by Digital that refused to let
you have a widget name that was duplicated. The tool itself took care
of making sure it was unique. It even went so far as to change all the
widget names when you pasted a copy of the widget tree somewhere else.
Painful. I don't think it is enough of a problem to require Glade to do
this.
Yes, it sounds painful, indeed. Still, it might be nice to set up a
version of lookup_widget() which only loops through the children of the
widget passed to it, looking for one with the appropriate name. It seems
that it could prove quite useful. Perhaps it could be restricted to work
only with GtkBin objects or subclasses thereof, with the assumption that
the GtkBin itself, or its sole child, would contain the GData structure to
be searched.
--
James Cameron (cameron stl dec com)
best,
Jim Wiggs
wiggs wiggs net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]