Re: how to know a widget?
- From: Mark Roberts <gtk manumark de>
- To: davidgn servidor unam mx, dabicho2001 yahoo com mx
- Cc: gtk-list gnome org
- Subject: Re: how to know a widget?
- Date: Sat, 17 Mar 2001 15:20:13 +0100 (MET)
Dear David!
> all functions seem to want a pointer to the widget in question.How can i
> get it? I would use it with another button to, that when it is pressed,
> it needs to read the status and contents of a couple of other widgets,
> to update the db from there.
This seams to be a question about software design and not about GTK. The
wrong answer to your question is: make each widget a global variable. A
better answer is: You want to break your problem up into modules that
solve small bits of the program. For instance:
(1) A gui-buildup-module, gui.c. It puts the buttons in a window and
installs the callback routines. It includes callback.h -> 2, in order to
do this.
(2) A callback module callback.c, which contains callback functions. It
includes either database.h, so that it can build the list and display it
or, better still it includes people.h or whatever, which deals with all
the database and gui stuff for you.
(3) people.c, which is the module that does all the real work, accesses
the database, ...
and so on. This is just an example. What you need to do is draw the
structure on a piece of paper and try to minimize the number of #includes.
And make sure you have no cyclic includes. Your problem is then solved by
the widgets you need being global (but static) within gui.c. Other modules
can access them through the functions exported in gui.h, like
gui_update_peoplelist( person *array, int length);
It is possible to ask an hbox for its contents, but I don't know how and
there is usually a better solution.
All the best, Mark Roberts
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]