Re: gtk 1.1.14 - callback for button clicked changed?





Rasca Gmelch <thron@gmx.de> writes:

> hi owen,
>  
> > > for version 1.1.13 i had a button-clicked-callback like the following:
> > > /*
> > >  * callback if button was pressed (signal: "clicked")
> > >  */
> > > void
> > > button_clicked (GtkWidget *button, obj *prog, GdkEventButton *event)
> > 
> > You're lucky (or unlucky) that this didn't segfault with
> > 1.1.13. Try:
> > 
> >    (GtkWidget *widget, GdkEventButton *event, obj *prog).
> 
> i think you are wrong, first the theory:
> 
>  - in the 'prog' structure it is also passed a file name of an application
>    which will be started on button-click. until now it works fine.
>    if there would be an argument before the 'prog' argument a segmention
>    fault would be very likely (strings are more dangerous than just an
>    integer, isn't it?)
> 
> and then the praxis:
> 
>  - i've changed my code as you said, but now i get a segmention fault
>    while accessing the strings in the 'prog' structure.. so i think
>    the gpointer from the gtk_signal_connect() is as i had it first the
>    SECOND argument in the callback!
> 
>  - my question still lives: is there a third argument or not? is that
>    the event?
> 
> the function is connected via:
> 
> gtk_signal_connect (GTK_OBJECT(button), "clicked",
>         GTK_SIGNAL_FUNC(button_clicked), (void *) prog);

OK, I assummed you meant "button_press_event". 
"clicked" has no third parameter at all.

You can retrieve the button-release event that triggered
the "clicked" signal with gtk_get_current_event. (Make sure to
call gdk_event_free() on the result afterwards)

                                        Owen



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