Re: Blocking Main Window destroy siginal




On Sep 19, 2004, at 9:43 AM, Kevin C. Krinke wrote:

my $button = new Gtk2::Button ( "toggle block" );

or, you could use an actual ToggleButton and avoid the state variable while providing visual feedback, like so:

/usr/bin/perl -e '
use strict;
use Glib qw( TRUE FALSE );
use Gtk2 -init;

my $window = new Gtk2::Window ( "toplevel" );
my $toggle = new Gtk2::ToggleButton ( "block" );
$window->add($toggle);
$toggle->signal_connect( toggled => sub {
                         $_[0]->set_label ($_[0]->get_active
                                           ? "unblock"
                                           : "block");
                         });
$window->signal_connect( "delete-event" => sub {
                             # if we are blocked, do nothing:
                             return TRUE if $toggle->get_active;
                             # otherwise stop the main loop and let
                             # the default handler destroy the window.
                             Gtk2->main_quit;
                             return FALSE;
                         });
$window->show_all();
main Gtk2;
'

:-)


--
I think it worked on the Wiley Coyote model of project management - if
at any point you looked down and realised what you were doing was
impossible then you'd instantly fail.
  -- Simon Wistow




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