Passing a struct through a gtk_connect_signal



Hi ALL :-)

I'm trying the all day to pass a struct as last argument through a 
gtk_connect_signal, but I must be overlooking something, so that this is 
not working at all :(

I have the following piece of code:

static void 
press_3rd_button_event (GtkWidget *widget,
			GdkEventButton *event,
			gpointer user_data)
{
  /* We only do something if the third (rightmost mouse button
   * was released
   */
  if (event->type==GDK_BUTTON_PRESS && event->button==3) 
    {
      printf("Original ymax = %g\n",user_data.orig_ymax);
    }
}

...

int main(int argc, char *argv[])
{

...

  static struct
  {
    gdouble orig_xmin;
    gdouble orig_xmax;
    gdouble orig_ymin;
    gdouble orig_ymax;
  } axis_lim = {-1,1,-1,1.4};

...

  gtk_signal_connect (GTK_OBJECT(canvas), "button_press_event", 
GTK_SIGNAL_FUNC(press_3rd_button_event), (gpointer) &axis_lim);

...

}

The compiler bombs out with the following message error:

test.c: In function `press_3rd_button_event':
test.c:39: request for member `orig_ymax' in something not a 
structure or union
make: *** [testgtkplot2.o] Error 1 

It's clear to me that the struct is not beeing passed this way, but I 
think I'm somewhat near of the right procedure. Can anyone of you guys 
help me to make this work?

Thanks a lot in advance,

Rafael (8-)

P.S. (Of course I could pass the struct as global variable to the function, 
but I have learned in this list that this is no good GTK programming :-)

rafael@bmt4.kf.TU-Berlin.DE
Take a look at our site!
http://privat.schlund.de/bsos/
______________________________

"Unshakable faith is only that
 which can meet reason face to
 face in every Human epoch"

              Allan Kardec
              (1804-1869)
______________________________



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