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

Re: Destroy signal: Quit Y/N?




On Wed, 20 Oct 1999, Erik de Castro Lopo wrote:
> Hi *,
> 
> I've got an app which does the standard handling of the
> destroy signal ie:
> 
> gtk_signal_connect(GTK_OBJECT(window), "destroy",
>       GTK_SIGNAL_FUNC(destroy_func), NULL);
> 
> with gtk_main_quit() called in destroy_func().
> 
> Is there any way to pop up a dialog box in destroy_func()
> to give a Quit Y/N? option?
> 

Well, you can pop up a dialog but you can't prevent the window from being
destroyed at this stage. 

What you probably want to do is connect to delete_event, which is the
event you receive when the window manager "close" button is clicked. The
default delete_event action is to destroy the window. However, if you
connect a signal handler that returns TRUE, the window won't be destroyed. 
So in your delete event handler, pop up the dialog, and if the user says
"No" you return TRUE, otherwise return FALSE.

Havoc




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