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

On Thu, 5 Oct 2000, James Cameron wrote:

David Cooper wrote:
2. I was also considering a way to allow the GUI builder to do even
more of the work for us. Did I mention that I was lazy? If some pointer
based or programatic method was provided and maintained by the builder,
then we could ignore the tedium, let the builder do our job for us, and
have more time to write more bad code.

Have you any suggestions on how Glade can provide such a service?  It
already provides lookup_widget() in support.c along with the code in
interface.c to make it easy to find a widget by name given a pointer to
any other widget in the same window.

   This prompts a question from me: it is stated that lookup_widget()
finds any widget by name given a pointer to any other widget in the same
*window*.  This presents a problem for me, as I'm trying to make mods to
code created by Glade (let it do some of the grunt work, then tune the
final code).  The interface I'm building is self-modifying.  Given choices
that users make from the various ComboBoxes in the GUI, frames within the
GUI are filled with small sub-GUIs.  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?

   For example: the user chooses formula A from the combo box for the
"primary formula".  A frame with the label "Primary Formula" will then
have a sub-GUI with the inputs appropriate for formula A dropped into it,
and the various widget names will be prefixed with "FormulaA_".  If the
user then also selects formula A for the "secondary formula", an identical
sub-GUI will be created and dropped into the "Secondary Formula" frame.
If I then go looking for the values in the various inputs when the "OK"
button is clicked and I'm in the callback, and I specifically pass the
frame containing each sub-GUI to lookup_widget() along with the name
"FormulaA_Value1" or whatever, will I get the widget named "FormulaA_Val1"
contained in that frame, or will the result be indeterminate?

We know that making everything global would be bad ... so this has to be
a decision made by the programmer, not by the builder.

I agree that code quality may not be as important as getting the job
done sooner.

James Cameron                                      (cameron stl dec com)

Jim Wiggs
wiggs wiggs net

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