Re: dialog close signal and hiding dialog...



-- muppet <scott asofyet org> wrote
(on Tuesday, 12 August 2003, 09:00 PM -0400):
On Tuesday, August 12, 2003, at 12:22  PM, Matthew Weier OPhinney wrote:

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

there is no 'close' signal.  i think what you meant to type was 
'delete-event'.

Aha! That's what I was looking for! I've tried 'destroy' and 'close',
and neither did what I was wanting!

as well as the response signal. I've determined that
closing the window sends a response of '-4',

i apologize that the response signal doesn't use the enums, but as i've 
mentioned before, it's out of my control because the signal is 
marshaled with an int.  (but i'm still embarrassed about it, as it's 
something of a wart on gtk2-perl.)  anyway....

Not a problem -- I was mentioning it so that I could be more specific in
the details of what I was trying to do. Tho' I wouldn't mind using the
enums... ;-)

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?

nope.  the delete-event gets routed through response as a certain 
response code, but the event continues to propagate, resulting in the 
destruction of the window.  you simply need to bind to delete-event a 
signal handler that returns TRUE, to stop the propagation.

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

here's some code, fresh out of vim and a test-run.  if you try this, 
you should be able to resize the dialog, close it, and see it reappear 
at the same size.  if you don't see this, i want to know about it.  

Works perfectly -- certainly something to add to my toolbox! Wierd
trick; it'd be nice to see a dialog called with '$dialog->show;' have
this bound automatically.

-- 
Matthew Weier O'Phinney
http://weierophinney.net/matthew/



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