Re: blocking, non-modal dialog?



On Mon, 29 Aug 2005, Chris Vine wrote:

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".

Sorry, I wasn't very clear. There is only one gtk process in play. This is what I mean:

1 My app's main window is displayed
2 The user opens a blocking dialog
3 Without closing the dialog box, the user deletes the main
  window via the window manager ('X')
4 Deletion of the main window triggers gtk_main_quit(), but at
  this point gtk_main_level = 2.
5 The blocking dialog remains open

If I set up the dialog with the main window as parent, and
call gtk_window_set_destroy_with_parent() on the blocking dialog,
then at step 5 the blocking dialog disappears OK, but it seems that gtk_main_level remains at 1, in the background:
the application is not actually terminated.

My workaround at present is to record whether a blocking dialog is open: when the user attempts to delete the main window, I check for the presence of such a dialog and if there is one, I raise it instead of deleting the main window.

Allin Cottrell




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