Re: Blocking Main Window destroy siginal



On Sun, 2004-09-19 at 10:33, muppet wrote:
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;
'

:-)

Show off ;-)

Wait a sec... is that the pot calling the kettle what? hehe

-- 
Kevin C. Krinke <kckrinke opendoorsoftware com>
Open Door Software Inc.




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