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



Hi!


>Secondly, signals and callbacks. I'm trying to implement a simple zoom
routine
>for each image, activated whenever the event box holding the image is
clicked,
>at present using:
>
>    gtk_signal_connect (GTK_OBJECT (event_box_right), "button_press_event",
>        GTK_SIGNAL_FUNC (magnify_image), NULL);
>
>However, the magnify_image function needs quite a lot of information passed
to
>it:
>
>    struct _imageData{
>        GdkImlibImage *image;
>        GtkWidget *pixmapwidget;
>        gint magnification_factor;
>    }
>
>, and for the life of me I can't work out how to do it. I think it's
something
>to do with my lack of understanding of gpointers. Could anyone help me work
>this one out?
>
If what you mean is how to pass this data to the callback, you should
replace the above function line with:

    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 *.

I hope this was what you were asking.

Cheers



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