Problem running a shell script using Zenity. Message: Gtk-Message: Gtkdialog Mapped without a Transient Parent. This is discouraged

Asked

Viewed 174 times

1

When I execute script sh. via shell linux, appears this message: Gtk-Message: Gtkdialog Mapped without a Transient Parent. This is discouraged. How do I resolve this issue?

#!/bin/bash

get_url ()
{
    url=$(zenity --entry --title="Youtube" --text="Criado por: Leandro Sciola\\nCole o link do vídeo aqui para extrair o áudio:" --ok-label=Extrair --width="600" height="50")

    if [ $? -eq 1 ]; then
        exit
    fi
}

download ()
{
    (
        youtube-dl -f m4a --output "%(title)s.%(ext)s" --print-json --no-warnings $url >metadata
    ) | zenity --progress --title="Youtube" --pulsate --auto-close --no-cancel --text "Extraindo o áudio..."

    title=$(jq -r ".title" metadata)
    rm metadata

    if [ "$title" ]; then
        zenity --info --title="Youtube" --text="Áudio extraído com sucesso!\\nTítulo: $title"
    else
        zenity --error --title="Youtube" --text="Erro! Não foi possível extrair o áudio!"
        setup
    fi
}

setup ()
{
    get_url

    if [ "$url" ]; then
        download
    else
        zenity --warning --title="Youtube" --text="Nenhum link foi adicionado no campo!"
        setup
    fi
}

setup

1 answer

1


Warning messages in GTK are something frequent and often, as in this case, can be ignored without there being any problem.

In this particular case, to translate into intelligible language, the message is saying: "dialog windows should be started by other windows", that is, they must have mother windows. This ensures that the window manager can know what is application and what is dialog, know which windows are associated with the same application, etc.

In this way, it is a warning inherent to the use of Zenity, because it is precisely a case in which dialog windows come, directly and legitimately, from a command line interface! Note that the message says that such practice is discouraged, but does not say that this is a mistake. The existence of the message does not affect in any way the execution of your script.

Since there is no way for Zenity to inhibit the return of GTK messages, in case you want to keep the console clean when executing the script, I suggest you redirect the error output of the calls zenity to the /dev/null, for example:

    url=$(zenity --entry --title ... height="50" 2> /dev/null);

I also suggest that this be done after ensuring that calls to zenity do not fail as this inhibits any error output and can hinder the process of debug.

Reference: linuxquestions.org

  • I didn’t know that. Thanks!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.