Returning order of the dialog boxex

Hi all,
GTK3 on Linaro (Debian based) embedded board.

I have a weird behavior on a sequence of GtkDialog window.

I run the main window: from there I show other GtkDialog window by gtk_dialog_run(), I will call it dlg1.
From dlg1 I show other GtkDialog window by gtk_dialog_run: I will call it dlg2.
From dlg2 I show other GtkDialog window by gtk_dialog_run: I will call it dlg3.
When I return from dlg3 I see some output debug message after the gtk_dialog_run on dlg2 but at screen I see dlg1: its buttons are (correctly) unclickable cause the focus should be on dlg2!
If I move on foreground dlg2 I can press its buttons.

If I press other buttons on dlg2 to open other dialog boxes (in the same way of dlg3) I have the correct order of dialog boxes.

All the GtkDialog are full-screen and they have the Modal flag set (by glade file) … I don’t understand why I can select the parent window by Alt-Tab keys and, above all, how is possible that dlg1 goes in foreground in front of dlg2 when dlg3 exits.
All the windows close themselves by gtk_window_close() (on close button) and, when the code exit from the gtk_dialog_run, the windows are destroyed by gtk_widget_destroy().

Thanks!

How do you set parents for dialogs? The parent of dlg3 is dlg2; the parent of dlg2 is dlg1; the parent of dlg1 is the main window. The situation is different by non-modal dialogs: they all should be ā€œchildrenā€ of the main window, because there is no fixed Z-order here.

The parent of a dialog window can be set in the second parameter of gtk_dialog_new_with_buttons, or explicitly with gtk_window_set_transient_for.

Quick recommendation: if you find yourself with 3 levels of dialogs, please rethink your UI. It’s going to be extremely confusing, and it’s going to rely a lot on window management doing the right thing, something that no toolkit can guarantee.

1 Like

Yes, you should look to replace ā€˜dialogs over dialogs’ with a ā€˜wizard’ approach via GtkAssistant or GtkStack.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.