#!/usr/bin/perl -w use strict; use warnings; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use threads; use threads::shared; my $magic: shared = 0; my $die: shared = 0; my $test = threads->new( \&test); my $window = Gtk2::Window->new( 'toplevel'); $window->set_border_width(20); $window->signal_connect('delete_event' => sub { $die = 1; $test->join; Gtk2->main_quit; }); my $vbox = Gtk2::VBox->new( FALSE, 2); my $button = Gtk2::Button->new( "start"); $vbox->pack_start($button,FALSE,FALSE,4); $button->signal_connect( 'clicked' => sub { $magic = 1}); my $button1 = Gtk2::Button->new( "go"); $vbox->pack_start($button1,FALSE,FALSE,4); $button->signal_connect( 'clicked' => sub { $magic = 2}); $window->add( $vbox); $window->show_all; my $timer2 = Glib::Timeout->add(100, \&dialog); Gtk2->main; sub dialog { if ( $magic == 2) { # my $messagedialog_verification = Gtk2::MessageDialog->new( undef, 'destroy-with-parent', 'question', 'yes-no', "Verify waypoints?"); # my $response = $messagedialog_verification->run; # $messagedialog_verification->destroy; $magic = 1; } } sub test { while (1) { if ( $die == 1) {goto END}; if ($magic == 1) { for (;;) { if ( $magic == 2) { for (;;) { if ( $magic == 1) { last}; } } print "happy\n"; if ( $die == 1) {goto END}; if ( $magic == 0) { last}; } } } END: }