--
Victor Ananjevsky <anan...@gmail.com>
Ok, absolutely no problem. I've settled for using different dialogs for each item and showing a progress bar while the backend loads the data for the next item. It's a good solution, I think, and works pretty well so far. A tabbed dialog probably wouldn't be the right choice in this case because I am going through dozens of files and need a dialog for each. Thanks for the suggestion, though! I am sure I will find a good use for the notebook dialog in the future.
Now that I have the chance, may I ask for a somewhat related feature? One downside to having multiple dialogs spawn one after another in one workflow is that their position gets reset each time. I know that I can set the window geometry or simply set dialogs to spawn in the screen center but sometimes you just want the layout to be more dynamic.
It really would be nice if there was an option to retain the window position across all yad instances spawned from the same script. I could think of a global variable like YAD_GEOMETRY as a possible solution to this.
I did manage to achieve persistent geometry by monitoring yad in the background, but I fear it's not very elegant and probably quite resource-intensive:
#!/bin/bash
WMCLASS="YadTestClass"
TMPDIR="/run/shm"
GEOMETRYOPTS="--geometry=960x1020+1366+26"
GEOMETRYPIPE="$(mktemp -u --tmpdir="$TMPDIR" ${0##*/}.XXXXXXXX)"
trap "rm "$GEOMETRYPIPE"; exit" EXIT
gui_form(){
YADOPTS="$(yad --form $GEOMETRYOPTS --field=text --class="$WMCLASS")"
}
gui_monitor_geometry(){
sleep 2
while true; do
GEOMETRY="$(xwininfo -id $(wmctrl -lx | grep "$WMCLASS" | cut -d " " -f1 ) 2> /dev/null \
| sed -n 's/ -geometry //p')"
if [[ -z "$GEOMETRY" ]]
then
break
else
echo "--geometry=$GEOMETRY" > "$GEOMETRYPIPE"
fi
sleep 1
done
}
get_geo&
gui_form
GEOMETRYOPTS="$(cat "$GEOMETRYPIPE")"
echo "geo: $GEOMETRYOPTS"
echo "opts: $YADOPTS"
gui_form
I'd really love to see something like integrated into yad. It certainly would make working with multiple consecutive much easier.
Thank you! That was it. Just for posterity's sake: If the fields contain whitespace you can quote the arguments by escaping the double quotes, e.g.:
'bash -c "on_click \"%1\" \"%2\" \"%3\""'
One thing, though: I am having a bit of trouble replicating this with normal variables. Take this code for instance:
"bash -c "on_click \"$Var1\" \"$Var2\"""
The first bash call works perfectly fine, the second one doesn't. If I replace the latter with "bash -c 'on_click $Var1 $Var2'" it does work, but the whitespace isn't handled correctly and the wrong variables are passed on.
I guess my main question is: Is there any way to pass on arguments with whitespace/other special characters?
Thank you very much in advance!
-- Glutanimate