Ubuntu – error message when running zenity under 16.04: Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged

gtkguizenity

Under ubuntu 16.04 I get the following message

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

when I open zenity with the command

  zenity --text-info --filename=<filename>

This didn't happen under 14.04. I presume that the answer is related to this post but the post doesn't explain how to implement the proposed solution. Could somebody please explain which file I should add the suggested lines to?

You fix this warning by giving the GtkDialog a parent to be modal to.
The relevant functions are gtk_window_set_transient_for() (which sets
this window to always be on top of, or transient for, another one) and
optionally gtk_window_set_modal() to make it a modal dialog. This is
ultimately what the various GtkDialog constructors do.

Best Answer

Ignore it.

It's a warning, not an error. The application works, it's just not coded with best practices in mind, as it seems. You would have to modify zenity's source code to implement the fix described in your linked question and then compile it yourself, but... it works anyway, so why should you bother?

If you just want to get rid of the output in your terminal, you could simply redirect STDERR (standard error stream, that's where the warning gets printed to) to /dev/null (virtual character device that swallows data) by appending 2> /dev/null to the end of the command, like this:

zenity --text-info --filename=<filename> 2> /dev/null
Related Question