#!/bin/sh
#260122 sfs
yad --version |grep -E '^0' && export gtk=gtk || export gtk=yad
NTF2(){
    #NTF -i gtk-info "line 1" "line 2"
    [ "$1" = "-i" ] && { notify-send -a "`basename $0`" -i $2 "`printf "$3\n$4 "`" ; return ; }
    i=dialog-info && b="--button=$gtk-ok:0" && t="<b>$2</b>\n<i>$3</i>"
    [ "$1" = "-q" ] && i=dialog-question && b="--button=$gtk-yes:0 --button=$gtk-no"
    [ "$1" = "-a" ] && i=dialog-error && b="--button=$gtk-ok:0" && t="<span color=\"red\"><b>$2</b></span>\n<i>$3</i>"
    [ "$1" = "-w" ] && e=--entry && ee=entry- && t="$2" && x=X
    tit="`echo $2 | sed 's/<[^>]*>//g'`"
    yad $e --Xwidth=600 --fixed --name=$i  \
    --image-on-top --${x}image=$i $b  --mouse \
    --window-icon=$i --title="$tit" \
    --${ee}text "$t"  >/dev/null && echo $? 
}

F(){ fc-match $1 |awk -F'"' '{print $2}' ; } 
se="`F serif`"
sa="`F sans-serif`"
mo="`F monospace`"

f="$(yad --font --title "yfontsel" --name "gtk-font" --window-icon=gtk-font \
    --text "<b>Preferred fonts:</b>
    Sans:	<span font='$sa'>`fc-match sans-serif`</span>
    Serif:	<span font='$se'>`fc-match serif`</span>
    Mono:	<span font='$mo'>`fc-match monospace`</span>" \
)" && echo $f && NTF2 -w "$f" 
