Re: [gtk-list] Effecting more than 1 GTK object when a button is clicked



On Mon, Feb 07, 2000 at 01:37:01PM -0500, Matthew Cordes wrote:
> Am I correct in assuming that if  I want a button click to grab data from
> a number of GkEntry boxes, then display the output on a GtkText widget
> and have the Window created in a separate file from my callbacks (and
> main) I need to make the widgets global throughout the files via
> extern?
> Or is it possible to pass a number of objects via a callback?

No, you just get to pass that one gpointer to your callbacks --- but
remember that your one gpointer can be cast into a pointer to
*anything* -- like, for example, a struct containing all sorts of
other widgets.  One gpointer should be enough to pass arbitrarily
complex information around.

Another alternative would be to attach data to the button, which you
could then fetch in the callback.  (See "Attaching Data to Objects" in
the "GTK+ Object and Type System" chapter of GGAD.)  But doing this
can get gross and hacky really fast.

Of course, you can use global data if you want, but that has been
known to result in ugly and backwards programs.

> Or is there
> some sort of central table of all widgets I create that I can access by
> name?

God, I hope not! :-)

-JT

-- 
COMINT secret | Jam Echelon! http://www.echelon.wiretapped.net | NSA explosives
assassin terrorist car bomb tactical bin laden waco white house nuclear clinton



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