Re: [gtk-list] How can i trap the Close Event





On 2 Jul 1997, Fritz Heinrichmeyer wrote:

> 
> I wonder how it is possible to react on the Close Event (to save work on
> files ..)?

Looking at the code, I don't think GTK has support for this yet. The 
relevant code is gtk_main_iteration () in gtk+/gtk/gtkmain.c. You'll need 
to somehow disable the gtk_widget_destroy (event_widget) call in the 
GDK_DESTROY case if the signal is handled. Something like:

          if (!gtk_widget_event (event_widget, &event_copy))
            gtk_widget_destroy (event_widget);

Then, you just need to connect to the delete_event signal of the window, 
and return TRUE if you don't want to destroy the window.

I haven't checked through the signal code to make sure that the 
gtk_widget_event will reliably return a FALSE in the case that there is 
no handler for the delete_event signal, but it seems like a good bet.

Raph



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]