Open_dialog with a transient parent

question

#1

How exactly do I use Gtk.open_dialog from Gtk with a parent, and avoid this:

Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

Any MWE would be great, thanks!


#2

How do you user open_dialog right now?
https://developer.gnome.org/gtk3/stable/GtkWindow.html
has a paragraph about
gtk_window_set_transient_for ()
and i’d guess this should be used to give a modal window like the dialog a parent.


#3

Thanks for the tip, but I’m still not sure how I can specify that there is no parent window. What I do now is:

txtfile = open_dialog("Pick a `.txt` file", Null(), ("*.txt",))

#4

and open_dialog is from where?


#5

OMG, sorry: Gtk.


#6

https://github.com/JuliaGraphics/Gtk.jl/blob/5d12682c9ffa75f7ff5e24d352643e61d9ce10ba/docs/src/manual/filedialogs.md says the second argument is the parent container.


#7

Yea, but if I use their example, I still get that warning:

julia> using Gtk

julia> open_dialog("title", GtkNullContainer(), String[])
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

Maybe there is no way to circumvent that warning?


#8

The warning is there, because a Null container is somehow a non-window and therefore the parent is missing. Digging a little bit deeper: the warning shows up to inform you, that with a setup like this your window manager might not be able to manage the dialog window which can have strange side effects like sticking on your screen (happens a lot with tool tips from Gtk on windows).


#9

I see. So it’s there to stick, unless I give it a real parent. But is there a clean simple way to do that? Like what would be the correct way to use open_dialog if that is the only need we have to communication with the user?


#10

Afair (i haven’t done gtk application development for some time), a well behaving gtk GUI application should have an top-level application window to which you add menu, dialogs etc. If you only call open_dialog to ask for input and your application is terminal only, i’d guess you can live with the warning.


#11

yes, this is the way I do this as well. The advantage when passing the top-level window is that one can set the dialog to be modal.


#12

It makes sense. I guess one way “around it” is to open a transparent window as a default parent and kill it with the dialog.