Re: blocking, non-modal dialog?



On Sunday 28 August 2005 22:30, Allin Cottrell wrote:
I'm having trouble engineering the following: a dialog which blocks
(execution in the caller must not proceed till a choice has been
made in the dialog's callbacks), but is not modal (the user may want
to consult other aspects of the gui in the process of making a
choice).

Or rather, while the above is easy to achieve with gtk_main() in the
dialog code itself and gtk_main_quit() in a callback to the
"destroy" signal of the dialog window, the problem is that such a
dialog stays open when my main app is closed.

I thought I could fix that with
gtk_window_set_destroy_with_parent(), but this seems to disable the
calling of gtk_main_quit.  That is, when I add destroy_with_parent
the dialog disappears OK when you exit the app, but the app hangs:
the gui's gone but gtk_main is still running.

I must be missing something fairly obvious: could anyone tell me
what it is?  Thanks.

I think you need to re-specify you question.

What do you mean by "when my main app is closed".  If the dialog is shown (and 
gtk_main() called with respect to it) in a particular process it must be 
destroyed when that process finishes.  Do you have different instances of 
GTK+ running in two different processes/programs which communicate in some 
way?  If so, and you want all processes to end if one ends, one approach is 
to put all of the processes in the same process group and have the 
terminating process call call kill(0, SIGTERM) in its exit clean-up handler 
(if you are using a Unix-like system).

However given your reference to calling gtk_window_set_destroy_with_parent(), 
I think you must mean something different, because that would only have any 
effect in respect of a parent and child window in a single process (you 
cannot have parent and child windows in the GTK+ sense in different 
processes/address spaces).  If they are both in the same process you need to 
explain what you are doing (but after calling gtk_object_destroy() on the 
parent window you can of course always call gtk_object_destroy() on the 
other, and to do this you could connnect a call to gtk_object_destroy() for 
both to the delete event signal of the parent window.)

Chris



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