tags:

views:

71

answers:

1

I am trying to build a gtk widget which will exists when Escape key is pressed. Here is my code.

gtk_signal_connect (GTK_OBJECT(window), "delete-event",
                   GTK_SIGNAL_FUNC(gtk_main_quit), NULL);

/* FIXME */
GtkAccelGroup *accels = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(window), accels);
gtk_widget_add_accelerator(window, "delete-event", accels,
                           GDK_Escape, 0, GTK_ACCEL_VISIBLE);

But it doesn't work saying widget `GtkWindow' has no activatable signal "delete-event" without arguments

what's wrong ? or Is there any other ways to achieve this ?

+1  A: 

The problem is that delete-event is not an Action signal.

Usually there would be a Quit menu item and you could link the Escape key to the menu item's activate signal or a Quit button and you could use the button's clicked signal. Those are both Action type signals.

John