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.
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 appending2> /dev/null
to the end of the command, like this:It seems that the Gtk devs decided to add this warning which affects a number of packages. We just have to wait for the Zenity dev to catch up and fix Zenity.
With the bash shell (this is not Posix-compliant) it's relatively simple to suppress specific error messages while allowing other messages through to stderr:
This does not interfere with stdout, so that may be piped or used in command substitution as normal:
zenity ... 2>/dev/null
works for me. The only problem I see is that other (important) errors messages will also be suppressed so better build error capture somehow in your codeBuilding on Dave Rove's answer, if you have many prompts, you could clean this up by creating a function such as
then use it like this:
This makes things a little easier to read when combining with other logic: