Can't get text from entry
- From: César Leonardo Blum Silveira <cesarbs brturbo com>
- To: gtk-app-devel <gtk-app-devel-list gnome org>
- Subject: Can't get text from entry
- Date: Tue, 14 Dec 2004 01:06:02 -0200
Why doesn't the following piece of code work?
#include <gtk/gtk.h>
char *string=NULL;
void combo_change(GtkWidget *widget, gpointer data)
{
gchar *selected;
selected = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(widget)->entry));
strcpy(string, selected);
printf("%s\n",string);
}
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *combo;
GList *opt;
gtk_init(&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
combo = gtk_combo_new();
opt = g_list_append(opt, "string 1");
opt = g_list_append(opt, "string2");
gtk_combo_set_popdown_strings(GTK_COMBO(combo),opt);
g_signal_connect(G_OBJECT(GTK_COMBO(combo)->entry),"activated",G_CALLBACK(combo_change),NULL);
gtk_container_add(GTK_CONTAINER(window),combo);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
Thanks
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]