Re: Blocking Main Window destroy siginal

* Jasun Wurster <jasun pnxcorp com> [2004-09-20 04:46]:
I would like to prevent my app from being closed by the user
during some database writes and data transfers.

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?

It would be nice if you'd actually handle the click though,
providing the user with a visual indication also. Something like
the following, around the part of the code which handles the

    my $exit_request = 0;
    my $block_exit = $window->signal_connect( delete_event => sub {
        my $monolog = Gtk2::Dialog->new(
            'Please wait.',
            [ qw( destroy-with-parent no-separator ) ],
        $monolog->vbox->add( Gtk2::Label->new( "Updating database." ) );
        $exit_request = TRUE;
        return TRUE; # we handled it, no further processing
    } );
    # ...
    # database updates here
    # ...

    $window->signal_handler_disconnect( $block_exit );
    Gtk2->main_quit if $exit_request;

"If you can't laugh at yourself, you don't take life seriously enough."

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