Re: Closing a window to trigger the 'delete_event' signal
- From: muppet <scott asofyet org>
- To: gtk-perl mailing list <gtk-perl-list gnome org>
- Subject: Re: Closing a window to trigger the 'delete_event' signal
- Date: Wed, 28 Jul 2004 21:20:21 -0400
On Jul 28, 2004, at 8:57 PM, Francois Marier wrote:
So is this the idiomatic way to do close a Window in GTK2 ?
sub {
unless ($window->signal_emit('delete_event',
Gtk2::Gdk::Event->new("nothing")))
{
$window->destroy();
}
}
i'm not very fond of emitting signals directly outside of a widget's
implementation, so although this works, i generally avoid it.
I was somehow expecting to be able to do something like
$window->close() and have it check the signal and do the right thing.
All the tutorials I've seen either call $window->destroy() or
Gtk2->main_quit directly, bypassing the delete_event completely.
if you really want the checking, what you do is put the checking into
another function and call that function from both the delete-event
handler and the button click.
sub my_app_window_destroy {
# do your custom stuff, and call destroy when you want it destroyed
}
$window->signal_connect (delete_event => \&my_app_window_destroy);
$button->signal_connect (clicked => \&my_app_window_destroy);
--
"that's it! you're a genius!" "yes. that's what i think. do you
think i deserve a raise?"
- dialogue from 'Godzilla versus Mothra', 1964
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]