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

Re: Widget returning NULL?



Brett Nash wrote:
>>Here is the portion that builds them.
> 
> 
> NFI what causes the problem - there must be something else going on else
> where trashing them or something.  However as an easy solution - why not
> pass them as the data on the callback?
> 
> 
>>Signal Connects
>>
>>gtk_signal_connect (GTK_OBJECT (entry20), "changed",
>>                     GTK_SIGNAL_FUNC (on_entry20_changed),
>>                     NULL);
> 
> 
> Changes to: (note last arg)
> 
>  gtk_signal_connect(GTK_OBJECT(entry20),"changed",
>                         GTK_SIGNAL_FUNC(on_entry20_changed), entry20);
>  gtk_signal_connect(GTK_OBJECT(entry22),"changed",
>                         GTK_SIGNAL_FUNC(on_entry20_changed), entry22);
>  gtk_signal_connect(GTK_OBJECT(entry23),"changed",
>                         GTK_SIGNAL_FUNC(on_entry20_changed), entry23);
> 
> And then in the callback do something like:
> 
> 
>>void
>>on_entry20_changed                (GtkEditable     *editable,
>>                                       gpointer         user_data)
>>{
> 
>         GtkWidget *entry;
> 
>         if (user_data == NULL){
>                 g_warning("userdata is not a widget\n");
>                 return;
>         }
> 
>         entry = GTK_WIDGET(user_data);
>         
>         if(strlen(gtk_editable_get_chars(GTK_EDITABLE(entry),0,-1)) > 6) {
>                   gtk_widget_set_sensitive (button19, TRUE);
>         }else{
>                   gtk_widget_set_sensitive (button19, FALSE);
>         }
> }
> 
> 
> 
>>The vars used are global. The commented out if is what I want to do but 
>>test all three entries for sensitivity. Works fine if I am only testing 
>>entry20 but as soon as I try to add another it fails to operate as 
>>expected. I put in the test for NULL and entry22 and 23 always return NULL.
> 
> 
> Logically there is nothing wrong with that code - it must be somewhere
> else that is stomping on the variables.  NFI what. 
> 
> If you need all three entrys, create a struct or an array and pass that
> as the callback data.
> 
>         Regards,
>         nash

Brett you rule! Have no idea what happened. I set up a struct global and 
ran the same func. All three entries come back as not NULL. Now I 
suppose I can get all fancy and pass the struct to the func but for now 
it works. All this to make a button sensitive/insensitive :)

Steve







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