Re: modal dialogs and return()



On 09/03/00 samuel-tribehou mail cpod fr wrote:
I'd like to know if I can make a modal dialog which calls Gtk->main() return 
something usefull while calling Gtk->main_quit() to end the dialog.
I'd like to be able to do something like this: 

sub message
                      {               
                              $ok_button->signal_connect ('clicked', $window->destroy();Gtk->main_quit(); 
return (1);
                              $cancel_button->signal_connect ('clicked', $window->destroy(); 
Gtk->main_quit(); return (0);    
                      }

if (message("blah blah") ) 
                                                      {       
                                                              #do something
                                                      }
                      
Of course, that doesn't work. So how could I make the function return something 
usefull without using global vars ?

In perl you could use a local var or store the result in some widget.

sub message {
        local $result;
        # create dialog
        ...
        # connect signals
        $dialog->ok_button->signal_connect('clicked', sub {$result=1});
        $dialog->cancel_button->signal_connect('clicked', sub {$result=0});
        ...
        $dialog->show;
        Gtk->main;
        # use $result...
}

lupus / using new ... operator from perl 6 :-)

-- 
Paolo Molaro, Open Source Developer, Linuxcare, Inc.
+39.049.8043411 tel, +39.049.8043412 fax
lupus linuxcare com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.




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