[421] in The GTK GIMP ToolKit mailing list archive
[gtk-list] Re: How can i trap the Close Event
daemon@ATHENA.MIT.EDU (Otto Hammersmith)
Wed Jul 2 11:47:07 1997
Date: Wed, 2 Jul 1997 11:38:33 -0400
From: Otto Hammersmith <otto@redhat.com>
To: gtk-list@redhat.com
In-Reply-To: <Pine.BSF.3.91.970702080644.20184A-100000@blacklodge.c2.net>; from Raph Levien on Wed, Jul 02, 1997 at 08:16:58AM -0700
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com
On Wed, Jul 02, 1997 at 08:16:58AM -0700, Raph Levien wrote:
>
>
> 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
Hrmph?
Maybe I'm misunderstanding, but I think you're talking about the
window manager telling a window to close itself, right?
That's easy enough to catch... just attach a function to the "destroy"
signal of the main window. testgtk does it, does it not? At least, to
call gtk_exit to exit cleanly, rather than haning around for no good
reason.
--
-Otto.
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null