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

Re: Destroy signal: Quit Y/N?



Actually there is a way to do it. Display the quit y/n dialog in the callback,
and create a loop:
	 while (quitApp==0) { 
		/* loop here */ 
	}

	if(quitApp==1)
	{
		gtk_main_quit();
	}
	else { return; }
	
When the yes button is clicked, set quitApp to something besides 0. To make
this work (since you'll need to use another calleback for the
button_press_event on the yes and no buttons, make quitApp global, that way
when set to 1 or whatever, the while loop will see it. In this example 1 will
cause it to quit, any other value will cause it to return and not quit.

On Thu, 21 Oct 1999, Havoc Pennington wrote:
> 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
> 
> 
> 
> -- 
>          To unsubscribe: mail gtk-app-devel-list-request@redhat.com with 
>                        "unsubscribe" as the Subject.
> 
> 	Mailing list concerns should be mailed to <listmaster@redhat.com>



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