delete event for contained widget does not work
- From: Deekshit Mantampady <dmantamp gmail com>
- To: gtk-app-devel-list gnome org
- Subject: delete event for contained widget does not work
- Date: Sun, 2 Oct 2005 11:39:48 +0530
Hi all,
I have an entry in window with containment as
window > vbox > hbox >entry. (Code pasted below).
I registered for window delete_event, I call destroy on window, in
the callback. I was expecting it to destroy the etry also. In that
case destroy/delete event callback for entry should be called. But it
does not happen.
In my real application, I need to free up memory allocated for a
data structure(application specific) associated with the entry. I
cannot do it when window is deleted.
Is there any way to catch, the event when the entry or any such widget
is deleted ?
Please help me.
code that I tried
==========================
#include <gtk/gtk.h>
gboolean window_deleted(GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_destroy(widget);
printf("Window deleted...\n");
gtk_main_quit();
return FALSE;
}
gboolean entry_deleted(GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
printf("Entry Deleted ...\n"); /* This is not called */
return FALSE;
}
int main(int argc, char *argv[])
{
GtkWidget *window, *vbox, *hbox, *entry;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(window_deleted), NULL);
vbox = gtk_vbox_new(FALSE, 2);
gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 2);
gtk_widget_show(hbox);
entry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 2);
gtk_signal_connect(GTK_OBJECT(entry), "delete_event",
GTK_SIGNAL_FUNC(window_deleted), NULL);
gtk_signal_connect(GTK_OBJECT(entry), "destroy_event",
GTK_SIGNAL_FUNC(window_deleted), NULL);
gtk_widget_show(entry);
gtk_widget_show(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]