Re: Blocking Main Window destroy siginal

On Sep 19, 2004, at 8:52 AM, Jasun Wurster wrote:

Is there a way to block the Window destroy signal so that if the 'x' button in
the main window is clicked it is ignored and the app keeps running?

i would've sworn this was in the gtk+ faq, but it's apparently not.

when then window manager attempts to destroy a window, it sends the "delete-event" to the window.

GtkWindow's default handler for delete-event is to destroy the window. if you connect your own handler to delete event, you can decide whether to let the default handler run.

   $window->signal_connect (delete_event => sub {
       my ($self) = @_;  # also an event, but we don't need it
       # do something interesting, like ask the user if he really
       # wants to exit, etc.
       if ($really_want_to_close) {
           # allow default handler to run, which will destroy
           # the window.
           return FALSE;
       } else {
           # inhibit default handler and keep window alive
           return TRUE;

Examples really shouldn't include unexploded ordnance.
  -- Joe Smith, referring to an example program i wrote.

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