[Glade-users] globals vs locals... again




On Fri, 6 Oct 2000, James Cameron wrote:

"James K. Wiggs" wrote:
Then lookup_widget() first does a loop looking for the parentless
widget, i.e. the top-level window, 

Damon, perhaps it should use gtk_widget_get_toplevel() instead.  ;-)

   Does gtk_widget_get_toplevel() handle menus properly?  I noticed that
the for(;;) loop specifically checks to see if the widget is a menu, and
if so, calls gtk_menu_get_attach_widget() to get the parent rather than
just using widget->parent.  Perhaps this is why Damon doesn't use the
get_toplevel routine?

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?

Yes, and quite simple.

Although if it is that important, I'd be saving the widget pointers in a
structure or array at the outset rather than doing a name lookup each
time.

   Possibly, but since the set of pointers that would need to be kept
would be completely unpredictable, it seems simpler and more foolproof to
just use a name lookup.  The callback is not something that will be done
frequently, so it doesn't have to be blindingly fast.

   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.

Easily done.  I needed a version of lookup_widget() that does not
complain if it fails to find the widget.  I just copied it and called it
widget().

   Well, I'll see if I can't put something together and test it out.  If
anyone is interested, I'd be happy to post the code when I'm done with it.
I'll call it something like lookup_subwidget().

   GTK_IS_CONTAINER() will return true for any subclass of GtkContainer,
correct?

-- 
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]