views:

34

answers:

1

I need to get text from an entry in a dialog, like a login dialog (get the user and password), I've tryied to use 'gtk_entry_get_text' but I did something wrong or there's something else I could use... I'm programing in C... please help me...

A: 

In order to get the text from an entry widget in a dialog, you should use gtk_entry_get_text.

char* entry_content;
entry_content = gtk_entry_get_text(GTK_ENTRY(entry_widget));

You should take care of this things:

  • First, you should pass the entry widget as a parameter, not the window dialog or other widget.
  • You should cast the GtkWidget into a GtkEntry.
  • The returning string is allocated by the GtkEntry, so you must not free it.
Matachana