connecting entry to button
- From: Yucehan Kutlu <yucehan gmail com>
- To: gtk-app-devel-list gnome org
- Subject: connecting entry to button
- Date: Sun, 24 Apr 2005 19:24:36 +0300
Hi
when press okay the title on the entry will be write on console but i
cannot connect enter function to okay button program compile normaly but
hiting okay it gives this error
(iler:5219): GLib-GObject-WARNING **: invalid cast from `GParamBoolean'
to `GtkEntry'
(iler:5219): Gtk-CRITICAL **: file gtkentry.c: line 3797
(gtk_entry_get_text): assertion `GTK_IS_ENTRY (entry)' failed
(null)
#include<gtk/gtk.h>
gint eventDelete(GtkWidget *widget,GdkEvent *event,gpointer data)
{
gtk_main_quit();
return 0;
}
static void enter(GtkWidget *widget,GdkEvent *event,GtkEntry *edit)
{
const gchar *input;
input=gtk_entry_get_text(GTK_ENTRY(edit));
g_print("%s\n",input);
}
gint main(int argc,gchar *argv[])
{
GtkWidget *window;
GtkWidget *edit;
GtkWidget *label;
GtkWidget *label2;
GtkWidget *table;
GtkWidget *button1;
GtkWidget *button2;
gtk_init(&argc,&argv);
button1=gtk_button_new_with_label("Cancel");
button2=gtk_button_new_with_label("Okay");
table=gtk_table_new(3,2,TRUE);
label=gtk_label_new("Example ");
label2=gtk_label_new("Name :");
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
edit=gtk_entry_new();
gtk_misc_set_alignment(GTK_MISC(label2), 0.0f, 0.5f);
gtk_container_set_border_width(GTK_CONTAINER(window),10);
edit=gtk_entry_new_with_max_length(40);
gtk_entry_set_text(GTK_ENTRY(edit),"Write here");
gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1);
gtk_table_attach_defaults(GTK_TABLE(table),edit,1,2,1,2);
gtk_table_attach_defaults(GTK_TABLE(table),label2,0,1,1,2);
gtk_table_attach_defaults(GTK_TABLE(table),button1,0,1,2,3);
gtk_table_attach_defaults(GTK_TABLE(table),button2,1,2,2,3);
gtk_container_add(GTK_CONTAINER(window),table);
gtk_signal_connect(GTK_OBJECT(window),"delete_event",GTK_SIGNAL_FUNC(eventDelete),NULL);
gtk_signal_connect(GTK_OBJECT(button2),"clicked",GTK_SIGNAL_FUNC(enter),(gpointer)edit);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]