Re: using multiple widgets in a callback




  The approach I use is to create a GlobalUI struct and pass it around on the
callbacs. SInce itis only a poiter passed in, the overhead is the same.

 main.c

  struct GlobalUI
  {

   GtkWidget *main_win;
   GtkWidget *main_toolbar;
   GtkWidget *file_sel;
   ... you got the idea ..
 
  };

  init the GlobalUI either "at once" or as you create the Widget components.

   Then we  you pass the pointer to the GlobalUI to all the callbacks, or at
least to the ones that need to access the Widgets as the gpointer data
component of the callback.

 gtk_signal_connect( ..., ..., poiter_to_global);

  Then on the callback fucntion, we can do something like:

  on_ok_press(...., gpointer data);
  {
    GlobalUI *ui = (GlobalUI*)data;

   set_whaterver (ui->main_win);


Hope you got the point.

Harring.
  }




--- Scott Barron <sb125499 ohiou edu> wrote:
On Fri, Jul 26, 2002 at 03:21:21PM -0500, Jeffrey Goddard wrote:
I've seen, somewhere, a method for passing more than two widgets to a 
callback routine, but I can't seem to find it anywhere in my office. Could 
someone please give me a clue?
TIA 
Jeffrey
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Hi,

I don't know if there is a "correct" way to do this or not but when I
personally do such a thing I use g_object_set_data() to give one widget
pointers to the other widgets and pass that to the callback.  Then you
can use g_object_get_data() in the callback to get those other widgets
back.  Others may have different ways, that's just how I do it.

-Scott

-- 
We are not humanity.
-B
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com



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