Re: gtk 1.1.14 - callback for button clicked changed?



On Sat, 30 Jan 1999, Rasca Gmelch wrote:

> 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);

GtkButton::clicked has the signature:

void button_clicked (GtkButton *button, gpointer prog);

if you need the event, you want to connect to GtkWidget::button_press_event
with

gint button_press_event (GtkWidget          *widget,
                         GdkEventButton     *event,
                         gpointer            prog);
                                      

> 
> cu
>  rasca
> 

---
ciaoTJ



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