Re: [gtk-list] Re: Signals and callbacks



On Thu, Dec 03, 1998 at 04:19:16PM +0000, Karl Mitchell wrote:
> > >
> > >    struct _imageData{
> > >        GdkImlibImage *image;
> > >        GtkWidget *pixmapwidget;
> > >        gint magnification_factor;
> > >    }
...
> >     gtk_signal_connect (GTK_OBJECT (event_box_right), "button_press_event",
> >         GTK_SIGNAL_FUNC (magnify_image),  (gpointer) &_imageData);
> >
> > replacing _imageData with the name of the variable you want to pass.
> > gpointer is just a void *.
...
> 
> That's about it. Thankyou! So how do you access the structure data in the
> magnify_image function? I always seem to get confused when passing pointers
> around the place.

try:

void
magnify_image(GtkWidget *widget, GdkEventButton *event, gpointer cbdata)
{
	struct _imageData *imgdata = (struct _imageData *)cbdata;
	...
	...
	rest of your code here.
}


hope this helps,
--andy



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