Is it possible to stop a signal callback?
- From: "Ye Wenbin" <wenbinye gmail com>
- To: gtk-perl-list gnome org
- Subject: Is it possible to stop a signal callback?
- Date: Sun, 05 Aug 2007 23:35:24 +0800
Hi,
In my application, there is a callback which may take a long time to
finish.
Is it possible to return from the callback when user really need? For
example,
code as following, can I press the button 'cancel' to stop the counting?
Is there any document about thread in Gtk2?
use Gtk2 '-init';
use Glib qw(TRUE FALSE);
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { Gtk2->main_quit; });
my $hbox= Gtk2::HBox->new(FALSE, 0);
my $but;
$but = Gtk2::Button->new('start');
$but->signal_connect(
'clicked' => sub {
my $i = 0;
while ($i < 10) {
sleep( 1 );
$i++;
print "I'm working\n";
}
return FALSE;
}
);
$hbox->pack_start($but, TRUE, TRUE, 5);
$but = Gtk2::Button->new('Cancel');
$but->signal_connect(
'clicked' => sub {
die "Stop it\n";
}
);
$hbox->pack_start($but, TRUE, TRUE, 5);
$window->add($hbox);
$window->show_all();
Gtk2->main;
--
Best regards,
Ye Wenbin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]