[Gtk-sharp-list] prevent window from closing

Martin Willemoes Hansen mwh@sysrq.dk
Wed, 31 Dec 2003 12:55:43 +0100


On Wed, 2003-12-31 at 12:10, Franz Burgmann wrote:
> hi,
> 
> a question: when I'm pressing the delete-button of a window it is going to be hidden.
> How can I get it back or how can I prevent the window from disappearing (like do_nothing_on_close)?
> 
> The reason is, I wan't to put a confirm-dialog before the window is going to close.

I do something like this, when I want confirmation before closing my
app:

[Glade.Widget] Dialog quit;
void Quit (object sender, EventArgs args)
{
        XML dialog = new XML (null, "glade/gui.glade", "quit", null);
        dialog.Autoconnect (this);
     
        switch (quit.Run()) {
                case (int)ResponseType.Yes:
        		Content.Save();
	                Application.Quit();
                        break;
                case (int)ResponseType.No:
                        Application.Quit();
                        break;
                }
                                                                                	quit.Destroy();
                                                                       
        DeleteEventArgs deargs = args as DeleteEventArgs;
        if (deargs != null)
                deargs.RetVal = true;
}

1. Put up a dialog, to check if the user rely wants to quit or wants
to quit and save his work.
2. If the app is closed with a DeleteEvent, then set RetVal to true so
   that the windowmanager does not close down the main window


> franz
> 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
-- 
Martin Willemoes Hansen

--------------------------------------------------------
E-Mail	mwh@sysrq.dk	Website	mwh.sysrq.dk
IRC     MWH, freenode.net
--------------------------------------------------------