v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
657 stars 58 forks source link

Yad height setting not work when text is too long #140

Open salpaca opened 3 years ago

salpaca commented 3 years ago

Hello,

I am using yad to display notification in BASH. However, there is some trouble while showing long text with specified height.

My os system verison is Ubuntu 18.04.4 LTS, yad version is 0.40.0 (GTK+ 3.22.30). At first, I try to display a short text with height equal to 100 and everything is fine as follows.

/usr/bin/yad --text="Set height equal to 100" --width=500 --height=100 --on-top --center --button="OK" --undecorated --borders=15 --image="dialog-warning"

image

Then, if i try to display a longer text. The shown dialog height is actually larger than specified 100 value with a lot of space below the string.

/usr/bin/yad --text="Set height equal to 100;Set height equal to 100;Set height equal to 100;" --width=500 --height=100 --on-top --center --button="OK" --undecorated --borders=15 --image="dialog-warning"

image

It seems that the dialog default height will increase if text is long enough. It will show default height when setting height is lower than default value. The setting height will work only when the specified value is larger than default height. For example, it will be normal if i set height equal to 500 for previous example2.

/usr/bin/yad --text="Set height equal to 100;Set height equal to 100;Set height equal to 100;" --width=500 --height=500 --on-top --center --button="OK" --undecorated --borders=15 --image="dialog-warning"

image

I would like to know whether there is one method that makes the specified height always work no matter how long the text string height is? Thanks!

frostworx commented 3 years ago

Hi, would you say this is a duplicate from my https://github.com/v1cont/yad/issues/136?

Misko-2083 commented 3 years ago

I have the latest from master branch and this still happens. This expands height: yad --text="Set height equal to 100&#59;Set height equal to 100&#59;Set height equal to 100&#59;" --width=500 --height=100 --on-top --center --button="OK" --undecorated --borders=15 --image="dialog-warning" But without pango markup it doesn't: yad --text="Set height equal to 100&#59;Set height equal to 100&#59;Set height equal to 100&#59;" --width=500 --height=100 --on-top --center --button="OK" --undecorated --borders=15 --image="dialog-warning" --no-markup So I counted the characters:

echo "Set height equal to 100;Set height equal to 100;Set height equal to 100;" | wc -c
73
echo "Set height equal to 100&#59;Set height equal to 100&#59;Set height equal to 100&#59;"| wc -c
85

With 73 characters it expands the height, with 85 it doesn't that much.

I tried adding more spaces to increase the number of character. The more spaces added -> the less the height of the dialog.

yad --text="Set height equal to 100;Set height equal to 100;Set height equal to 100;                                                                                                        " --width=500 --height=100 --on-top --center --button="OK" --undecorated --borders=15 --image="dialog-warning"

echo "Set height equal to 100;Set height equal to 100;Set height equal to 100;                                                                                                        " | wc -c
177

At 177 characters the dialog's height is less than 100 pixels.

It doesn't have to be a space, but definitely has to do with the number of characters:

yad --text="Set height equal to 100;Set height equal to 100;Set height equal to 100;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" --width=500 --height=100 --on-top --center --button="OK" --undecorated --borders=15 --image="dialog-warning"

Batwam commented 2 years ago

I agree with this comment. I have seen this issue multiple times. Based on investigations, it seems that this is less prominent for screen with higher resolutions (ie. UHD and above), possibly due to the use of fractional scaling... not too sure.

When using yad in script code, I am having to adjust the heights by 15-20% between HD and UHD screens to adjust for these oversized dialogs. It looks like yad is trying to calculate the optimal dialog size based on the amount of characters and visibly overestimating it.

Would someone know in which part of the yad source code this size calculation is made?

step- commented 1 year ago

So I think this issue is caused by the different design of the GtkLabel widget in GTK 3 vs GTK 2.

text='jdlska ldksajl alksdjlask jaldkjalskdjalskdjal kjdlaksjdla kjdlakjsd lkasjd lakdjal kjdlaksjd lakjsd lakjdlak jldkajsldk jalskdj laksj dlakdjlakjdlaksjdlaksjdlak jlakdjalksj laksjdalksj dlakjdakjs d jdlaskdjla kjlakjsdl kajs lkdjals kjdlakjs lkdajls kjdlaksj lakjs ldkajsl kjalksjd lakj lakdjals kjalksjd laksjdl aksjdla kjsldkajs ldkajs lakdjal ksjalksdj laksdlak jdlaksjd laksd lakdjlaksdj lakdjalskd jalkdjlakdjalkdjalskdj alk'

yad_gtk2 --text="$text" # gtk2 0.40.x

yad_gtk3 --text="$text" # gtk3 0.40.x

yad_master --text="$text" # gtk3 master 12.0

yad_gtk2

yad-20221024

yad_gtk3

yad-20221024-001

yad_master

yad-20221024-002