Re: [gtk-list] GtkEntry...



ZioBudda wrote:

> now, in the main window I have a Button call "ok" and I want to associate
> the "pressed" event with a my function ("on_ok_pressed") and I want to
> pass "contain" variable. I (with glade) have write this code:
> 
> gtk_signal_connect(GTK_OBJECT (ok), "pressed",
>                             GTK_SIGNAL_FUNC (on_ok_pressed),
>                             (struct _contain*)&contain);

That looks OK, but you can just use this:

  gtk_signal_connect (GTK_OBJECT (ok), "pressed",
                      GTK_SIGNAL_FUNC (on_ok_pressed),
                      &contain);


> This is on_ok_pressed function:
> void
> on_ok_pressed                          (GtkButton       *button,
>                                         struct _contain contain)
> {
>  printf("%s",gtk_entry_get_text(GTK_ENTRY((GtkWidget *)contain.port)));
> }

This is the problem. It should be


void
on_ok_pressed                          (GtkButton       *button,
                                        struct _contain *contain)
{
 printf ("%s", gtk_entry_get_text(GTK_ENTRY(contain->port)));
}


Damon




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