Re: dialog close signal and hiding dialog...



Matthew Weier OPhinney said:
I've created an options dialog for an application, and I only want to
create it once per session. I've setup the GtkDialog to capture the
'close' signal as well as the response signal. I've determined that
closing the window sends a response of '-4', and I've setup both my
close and my response callbacks to do a "$dialog->hide" on receiving
such a signal. This works fine. It's when I try and open the dialog
again that I get an error. I try to show it using "$dialog->show", but
the window appears with now widgets, and I get a segmentation fault when
I close that window.

Am I capturing the signals correctly? Am I trying to re-display the
dialog correctly? Or do I need to post some code...? ;-)

it would be my guess that all of the widgets are getting the signal to be
destroyed and you're only preventing the dialog from being, not its contents.

ignoring the fact that it never exits the following code works:

use Gtk2 '-init';
my $dialog = Gtk2::Dialog->new (
                        "Test", undef, 'modal',
                        'gtk-cancel', 'cancel',
                        'gtk-ok', 'ok');
Glib::Timeout->add( 500, sub {
                $res = $dialog->run;
                $dialog->hide;
                print "$res\n";
                $res eq 'ok';
        });
Gtk2->main;

so long as you click ok the dialog will pop up every 1/2 second. if you click
cancle it won't any more. notice that run is blocking, hide causes the dialog
to disappear. i probably should have to be as complicated as what you were
describing.

if you're not using a Gtk::Dialog then i would suggest doing so as much of
what you're trying to deal with is handled for you with them.

-rm



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