Re: text entry validation




void
on_bt_validate_clicked (GtkButton *button,* gpointer user_data*) {
        *GtkWidget *entry;*
        [.....]
}

there is no error but nothing is displayed and the application is
closed...please help

thanks


Well, the code i sent you to my surprise, did things right the first time I tried it. The error with your code, is that you don't understand the way signals are connected:

When you connect a signal you use the g_signal_connect function that connects a GCallback <http://developer.gnome.org/doc/API/2.0/gobject/gobject-Closures.html#GCallback> function to a signal for a particular object.
From the code i attach with this email:

g_signal_connect (G_OBJECT (button), "clicked", (GCallback) entry_validation, *entry);*

*button:* the putton that will emit emit the signal.
*"clicked":* the signal
*entry_validation:* the function that will respond to the signal
*entry:* here you can pass data that the entry_validation function will receive, it is not necesary (you can specify NULL). Here we use so the entry_validation function knows the entry where the text is.

What you did wrong was create a new entry in the callback function that knows nothing about the other entry where you wrote the text.

Look at the file I attached, it works just fine, at least in my linux. If you're in linux you can compile it with:

gcc `pkg-config --cflags gtk+-2.0` -o entryvalidation entryvalidation.c `pkg-config --libs gtk+-2.0`


Please read this: GTK+-2.0 Tutorial <http://gtk.org/tutorial/>. It shows how to connect and handle signals. Respond to the list so the messages related to this thread are not interrupted.

Matias


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