Re: [gtk-list] newbie question



On Sun, Jun 06, 1999 at 06:23:05PM -0400, Graham Street wrote:

> So, How can I pass several widget's data into a function?
> 
> Right now my callback looks like this:

I defined a structure which contains all widgets I need access to:

typedef struct {

  GtkWidget *window;
  GtkWidget *hpaned;
  GtkWidget *serverList, *playerList;
  GtkWidget *mainvbox, *vbox, *hbox;
  GtkWidget *engineCombo, *fieldCombo, *searchFor;
  GtkWidget *searchButton, *pingButton, *optionsButton;
  GtkWidget *progressBar;

  GList     *serverGList;

} GameStalker_UI;

I use these guys to create all the widgets, i.e.:

 gui->fieldCombo = gtk_combo_new();

Then I pass 'gui' around in my signal handlers, and get it back like
so:

	void callbackServerListEndSelection(GtkCList *list, gpointer data) {

  		GameStalker_UI *gui = (GameStalker_UI *)data;
.
.

This works pretty well. I declare the 'gui' struct in main and just
make sure it gets to where it needs to be (so there still isn't a
global variable). But you could define it global too if you like.

rjf&



 



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